Fixes #4020 - Deprecate ExtensionFactory

+ This class is removed in Jetty 10 anyway.
+ If all you want is to access available extension names
  then use the Factory.getAvailableExtensionNames() method
  (which exists in Jetty 10.0.0 as well)

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2019-08-27 13:25:08 -05:00
parent 149d9d4862
commit 6bcfa2dc6e
3 changed files with 31 additions and 0 deletions

View File

@ -24,6 +24,12 @@ import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;
/**
* The Factory for Extensions.
*
* @deprecated this class is removed from Jetty 10.0.0+
*/
@Deprecated
public abstract class ExtensionFactory implements Iterable<Class<? extends Extension>>
{
private ServiceLoader<Extension> extensionLoader = ServiceLoader.load(Extension.class);

View File

@ -29,6 +29,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Executor;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@ -450,6 +451,13 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
return eventDriverFactory;
}
@Override
public Set<String> getAvailableExtensionNames()
{
return Collections.unmodifiableSet(extensionFactory.getExtensionNames());
}
@Deprecated
@Override
public ExtensionFactory getExtensionFactory()
{

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.websocket.servlet;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Set;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -66,8 +67,24 @@ public interface WebSocketServletFactory
void stop() throws Exception;
/**
* Get the set of available Extensions by registered name.
*
* @return the set of available extensions by registered name.
*/
Set<String> getAvailableExtensionNames();
WebSocketCreator getCreator();
/**
* Get the registered extensions for this WebSocket factory.
*
* @return the ExtensionFactory
* @see #getAvailableExtensionNames()
* @deprecated this class is removed from Jetty 10.0.0+. To remove specific extensions
* from negotiation use {@link WebSocketCreator} to remove then during handshake.
*/
@Deprecated
ExtensionFactory getExtensionFactory();
/**