hivemind-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Carman" <ja...@carmanconsulting.com>
Subject RE: [Newbie] Singletons starting twice
Date Thu, 26 May 2005 10:33:52 GMT
HiveMindFilter will initialize the Registry before your webapp receives any
requests.  The servlet container will call the init() method, which is where
the Registry is created.  I do this with my applications and it works just
fine.  The Registry starts up when the application is deployed and I can see
if anything goes wrong.  

Now, on to your other request, a JVM-wide Registry.  If you deploy your
webapp using HiveMindFilter, it will not be JVM-wide.  It will be used only
within your webapp.  You never mentioned anything before about the Registry
having to be JVM-wide, did you?  Is this necessary, as it appears that
you're only starting one webapp within Jetty anyway?

-----Original Message-----
From: Geoff Hopson [mailto:geoff.hopson@gmail.com] 
Sent: Thursday, May 26, 2005 5:43 AM
To: John.Prince@bedag.ch
Cc: hivemind-user@jakarta.apache.org
Subject: Re: [Newbie] Singletons starting twice

OK - I set this up, but it still looks like the registry is set up in
the Main thread along with my singleton service, and then when the
first servlet request comes in, the registry is loaded again on one of
the web server listener threads. All subsequent calls use this second
registry.

Is this something to do with the <filter-mapping> stuff in web.xml?

Is it not possible to have a JVM-wide HiveMind registry?



On 5/26/05, John.Prince@bedag.ch <John.Prince@bedag.ch> wrote:
> Hi,
> 
> You could try adding a ServletContextListener to the webapp and
> initialize the registry in contextInitialized. That should be called as
> soon as the webapp is loaded, and before any requests come in.
> 
> Best wishes
> 
> John
> 
> -----Original Message-----
> From: Geoff Hopson [mailto:geoff.hopson@gmail.com]
> Sent: Thursday, May 26, 2005 9:59 AM
> To: hivemind-user@jakarta.apache.org
> Subject: Re: [Newbie] Singletons starting twice
> 
> 
> Thanks for the help so far. Maybe I'm being dumb (again), but here's
> what I want.
> 
> I have a web services-based application. I need to get some
> configuration from a database loaded up BEFORE I receive my first web
> srevice request, since connecting to the database, fetching, loading,
> rejigging etc takes time I haven't got when I recieve my first web
> service call.
> 
> Therefore I want my HiveMind service to init BEFORE the web server
> starts up, so that all my ducks are in a row before I start receiving
> calls.
> 
> I have a main in my startup class that starts up the web server (Jetty).
> 
> Creating the registry in this main method doesn't work, because the
> Jetty listener threads have no idea that the registry has been started
> (since I haven't received a request yet, I can't use HiveMindFilter).
> 
> Here's a dump of the main chunk of my Main method...
> 
> // eagerload my service by constructing registry
> Registry registry = RegistryBuilder.constructDefaultRegistry();
> // my service has now been created and inited. Who-hoo...
> // now start jetty...
> Server server = new Server(); server.addWebApplication("/MyApp",
> "./context/"); server.setTrace(true); SocketListener listener = new
> SocketListener(); listener.setPort(8081);
> listener.setMinThreads(5);
> listener.setMaxThreads(250);
> server.addListener(listener);
> server.start();
> // And we are ready to receive our first caller...
> 
> 
> Trouble is, the first web service request comes in, and the HiveMind
> registry gets reloaded into the first Listener thread that responds,
> along with all the initialisation I think I have already done.
> 
> Thanks again for any insights.
> 
> Geoff
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Mime
View raw message