I need to call java class Method by passing parameter where class name , method name and list of parameter are stored in xml ..
I can call dynamically method of class through reflection but I don't want to call it through reflection because EJB 3.1 has some restriction to use Reflection as described in EJB 3.1 specification , 21.2.2 Programming Restrictions.
Welcome to CodeRanch! The spec doesn't say you can't use reflection. It says you can't use reflection in certain ways.
A direct code from the spec is:
The enterprise bean must not attempt to query a class to obtain information about the declared members that are not otherwise accessible to the enterprise bean because of the security rules of the Java language. The enterprise bean must not attempt to use the Reflection API to access information that the security rules of the Java programming language make unavailable.
Thanks Sir for your reply ,
But may you clarify , what would be best practice to call Java Class Method with parameter at runtime where Class and Method name is stored in String form that would not cause too much memory load at enterprises level in projects (ex. banking solution).
author & internet detective
I can only think of two options
2) Cache the expected classes in a map and look it up from that map.
Personally, I'd use reflection. Unless you are running reflection in a tight loop, it is unlikely to be a performance problem. Or design the app so it doesn't pass class information as a String. For a banking application, I wouldn't store the class/method names in the form anyway - too much info for the user.
subject: Call java Class method without reflection