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:[EMAIL PROTECTED] 
Sent: Thursday, May 26, 2005 9:59 AM
To: [email protected]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to