wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes How to identify the current running context? 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 "How to identify the current running context?" Watch "How to identify the current running context?" New topic
Author

How to identify the current running context?

Boopathi Ramasamy
Greenhorn

Joined: Dec 03, 2004
Posts: 3
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29255
    
140

Boopathi,
Can you pass this information to your class when you instantiate it?


[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
Camilo Morales
Ranch Hand

Joined: Jul 14, 2007
Posts: 91
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


Camilo Morales<br />SCJP 5, SCBCD 5
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
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
 
subject: How to identify the current running context?
 
Similar Threads
Accessing a servlet from a Struts App running in another context.
calling external servlet from my servlet
Installing Softwares & Updating Ubuntu
New forum for Sun Certified Web Component Developer
Identify context path + servlet path+ path info for given URL