revert to using init parameter to identify the WebSocketUpgradeFilter
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
c40d14a1e9
commit
5d9c81a511
|
@ -36,7 +36,6 @@ import javax.servlet.ServletRequest;
|
|||
import javax.servlet.ServletResponse;
|
||||
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.util.Loader;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.component.DumpableCollection;
|
||||
|
@ -222,39 +221,6 @@ public class FilterHolder extends Holder<Filter>
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Work out the class of the held {@link Filter} even before the {@link FilterHolder} has been started.
|
||||
* @return the class of the held {@link Filter}, or null if not available.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Class<? extends Filter> getFilterClass()
|
||||
{
|
||||
if (_filter != null)
|
||||
return _filter.getClass();
|
||||
|
||||
Filter filter = getInstance();
|
||||
if (filter != null)
|
||||
return filter.getClass();
|
||||
|
||||
Class<? extends Filter> heldClass = getHeldClass();
|
||||
if (heldClass != null)
|
||||
return heldClass;
|
||||
|
||||
String className = getClassName();
|
||||
if (className != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Loader.loadClass(className);
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
LOG.warn("Could not load filter class", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
|
|
|
@ -80,7 +80,7 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
|
|||
/**
|
||||
* The init parameter name used to define {@link ServletContext} attribute used to share the {@link WebSocketMapping}.
|
||||
*/
|
||||
public static final String MAPPING_ATTRIBUTE_INIT_PARAM = "org.eclipse.jetty.websocket.util.server.internal.WebSocketMapping.key";
|
||||
public static final String MAPPING_ATTRIBUTE_INIT_PARAM = "jetty.websocket.WebSocketMapping";
|
||||
|
||||
/**
|
||||
* Return any {@link WebSocketUpgradeFilter} already present on the {@link ServletContext}.
|
||||
|
@ -94,7 +94,7 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
|
|||
ServletHandler servletHandler = contextHandler.getChildHandlerByClass(ServletHandler.class);
|
||||
for (FilterHolder holder : servletHandler.getFilters())
|
||||
{
|
||||
if (WebSocketUpgradeFilter.class.isAssignableFrom(holder.getFilterClass()))
|
||||
if (holder.getInitParameter(MAPPING_ATTRIBUTE_INIT_PARAM) != null)
|
||||
return holder;
|
||||
}
|
||||
return null;
|
||||
|
@ -178,7 +178,7 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
|
|||
|
||||
String mappingKey = config.getInitParameter(MAPPING_ATTRIBUTE_INIT_PARAM);
|
||||
if (mappingKey == null)
|
||||
mappingKey = WebSocketMapping.DEFAULT_KEY;
|
||||
throw new ServletException("the WebSocketMapping init param must be set");
|
||||
mapping = WebSocketMapping.ensureMapping(context, mappingKey);
|
||||
|
||||
String max = config.getInitParameter("idleTimeout");
|
||||
|
|
|
@ -133,7 +133,7 @@ public class WebSocketMapping implements Dumpable, LifeCycle.Listener
|
|||
throw new IllegalArgumentException("Unrecognized path spec syntax [" + rawSpec + "]");
|
||||
}
|
||||
|
||||
public static final String DEFAULT_KEY = "org.eclipse.jetty.websocket.util.server.internal.WebSocketMapping";
|
||||
public static final String DEFAULT_KEY = "jetty.websocket.defaultMapping";
|
||||
|
||||
private final PathMappings<Negotiator> mappings = new PathMappings<>();
|
||||
private final WebSocketComponents components;
|
||||
|
|
Loading…
Reference in New Issue