Skip to content

Commit

Permalink
Issue #5320 - changes from review
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed Nov 9, 2020
1 parent 32433b1 commit b6688c0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 37 deletions.
Expand Up @@ -20,7 +20,6 @@

import java.util.ServiceLoader;

import org.eclipse.jetty.util.Loader;
import org.eclipse.jetty.webapp.AbstractConfiguration;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.FragmentConfiguration;
Expand Down Expand Up @@ -48,13 +47,8 @@ public class JettyWebSocketClientConfiguration extends AbstractConfiguration
public JettyWebSocketClientConfiguration()
{
addDependencies(WebXmlConfiguration.class, MetaInfConfiguration.class, WebInfConfiguration.class, FragmentConfiguration.class);

if (isAvailable("org.eclipse.jetty.osgi.annotations.AnnotationConfiguration"))
addDependents("org.eclipse.jetty.osgi.annotations.AnnotationConfiguration", WebAppConfiguration.class.getName());
else if (isAvailable("org.eclipse.jetty.annotations.AnnotationConfiguration"))
addDependents("org.eclipse.jetty.annotations.AnnotationConfiguration", WebAppConfiguration.class.getName());
else
throw new RuntimeException("Unable to add AnnotationConfiguration dependent (not present in classpath)");
addDependents("org.eclipse.jetty.osgi.annotations.AnnotationConfiguration", WebAppConfiguration.class.getName());
addDependents("org.eclipse.jetty.annotations.AnnotationConfiguration", WebAppConfiguration.class.getName());

protectAndExpose("org.eclipse.jetty.websocket.api.");
protectAndExpose("org.eclipse.jetty.websocket.client.");
Expand All @@ -64,20 +58,17 @@ else if (isAvailable("org.eclipse.jetty.annotations.AnnotationConfiguration"))

@Override
public boolean isAvailable()
{
return isAvailable("org.eclipse.jetty.websocket.client.WebSocketClient");
}

private boolean isAvailable(String classname)
{
try
{
return Loader.loadClass(classname) != null;
ClassLoader classLoader = JettyWebSocketClientConfiguration.class.getClassLoader();
return classLoader.loadClass("org.eclipse.jetty.websocket.client.WebSocketClient") != null;
}
catch (Throwable e)
{
LOG.trace("IGNORED", e);
return false;
}

return false;
}
}
Expand Up @@ -20,7 +20,6 @@

import java.util.ServiceLoader;

import org.eclipse.jetty.util.Loader;
import org.eclipse.jetty.webapp.AbstractConfiguration;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.FragmentConfiguration;
Expand Down Expand Up @@ -49,39 +48,29 @@ public class JettyWebSocketConfiguration extends AbstractConfiguration
public JettyWebSocketConfiguration()
{
addDependencies(WebXmlConfiguration.class, MetaInfConfiguration.class, WebInfConfiguration.class, FragmentConfiguration.class);
addDependents("org.eclipse.jetty.osgi.annotations.AnnotationConfiguration", WebAppConfiguration.class.getName());
addDependents("org.eclipse.jetty.annotations.AnnotationConfiguration", WebAppConfiguration.class.getName());

if (isAvailable("org.eclipse.jetty.osgi.annotations.AnnotationConfiguration"))
addDependents("org.eclipse.jetty.osgi.annotations.AnnotationConfiguration", WebAppConfiguration.class.getName());
else if (isAvailable("org.eclipse.jetty.annotations.AnnotationConfiguration"))
addDependents("org.eclipse.jetty.annotations.AnnotationConfiguration", WebAppConfiguration.class.getName());
else
throw new RuntimeException("Unable to add AnnotationConfiguration dependent (not present in classpath)");

protectAndExpose(
"org.eclipse.jetty.websocket.api.",
"org.eclipse.jetty.websocket.server.",
"org.eclipse.jetty.websocket.util.server."); // For WebSocketUpgradeFilter

hide("org.eclipse.jetty.server.internal.",
"org.eclipse.jetty.server.config.");
protectAndExpose("org.eclipse.jetty.websocket.api.");
protectAndExpose("org.eclipse.jetty.websocket.server.");
protectAndExpose("org.eclipse.jetty.websocket.util.server."); // For WebSocketUpgradeFilter
hide("org.eclipse.jetty.server.internal.");
hide("org.eclipse.jetty.server.config.");
}

@Override
public boolean isAvailable()
{
return isAvailable("org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer");
}

private boolean isAvailable(String classname)
{
try
{
return Loader.loadClass(classname) != null;
ClassLoader classLoader = JettyWebSocketConfiguration.class.getClassLoader();
return classLoader.loadClass("org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer") != null;
}
catch (Throwable e)
{
LOG.trace("IGNORED", e);
return false;
}

return false;
}
}

0 comments on commit b6688c0

Please sign in to comment.