• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Managing lifecycle of servlets

 
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Does there exists features in the current opensource/commercial appservers that would allow you to manage the lifecycle of individual servlets ?
By "management", I mean I want to be able to stop/start a servlet - i.e. equivalent to calling destroy/init respectively. When the servlet is "stopped", accessing the url mapped to the servlet should flag a 404. I've read this Invoker Servlet Thread but it doesn't seem to provide a definite answer.

On the top of my head, one way would be to archive one servlet in its own individual war file. Then one would be able to deploy/undeploy the war - effectively doing the start/stop in a crude way. Hope to hear from users of commercial appservers like BEA, Oracle etc.. Thanks a lot everyone.

Regards,

Pho
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know of no server that would such functionality. And I'm not sure why any would -- it's a really odd thing to want to do.

What are you really trying to accomplish? I'm sure a supported means to do what you really need can be devised.
 
Pho Tek
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

I need to have fine grained control on the lifecycle of servlets (from an administrative perspective). I don't think it's an odd request at all. Currently if I wanted to disable a servlet for a short amount of time, I would need to deactivate the whole war/ear, modify the web.xml, then redeploy. Then when I want to RE-ENABLE the servlet, I would need to redo the shtick again. Seems very inflexible to me.

Regards,

Pho
[ February 19, 2007: Message edited by: Pho Tek ]
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I need to have fine grained control on the lifecycle of servlets (from an administrative perspective).



Well then create your own administrative servlet as part of the web application. This servlet would manage a resource held in the application context which would control and monitor all the public servlets in the context. In addition to switching servlets on and off it could count accesses, monitor response time, etc etc.
Before responding to a request, a public servlet would check this shared resource to see if it currently allowed to run.

Bill
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to explore the concept of filters or the Front Controller pattern.

Breaking each servlet up into its own web application would be folly.
 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could simply make a new servlet base class that implemented its own start/stop functionality via a special HTTP or JMX request.

Normally, however, I expect servlets to be supporting components of an app, not business units in their own right. So about the closest I get is starting and stopping application subsystems. To do otherwise for me would be the same as starting and stopping classes.

And, of course, neither servlets nor classes are thread objects (OK, so java.lang.Thread and descendents are exceptions), so actually starting and stopping a servlet isn't technically possible - all you can do is either stop passing it requests or make it reject the requests it does get.
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic