You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Darryl L. Pierce" <mc...@gmail.com> on 2005/09/27 13:49:05 UTC
Embedded Tomcat and shared objects...
I have embedded Tomcat 5.0.28 into an application I'm writing. Tomcat is
being used primarily as the configuration system. I would like to, from
the servlet running within Tomcat, access objects that are a part of the
main application itself, specific some configuration objects. Is there a
way, while I'm created the instance of
org.apache.catalina.startup.Embedded and all of the related objects, to
set a reference to some objects? I tried setting it in the servlet
context as I created the instance of org.apache.catalina.Context for my
servlet's context but getServletContext() returns null at that point...
--
Darryl L. Pierce <mc...@gmail.com>
Homepage: http://mcpierce.multiply.com/
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Embedded Tomcat and shared objects...
Posted by Mark <el...@gmail.com>.
I have done something like this. The Factory and Singleton design
patters work perfectly for this type of thing. If you create an
abstraction layer, then there should be no problems....
On 9/28/05, Leon Rosenberg <ro...@googlemail.com> wrote:
> still, spring can use the same factory.
> If not, use a container that can use factories :-)
>
> If nothing works, the hack would be:
>
> class MyObjectInstanceHolder{
> private static MyObject instance;
>
> public set/getInstance...
> }
>
> ?
> regards
> leon
>
> On 9/28/05, Darryl L. Pierce <mc...@gmail.com> wrote:
> > Leon Rosenberg wrote:
> > > Aehm, without looking deeper into context initialization, just a short guess:
> > > what about making your configuration objects a singleton with
> > > public static CLASSNAME getInstance()
> > > or
> > > provide a factory for them?
> >
> > Because the class in question is created by Spring's application context.
> >
> > --
> > Darryl L. Pierce <mc...@gmail.com>
> > Homepage: http://mcpierce.multiply.com/
> > "Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Embedded Tomcat and shared objects...
Posted by Leon Rosenberg <ro...@googlemail.com>.
still, spring can use the same factory.
If not, use a container that can use factories :-)
If nothing works, the hack would be:
class MyObjectInstanceHolder{
private static MyObject instance;
public set/getInstance...
}
?
regards
leon
On 9/28/05, Darryl L. Pierce <mc...@gmail.com> wrote:
> Leon Rosenberg wrote:
> > Aehm, without looking deeper into context initialization, just a short guess:
> > what about making your configuration objects a singleton with
> > public static CLASSNAME getInstance()
> > or
> > provide a factory for them?
>
> Because the class in question is created by Spring's application context.
>
> --
> Darryl L. Pierce <mc...@gmail.com>
> Homepage: http://mcpierce.multiply.com/
> "Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Embedded Tomcat and shared objects...
Posted by "Darryl L. Pierce" <mc...@gmail.com>.
Leon Rosenberg wrote:
> Aehm, without looking deeper into context initialization, just a short guess:
> what about making your configuration objects a singleton with
> public static CLASSNAME getInstance()
> or
> provide a factory for them?
Because the class in question is created by Spring's application context.
--
Darryl L. Pierce <mc...@gmail.com>
Homepage: http://mcpierce.multiply.com/
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Embedded Tomcat and shared objects...
Posted by Leon Rosenberg <ro...@googlemail.com>.
Aehm, without looking deeper into context initialization, just a short guess:
what about making your configuration objects a singleton with
public static CLASSNAME getInstance()
or
provide a factory for them?
regards
leon
On 9/27/05, Darryl L. Pierce <mc...@gmail.com> wrote:
> I have embedded Tomcat 5.0.28 into an application I'm writing. Tomcat is
> being used primarily as the configuration system. I would like to, from
> the servlet running within Tomcat, access objects that are a part of the
> main application itself, specific some configuration objects. Is there a
> way, while I'm created the instance of
> org.apache.catalina.startup.Embedded and all of the related objects, to
> set a reference to some objects? I tried setting it in the servlet
> context as I created the instance of org.apache.catalina.Context for my
> servlet's context but getServletContext() returns null at that point...
> --
> Darryl L. Pierce <mc...@gmail.com>
> Homepage: http://mcpierce.multiply.com/
> "Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org