This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to identify the current running context?

 
Boopathi Ramasamy
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a class file that needs to identify the context it is currently running in. Based on its context my logic will differ.
For ex: my class can be instantiated by a servlet or a session bean. How do i find out at runtime, the code is getting called from servlet or ejb?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33696
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Boopathi,
Can you pass this information to your class when you instantiate it?
 
Camilo Morales
Ranch Hand
Posts: 92
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

There is a class called: SessionContext, that you can inject with EJB 3.0, or, I guess, lookup in EJB 2.x.


SessionContext extends the javax.ejb.EJBContext class. EJBContext defines several methods that provide useful information to a bean at runtime.



There is a lot of information about this class in the Enterprise JavaBeans, 3.0 By Bill Burke, Richard Monson-Haefel, (O'Reilly).


Hope this helps,

Camilo Morales
SCJP 5
 
Michael Ku
Ranch Hand
Posts: 510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is usually an indication of poor design if you need to know in what context you class exists. It makes your class non portable...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic