dev@glassfish.java.net

Re: How to tell if running in GF server JVM?

From: Tim Quinn <tim.quinn_at_oracle.com>
Date: Wed, 30 Jun 2010 21:50:41 -0500

Cheng,

In the client case are you talking about the utility being part of the
Java EE app client container environment or in a Java SE client?

If this code is running as part of GlassFish then the best way - and
maybe you want to avoid this based on your "not a component or
service" comment - is to use the ProcessEnvironment service which lets
you find out if your environment is server, ACC, embedded ,or other..
But of course to use an injected service like that you don't just
refer to it or instantiate it. It needs to be set up by hk2 as part
of the general container set-up.

Can you explain a little more about this utility class? Maybe that
will help us see some other possibilities.

- Tim

On Jun 30, 2010, at 9:10 PM, Cheng Fang wrote:

> Thanks, Byron. Are the same set of sysprops also available in
> GlassFish embedded? For my purpose, I also consider GF embedded as
> a server environment.
>
> -cheng
>
> On 6/30/10 1:57 PM, Byron Nevins wrote:
>> one simple inelegant possibility --
>> Take a look at the output of "asadmin generate-jvm-report" and pick
>> a system property or three that the server always sets and that
>> clients wouldn't set.
>>
>> On 6/30/2010 10:47 AM, Cheng Fang wrote:
>>>
>>> I have a GlassFish utility class (not a component or service) that
>>> may need to do things a little differently depends on its
>>> execution environment.
>>>
>>> Is there a way to tell whether a class is currently running inside
>>> GF server JVM, or in the client-side as a referenced library?
>>>
>>> Thanks,
>>> -cheng
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>




Tim Quinn | Principal Member of Technical Staff | +1.847.604.9475
Oracle GlassFish Engineering
Lake Forest, IL