Thursday, October 14, 2010

Implementing Singleton in cluster envirnoment - Option 1

Steps 1: Write a singleton class which willl implement interface - weblogic.cluster.singleton.SingletonService              
  • public void activate()
  • This method should obtain any system resources and start any services required for the singleton service to begin processing requests. This method is called in the following cases:
    • When a newly deployed application is started
    • During server start
    • During the activation stage of service migration
  • public void deactivate()
  • This method is called during server shutdown and during the deactivation stage of singleton service migration. This method should release any resources obtained through the activate() method. Additionally, it should stop any services that should only be available from one member of a cluster. 

Steps 2:  make a jar and copy to App-Inf/lib folder so that it is picked during application intialisation.


Step 3:
Add the following entry to the weblogic-application.xml descriptor file.
<weblogic-application>
...
   <singleton-service>
      <class-name>mypackage.MySingletonServiceImpl</class-name>
      <name>Appscoped_Singleton_Service</name>
   </singleton-service>
...
</weblogic-application>
  
 
 
Resource -- 
http://download.oracle.com/docs/cd/E11035_01/wls100/cluster/service_migration.html#wp1051471 
 

No comments:

Post a Comment