- Previous thread: jruby-user - File descriptor leak using persistent connections with Net::Http
- Next thread: jruby-user - status of sonatypes gem repository for maven artifacts
- Threads sorted by date: jruby-user 201007
I am trying to find the best way to implement ServletContextListener for my
rails application deployed in tomcat to receive application start and stop
events.
Thanks,
-Rakesh
I am trying to find the best way to implement ServletContextListener for my rails application deployed in tomcat to receive application start and stop events. Thanks,-Rakesh
rails application deployed in tomcat to receive application start and stop
events.
Thanks,
-Rakesh
I am trying to find the best way to implement ServletContextListener for my rails application deployed in tomcat to receive application start and stop events. Thanks,-Rakesh
Hi Rakesh
Am 27.07.2010 um 17:00 schrieb Rakesh Arora:
this is what we use
first change your web.xml:
full.package.path.to.your.ServletContextListnerClass
org.jruby.rack.rails.RailsServletContextListener
And
package full.package.path.to.your;
public class ServletContextListnerClass implements ServletContextListener {
final static Logger logger = Logger.getLogger(ServletContextListnerClass.class);
@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext ctx = sce.getServletContext();
MyApp app = MyApp myApp(ctx.getRealPath("/"));
ctx.setAttribute("myApp", app);
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
logger.info("My application is being stopped...");
MyApp app = (MyApp) sce.getServletContext().getAttribute("myapp");
if (app != null) {
app.shutdown();
logger.info("My application shutdown complete, good bye!");
} else {
logger.warn("No application instance found, skipping shutdown");
}
}
}
Checkout the Java Servlet specification for more details.
I'd be interested in a more clever way to handle the application instance. :)
Cheers
Reto Schüttel
http://xircles.codehaus.org/manage-email
Am 27.07.2010 um 17:00 schrieb Rakesh Arora:
this is what we use
first change your web.xml:
full.package.path.to.your.ServletContextListnerClass
org.jruby.rack.rails.RailsServletContextListener
And
package full.package.path.to.your;
public class ServletContextListnerClass implements ServletContextListener {
final static Logger logger = Logger.getLogger(ServletContextListnerClass.class);
@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext ctx = sce.getServletContext();
MyApp app = MyApp myApp(ctx.getRealPath("/"));
ctx.setAttribute("myApp", app);
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
logger.info("My application is being stopped...");
MyApp app = (MyApp) sce.getServletContext().getAttribute("myapp");
if (app != null) {
app.shutdown();
logger.info("My application shutdown complete, good bye!");
} else {
logger.warn("No application instance found, skipping shutdown");
}
}
}
Checkout the Java Servlet specification for more details.
I'd be interested in a more clever way to handle the application instance. :)
Cheers
Reto Schüttel
http://xircles.codehaus.org/manage-email
Am 27.07.2010 um 17:43 schrieb Reto Schüttel:
Meh, removed the wrong things, this should be:
The ctx.getRealPath("/") is used to know the place of the public folder. Usually you wont need this.
Cheers,
Reto
http://xircles.codehaus.org/manage-email
Meh, removed the wrong things, this should be:
The ctx.getRealPath("/") is used to know the place of the public folder. Usually you wont need this.
Cheers,
Reto
http://xircles.codehaus.org/manage-email
Related Threads
- C++-sig - Virtual methods with arguments and boost::cref - cplusplus-sig
- CentOS - unable to get domain status from libvirt & KVM - centos-general
- Re: I-D ACTION:draft-ietf-httpbis-security-properties-04.txt - w3c-ietf-http-wg
- yast-devel - WebYaST status 15-Mar-2010 - opensuse-yast-devel
- dm-devel - dmraid ./dmraid.spec ./make.tmpl.in include/Ma ... - redhat-dm-devel
- rules-users - Question About Programmatically Creating Drools Rules Remotely - jboss-rules-users
- asterisk-users - Asterisk 1.6 and OpenVPN RTP problem - asterisk-users
- Wine - Program links result in error - wine-users
- asterisk-users - send a call from A to B use sip trunk prablem - asterisk-users
- Creating PDF files with chinese characters - pdfbox-users