• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Call java Class method without reflection

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Gaurav Gupta Ser
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic