You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by joe panico <pi...@yahoo.com> on 2004/03/17 02:57:35 UTC
global visibility of ApplicationServlet instance
Folks,
I typically subclass ApplicationServlet to create a class that acts as the
central notion of "application"-- the closest thing there is in Tapestry to the
one class that binds the application together. Put another, I think of this
class as the Tapestry equivalent of the WOApplication in WOF.
As the central notion of applicationness, I make application wide services, like
configuration, locatable from the ApplicationServlet. Because of this, there are
a number of places where I need global (static) visibility of the application
object.
I would like to request/propose the following method:
public static ApplicationServlet getInstance()
It could be quite simply implemented this way:
public ApplicationServlet
{
private static ApplicationServlet _instance;
public void init(ServletConfig config) throws ServletException
{
...
_instance = this;
...
}
There are a couple of caveats, of course ;)
This scheme breaks down for the Servlet "SingleThreadModel", but there's really
no reason to use SingleThreadModel with Tapestry anyhow. And in a distributed
Servlet container, you end up with more than one ApplicationServlet. But that's
ok as long as the developer understands that it means 1 ApplicationServlet/jvm.
Any thoughts?
regards,
joe
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
Re: global visibility of ApplicationServlet instance
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
Out of curiosity, why is not Tapestry's concept of the Global object
not sufficient for your configuration and services?
Erik
On Mar 16, 2004, at 8:57 PM, joe panico wrote:
> Folks,
>
> I typically subclass ApplicationServlet to create a class that acts as
> the
> central notion of "application"-- the closest thing there is in
> Tapestry to the
> one class that binds the application together. Put another, I think of
> this
> class as the Tapestry equivalent of the WOApplication in WOF.
>
> As the central notion of applicationness, I make application wide
> services, like
> configuration, locatable from the ApplicationServlet. Because of this,
> there are
> a number of places where I need global (static) visibility of the
> application
> object.
>
> I would like to request/propose the following method:
>
> public static ApplicationServlet getInstance()
>
> It could be quite simply implemented this way:
>
> public ApplicationServlet
> {
> private static ApplicationServlet _instance;
>
> public void init(ServletConfig config) throws ServletException
> {
> ...
> _instance = this;
> ...
> }
>
>
> There are a couple of caveats, of course ;)
>
> This scheme breaks down for the Servlet "SingleThreadModel", but
> there's really
> no reason to use SingleThreadModel with Tapestry anyhow. And in a
> distributed
> Servlet container, you end up with more than one ApplicationServlet.
> But that's
> ok as long as the developer understands that it means 1
> ApplicationServlet/jvm.
>
> Any thoughts?
>
> regards,
>
> joe
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org