aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Call java Class method without reflection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Call java Class method without reflection" Watch "Call java Class method without reflection" New topic
Author

Call java Class method without reflection

Gaurav Gupta Ser
Greenhorn

Joined: Dec 22, 2012
Posts: 6
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.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29245
    
139

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Gaurav Gupta Ser
Greenhorn

Joined: Dec 22, 2012
Posts: 6
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).
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29245
    
139

Gaurav,
I'm female, let's not call me "sir."

I can only think of two options
1) Reflection
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Call java Class method without reflection
 
Similar Threads
function points
ejb-ref lookup does not work with JBoss 4.2.0GA _CP07, pleas help.
passing a class to a method?
Jboss and Ejb 2.1 ejb-ref lookup
JUnit - List of test methods through TestRunner