320073 further improved configuration
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2175 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
badbe6d252
commit
b4f4c0ae36
|
@ -13,6 +13,7 @@
|
|||
|
||||
package org.eclipse.jetty.annotations;
|
||||
|
||||
import org.eclipse.jetty.webapp.AbstractConfiguration;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
|
@ -21,31 +22,17 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
|||
*
|
||||
*
|
||||
*/
|
||||
public class AnnotationConfiguration implements Configuration
|
||||
public class AnnotationConfiguration extends AbstractConfiguration
|
||||
{
|
||||
|
||||
public void preConfigure(final WebAppContext context) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void configure(WebAppContext context) throws Exception
|
||||
{
|
||||
WebAppDecoratorWrapper wrapper = new WebAppDecoratorWrapper(context, context.getDecorator());
|
||||
context.setDecorator(wrapper);
|
||||
context.addDecorator(new AnnotationDecorator(context));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void deconfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void postConfigure(WebAppContext context) throws Exception
|
||||
@Override
|
||||
public void cloneConfigure(WebAppContext template, WebAppContext context) throws Exception
|
||||
{
|
||||
context.addDecorator(new AnnotationDecorator(context));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,17 +30,15 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
|||
*
|
||||
*
|
||||
*/
|
||||
public class WebAppDecoratorWrapper implements Decorator
|
||||
public class AnnotationDecorator implements Decorator
|
||||
{
|
||||
Decorator _wrappedDecorator;
|
||||
AnnotationIntrospector _introspector = new AnnotationIntrospector();
|
||||
|
||||
/**
|
||||
* @param context
|
||||
*/
|
||||
public WebAppDecoratorWrapper(WebAppContext context, Decorator wrappedDecorator)
|
||||
public AnnotationDecorator(WebAppContext context)
|
||||
{
|
||||
_wrappedDecorator = wrappedDecorator;
|
||||
_introspector.registerHandler(new ResourceAnnotationHandler(context));
|
||||
_introspector.registerHandler(new ResourcesAnnotationHandler(context));
|
||||
_introspector.registerHandler(new RunAsAnnotationHandler(context));
|
||||
|
@ -48,13 +46,6 @@ public class WebAppDecoratorWrapper implements Decorator
|
|||
_introspector.registerHandler(new PreDestroyAnnotationHandler(context));
|
||||
_introspector.registerHandler(new DeclareRolesAnnotationHandler(context));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public Decorator cloneFor(ContextHandler context)
|
||||
{
|
||||
WebAppContext wac = (WebAppContext)context;
|
||||
return new WebAppDecoratorWrapper(wac,_wrappedDecorator.cloneFor(context));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
@ -64,7 +55,6 @@ public class WebAppDecoratorWrapper implements Decorator
|
|||
*/
|
||||
public void decorateFilterHolder(FilterHolder filter) throws ServletException
|
||||
{
|
||||
_wrappedDecorator.decorateFilterHolder(filter);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -78,7 +68,7 @@ public class WebAppDecoratorWrapper implements Decorator
|
|||
public <T extends Filter> T decorateFilterInstance(T filter) throws ServletException
|
||||
{
|
||||
introspect(filter);
|
||||
return _wrappedDecorator.decorateFilterInstance(filter);
|
||||
return filter;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -92,7 +82,7 @@ public class WebAppDecoratorWrapper implements Decorator
|
|||
public <T extends EventListener> T decorateListenerInstance(T listener) throws ServletException
|
||||
{
|
||||
introspect(listener);
|
||||
return _wrappedDecorator.decorateListenerInstance(listener);
|
||||
return listener;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -103,7 +93,6 @@ public class WebAppDecoratorWrapper implements Decorator
|
|||
*/
|
||||
public void decorateServletHolder(ServletHolder servlet) throws ServletException
|
||||
{
|
||||
_wrappedDecorator.decorateServletHolder(servlet);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -117,7 +106,7 @@ public class WebAppDecoratorWrapper implements Decorator
|
|||
public <T extends Servlet> T decorateServletInstance(T servlet) throws ServletException
|
||||
{
|
||||
introspect(servlet);
|
||||
return _wrappedDecorator.decorateServletInstance(servlet);
|
||||
return servlet;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -127,7 +116,6 @@ public class WebAppDecoratorWrapper implements Decorator
|
|||
*/
|
||||
public void destroyFilterInstance(Filter f)
|
||||
{
|
||||
_wrappedDecorator.destroyFilterInstance(f);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -137,7 +125,6 @@ public class WebAppDecoratorWrapper implements Decorator
|
|||
*/
|
||||
public void destroyServletInstance(Servlet s)
|
||||
{
|
||||
_wrappedDecorator.destroyServletInstance(s);
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,7 +138,6 @@ public class WebAppDecoratorWrapper implements Decorator
|
|||
*/
|
||||
public void destroyListenerInstance(EventListener f)
|
||||
{
|
||||
_wrappedDecorator.destroyListenerInstance(f);
|
||||
}
|
||||
|
||||
/**
|
|
@ -92,9 +92,13 @@ public class AnnotationIntrospector
|
|||
{
|
||||
handler.handle(clazz);
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package org.eclipse.jetty.deploy;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.webapp.WebAppClassLoader;
|
||||
|
||||
public class CloudLoader extends WebAppClassLoader
|
||||
{
|
||||
final WebAppClassLoader.Context _context;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public CloudLoader(WebAppClassLoader.Context context)
|
||||
throws IOException
|
||||
{
|
||||
super(context);
|
||||
_context=context;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public CloudLoader(ClassLoader parent,WebAppClassLoader.Context context)
|
||||
throws IOException
|
||||
{
|
||||
super(parent,context);
|
||||
_context=context;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see java.net.URLClassLoader#findClass(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> findClass(String name) throws ClassNotFoundException
|
||||
{
|
||||
Class<?> clazz = super.findClass(name);
|
||||
|
||||
if (clazz!=null && clazz.getClassLoader()==this)
|
||||
{
|
||||
boolean has_non_final_static_fields=false;
|
||||
for (Field field : clazz.getFields())
|
||||
{
|
||||
int mods = field.getModifiers();
|
||||
if (Modifier.isStatic(mods) && !Modifier.isFinal(mods))
|
||||
{
|
||||
has_non_final_static_fields=true;
|
||||
}
|
||||
}
|
||||
|
||||
if (has_non_final_static_fields && !_context.isSystemClass(name))
|
||||
{
|
||||
Log.info("Has non-final static fields: "+name);
|
||||
}
|
||||
}
|
||||
return clazz;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -149,23 +149,22 @@ public class CloudServer
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
WebAppClassLoader loader = new WebAppClassLoader(loaderContext);
|
||||
WebAppClassLoader loader = new CloudLoader(loaderContext);
|
||||
loader.addClassPath("../test-jetty-webapp/target/classes");
|
||||
loader.addJars(Resource.newResource("../test-jetty-webapp/target/test-jetty-webapp-7.2.0-SNAPSHOT/WEB-INF/lib"));
|
||||
|
||||
|
||||
// Create a base configuration
|
||||
/* Cloud deploy */
|
||||
boolean cloud=Boolean.getBoolean("nocloud");
|
||||
boolean cloud=!Boolean.getBoolean("nocloud");
|
||||
if (cloud)
|
||||
{
|
||||
Log.info("Cload deploy");
|
||||
final WebAppContext template = new WebAppContext();
|
||||
template.setClassLoader(loader);
|
||||
template.setBaseResource(baseResource);
|
||||
template.setDefaultsDescriptor("src/main/config/etc/webdefault.xml");
|
||||
template.setAttribute("instance","-1");
|
||||
template.setServer(server);
|
||||
template.preConfigure();
|
||||
|
@ -175,7 +174,7 @@ public class CloudServer
|
|||
for (int i=0;i<10;i++)
|
||||
{
|
||||
final WebAppContext webapp = new WebAppContext(template);
|
||||
webapp.setAttribute("cloudCache",cache);
|
||||
webapp.setAttribute("resourceCache",cache);
|
||||
webapp.setAttribute("instance",i);
|
||||
|
||||
if (i>0)
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.jetty.plus.jndi.EnvEntry;
|
|||
import org.eclipse.jetty.plus.jndi.NamingEntry;
|
||||
import org.eclipse.jetty.plus.jndi.NamingEntryUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.webapp.AbstractConfiguration;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
@ -38,7 +39,7 @@ import org.eclipse.jetty.xml.XmlConfiguration;
|
|||
*
|
||||
*
|
||||
*/
|
||||
public class EnvConfiguration implements Configuration
|
||||
public class EnvConfiguration extends AbstractConfiguration
|
||||
{
|
||||
private URL jettyEnvXmlUrl;
|
||||
|
||||
|
@ -56,6 +57,7 @@ public class EnvConfiguration implements Configuration
|
|||
* @see Configuration#configure(WebAppContext)
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void preConfigure (WebAppContext context) throws Exception
|
||||
{
|
||||
//create a java:comp/env
|
||||
|
@ -65,6 +67,7 @@ public class EnvConfiguration implements Configuration
|
|||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void configure (WebAppContext context) throws Exception
|
||||
{
|
||||
if (Log.isDebugEnabled())
|
||||
|
@ -99,16 +102,13 @@ public class EnvConfiguration implements Configuration
|
|||
bindEnvEntries(context);
|
||||
}
|
||||
|
||||
public void postConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove all jndi setup
|
||||
* @see Configuration#deconfigure(WebAppContext)
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void deconfigure (WebAppContext context) throws Exception
|
||||
{
|
||||
//get rid of any bindings for comp/env for webapp
|
||||
|
|
|
@ -19,8 +19,12 @@ import javax.naming.Context;
|
|||
import javax.naming.InitialContext;
|
||||
import javax.naming.NameNotFoundException;
|
||||
|
||||
import org.eclipse.jetty.plus.annotation.InjectionCollection;
|
||||
import org.eclipse.jetty.plus.annotation.LifeCycleCallbackCollection;
|
||||
import org.eclipse.jetty.plus.annotation.RunAsCollection;
|
||||
import org.eclipse.jetty.plus.jndi.Transaction;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.webapp.AbstractConfiguration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
|
||||
|
@ -29,20 +33,24 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
|||
*
|
||||
*
|
||||
*/
|
||||
public class Configuration implements org.eclipse.jetty.webapp.Configuration
|
||||
public class PlusConfiguration extends AbstractConfiguration
|
||||
{
|
||||
|
||||
private Integer _key;
|
||||
|
||||
@Override
|
||||
public void preConfigure (WebAppContext context)
|
||||
throws Exception
|
||||
{
|
||||
WebAppDecorator decorator = new WebAppDecorator(context);
|
||||
context.setDecorator(decorator);
|
||||
context.addDecorator(new PlusDecorator(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneConfigure(WebAppContext template, WebAppContext context) throws Exception
|
||||
{
|
||||
context.addDecorator(new PlusDecorator(context));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void configure (WebAppContext context)
|
||||
throws Exception
|
||||
{
|
||||
|
@ -50,13 +58,15 @@ public class Configuration implements org.eclipse.jetty.webapp.Configuration
|
|||
|
||||
context.getMetaData().addDescriptorProcessor(new PlusDescriptorProcessor());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void postConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
//lock this webapp's java:comp namespace as per J2EE spec
|
||||
lockCompEnv(context);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deconfigure (WebAppContext context)
|
||||
throws Exception
|
||||
{
|
|
@ -34,27 +34,14 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
|||
*
|
||||
*
|
||||
*/
|
||||
public class WebAppDecorator implements Decorator
|
||||
public class PlusDecorator implements Decorator
|
||||
{
|
||||
protected WebAppContext _context;
|
||||
|
||||
public WebAppDecorator (WebAppContext context)
|
||||
public PlusDecorator (WebAppContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.servlet.ServletContextHandler.Decorator#cloneFor(org.eclipse.jetty.server.handler.ContextHandler)
|
||||
*/
|
||||
public Decorator cloneFor(ContextHandler context)
|
||||
{
|
||||
return new WebAppDecorator((WebAppContext)context);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
@ -62,8 +49,6 @@ public class WebAppDecorator implements Decorator
|
|||
*/
|
||||
public void decorateFilterHolder(FilterHolder filter) throws ServletException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
|
@ -67,13 +67,13 @@ import org.eclipse.jetty.util.resource.ResourceFactory;
|
|||
* on the servlet itself or as ServletContext initParameters with a prefix
|
||||
* of org.eclipse.jetty.servlet.Default. :
|
||||
* <PRE>
|
||||
* acceptRanges If true, range requests and responses are
|
||||
* acceptRanges If true, range requests and responses are
|
||||
* supported
|
||||
*
|
||||
* dirAllowed If true, directory listings are returned if no
|
||||
* dirAllowed If true, directory listings are returned if no
|
||||
* welcome file is found. Else 403 Forbidden.
|
||||
*
|
||||
* welcomeServlets If true, attempt to dispatch to welcome files
|
||||
* welcomeServlets If true, attempt to dispatch to welcome files
|
||||
* that are servlets, but only after no matching static
|
||||
* resources could be found. If false, then a welcome
|
||||
* file must exist on disk. If "exact", then exact
|
||||
|
@ -83,17 +83,17 @@ import org.eclipse.jetty.util.resource.ResourceFactory;
|
|||
* This must be false if you want directory listings,
|
||||
* but have index.jsp in your welcome file list.
|
||||
*
|
||||
* redirectWelcome If true, welcome files are redirected rather than
|
||||
* redirectWelcome If true, welcome files are redirected rather than
|
||||
* forwarded to.
|
||||
*
|
||||
* gzip If set to true, then static content will be served as
|
||||
* gzip If set to true, then static content will be served as
|
||||
* gzip content encoded if a matching resource is
|
||||
* found ending with ".gz"
|
||||
*
|
||||
* resourceBase Set to replace the context resource base
|
||||
*
|
||||
* resourceCache If set, this is a context attribute name, which the servlet
|
||||
* will use to look for a shared ResourceCache instance.
|
||||
* will use to look for a shared ResourceCache instance.
|
||||
*
|
||||
* relativeResourceBase
|
||||
* Set with a pathname relative to the base of the
|
||||
|
@ -222,30 +222,28 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
_cache=(ResourceCache)_servletContext.getAttribute(resourceCache);
|
||||
|
||||
if (_cache==null)
|
||||
throw new UnavailableException("Could not find resourceCache "+resourceCache);
|
||||
Log.debug("Could not find resourceCache "+resourceCache);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
if (max_cached_files>0)
|
||||
{
|
||||
_cache= new ResourceCache(this,_mimeTypes,_useFileMappedBuffer);
|
||||
|
||||
if (max_cache_size>0)
|
||||
_cache.setMaxCacheSize(max_cache_size);
|
||||
if (max_cached_file_size>=-1)
|
||||
_cache.setMaxCachedFileSize(max_cached_file_size);
|
||||
if (max_cached_files>=-1)
|
||||
_cache.setMaxCachedFiles(max_cached_files);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
try
|
||||
{
|
||||
if (_cache==null && max_cached_files>0)
|
||||
{
|
||||
Log.warn(Log.EXCEPTION,e);
|
||||
throw new UnavailableException(e.toString());
|
||||
_cache= new ResourceCache(this,_mimeTypes,_useFileMappedBuffer);
|
||||
|
||||
if (max_cache_size>0)
|
||||
_cache.setMaxCacheSize(max_cache_size);
|
||||
if (max_cached_file_size>=-1)
|
||||
_cache.setMaxCachedFileSize(max_cached_file_size);
|
||||
if (max_cached_files>=-1)
|
||||
_cache.setMaxCachedFiles(max_cached_files);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.warn(Log.EXCEPTION,e);
|
||||
throw new UnavailableException(e.toString());
|
||||
}
|
||||
|
||||
_servletHandler= (ServletHandler) _contextHandler.getChildHandlerByClass(ServletHandler.class);
|
||||
for (ServletHolder h :_servletHandler.getServlets())
|
||||
|
|
|
@ -13,11 +13,14 @@
|
|||
|
||||
package org.eclipse.jetty.servlet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.EventListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -63,13 +66,13 @@ public class ServletContextHandler extends ContextHandler
|
|||
public final static int SECURITY=2;
|
||||
public final static int NO_SESSIONS=0;
|
||||
public final static int NO_SECURITY=0;
|
||||
|
||||
|
||||
protected final List<Decorator> _decorators= new ArrayList<Decorator>();
|
||||
protected Class<? extends SecurityHandler> _defaultSecurityHandlerClass=org.eclipse.jetty.security.ConstraintSecurityHandler.class;
|
||||
protected SessionHandler _sessionHandler;
|
||||
protected SecurityHandler _securityHandler;
|
||||
protected ServletHandler _servletHandler;
|
||||
protected int _options;
|
||||
protected Decorator _decorator;
|
||||
protected Object _restrictedContextListeners;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -227,14 +230,14 @@ public class ServletContextHandler extends ContextHandler
|
|||
// OK to Initialize servlet handler now
|
||||
if (_servletHandler != null && _servletHandler.isStarted())
|
||||
{
|
||||
if (_decorator!=null)
|
||||
for (Decorator decorator : _decorators)
|
||||
{
|
||||
if (_servletHandler.getFilters()!=null)
|
||||
for (FilterHolder holder:_servletHandler.getFilters())
|
||||
_decorator.decorateFilterHolder(holder);
|
||||
decorator.decorateFilterHolder(holder);
|
||||
if(_servletHandler.getServlets()!=null)
|
||||
for (ServletHolder holder:_servletHandler.getServlets())
|
||||
_decorator.decorateServletHolder(holder);
|
||||
decorator.decorateServletHolder(holder);
|
||||
}
|
||||
|
||||
_servletHandler.initialize();
|
||||
|
@ -401,34 +404,44 @@ public class ServletContextHandler extends ContextHandler
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return The decorator used to resource inject new Filters, Servlets and EventListeners
|
||||
* @return The decorator list used to resource inject new Filters, Servlets and EventListeners
|
||||
*/
|
||||
public Decorator getDecorator()
|
||||
public List<Decorator> getDecorators()
|
||||
{
|
||||
return _decorator;
|
||||
return Collections.unmodifiableList(_decorators);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param decorator The inject used to resource inject new Filters, Servlets and EventListeners
|
||||
* @param decorators The lis of {@link Decorator}s
|
||||
*/
|
||||
public void setDecorator(Decorator decorator)
|
||||
public void setDecorators(List<Decorator> decorators)
|
||||
{
|
||||
_decorator = decorator;
|
||||
_decorators.clear();
|
||||
_decorators.addAll(decorators);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param decorator The decorator to add
|
||||
*/
|
||||
public void addDecorator(Decorator decorator)
|
||||
{
|
||||
_decorators.add(decorator);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
void destroyServlet(Servlet servlet)
|
||||
{
|
||||
if (_decorator!=null)
|
||||
_decorator.destroyServletInstance(servlet);
|
||||
for (Decorator decorator : _decorators)
|
||||
decorator.destroyServletInstance(servlet);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
void destroyFilter(Filter filter)
|
||||
{
|
||||
if (_decorator!=null)
|
||||
_decorator.destroyFilterInstance(filter);
|
||||
for (Decorator decorator : _decorators)
|
||||
decorator.destroyFilterInstance(filter);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -563,8 +576,8 @@ public class ServletContextHandler extends ContextHandler
|
|||
try
|
||||
{
|
||||
T f = c.newInstance();
|
||||
if (_decorator!=null)
|
||||
f=_decorator.decorateFilterInstance(f);
|
||||
for (Decorator decorator : _decorators)
|
||||
f=decorator.decorateFilterInstance(f);
|
||||
return f;
|
||||
}
|
||||
catch (InstantiationException e)
|
||||
|
@ -583,8 +596,8 @@ public class ServletContextHandler extends ContextHandler
|
|||
try
|
||||
{
|
||||
T s = c.newInstance();
|
||||
if (_decorator!=null)
|
||||
s=_decorator.decorateServletInstance(s);
|
||||
for (Decorator decorator : _decorators)
|
||||
s=decorator.decorateServletInstance(s);
|
||||
return s;
|
||||
}
|
||||
catch (InstantiationException e)
|
||||
|
@ -699,9 +712,9 @@ public class ServletContextHandler extends ContextHandler
|
|||
{
|
||||
throw new ServletException(e);
|
||||
}
|
||||
|
||||
if (_decorator!=null)
|
||||
l=_decorator.decorateListenerInstance(l);
|
||||
|
||||
for (Decorator decorator : _decorators)
|
||||
l=decorator.decorateListenerInstance(l);
|
||||
return l;
|
||||
}
|
||||
catch(ServletException e)
|
||||
|
@ -733,6 +746,10 @@ public class ServletContextHandler extends ContextHandler
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Interface to decorate loaded classes.
|
||||
*/
|
||||
public interface Decorator
|
||||
{
|
||||
<T extends Filter> T decorateFilterInstance(T filter) throws ServletException;
|
||||
|
@ -745,7 +762,5 @@ public class ServletContextHandler extends ContextHandler
|
|||
void destroyServletInstance(Servlet s);
|
||||
void destroyFilterInstance(Filter f);
|
||||
void destroyListenerInstance(EventListener f);
|
||||
|
||||
public Decorator cloneFor(ContextHandler context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,63 +40,63 @@
|
|||
<param-value>-1</param-value> </context-param>
|
||||
-->
|
||||
|
||||
|
||||
<!-- ==================================================================== -->
|
||||
<!-- The default servlet. -->
|
||||
<!-- This servlet, normally mapped to /, provides the handling for static -->
|
||||
<!-- content, OPTIONS and TRACE methods for the context. -->
|
||||
<!-- The following initParameters are supported: -->
|
||||
<!-- -->
|
||||
<!-- aliases If true, aliases like symlinks are allowed. Note -->
|
||||
<!-- that security constraints might be bypassed by -->
|
||||
<!-- aliases static content. -->
|
||||
<!-- -->
|
||||
<!-- acceptRanges If true, range requests and responses are -->
|
||||
<!-- supported -->
|
||||
<!-- -->
|
||||
<!-- dirAllowed If true, directory listings are returned if no -->
|
||||
<!-- welcome file is found. Else 403 Forbidden. -->
|
||||
<!-- -->
|
||||
<!-- welcomeServlets If true, attempt to dispatch to welcome files -->
|
||||
<!-- that are servlets, if no matching static -->
|
||||
<!-- resources can be found. -->
|
||||
<!-- -->
|
||||
<!-- redirectWelcome If true, redirect welcome file requests -->
|
||||
<!-- else use request dispatcher forwards -->
|
||||
<!-- -->
|
||||
<!-- gzip If set to true, then static content will be served-->
|
||||
<!-- as gzip content encoded if a matching resource is -->
|
||||
<!-- found ending with ".gz" -->
|
||||
<!-- -->
|
||||
<!-- resoureBase Can be set to replace the context resource base -->
|
||||
<!-- -->
|
||||
<!-- relativeResourceBase -->
|
||||
<!-- Set with a pathname relative to the base of the -->
|
||||
<!-- servlet context root. Useful for only serving -->
|
||||
<!-- static content from only specific subdirectories. -->
|
||||
<!-- -->
|
||||
<!-- useFileMappedBuffer -->
|
||||
<!-- If set to true (the default), a memory mapped -->
|
||||
<!-- file buffer will be used to serve static content -->
|
||||
<!-- when using an NIO connector. Setting this value -->
|
||||
<!-- to false means that a direct buffer will be used -->
|
||||
<!-- instead. If you are having trouble with Windows -->
|
||||
<!-- file locking, set this to false. -->
|
||||
<!-- -->
|
||||
<!-- cacheControl If set, all static content will have this value -->
|
||||
<!-- set as the cache-control header. -->
|
||||
<!-- -->
|
||||
<!-- maxCacheSize Maximum size of the static resource cache -->
|
||||
<!-- -->
|
||||
<!-- maxCachedFileSize Maximum size of any single file in the cache -->
|
||||
<!-- -->
|
||||
<!-- maxCachedFiles Maximum number of files in the cache -->
|
||||
<!-- -->
|
||||
<!-- cacheType "nio", "bio" or "both" to determine the type(s) -->
|
||||
<!-- of resource cache. A bio cached buffer may be used-->
|
||||
<!-- by nio but is not as efficient as a nio buffer. -->
|
||||
<!-- An nio cached buffer may not be used by bio. -->
|
||||
<!-- -->
|
||||
<!--
|
||||
* acceptRanges If true, range requests and responses are
|
||||
* supported
|
||||
*
|
||||
* dirAllowed If true, directory listings are returned if no
|
||||
* welcome file is found. Else 403 Forbidden.
|
||||
*
|
||||
* welcomeServlets If true, attempt to dispatch to welcome files
|
||||
* that are servlets, but only after no matching static
|
||||
* resources could be found. If false, then a welcome
|
||||
* file must exist on disk. If "exact", then exact
|
||||
* servlet matches are supported without an existing file.
|
||||
* Default is true.
|
||||
*
|
||||
* This must be false if you want directory listings,
|
||||
* but have index.jsp in your welcome file list.
|
||||
*
|
||||
* redirectWelcome If true, welcome files are redirected rather than
|
||||
* forwarded to.
|
||||
*
|
||||
* gzip If set to true, then static content will be served as
|
||||
* gzip content encoded if a matching resource is
|
||||
* found ending with ".gz"
|
||||
*
|
||||
* resourceBase Set to replace the context resource base
|
||||
*
|
||||
* resourceCache If set, this is a context attribute name, which the servlet
|
||||
* will use to look for a shared ResourceCache instance.
|
||||
*
|
||||
* relativeResourceBase
|
||||
* Set with a pathname relative to the base of the
|
||||
* servlet context root. Useful for only serving static content out
|
||||
* of only specific subdirectories.
|
||||
*
|
||||
* aliases If True, aliases of resources are allowed (eg. symbolic
|
||||
* links and caps variations). May bypass security constraints.
|
||||
*
|
||||
* maxCacheSize The maximum total size of the cache or 0 for no cache.
|
||||
* maxCachedFileSize The maximum size of a file to cache
|
||||
* maxCachedFiles The maximum number of files to cache
|
||||
*
|
||||
* useFileMappedBuffer
|
||||
* If set to true, it will use mapped file buffer to serve static content
|
||||
* when using NIO connector. Setting this value to false means that
|
||||
* a direct buffer will be used instead of a mapped file buffer.
|
||||
* By default, this is set to true.
|
||||
*
|
||||
* cacheControl If set, all static content will have this value set as the cache-control
|
||||
* header.
|
||||
-->
|
||||
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<servlet>
|
||||
<servlet-name>default</servlet-name>
|
||||
|
@ -133,10 +133,6 @@
|
|||
<param-name>maxCachedFiles</param-name>
|
||||
<param-value>2048</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>cacheType</param-name>
|
||||
<param-value>both</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>gzip</param-name>
|
||||
<param-value>true</param-value>
|
||||
|
@ -145,6 +141,10 @@
|
|||
<param-name>useFileMappedBuffer</param-name>
|
||||
<param-value>true</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>resourceCache</param-name>
|
||||
<param-value>resourceCache</param-value>
|
||||
</init-param>
|
||||
<!--
|
||||
<init-param>
|
||||
<param-name>cacheControl</param-name>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package org.eclipse.jetty.webapp;
|
||||
|
||||
public class AbstractConfiguration implements Configuration
|
||||
{
|
||||
public void preConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void configure(WebAppContext context) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void postConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void deconfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void cloneConfigure(WebAppContext template, WebAppContext context) throws Exception
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package org.eclipse.jetty.webapp;
|
||||
|
||||
|
||||
public class CloneConfiguration extends AbstractConfiguration
|
||||
{
|
||||
final WebAppContext _template;
|
||||
|
||||
CloneConfiguration(WebAppContext template)
|
||||
{
|
||||
_template=template;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(WebAppContext context) throws Exception
|
||||
{
|
||||
for (Configuration configuration : _template.getConfigurations())
|
||||
configuration.cloneConfigure(_template,context);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deconfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
for (Configuration configuration : _template.getConfigurations())
|
||||
configuration.deconfigure(context);
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ public interface Configuration
|
|||
/** Set up for configuration.
|
||||
* <p>
|
||||
* Typically this step discovers configuration resources
|
||||
* @param context The context to configure
|
||||
* @throws Exception
|
||||
*/
|
||||
public void preConfigure (WebAppContext context) throws Exception;
|
||||
|
@ -36,6 +37,7 @@ public interface Configuration
|
|||
* <p>
|
||||
* Typically this step applies the discovered configuration resources to
|
||||
* either the {@link WebAppContext} or the associated {@link MetaData}.
|
||||
* @param context The context to configure
|
||||
* @throws Exception
|
||||
*/
|
||||
public void configure (WebAppContext context) throws Exception;
|
||||
|
@ -43,6 +45,7 @@ public interface Configuration
|
|||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/** Clear down after configuration.
|
||||
* @param context The context to configure
|
||||
* @throws Exception
|
||||
*/
|
||||
public void postConfigure (WebAppContext context) throws Exception;
|
||||
|
@ -51,9 +54,20 @@ public interface Configuration
|
|||
/** DeConfigure WebApp.
|
||||
* This method is called to undo all configuration done. This is
|
||||
* called to allow the context to work correctly over a stop/start cycle
|
||||
* @param context The context to configure
|
||||
* @throws Exception
|
||||
*/
|
||||
public void deconfigure (WebAppContext context) throws Exception;
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/** Clone configuration instance.
|
||||
* <p>
|
||||
* Configure an instance of a WebAppContext, based on a template WebAppContext that
|
||||
* has previously been configured by this Configuration.
|
||||
* @param template The template context
|
||||
* @param context The context to configure
|
||||
* @throws Exception
|
||||
*/
|
||||
public void cloneConfigure (WebAppContext template, WebAppContext context) throws Exception;
|
||||
}
|
||||
|
|
|
@ -25,10 +25,11 @@ import org.eclipse.jetty.util.resource.Resource;
|
|||
*
|
||||
* Process web-fragments in jars
|
||||
*/
|
||||
public class FragmentConfiguration implements Configuration
|
||||
public class FragmentConfiguration extends AbstractConfiguration
|
||||
{
|
||||
public final static String FRAGMENT_RESOURCES="org.eclipse.jetty.webFragments";
|
||||
|
||||
@Override
|
||||
public void preConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
if (!context.isConfigurationDiscovered())
|
||||
|
@ -38,7 +39,8 @@ public class FragmentConfiguration implements Configuration
|
|||
findWebFragments(context, context.getMetaData());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void configure(WebAppContext context) throws Exception
|
||||
{
|
||||
if (!context.isConfigurationDiscovered())
|
||||
|
@ -48,11 +50,7 @@ public class FragmentConfiguration implements Configuration
|
|||
context.getMetaData().orderFragments();
|
||||
}
|
||||
|
||||
public void deconfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
context.setAttribute(FRAGMENT_RESOURCES, null);
|
||||
|
|
|
@ -30,18 +30,13 @@ import org.eclipse.jetty.xml.XmlConfiguration;
|
|||
*
|
||||
*
|
||||
*/
|
||||
public class JettyWebXmlConfiguration implements Configuration
|
||||
public class JettyWebXmlConfiguration extends AbstractConfiguration
|
||||
{
|
||||
/** The value of this property points to the WEB-INF directory of
|
||||
* the web-app currently installed.
|
||||
* it is passed as a property to the jetty-web.xml file */
|
||||
public static final String PROPERTY_THIS_WEB_INF_URL = "this.web-inf.url";
|
||||
|
||||
public void preConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
* the web-app currently installed.
|
||||
* it is passed as a property to the jetty-web.xml file */
|
||||
public static final String PROPERTY_THIS_WEB_INF_URL = "this.web-inf.url";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -49,6 +44,7 @@ public class JettyWebXmlConfiguration implements Configuration
|
|||
* Apply web-jetty.xml configuration
|
||||
* @see Configuration#configure(WebAppContext)
|
||||
*/
|
||||
@Override
|
||||
public void configure (WebAppContext context) throws Exception
|
||||
{
|
||||
//cannot configure if the _context is already started
|
||||
|
@ -110,17 +106,4 @@ public class JettyWebXmlConfiguration implements Configuration
|
|||
props.put(PROPERTY_THIS_WEB_INF_URL, web_inf.getURL());
|
||||
}
|
||||
|
||||
|
||||
public void postConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void deconfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
package org.eclipse.jetty.webapp;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public class MetaDataConfiguration implements Configuration
|
||||
{
|
||||
final WebAppContext _template;
|
||||
|
||||
MetaDataConfiguration(WebAppContext template)
|
||||
{
|
||||
_template=template;
|
||||
}
|
||||
|
||||
public void preConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
File tmpDir=File.createTempFile(WebInfConfiguration.getCanonicalNameForWebAppTmpDir(context),"",_template.getTempDirectory().getParentFile());
|
||||
if (tmpDir.exists())
|
||||
tmpDir.delete();
|
||||
tmpDir.mkdir();
|
||||
tmpDir.deleteOnExit();
|
||||
context.setTempDirectory(tmpDir);
|
||||
}
|
||||
|
||||
public void configure(WebAppContext context) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void postConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void deconfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
// TODO delete temp dir?
|
||||
// TODO other stuff from other configuration deconfigures?
|
||||
}
|
||||
}
|
|
@ -32,13 +32,13 @@ import org.eclipse.jetty.util.resource.Resource;
|
|||
* <li>resources
|
||||
* </ul>
|
||||
*/
|
||||
public class MetaInfConfiguration implements Configuration
|
||||
public class MetaInfConfiguration extends AbstractConfiguration
|
||||
{
|
||||
public static final String METAINF_TLDS = TagLibConfiguration.TLD_RESOURCES;
|
||||
public static final String METAINF_FRAGMENTS = FragmentConfiguration.FRAGMENT_RESOURCES;
|
||||
public static final String METAINF_RESOURCES = WebInfConfiguration.RESOURCE_URLS;
|
||||
|
||||
|
||||
@Override
|
||||
public void preConfigure(final WebAppContext context) throws Exception
|
||||
{
|
||||
//Merge all container and webinf lib jars to look for META-INF resources
|
||||
|
@ -75,21 +75,8 @@ public class MetaInfConfiguration implements Configuration
|
|||
scanner.scan(null, uris, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void configure(WebAppContext context) throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void deconfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void postConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
context.setAttribute(METAINF_FRAGMENTS, null);
|
||||
|
|
|
@ -48,7 +48,7 @@ import org.eclipse.jetty.xml.XmlParser;
|
|||
* TODO - this has been superceded by the new TldScanner in jasper which uses ServletContainerInitializer to
|
||||
* find all the listeners in tag libs and register them.
|
||||
*/
|
||||
public class TagLibConfiguration implements Configuration
|
||||
public class TagLibConfiguration extends AbstractConfiguration
|
||||
{
|
||||
public static final String TLD_RESOURCES = "org.eclipse.jetty.tlds";
|
||||
|
||||
|
@ -198,6 +198,7 @@ public class TagLibConfiguration implements Configuration
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
Set tlds = new HashSet();
|
||||
|
@ -269,6 +270,7 @@ public class TagLibConfiguration implements Configuration
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void configure (WebAppContext context) throws Exception
|
||||
{
|
||||
TldProcessor processor = (TldProcessor)context.getAttribute(TldProcessor.TAGLIB_PROCESSOR);
|
||||
|
@ -282,14 +284,10 @@ public class TagLibConfiguration implements Configuration
|
|||
processor.processRoots();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
context.setAttribute(TldProcessor.TAGLIB_PROCESSOR, null);
|
||||
}
|
||||
|
||||
public void deconfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.security.PermissionCollection;
|
|||
import java.util.Enumeration;
|
||||
import java.util.EventListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpSessionActivationListener;
|
||||
|
@ -172,7 +173,8 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
|
||||
//Make a new MetaData to hold descriptor and annotation metadata
|
||||
_metadata = template.getMetaData();
|
||||
_configurations = new Configuration[]{new MetaDataConfiguration(template)};
|
||||
|
||||
_configurations = new Configuration[]{new CloneConfiguration(template)};
|
||||
|
||||
// TODO we need some better way to work out what attributes should be copied at this stage.
|
||||
|
||||
|
@ -185,11 +187,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
setLogger(template.getLogger()); // TODO maybe not shared ???
|
||||
setMaxFormContentSize(template.getMaxFormContentSize());
|
||||
|
||||
Decorator decorator = template.getDecorator();
|
||||
if (decorator!=null)
|
||||
setDecorator(decorator.cloneFor(this));
|
||||
|
||||
Enumeration names=template.getAttributeNames();
|
||||
Enumeration<?> names=template.getAttributeNames();
|
||||
while(names.hasMoreElements())
|
||||
{
|
||||
String name = (String)names.nextElement();
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.jetty.util.resource.JarResource;
|
|||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.resource.ResourceCollection;
|
||||
|
||||
public class WebInfConfiguration implements Configuration
|
||||
public class WebInfConfiguration extends AbstractConfiguration
|
||||
{
|
||||
public static final String TEMPDIR_CONFIGURED = "org.eclipse.jetty.tmpdirConfigured";
|
||||
public static final String CONTAINER_JAR_PATTERN = "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern";
|
||||
|
@ -33,9 +33,7 @@ public class WebInfConfiguration implements Configuration
|
|||
|
||||
protected Resource _preUnpackBaseResource;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void preConfigure(final WebAppContext context) throws Exception
|
||||
{
|
||||
// Look for a work directory
|
||||
|
@ -108,14 +106,8 @@ public class WebInfConfiguration implements Configuration
|
|||
webInfJarNameMatcher.match(webInfPattern, uris, true); //null is inclusive, no pattern == all jars match
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void postConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
//context.setAttribute(CONTAINER_JAR_RESOURCES, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void configure(WebAppContext context) throws Exception
|
||||
{
|
||||
//cannot configure if the context is already started
|
||||
|
@ -153,7 +145,8 @@ public class WebInfConfiguration implements Configuration
|
|||
context.setBaseResource(new ResourceCollection(collection));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deconfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
// delete temp directory if we had to create it or if it isn't called work
|
||||
|
@ -172,6 +165,22 @@ public class WebInfConfiguration implements Configuration
|
|||
context.setBaseResource(_preUnpackBaseResource);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.webapp.AbstractConfiguration#cloneConfigure(org.eclipse.jetty.webapp.WebAppContext, org.eclipse.jetty.webapp.WebAppContext)
|
||||
*/
|
||||
@Override
|
||||
public void cloneConfigure(WebAppContext template, WebAppContext context) throws Exception
|
||||
{
|
||||
File tmpDir=File.createTempFile(WebInfConfiguration.getCanonicalNameForWebAppTmpDir(context),"",template.getTempDirectory().getParentFile());
|
||||
if (tmpDir.exists())
|
||||
tmpDir.delete();
|
||||
tmpDir.mkdir();
|
||||
tmpDir.deleteOnExit();
|
||||
context.setTempDirectory(tmpDir);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Get a temporary directory in which to unpack the war etc etc.
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.eclipse.jetty.util.resource.Resource;
|
|||
* Configure by parsing default web.xml and web.xml
|
||||
*
|
||||
*/
|
||||
public class WebXmlConfiguration implements Configuration
|
||||
public class WebXmlConfiguration extends AbstractConfiguration
|
||||
{
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
|
@ -35,6 +35,7 @@ public class WebXmlConfiguration implements Configuration
|
|||
*
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void preConfigure (WebAppContext context) throws Exception
|
||||
{
|
||||
//parse webdefault.xml
|
||||
|
@ -71,6 +72,7 @@ public class WebXmlConfiguration implements Configuration
|
|||
* Process web-default.xml, web.xml, override-web.xml
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void configure (WebAppContext context) throws Exception
|
||||
{
|
||||
// cannot configure if the context is already started
|
||||
|
@ -82,11 +84,7 @@ public class WebXmlConfiguration implements Configuration
|
|||
|
||||
context.getMetaData().addDescriptorProcessor(new StandardDescriptorProcessor());
|
||||
}
|
||||
|
||||
public void postConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
protected Resource findWebXml(WebAppContext context) throws IOException, MalformedURLException
|
||||
{
|
||||
|
@ -110,12 +108,12 @@ public class WebXmlConfiguration implements Configuration
|
|||
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
@Override
|
||||
public void deconfigure (WebAppContext context) throws Exception
|
||||
{
|
||||
// TODO preserve any configuration that pre-existed.
|
||||
|
||||
ServletHandler _servletHandler = context.getServletHandler();
|
||||
SecurityHandler _securityHandler = (SecurityHandler)context.getSecurityHandler();
|
||||
|
||||
_servletHandler.setFilters(null);
|
||||
_servletHandler.setFilterMappings(null);
|
||||
|
|
Loading…
Reference in New Issue