FileDocCategorySizeDatePackage
ActionServlet.javaAPI DocJBoss 4.2.13811Fri Jul 13 20:55:42 BST 2007xpetstore.web.servlet

ActionServlet

public class ActionServlet extends webwork.dispatcher.ServletDispatcher
author
Herve Tchepannou
web.servlet
name="action" display-name="xPetstore WebWork Action Servlet" load-on-startup="1"
web.servlet-mapping
url-pattern="*.action"
web.resource-ref
name="${jndi.mail.session}" type="javax.mail.Session" auth="Container"
jboss.resource-ref
res-ref-name="${jndi.mail.session}" jndi-name="${jboss.mail.session}"
weblogic.resource-description
res-ref-name="${jndi.mail.session}" jndi-name="${weblogic.mail.session}"

Fields Summary
private static final Logger
__logger
public static final String
SESSION_FACTORY_KEY
Constructors Summary
Methods Summary
public voiddestroy()

see
javax.servlet.Servlet#destroy()

        getServletContext(  ).removeAttribute( SESSION_FACTORY_KEY );

        super.destroy(  );
    
public voidinit(javax.servlet.ServletConfig config)

see
javax.servlet.Servlet#init(javax.servlet.ServletConfig)


    //~ Methods ----------------------------------------------------------------

           
         
         
    
        super.init( config );

        __logger.info( "Initializing" );

        try
        {
            Datastore ds = Hibernate.createDatastore(  );

            /* Classes */
            load( Account.class, ds );
            load( Category.class, ds );
            load( Customer.class, ds );
            load( Item.class, ds );
            load( Order.class, ds );
            load( OrderItem.class, ds );
            load( Product.class, ds );

            /* Hibernate properties */
            __logger.info( "...loading: hibernate.properties" );

            InputStream in = getClass(  ).getClassLoader(  ).getResourceAsStream( "hibernate.properties" );
            Properties  props = new Properties(  );
            props.load( in );

            /* Session Factory */
            __logger.info( "...initializing the Hibernate SessionFactory" );

            SessionFactory sessionFactory = ds.buildSessionFactory( props );
            config.getServletContext(  ).setAttribute( SESSION_FACTORY_KEY, sessionFactory );

            __logger.info( "Initialized" );
        }
        catch ( HibernateException h )
        {
            throw new ServletException( h );
        }
        catch ( IOException io )
        {
            throw new ServletException( "Unable to load: hibernate.properties", io );
        }
    
private voidload(java.lang.Class type, cirrus.hibernate.Datastore ds)

        try
        {
            __logger.info( "... loading mapping for: " + type );
            ds.storeClass( type );
        }
        catch ( Exception e )
        {
            throw new ServletException( "Unable to load Hibernate mapping:" + type, e );
        }