How to use ContextLoaderListener,how to make application Listener

publicclass Main extends org.springframework.web.context.ContextLoaderListener {

 /**

*@param args

*/

DatabaseListner listener = new DatabaseListner();

publicvoid contextDestroyed(ServletContextEvent event) {

super.contextDestroyed(event);

listener.end();

listener = null;

System.out.println(“web app undeployed”);

}

publicvoid contextInitialized(ServletContextEvent event) {

super.contextInitialized(event);

new Thread(){

publicvoid run() {

listener.listen();

}

}.start();

System.out.println(“Web app is ready.”);

}

}

and add those lines to servlet at web.xml

<listener>
<listener-class>com.amazon.synchronizer.Main</listener-class>
</listener>

Advertisements

About lorddisk

WebCenter Content, WebCenter Portal, WebCenter Sites,Weblogic, Identity and Access Management (IAM),SSO,OAM,OIM,OAAM,OUD, OPAM,OID, OVD ,Oracle API Gateway ,OBIEE,OEDQ, Oracle ADF, Oracle SOA,J2EE, CackePHP ,PHP,J2SE,J2EE,Spring,Hibernate,JQuery,CSS,Java Script ,Joomla,Drupal,Worpress
This entry was posted in java and tagged , . Bookmark the permalink.