If I understand you correctly, you have a EJB container and you have a
stand-alone application that are using the same classes. If that is the
case, the following solution that I did might be helpful for you:
Because they are different VM processes, you can have a singleton class (or
a class with a static variable). You can define a boolean field, say
'flag', in the class. By default, the value is true, so in EJB container,
you will get a true when referring to it (of course, I suggest you use
getter and setter for encapsulation). In stand-alone application, you can
use the main class to switch the flag to false and from then on you can use
this flag to check if you are inside the EJB container.
Hope this helps.
Shane
-----Original Message-----
From: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]On Behalf Of Dave Glasser
Sent: Wednesday, March 07, 2001 10:06 PM
To: [EMAIL PROTECTED]
Subject: Determining if code is running in EJB container
I have a class which is used in both EJB and non-EJB environments, and
some of its behavior is determined by whether or not it's running
inside an EJB container. Right now, I'm using a system property,
"NO_EJB", which I set from the command line to tell the class that
it's not running inside an EJB container. What I'm wondering is
whether or not there's a more elegant way for the class to determine
if it's running inside an EJB container, that doesn't rely on command
line switches. Is there some other system property that will always be
set in an EJB environment but not set otherwise? Or some other part of
the runtime system it could interrogate to find out this information?
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".