Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Startup Classloading in Websphere

 
Sumona Dev
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am using WebSphere4.0 AEs.I want to load a class as soon as server starts up. In there any option for that.
For example in weblogic server admin console there is one option called startup and shutdown.
There you can specify the class which you want to load.Is there any option in WebSphere?
Help needed.
Thanks
Sumona
 
Rajeev Gupta
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can pre load a servlet, and let it perform the tasks at startup time. This can be setup in web.xml file.
<servlet>
<your servlet parameters ... />
<load-on-startup>1</load-on-startup>
</servlet>
 
Rajeev Gupta
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
example:
<servlet>
<your servlet parameters ... />
<load-on-startup>1</load-on-startup> </servlet>
 
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by
.I want to load a class as soon as server starts up.

Do you mean as soon as the Admin server starts.
Or as soon as the application server where your application is deployed starts
What kind of class is it ? How are you going to use it ?
Maybe this documentationm from the infocenter could help
 
Junaid Bhatra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WebSphere has a similar feature, called as Custom Services. But unlike WebLogic, in which you can give any arbitrary class file with a main() method, the custom service in WebSphere *has* to implement a specific interface. When the application server starts up, it will call a particular method on your class. Search the WebSphere docs for specifics on this.
However you must be careful in using this WebSphere feature. WebSphere makes no guarantee about the order in which this custom service will be called. Also there is no guarantee that any app-server services (eg, JNDI naming service, Connection Pools) will be fully initialized when your custom service is called. So if your custom class needs to lookup, say a JNDI reference, it may not be available!
As someone else suggested, the cleanest way is to implement a startup servlet, which simply calls your custom class within the init() method. Using this approach, it is guaranteed that the app-server services will be fully initialized by the time the servlet is loaded.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic