Recently, I use reflection technology on EJB to get/set properties of a bean.
We need it because we need to encapsulate data in a map to transfer data between
presentation layer and business back end(i.e. the so-called value data object).
A bean is packed into a map as following:
The property name of a bean becomes the key in the map, and its value becomes the
corresponding value in the map.
So we have to do two things:
1)Given a bean, convert it to a map;
2)Given a data map, assign the value to a bean
It would be nice if we can implement the two requirements in a base class. So I use
reflection. And succeed to achieve the goal.
But there are two problems occured and I can't understand why.
1)If I use Class.forName() to load the entity bean implementation class(BMP or CMP abstract
schema) I got a ClassNotFoundException. A workaround is to jar the BMP or CMP bean class
and place it on the classpath.
So, I want to know why there is such restriction.
2)For the classes java.lang.reflect.Method, java.lang.reflect.InvocationTargetException
I reference to in bean class, the IDE(I use IntelliJ Idea) give me a
warning: "Use java.lang.reflect.Method are not allowed in EJB". Are the methods really
dangerous in EJB environment?
Can anyone explain me these pluzzles?
Thank you in advance!
BTW, I develop under weblogic 7.0. Now, my program functions well, I just can't understand
the above phenomena.