Hi Q,

On 7/24/09 6:41 PM, Q wrote:


Oh. I have the source code with comments and everything else. It is
not available anywhere inside project Wonder only.

Can you send me a copy please. I was looking for this recently.


The source code is attached.

Cheers,

Henrique
package er.extensions.jspservlet;

import java.lang.reflect.Method;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;

import com.webobjects.jspservlet.WOServletAdaptor;

import er.extensions.ERXApplication;

/**
 * This class is just a wrapper around <code>WOServletAdaptor</code>.
 * <code>ERXServletAdaptor</code> must be used to make Wonder applications
 * compliant with WAR deployment.
 * <p>
 * This class is responsible to invoke the
 * {...@link ERXApplication#setup(String[])} method before the application
 * initialization.
 * 
 * @see WOServletAdaptor
 * @author <a href="mailto:[email protected]";>Henrique Prange</a>
 */
public class ERXServletAdaptor extends WOServletAdaptor
{
        /**
         * Invoke the <code>setup</code> method on the specified 
WOApplicationClass.
         * 
         * @param servletContext The servlet context to get the application 
class
         * @throws UnavailableException If something wrong happens while trying 
to
         *             invoke the application setup method.
         */
        static void invokeApplicationSetupMethod( final ServletContext 
servletContext ) throws UnavailableException
        {
                ClassLoader classLoader = 
WOServletAdaptor.class.getClassLoader();

                try
                {
                        String applicationClassName = 
servletContext.getInitParameter( "WOApplicationClass" );

                        if( applicationClassName == null || "".equals( 
applicationClassName ) )
                        {
                                throw new UnavailableException( 
"WOApplicationClass must be defined. Verify your web.xml configuration." );
                        }

                        Class<?> applicationClass = classLoader.loadClass( 
applicationClassName );

                        Method method = applicationClass.getMethod( "setup", 
new Class[] { String[].class } );

                        method.invoke( null, new Object[] { new String[0] } );
                }
                catch( Exception exception )
                {
                        exception.printStackTrace();

                        throw new UnavailableException( "Error initializing 
ERXServletAdaptor: " + exception.getMessage() );
                }
        }

        public ERXServletAdaptor() throws ServletException
        {
                super();
        }

        /**
         * Overrides the <code>_appliationInit</code> and invoke the
         * {...@link ERXApplication#setup(String[])} method before the 
application
         * initialization.
         * 
         * @see WOServletAdaptor#init()
         */
        @Override
        public void init() throws ServletException
        {
                invokeApplicationSetupMethod( getServletContext() );

                super.init();

                // TODO: Check if this is really necessary
                ERXApplication.erxApplication().didFinishLaunching();
        }

}
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to