001 package com.sptci.echo2demo;
002
003 import java.util.logging.Logger;
004 import nextapp.echo2.app.ApplicationInstance;
005 import nextapp.echo2.webcontainer.WebContainerServlet;
006
007 import javax.jdo.PersistenceManager;
008 import com.sptci.jdo.PersistenceManagerFactory;
009
010 /**
011 * The <code>WebContainerServlet</code> implementation required for
012 * the <b>Echo2</b> event-driven web development framework.
013 *
014 * <p>Copyright 2006 Sans Pareil Technologies, Inc.</p>
015 * @author Rakesh Vidyadharan 2006-01-21
016 * @version $Id: Servlet.java,v 1.3 2006/02/14 22:39:17 rakesh Exp $
017 */
018 public class Servlet extends WebContainerServlet
019 {
020 /**
021 * The mandatory method that is to be implemented. Returns a new
022 * instance of {@link Application}.
023 *
024 * @return ApplicationInstance The appropriate implementation of
025 * <code>ApplicationInstance</code> for this web application.
026 */
027 public ApplicationInstance newApplicationInstance()
028 {
029 return new Application();
030 }
031
032 /**
033 * Close the <code>JDO PersistenceManager</code> upon web application
034 * de-installation.
035 */
036 public void destroy()
037 {
038 Logger.getLogger( "com.sptci.echo2demo.Servlet" ).info(
039 "Closing persistence manager." );
040 try
041 {
042 PersistenceManager pm =
043 PersistenceManagerFactory.getPersistenceManager();
044 pm.close();
045 }
046 catch ( Throwable t )
047 {
048 t.printStackTrace();
049 }
050 }
051 }