You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Daniel Olmedilla <ol...@learninglab.de> on 2004/04/28 01:14:41 UTC

Use the same singleton class for two different services

Hi,

I am using axis to provide 2 different services: service1 and service2. The 
1st service implements the interface1 and the 2nd one implements the 
interface2.

I implemented a class (called App) which implements both interfaces with a 
static singleton class. The idea is that both services would share the same 
variable (in my case a HashMap with properties that could change during the 
execution of the program). I created then two different wsdd and deployed 
both services. Everything works fine except because of it seems that each 
service runs in a different process and the singleton HashMap is not shared, 
so the information service1 introduces on the HashMap is not available in the 
HashMap of service2.

How is it possible to have 2 different services and to share one variable 
between both services?

Thanks in advance,

	DOC
-- 
     Daniel Olmedilla
     Learning Lab Lower Saxony (L3S)
     Deutscher Pavillon
     Expo plaza 1
     D - 30539 Hannover

     Phone: +49 (0)511 762.97.41
     Fax:     +49 (0)511 762.97.79

     http://www.learninglab.de/~olmedilla/
     E-Mail: olmedilla@learninglab.de

RE: Use the same singleton class for two different services

Posted by Robert Lowe <rm...@rmlowe.com>.
Are you deploying two copies of Axis as separate Web applications? If so,
each will get its own classloader, so if the class that contains your static
files is loaded by the Web app's class loader, you'll have two copies of the
static variable.

One way around this is deploy the relevant class in the shared lib directory
of your Web container. For example, using Tomcat, put your JAR file in
shared/lib instead of webapps/axis/WEB-INF/lib.


Best regards,

Robert Lowe
http://RMLowe.com/



-----Original Message-----
From: Daniel Olmedilla [mailto:olmedilla@learninglab.de]
Sent: Wednesday, April 28, 2004 7:15 AM
To: axis-user@ws.apache.org
Subject: Use the same singleton class for two different services


Hi,

I am using axis to provide 2 different services: service1 and service2. The
1st service implements the interface1 and the 2nd one implements the
interface2.

I implemented a class (called App) which implements both interfaces with a
static singleton class. The idea is that both services would share the same
variable (in my case a HashMap with properties that could change during the
execution of the program). I created then two different wsdd and deployed
both services. Everything works fine except because of it seems that each
service runs in a different process and the singleton HashMap is not shared,
so the information service1 introduces on the HashMap is not available in
the
HashMap of service2.

How is it possible to have 2 different services and to share one variable
between both services?

Thanks in advance,

	DOC
--
     Daniel Olmedilla
     Learning Lab Lower Saxony (L3S)
     Deutscher Pavillon
     Expo plaza 1
     D - 30539 Hannover

     Phone: +49 (0)511 762.97.41
     Fax:     +49 (0)511 762.97.79

     http://www.learninglab.de/~olmedilla/
     E-Mail: olmedilla@learninglab.de