[ajug-members] App Server Context from POJO?
Dan Marchant
driedtoast at gmail.com
Fri Jun 2 12:42:22 EDT 2006
Ok here is an idea (probably not the best but heh its free advice):
Create a weblogic.application.ApplicationLifecycleListener and in the
postStart method do the following (double check since I am doing it
off the top of my head), set the listener in the config.xml, probably
could do this in a weblogic.xml in your application as well check the
weblogic config guide:
Context context = new InitialContext();
context.bind("/application/Context", event.getApplicationContext());
in your runnable you could do the following:
Context context = new InitialContext();
AppContext context = (AppContext)context.lookup("/application/Context");
Ideally you want to abstract the context from your application but
this is the basic approach.
- Dan
On 6/2/06, Martin, Robert <RMartin at fhlbatl.com> wrote:
> The object is running inside the container so I have access to JNDI, but
> the JNDI tree does not by default contain the information I'm looking
> for. I was hoping for some kind of utility class that could return the
> server context that a thread or object was running in.
>
> Robert
>
> -----Original Message-----
> From: ajug-members-bounces at ajug.org
> [mailto:ajug-members-bounces at ajug.org] On Behalf Of Brian Lee
> Sent: Friday, June 02, 2006 11:42 AM
> To: ajug-members at ajug.org
> Subject: RE: [ajug-members] App Server Context from POJO?
>
> You could make sure that a jndi.properties file is always in your
> classpath,
> then new InitialContext() will point to whereever jndi.properties
> specifies.
>
> BAL
>
> >From: "Martin, Robert" <RMartin at fhlbatl.com>
> >Reply-To: "General AJUG membership forum (100-200
> >messages/month)"<ajug-members at ajug.org>
> >To: "General AJUG membership forum (100-200
> >messages/month)"<ajug-members at ajug.org>
> >Subject: [ajug-members] App Server Context from POJO?
> >Date: Fri, 2 Jun 2006 10:32:02 -0400
> >
> >I've got a Runnable object that needs to hit a web service on the local
> >app server. I have no control over the invocation of this object, so I
> >cannot pass it parameters. Is there any way to get the application
> >context (ideally at least the server name and port number of the
> >application server) from inside this object? Are there any static
> calls
> >for example that can provide this information? I'm running on BEA
> >Weblogic 8.1.
> >
> >
> >
> >I need to build out the URL to the web service, which will change as
> the
> >application is deployed across environments and I'd like to avoid
> having
> >to maintain this info in a database if possible.
> >
> >
> >
> >Robert
> >
> >
> >
> > _____
> >
> >From: ajug-members-bounces at ajug.org
> >[mailto:ajug-members-bounces at ajug.org] On Behalf Of Bill Siggelkow
> >Sent: Thursday, June 01, 2006 6:04 PM
> >To: General AJUG membership forum (100-200 messages/month)
> >Subject: Re: [ajug-members] Ternary Operator - simplification or
> >complication?
> >
> >
> >
> >Yep -- if I ever have a braceless "if" it's all on one line (and it's
> >usually just the "if" not the "else").
> >
> >
> >
> >-Bill
> >
> >
> >
> >On Jun 1, 2006, at 3:31 PM, John Camerin wrote:
> >
> >
> >
> >
> >
> >It has its place... It depends on priorities for the code. The
> >ternary operator is unfamiliar to many developers. Something with more
> >natural language is more likely to be understood correctly by another
> >developer unfamiliar with the piece of code.
> >Number of lines of code should never come into play. Plus, the if/else
> >can be written on a single line:
> >if(n==1)b=true;else b=false;
> >is a perfectly valid single line of code which, consisting of multiple
> >statements. It means exactly the same thing as the expanded version
> and
> >the ternary operator. All different ways to write identical logic.
> >
> >On 6/1/06, Rob Worsnop <rworsnop at gmail.com> wrote:
> >
> >On 6/1/06, Jonathan Komorek <jonathan.komorek at benefitfocus.com> wrote:
> > >
> > >
> > >
> > > I just opened up a can of worms within our development community by
> >stating
> > > that in certain cases, I find that the Ternary Operator simplifies
> >code.
> > > I've been given the impression that I'm the last Java developer
> alive
> >that
> > > believes the ternary operator should ever be used. I'm interested in
> >hearing
> > > the opinions of users on this group.
> > >
> > > Has the ternary operator helped you? Caused you great grief? Should
> it
> >even
> > > be in the language?
> > >
> >
> >I like it. It can be misused but so can a lot of other useful things.
> >
> >--
> >Rob Worsnop
> >http://eventsbyzip.com
> >http://h3t.sourceforge.net
> >_______________________________________________
> >ajug-members mailing list
> >ajug-members at ajug.org
> >http://www.ajug.org/mailman/listinfo/ajug-members
> >
> >
> >
> >_______________________________________________
> >
> >ajug-members mailing list
> >
> >ajug-members at ajug.org
> >
> >http://www.ajug.org/mailman/listinfo/ajug-members
> >
> >
> >
> >
> >
> >
> >-----------------------------------------
> >This e-mail message is private and may contain confidential or
> >privileged information.
> >
>
>
> >_______________________________________________
> >ajug-members mailing list
> >ajug-members at ajug.org
> >http://www.ajug.org/mailman/listinfo/ajug-members
>
>
> _______________________________________________
> ajug-members mailing list
> ajug-members at ajug.org
> http://www.ajug.org/mailman/listinfo/ajug-members
>
>
>
> -----------------------------------------
> This e-mail message is private and may contain confidential or
> privileged information.
>
>
> _______________________________________________
> ajug-members mailing list
> ajug-members at ajug.org
> http://www.ajug.org/mailman/listinfo/ajug-members
>
More information about the ajug-members
mailing list