Add module and configuration for websocket-client provided to webapp.
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
8d21bb7b63
commit
fc4e263f93
|
@ -35,6 +35,12 @@
|
|||
<artifactId>jetty-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html
|
||||
|
||||
[description]
|
||||
Expose the Jetty WebSocket Client classes to deployed web applications.
|
||||
|
||||
[tags]
|
||||
websocket
|
||||
|
||||
[depend]
|
||||
client
|
||||
annotations
|
||||
|
||||
[lib]
|
||||
lib/websocket/websocket-core-common-${jetty.version}.jar
|
||||
lib/websocket/websocket-core-client-${jetty.version}.jar
|
||||
lib/websocket/websocket-util-${jetty.version}.jar
|
||||
lib/websocket/websocket-jetty-api-${jetty.version}.jar
|
||||
lib/websocket/websocket-jetty-common-${jetty.version}.jar
|
||||
lib/websocket/websocket-jetty-client-${jetty.version}.jar
|
||||
|
||||
[jpms]
|
||||
# The implementation needs to access method handles in
|
||||
# classes that are in the web application classloader.
|
||||
add-reads: org.eclipse.jetty.websocket.jetty.common=ALL-UNNAMED
|
|
@ -20,6 +20,7 @@ module org.eclipse.jetty.websocket.jetty.client
|
|||
{
|
||||
exports org.eclipse.jetty.websocket.client;
|
||||
|
||||
requires static org.eclipse.jetty.webapp;
|
||||
requires org.eclipse.jetty.websocket.core.client;
|
||||
requires org.eclipse.jetty.websocket.jetty.common;
|
||||
requires org.slf4j;
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under
|
||||
// the terms of the Eclipse Public License 2.0 which is available at
|
||||
// https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// This Source Code may also be made available under the following
|
||||
// Secondary Licenses when the conditions for such availability set
|
||||
// forth in the Eclipse Public License, v. 2.0 are satisfied:
|
||||
// the Apache License v2.0 which is available at
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.websocket.client.config;
|
||||
|
||||
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;
|
||||
import org.eclipse.jetty.webapp.MetaInfConfiguration;
|
||||
import org.eclipse.jetty.webapp.WebAppConfiguration;
|
||||
import org.eclipse.jetty.webapp.WebInfConfiguration;
|
||||
import org.eclipse.jetty.webapp.WebXmlConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <p>Websocket Configuration</p>
|
||||
* <p>This configuration configures the WebAppContext server/system classes to
|
||||
* be able to see the org.eclipse.jetty.websocket package.
|
||||
* This class is defined in the webapp package, as it implements the {@link Configuration} interface,
|
||||
* which is unknown to the websocket package. However, the corresponding {@link ServiceLoader}
|
||||
* resource is defined in the websocket package, so that this configuration only be
|
||||
* loaded if the jetty-websocket jars are on the classpath.
|
||||
* </p>
|
||||
*/
|
||||
public class JettyWebSocketClientConfiguration extends AbstractConfiguration
|
||||
{
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JettyWebSocketClientConfiguration.class);
|
||||
|
||||
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)");
|
||||
|
||||
protectAndExpose("org.eclipse.jetty.websocket.api.");
|
||||
protectAndExpose("org.eclipse.jetty.websocket.client.");
|
||||
hide("org.eclipse.jetty.client.impl.");
|
||||
hide("org.eclipse.jetty.client.config.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable()
|
||||
{
|
||||
return isAvailable("org.eclipse.jetty.websocket.client.WebSocketClient");
|
||||
}
|
||||
|
||||
private boolean isAvailable(String classname)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Loader.loadClass(classname) != null;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
LOG.trace("IGNORED", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
org.eclipse.jetty.websocket.client.config.JettyWebSocketClientConfiguration
|
|
@ -7,18 +7,15 @@ Enable the Jetty WebSocket API for deployed web applications.
|
|||
websocket
|
||||
|
||||
[depend]
|
||||
client
|
||||
annotations
|
||||
|
||||
[lib]
|
||||
lib/websocket/websocket-core-common-${jetty.version}.jar
|
||||
lib/websocket/websocket-core-client-${jetty.version}.jar
|
||||
lib/websocket/websocket-core-server-${jetty.version}.jar
|
||||
lib/websocket/websocket-util-${jetty.version}.jar
|
||||
lib/websocket/websocket-util-server-${jetty.version}.jar
|
||||
lib/websocket/websocket-jetty-api-${jetty.version}.jar
|
||||
lib/websocket/websocket-jetty-common-${jetty.version}.jar
|
||||
lib/websocket/websocket-jetty-client-${jetty.version}.jar
|
||||
lib/websocket/websocket-jetty-server-${jetty.version}.jar
|
||||
|
||||
[jpms]
|
||||
|
|
|
@ -68,7 +68,7 @@ public class JettyWebSocketConfiguration extends AbstractConfiguration
|
|||
@Override
|
||||
public boolean isAvailable()
|
||||
{
|
||||
return isAvailable("org.eclipse.jetty.websocket.common.JettyWebSocketFrame");
|
||||
return isAvailable("org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer");
|
||||
}
|
||||
|
||||
private boolean isAvailable(String classname)
|
||||
|
|
|
@ -391,7 +391,7 @@ public class DistributionTests extends AbstractJettyHomeTest
|
|||
String[] args1 = {
|
||||
"--create-startd",
|
||||
"--approve-all-licenses",
|
||||
"--add-to-start=resources,server,webapp,deploy,jsp,jmx,servlet,servlets,websocket," + module,
|
||||
"--add-to-start=resources,server,webapp,deploy,jsp,jmx,servlet,servlets,websocket,websocket-jetty-client," + module,
|
||||
};
|
||||
try (JettyHomeTester.Run run1 = distribution.start(args1))
|
||||
{
|
||||
|
@ -405,9 +405,6 @@ public class DistributionTests extends AbstractJettyHomeTest
|
|||
String[] args2 = {
|
||||
"jetty.http.port=" + port,
|
||||
"jetty.ssl.port=" + port,
|
||||
// We need to expose the websocket client classes to the webapp for this to work.
|
||||
"jetty.webapp.addServerClasses+=,-org.eclipse.jetty.websocket.client.",
|
||||
"jetty.webapp.addSystemClasses+=,+org.eclipse.jetty.websocket.client.",
|
||||
// "jetty.server.dumpAfterStart=true",
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue