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 rouble <ro...@gmail.com> on 2009/01/18 17:44:52 UTC

Instantiate ServiceClass on start up

Hi All,

I have an "application" scope axis2 web service. I want the ServiceClass to
be instantiated on startup, as opposed to when the first method is invoked.

I found (and implemented) a ServiceLifeCycle class, but I don't know how
exactly to instantiate the ServiceClass from within the startup() method.

Any help will be appreciated.

TIA,
rouble

Re: Instantiate ServiceClass on start up

Posted by rouble <ro...@gmail.com>.
Hi Deepal et al,

You are right. An application scope service is instantiated when the system
(in my case tomcat) is started (or restarted).

Actually, I was hot deploying an application scope service. I would think
hot deploying an application scope service should also instantiate the
service, but, I would like to know your thoughts on that.

For now, I think this works for me. It just means that the service needs to
be in place before tomcat is started. I am going to continue testing axis2
to see if it works for our purposes.

Thanks much,
rouble

On Sun, Jan 18, 2009 at 12:56 PM, Deepal jayasinghe <de...@gmail.com>wrote:

> I went though the code and found that all the services (application
> scope) are there in the system when the system startup will called the
> init() method of the service impl class. For to check this I wrote a
> simple service with "init" method and deploy in application scope. Then,
> when I start tomcat I can see the output of the init method on the
> console. For your reference I have attached the service herewith this mail.
>
> So if the service is there in the system when the system startup then
> your application scope service will be initialized.
>
> Deepal
> > What part of the ServiceClass is supposed to be called on startup in
> > application scope? I am using axis2 1.4.1, and the constructor of the
> > ServiceClass is only called when the first method is invoked.
> >
> > I also implemented the init() and destroy() methods. The init() method
> > is also called when the first method is invoked.
> >
> > The order of things, seems to be:
> > 1. Service is deployed
> > 2. ServiceLifeCycle.startup() is called
> > 3. Everything just sits there
> > 4. method is called (in-only MEP)
> > 5. ServiceClass constructor called
> > 6. ServiceClass init() method is called.
> >
> > The ServiceClass does last the lifetime of the Server.
> >
> > That said, is there a workaround by which I can instantiate
> > ServiceClass on startup? I am thinking I can invoke something in
> > ServiceLifeCycle.startup(), or write a script that invokes a soap
> > client on startup.
> >
> > We are evaluating if we should use axis2 for one of our projects at
> > our company, and this is a must-have requirement.
> >
> > Cheers
> > rouble
> >
> > On Sun, Jan 18, 2009 at 11:58 AM, Deepal Jayasinghe
> > <deepal@opensource.lk <ma...@opensource.lk>> wrote:
> >
> >     Well ServiceLifeCycle class is different thing, anyway you may use
> >     that
> >     to do  the initialization logic.
> >     As I remember correct when you deploy a service in application
> >     scope it
> >     should initialize the class system startup time, if that does not
> work
> >     then it is a bug.
> >
> >     Deepal
> >
> >     rouble wrote:
> >     > Hi All,
> >     >
> >     > I have an "application" scope axis2 web service. I want the
> >     > ServiceClass to be instantiated on startup, as opposed to when the
> >     > first method is invoked.
> >     >
> >     > I found (and implemented) a ServiceLifeCycle class, but I don't
> know
> >     > how exactly to instantiate the ServiceClass from within the
> >     startup()
> >     > method.
> >     >
> >     > Any help will be appreciated.
> >     >
> >     > TIA,
> >     > rouble
> >
> >     --
> >     Thank you!
> >
> >
> >     http://blogs.deepal.org
> >     http://deepal.org
> >
> >
> >
> >
> > --
> > this message is composed of 100% recycled ascii
>
>
> --
> Thank you!
>
>
> http://blogs.deepal.org
> http://deepal.org
>
>


-- 
this message is composed of 100% recycled ascii

Re: Instantiate ServiceClass on start up

Posted by Deepal jayasinghe <de...@gmail.com>.
I went though the code and found that all the services (application
scope) are there in the system when the system startup will called the
init() method of the service impl class. For to check this I wrote a
simple service with "init" method and deploy in application scope. Then,
when I start tomcat I can see the output of the init method on the
console. For your reference I have attached the service herewith this mail.

So if the service is there in the system when the system startup then
your application scope service will be initialized.

Deepal
> What part of the ServiceClass is supposed to be called on startup in
> application scope? I am using axis2 1.4.1, and the constructor of the
> ServiceClass is only called when the first method is invoked.
>
> I also implemented the init() and destroy() methods. The init() method
> is also called when the first method is invoked.
>
> The order of things, seems to be:
> 1. Service is deployed
> 2. ServiceLifeCycle.startup() is called
> 3. Everything just sits there
> 4. method is called (in-only MEP)
> 5. ServiceClass constructor called
> 6. ServiceClass init() method is called.
>
> The ServiceClass does last the lifetime of the Server.
>
> That said, is there a workaround by which I can instantiate
> ServiceClass on startup? I am thinking I can invoke something in
> ServiceLifeCycle.startup(), or write a script that invokes a soap
> client on startup.
>
> We are evaluating if we should use axis2 for one of our projects at
> our company, and this is a must-have requirement.
>
> Cheers
> rouble
>
> On Sun, Jan 18, 2009 at 11:58 AM, Deepal Jayasinghe
> <deepal@opensource.lk <ma...@opensource.lk>> wrote:
>
>     Well ServiceLifeCycle class is different thing, anyway you may use
>     that
>     to do  the initialization logic.
>     As I remember correct when you deploy a service in application
>     scope it
>     should initialize the class system startup time, if that does not work
>     then it is a bug.
>
>     Deepal
>
>     rouble wrote:
>     > Hi All,
>     >
>     > I have an "application" scope axis2 web service. I want the
>     > ServiceClass to be instantiated on startup, as opposed to when the
>     > first method is invoked.
>     >
>     > I found (and implemented) a ServiceLifeCycle class, but I don't know
>     > how exactly to instantiate the ServiceClass from within the
>     startup()
>     > method.
>     >
>     > Any help will be appreciated.
>     >
>     > TIA,
>     > rouble
>
>     --
>     Thank you!
>
>
>     http://blogs.deepal.org
>     http://deepal.org
>
>
>
>
> -- 
> this message is composed of 100% recycled ascii


-- 
Thank you!


http://blogs.deepal.org
http://deepal.org


Re: Instantiate ServiceClass on start up

Posted by rouble <ro...@gmail.com>.
What part of the ServiceClass is supposed to be called on startup in
application scope? I am using axis2 1.4.1, and the constructor of the
ServiceClass is only called when the first method is invoked.

I also implemented the init() and destroy() methods. The init() method is
also called when the first method is invoked.

The order of things, seems to be:
1. Service is deployed
2. ServiceLifeCycle.startup() is called
3. Everything just sits there
4. method is called (in-only MEP)
5. ServiceClass constructor called
6. ServiceClass init() method is called.

The ServiceClass does last the lifetime of the Server.

That said, is there a workaround by which I can instantiate ServiceClass on
startup? I am thinking I can invoke something in ServiceLifeCycle.startup(),
or write a script that invokes a soap client on startup.

We are evaluating if we should use axis2 for one of our projects at our
company, and this is a must-have requirement.

Cheers
rouble

On Sun, Jan 18, 2009 at 11:58 AM, Deepal Jayasinghe <de...@opensource.lk>wrote:

> Well ServiceLifeCycle class is different thing, anyway you may use that
> to do  the initialization logic.
> As I remember correct when you deploy a service in application scope it
> should initialize the class system startup time, if that does not work
> then it is a bug.
>
> Deepal
>
> rouble wrote:
> > Hi All,
> >
> > I have an "application" scope axis2 web service. I want the
> > ServiceClass to be instantiated on startup, as opposed to when the
> > first method is invoked.
> >
> > I found (and implemented) a ServiceLifeCycle class, but I don't know
> > how exactly to instantiate the ServiceClass from within the startup()
> > method.
> >
> > Any help will be appreciated.
> >
> > TIA,
> > rouble
>
> --
> Thank you!
>
>
> http://blogs.deepal.org
> http://deepal.org
>
>


-- 
this message is composed of 100% recycled ascii

Re: Instantiate ServiceClass on start up

Posted by Deepal Jayasinghe <de...@opensource.lk>.
Well ServiceLifeCycle class is different thing, anyway you may use that
to do  the initialization logic.
As I remember correct when you deploy a service in application scope it
should initialize the class system startup time, if that does not work
then it is a bug.

Deepal

rouble wrote:
> Hi All,
>
> I have an "application" scope axis2 web service. I want the
> ServiceClass to be instantiated on startup, as opposed to when the
> first method is invoked.
>
> I found (and implemented) a ServiceLifeCycle class, but I don't know
> how exactly to instantiate the ServiceClass from within the startup()
> method.
>
> Any help will be appreciated.
>
> TIA,
> rouble

-- 
Thank you!


http://blogs.deepal.org
http://deepal.org