Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WebObjects apps in war; maven; where is ERXServletAdaptor; etc.



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@hidden";>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@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/email@hidden

This email sent to email@hidden

References: 
 >WebObjects apps in war; maven; where is ERXServletAdaptor; etc. (From: Greg Brown <email@hidden>)
 >Re: WebObjects apps in war; maven; where is ERXServletAdaptor; etc. (From: David Avendasora <email@hidden>)
 >Re: WebObjects apps in war; maven; where is ERXServletAdaptor; etc. (From: Lachlan Deck <email@hidden>)
 >Re: WebObjects apps in war; maven; where is ERXServletAdaptor; etc. (From: Henrique Prange <email@hidden>)
 >Re: WebObjects apps in war; maven; where is ERXServletAdaptor; etc. (From: Mike Schrag <email@hidden>)
 >Re: WebObjects apps in war; maven; where is ERXServletAdaptor; etc. (From: Henrique Prange <email@hidden>)
 >Re: WebObjects apps in war; maven; where is ERXServletAdaptor; etc. (From: Q <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.