• Post Reply Bookmark Topic Watch Topic
  • New Topic

design issue

 
shankar vembu
Ranch Hand
Posts: 309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a running web application on tomcat. Now I need to decouple some functionalities of this app and expose it as a web service. This is not a big problem cos I already have this functionality as an interface. But I face a problem, a design issue. When I start my web app using tomcat, I do some init stuff in the init() method of the base servlet like initialising logs, config files, db connections etc. My to-be-exposed service also needs to access these resources. So I wrote a separate logger, config files for my service thereby removing the dependencies the service had with the web app. Now where do I initilise these startup resources??? I thought of having static intializers in my code to handle this but the problem is I wanna take some apt action when an exception occurs during init-ing my service and hwo do I achive this ?? any pointers... i hope my question is clear.
thanx,shankar
 
shankar vembu
Ranch Hand
Posts: 309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK to put it in simpler words, I need to do some init stuff when my web service is deployed, abort the deployment if an exception occurs during init, and then if if everything goes fine I need to do some cleanup stuff when the service is undeployed. Is this possible ? This is exactly what I do when I get my web application running....
Regards
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really haven't thought of that kind of issue for web service deployment, but here's one suggestion anyway.
Have your deployment process do something like
  • Deploy the service
  • Invoke the service in such a way that your script can figure out whether the service was initialized correctly
  • Undeploy the service if the init failed
  •  
    Kyle Brown
    author
    Ranch Hand
    Posts: 3892
    5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Another possibility; Pretty much all the J2EE Web Services Engines (like Axis) are based on a Web Container like TomCat. So just keep your existing init() method, just move it into its own special "init" servlet and make sure that gets put in the same WebApp as your Web Services servlet.
    Kyle
     
    shankar vembu
    Ranch Hand
    Posts: 309
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you for the replies.
    Originally posted by Kyle Brown:
    So just keep your existing init() method, just move it into its own special "init" servlet and make sure that gets put in the same WebApp as your Web Services servlet.
    Kyle

    You mean to say that I have servlet registered in the axis web.xml alongwith other servlets like AxisServlet. And then when the init process in my servlet fails it will throw a ServletException that will stop the axis itself from being deployed, right??
    regards.
     
    Kyle Brown
    author
    Ranch Hand
    Posts: 3892
    5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Well, it depends on the container you are working in whether or not deployment of the Axis servlet would continue. But you would ertainly provide a notice that deployment failed at the right time.
    Kyle
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!