George Ludwig wrote:
> Ingo Schuster wrote:
>
> > Hello
> >
> > In his book "Enterprise Java Computing" Govind Seshadri writes:
> > "I would not recommend accessing an RMIlet using RMI clients due to
> > servlet lifecycle issues." (By RMIlet he means a servlet implementing the
> > Remote interface).
> > Does anybody have an idea why you shouldn't access an servlet via RMI?
> > What exactly does he mean by "lifecycle issues"?
>
> Did you ever get an asnwer on this? I've done some RMI, and Ica't think of any
> reason NOT to connect to a servlet via RMI.
>
I did in fact answer this question, but it probably only went out on JSP-INTEREST
where I originally saw it. Briefly, the "lifecycle" issue is the fact that a
servlet container is allowed to throw out your servlet instance at any time, and
create a new one at any time. This doesn't match the conceptual model of RMI
server objects, which normally stay resident the entire life of the server.
>
> I was considering doing exactly that to implement a servlet console.
>
IMHO trying to use the same class as a servlet and an RMI server object is not
very good O-O design. Perhaps a better strategy would be to create your RMI
server as a separate class. You could create an instance of it as the servlet
container starts up, and stash it as a servlet context attribute (presuming it
needs to be shared among several servlets and/or JSP pages in your application).
Now, whenever a servlet needs to modify its behavior based on the current state
information in your RMI server object, it does something like this:
ServerObject server = getServletContext().getAttribute("my_object_key")
if (server.getFooSetting() == 1) {
... do this ...
} else {
... do that ...
}
Now, you can focus the design of your ServerObject at being a good RMI server
design, and your servlet at being a good servlet design, without trying to cram
both sets of functionality into a single object.
>
> George
>
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html