Parameterize your beans constructor to indicate that it's in being used
within a container. Otherwise you'd have to rely on vendor specific
ClassForName lookups. Maybe you can assuming if you try to get an
InitialContext and it cannot connect then you aren't running in a container.

Does new InitialContext() throw a NamingException if called outside
of a container? I'm sure a lookup would fail ie. return null.

Open to ideas...

what do you need this for?

> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Dave Glasser
> Sent: Wednesday, March 07, 2001 9:48 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Determining if code is running in EJB container
>
>
> On Thu, 8 Mar 2001 10:45:36 +0530, Ashwani Kalra
> <[EMAIL PROTECTED]> wrote:
>
> >I thinks you can call ejbContext fns which tells its environment. when
> >running in NON-EJB environment it must return some error or exception
>
> Thanks for responding. The class I'm talking about is not an EJB, so
> there is no way for it to get an EJBContext.
>
>
>
> >
> >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >Warm Regards
> >Ashwani Kalra
> >Sr. Member Dev. Staff
> >Aithent Technologies(P) Ltd.(SSI)
> >Plot 8 & 9, Sector-18
> >Gurgaon,Haryana
> >Email   : [EMAIL PROTECTED]
> >          [EMAIL PROTECTED]
> >Phone :
> >Office   : 91- 6346338,6397836-37,6397533
> >             6397324,6397277 (Ext :307 )
> >Resi     :  5635718
> >
> >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> >
> >-----Original Message-----
> >From: A mailing list for Enterprise JavaBeans development
> >[mailto:[EMAIL PROTECTED]]On Behalf Of Dave Glasser
> >Sent: Thursday, March 08, 2001 9:36 AM
> >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".
>

===========================================================================
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".

Reply via email to