You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Dan Polivy <da...@hotmail.com> on 2001/11/03 19:56:21 UTC
Object Persistence
Hi,
I'm sort of new to SOAP, and had a couple questions that hopefully someone
can help me answer. I have a small application that I would like to be
created when my webserver (right now Apache Tomcat) starts up. This small
application will in turn create a few instances of other objects that will
run in their own threads and do their own things. The reason I want this to
happen within the same JVM as the webserver is that I do not want to have to
use RMI or some other abtraction to talk to my application using SOAP (i.e.
the SOAP request goes to a servlet that uses RMI to communicate with the
app). Now, here are my questions:
1) Assuming that I can create the master object, which in turn creates
other objects, can I then make SOAP RPC calls into methods on these other
objects (which is what I want to do)?
2) How would I create this master object when my webserver loads up so that
these subobjects are accesible through apache SOAP? The subobjects have to
be created by the master object, they cannot be created independently.
Thanks for your help! I appreciate it!
Dan
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
Re: Object Persistence
Posted by Nicholas Quaine <nq...@soapuser.com>.
Here is one idea that may help...
Your master object can simply be an object in another servlet which runs at
your servlet engine startup time (so it is in the same VM). Taking tomcat as
an example in the $TOMCAT_HOME/webapps/soap/WEB-INF directory you will see
web.xml which will already contain your soap rpcrouter servlet - just add
another servlet which will instantiate your object. Ensure that the
<load-on-startup> specifies "1" for true. Note that you can also specifiy
parameters to pass to your initialization class so you do not have to
hardcode anything (like database names for example). Example web.xml file is
below.
Note that when you want to make use of the master object you just invoke it
as you would any class/method - you do not use SOAP to communicate with it.
Rather your methods which are exposed to the outside world are invoked
thtrough SOAP and then those methods invoke master object methods.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>
rpcrouter
</servlet-name>
<servlet-class>
org.apache.soap.server.http.RPCRouterServlet
</servlet-class>
<init-param>
<param-name>ServicesStore</param-name>
<param-value>DeployedServices.ds</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>
myStartupServlet
</servlet-name>
<servlet-class>
com.mycompany.myproject.mypackagename.MyInitializationCodeClass
</servlet-class>
<init-param>
<param-name>-X</param-name>
<param-value>myStartupParameterValue1</param-value>
<param-name>-Y</param-name>
<param-value>myStartupParameterValue2</param-value>
<param-name>-Z</param-name>
<param-value>myStartupParameterValue3</param-value>
</init-param>
<load-on-startup>
1
</load-on-startup>
</servlet>
</web-app>
hope that helps
regards,
Nicholas Quaine
Visit http://www.soapuser.com/
nquaine@soapuser.com
----- Original Message -----
From: "Hung D. Viet" <di...@epiqus.com>
To: <so...@xml.apache.org>
Sent: Tuesday, November 06, 2001 3:24 AM
Subject: RE: Object Persistence
> Hi Dan,
>
> I don't think that Soap directly supports it. However, there maybe a work
> around in this case.
>
> If you make the "other sub-objects" to be singleton then would it be OK?
> Because you can access these "sub-objects" in the same VM.
>
> You can write a wrapper class to access this singleton, and deploy this
> class into Soap.
>
> I haven't tried what I'm just saying, but hope that it works.
>
> cheers,
> Hung
>
>
> -----Original Message-----
> From: Dan Polivy [mailto:danpolivy@hotmail.com]
> Sent: Sunday, November 04, 2001 2:56 AM
> To: soap-user@xml.apache.org
> Subject: Object Persistence
>
>
> Hi,
>
> I'm sort of new to SOAP, and had a couple questions that hopefully someone
> can help me answer. I have a small application that I would like to be
> created when my webserver (right now Apache Tomcat) starts up. This small
> application will in turn create a few instances of other objects that will
> run in their own threads and do their own things. The reason I want this
to
> happen within the same JVM as the webserver is that I do not want to have
to
> use RMI or some other abtraction to talk to my application using SOAP
(i.e.
> the SOAP request goes to a servlet that uses RMI to communicate with the
> app). Now, here are my questions:
>
> 1) Assuming that I can create the master object, which in turn creates
> other objects, can I then make SOAP RPC calls into methods on these other
> objects (which is what I want to do)?
>
> 2) How would I create this master object when my webserver loads up so
that
> these subobjects are accesible through apache SOAP? The subobjects have
to
> be created by the master object, they cannot be created independently.
>
> Thanks for your help! I appreciate it!
>
> Dan
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
Re: Object Persistence
Posted by Nicholas Quaine <nq...@soapuser.com>.
Here is one idea that may help...
Your master object can simply be an object in another servlet which runs at
your servlet engine startup time (so it is in the same VM). Taking tomcat as
an example in the $TOMCAT_HOME/webapps/soap/WEB-INF directory you will see
web.xml which will already contain your soap rpcrouter servlet - just add
another servlet which will instantiate your object. Ensure that the
<load-on-startup> specifies "1" for true. Note that you can also specifiy
parameters to pass to your initialization class so you do not have to
hardcode anything (like database names for example). Example web.xml file is
below.
Note that when you want to make use of the master object you just invoke it
as you would any class/method - you do not use SOAP to communicate with it.
Rather your methods which are exposed to the outside world are invoked
thtrough SOAP and then those methods invoke master object methods.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>
rpcrouter
</servlet-name>
<servlet-class>
org.apache.soap.server.http.RPCRouterServlet
</servlet-class>
<init-param>
<param-name>ServicesStore</param-name>
<param-value>DeployedServices.ds</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>
myStartupServlet
</servlet-name>
<servlet-class>
com.mycompany.myproject.mypackagename.MyInitializationCodeClass
</servlet-class>
<init-param>
<param-name>-X</param-name>
<param-value>myStartupParameterValue1</param-value>
<param-name>-Y</param-name>
<param-value>myStartupParameterValue2</param-value>
<param-name>-Z</param-name>
<param-value>myStartupParameterValue3</param-value>
</init-param>
<load-on-startup>
1
</load-on-startup>
</servlet>
</web-app>
hope that helps
regards,
Nicholas Quaine
Visit http://www.soapuser.com/
nquaine@soapuser.com
----- Original Message -----
From: "Hung D. Viet" <di...@epiqus.com>
To: <so...@xml.apache.org>
Sent: Tuesday, November 06, 2001 3:24 AM
Subject: RE: Object Persistence
> Hi Dan,
>
> I don't think that Soap directly supports it. However, there maybe a work
> around in this case.
>
> If you make the "other sub-objects" to be singleton then would it be OK?
> Because you can access these "sub-objects" in the same VM.
>
> You can write a wrapper class to access this singleton, and deploy this
> class into Soap.
>
> I haven't tried what I'm just saying, but hope that it works.
>
> cheers,
> Hung
>
>
> -----Original Message-----
> From: Dan Polivy [mailto:danpolivy@hotmail.com]
> Sent: Sunday, November 04, 2001 2:56 AM
> To: soap-user@xml.apache.org
> Subject: Object Persistence
>
>
> Hi,
>
> I'm sort of new to SOAP, and had a couple questions that hopefully someone
> can help me answer. I have a small application that I would like to be
> created when my webserver (right now Apache Tomcat) starts up. This small
> application will in turn create a few instances of other objects that will
> run in their own threads and do their own things. The reason I want this
to
> happen within the same JVM as the webserver is that I do not want to have
to
> use RMI or some other abtraction to talk to my application using SOAP
(i.e.
> the SOAP request goes to a servlet that uses RMI to communicate with the
> app). Now, here are my questions:
>
> 1) Assuming that I can create the master object, which in turn creates
> other objects, can I then make SOAP RPC calls into methods on these other
> objects (which is what I want to do)?
>
> 2) How would I create this master object when my webserver loads up so
that
> these subobjects are accesible through apache SOAP? The subobjects have
to
> be created by the master object, they cannot be created independently.
>
> Thanks for your help! I appreciate it!
>
> Dan
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
RE: Object Persistence
Posted by "Hung D. Viet" <di...@epiqus.com>.
Hi Dan,
I don't think that Soap directly supports it. However, there maybe a work
around in this case.
If you make the "other sub-objects" to be singleton then would it be OK?
Because you can access these "sub-objects" in the same VM.
You can write a wrapper class to access this singleton, and deploy this
class into Soap.
I haven't tried what I'm just saying, but hope that it works.
cheers,
Hung
-----Original Message-----
From: Dan Polivy [mailto:danpolivy@hotmail.com]
Sent: Sunday, November 04, 2001 2:56 AM
To: soap-user@xml.apache.org
Subject: Object Persistence
Hi,
I'm sort of new to SOAP, and had a couple questions that hopefully someone
can help me answer. I have a small application that I would like to be
created when my webserver (right now Apache Tomcat) starts up. This small
application will in turn create a few instances of other objects that will
run in their own threads and do their own things. The reason I want this to
happen within the same JVM as the webserver is that I do not want to have to
use RMI or some other abtraction to talk to my application using SOAP (i.e.
the SOAP request goes to a servlet that uses RMI to communicate with the
app). Now, here are my questions:
1) Assuming that I can create the master object, which in turn creates
other objects, can I then make SOAP RPC calls into methods on these other
objects (which is what I want to do)?
2) How would I create this master object when my webserver loads up so that
these subobjects are accesible through apache SOAP? The subobjects have to
be created by the master object, they cannot be created independently.
Thanks for your help! I appreciate it!
Dan
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
RE: Object Persistence
Posted by "Hung D. Viet" <di...@epiqus.com>.
Hi Dan,
I don't think that Soap directly supports it. However, there maybe a work
around in this case.
If you make the "other sub-objects" to be singleton then would it be OK?
Because you can access these "sub-objects" in the same VM.
You can write a wrapper class to access this singleton, and deploy this
class into Soap.
I haven't tried what I'm just saying, but hope that it works.
cheers,
Hung
-----Original Message-----
From: Dan Polivy [mailto:danpolivy@hotmail.com]
Sent: Sunday, November 04, 2001 2:56 AM
To: soap-user@xml.apache.org
Subject: Object Persistence
Hi,
I'm sort of new to SOAP, and had a couple questions that hopefully someone
can help me answer. I have a small application that I would like to be
created when my webserver (right now Apache Tomcat) starts up. This small
application will in turn create a few instances of other objects that will
run in their own threads and do their own things. The reason I want this to
happen within the same JVM as the webserver is that I do not want to have to
use RMI or some other abtraction to talk to my application using SOAP (i.e.
the SOAP request goes to a servlet that uses RMI to communicate with the
app). Now, here are my questions:
1) Assuming that I can create the master object, which in turn creates
other objects, can I then make SOAP RPC calls into methods on these other
objects (which is what I want to do)?
2) How would I create this master object when my webserver loads up so that
these subobjects are accesible through apache SOAP? The subobjects have to
be created by the master object, they cannot be created independently.
Thanks for your help! I appreciate it!
Dan
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp