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 Ted Neward <tn...@javageeks.com> on 2003/05/26 11:57:20 UTC

RE: Service Class as Singleton Class

Don't make it a Singleton-although you might be able to work your way
through this particular issue, a number of other issues are going to
arise that will ultimately make you regret making this class a
Singleton. Singletons imply object identity, which in turn implies
concurrency, which in turn implies contention, which hurts scalability.
Keep your services stateless so they can be shared freely without
thread-safety concerns for maximum scalability.
 
Ted Neward
Author, Instructor, Presenter: Java and .NET
http://www.neward.net/ted/weblog
http://www.javageeks.com
http://www.clrgeeks.com
-----Original Message-----
From: Niket Anand [mailto:niket@noida.manystreams.com] 
Sent: Monday, May 26, 2003 11:24 AM
To: axis-dev@ws.apache.org; axis-user@ws.apache.org
Subject: Service Class as Singleton Class
 
 
 
Hello All,
I am newbie to Axis. I am facing problem as java.lang.
<file:///C:\jdk1.3.1\docs\api\java\lang\InstantiationException.html>
InstantiationException exception when my service class is Singleton
class and having private constructor and getInstance() to get instance
of this class. When axis client ask for a method from the service class
then it throw this exception. If I remove the Singleton ability and
provide public constructor then it works fine. But I want it to be
remain Singleton . Please help me How to work with Service class as
Singleton and what modification needs to be done in wsdd.
 
waiting for reply...
thanks,
Niket

Re: Service Class as Singleton Class

Posted by Niket Anand <ni...@noida.manystreams.com>.
Thanks Peter,
I was waiting for this kind of response.....Yeah it is working if I make
wrapper of this class.

Thanks,
Niket
----- Original Message -----
From: "Peter Mount" <pe...@retep.org.uk>
To: <ax...@ws.apache.org>
Cc: <tn...@javageeks.com>
Sent: Monday, May 26, 2003 6:47 AM
Subject: Re: Service Class as Singleton Class


>
> Just thinking, whay not have a wrapper class which isn't a singleton. Have
> axis access this class, but it simply passes the calls on to the
> singleton. Should get rid of the InstantiationException.
>
> Peter
>
> --
> Peter Mount
> peter@retep.org.uk
> http://www.retep.org/
> http://retep.net/
>    Tel/Fax: +44 (0) 1622 749439
>     Mobile: +44 (0) 7903 155887
>     US Fax: 1 435 304 5165
>   US Voice: 1 435 304 5165
>     IM-MSN: retep207@hotmail.com
> IM-AOL/ICQ: retepworld
>
>
> On Mon, 26 May 2003, Niket Anand wrote:
>
> > Hello Ted,
> > Actually I have a Service class named SessionManager which keeps track
of all kinds of applications attached to Server. So I made this class as
Singleton and at server side I get some informations regarding all attached
applications using SessionManager getInstance() and call mehods..... as
SessionManager store all informations of attached Applications.
> > As an application as Axis client try to attach to server calling
SessionManager services. It give as java.lang.InstantiationException.
> > I can't remove the Singleton property of that class. Can this is
possible in AXIS?????
> >
> > Please reply back.
> > Thanks,
> > Niket
> >   ----- Original Message -----
> >   From: Ted Neward
> >   To: axis-user@ws.apache.org ; axis-dev@ws.apache.org
> >   Sent: Monday, May 26, 2003 5:57 AM
> >   Subject: RE: Service Class as Singleton Class
> >
> >
> >   Don't make it a Singleton-although you might be able to work your way
through this particular issue, a number of other issues are going to arise
that will ultimately make you regret making this class a Singleton.
Singletons imply object identity, which in turn implies concurrency, which
in turn implies contention, which hurts scalability. Keep your services
stateless so they can be shared freely without thread-safety concerns for
maximum scalability.
> >
> >
> >
> >   Ted Neward
> >   Author, Instructor, Presenter: Java and .NET
> >   http://www.neward.net/ted/weblog
> >   http://www.javageeks.com
> >   http://www.clrgeeks.com
> >
> >   -----Original Message-----
> >   From: Niket Anand [mailto:niket@noida.manystreams.com]
> >   Sent: Monday, May 26, 2003 11:24 AM
> >   To: axis-dev@ws.apache.org; axis-user@ws.apache.org
> >   Subject: Service Class as Singleton Class
> >
> >
> >
> >
> >
> >
> >
> >     Hello All,
> >
> >     I am newbie to Axis. I am facing problem as
java.lang.InstantiationException exception when my service class is
Singleton class and having private constructor and getInstance() to get
instance of this class. When axis client ask for a method from the service
class then it throw this exception. If I remove the Singleton ability and
provide public constructor then it works fine. But I want it to be remain
Singleton . Please help me How to work with Service class as Singleton and
what modification needs to be done in wsdd.
> >
> >
> >
> >     waiting for reply...
> >
> >     thanks,
> >
> >     Niket
> >
>


Re: Service Class as Singleton Class

Posted by Peter Mount <pe...@retep.org.uk>.
Just thinking, whay not have a wrapper class which isn't a singleton. Have
axis access this class, but it simply passes the calls on to the
singleton. Should get rid of the InstantiationException.

Peter

-- 
Peter Mount
peter@retep.org.uk
http://www.retep.org/
http://retep.net/
   Tel/Fax: +44 (0) 1622 749439
    Mobile: +44 (0) 7903 155887
    US Fax: 1 435 304 5165
  US Voice: 1 435 304 5165
    IM-MSN: retep207@hotmail.com
IM-AOL/ICQ: retepworld


On Mon, 26 May 2003, Niket Anand wrote:

> Hello Ted,
> Actually I have a Service class named SessionManager which keeps track of all kinds of applications attached to Server. So I made this class as Singleton and at server side I get some informations regarding all attached applications using SessionManager getInstance() and call mehods..... as SessionManager store all informations of attached Applications.
> As an application as Axis client try to attach to server calling SessionManager services. It give as java.lang.InstantiationException.
> I can't remove the Singleton property of that class. Can this is possible in AXIS?????
>
> Please reply back.
> Thanks,
> Niket
>   ----- Original Message -----
>   From: Ted Neward
>   To: axis-user@ws.apache.org ; axis-dev@ws.apache.org
>   Sent: Monday, May 26, 2003 5:57 AM
>   Subject: RE: Service Class as Singleton Class
>
>
>   Don't make it a Singleton-although you might be able to work your way through this particular issue, a number of other issues are going to arise that will ultimately make you regret making this class a Singleton. Singletons imply object identity, which in turn implies concurrency, which in turn implies contention, which hurts scalability. Keep your services stateless so they can be shared freely without thread-safety concerns for maximum scalability.
>
>
>
>   Ted Neward
>   Author, Instructor, Presenter: Java and .NET
>   http://www.neward.net/ted/weblog
>   http://www.javageeks.com
>   http://www.clrgeeks.com
>
>   -----Original Message-----
>   From: Niket Anand [mailto:niket@noida.manystreams.com]
>   Sent: Monday, May 26, 2003 11:24 AM
>   To: axis-dev@ws.apache.org; axis-user@ws.apache.org
>   Subject: Service Class as Singleton Class
>
>
>
>
>
>
>
>     Hello All,
>
>     I am newbie to Axis. I am facing problem as java.lang.InstantiationException exception when my service class is Singleton class and having private constructor and getInstance() to get instance of this class. When axis client ask for a method from the service class then it throw this exception. If I remove the Singleton ability and provide public constructor then it works fine. But I want it to be remain Singleton . Please help me How to work with Service class as Singleton and what modification needs to be done in wsdd.
>
>
>
>     waiting for reply...
>
>     thanks,
>
>     Niket
>


Re: Service Class as Singleton Class

Posted by Niket Anand <ni...@noida.manystreams.com>.
Hello Ted,
Actually I have a Service class named SessionManager which keeps track of all kinds of applications attached to Server. So I made this class as Singleton and at server side I get some informations regarding all attached applications using SessionManager getInstance() and call mehods..... as SessionManager store all informations of attached Applications. 
As an application as Axis client try to attach to server calling SessionManager services. It give as java.lang.InstantiationException.
I can't remove the Singleton property of that class. Can this is possible in AXIS?????

Please reply back.
Thanks,
Niket
  ----- Original Message ----- 
  From: Ted Neward 
  To: axis-user@ws.apache.org ; axis-dev@ws.apache.org 
  Sent: Monday, May 26, 2003 5:57 AM
  Subject: RE: Service Class as Singleton Class


  Don't make it a Singleton-although you might be able to work your way through this particular issue, a number of other issues are going to arise that will ultimately make you regret making this class a Singleton. Singletons imply object identity, which in turn implies concurrency, which in turn implies contention, which hurts scalability. Keep your services stateless so they can be shared freely without thread-safety concerns for maximum scalability.

   

  Ted Neward
  Author, Instructor, Presenter: Java and .NET
  http://www.neward.net/ted/weblog
  http://www.javageeks.com
  http://www.clrgeeks.com

  -----Original Message-----
  From: Niket Anand [mailto:niket@noida.manystreams.com] 
  Sent: Monday, May 26, 2003 11:24 AM
  To: axis-dev@ws.apache.org; axis-user@ws.apache.org
  Subject: Service Class as Singleton Class

   

   

     

    Hello All,

    I am newbie to Axis. I am facing problem as java.lang.InstantiationException exception when my service class is Singleton class and having private constructor and getInstance() to get instance of this class. When axis client ask for a method from the service class then it throw this exception. If I remove the Singleton ability and provide public constructor then it works fine. But I want it to be remain Singleton . Please help me How to work with Service class as Singleton and what modification needs to be done in wsdd.

     

    waiting for reply...

    thanks,

    Niket