Add appropriate headers to allow ServiceLoader mechanism to work with OSGi.
This commit is contained in:
parent
272940c2ec
commit
b6f36dadb2
|
@ -44,6 +44,7 @@
|
|||
<configuration>
|
||||
<instructions>
|
||||
<Import-Package>javax.servlet.*;version="[2.6.0,3.2)",*</Import-Package>
|
||||
<Require-Capability>osgi.serviceloader; filter:="(osgi.serviceloader=javax.servlet.ServletContainerInitializer)";cardinality:=multiple, osgi.extender; filter:="(osgi.extender=osgi.serviceloader.processor)"</Require-Capability>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -793,15 +793,23 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
|
||||
//We use the ServiceLoader mechanism to find the ServletContainerInitializer classes to inspect
|
||||
long start = 0;
|
||||
if (LOG.isDebugEnabled())
|
||||
start = System.nanoTime();
|
||||
ServiceLoader<ServletContainerInitializer> loadedInitializers = ServiceLoader.load(ServletContainerInitializer.class, context.getClassLoader());
|
||||
|
||||
ClassLoader old = Thread.currentThread().getContextClassLoader();
|
||||
ServiceLoader<ServletContainerInitializer> loadedInitializers = null;
|
||||
try
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
start = System.nanoTime();
|
||||
Thread.currentThread().setContextClassLoader(context.getClassLoader());
|
||||
loadedInitializers = ServiceLoader.load(ServletContainerInitializer.class);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Thread.currentThread().setContextClassLoader(old);
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Service loaders found in {}ms", (TimeUnit.MILLISECONDS.convert((System.nanoTime()-start), TimeUnit.NANOSECONDS)));
|
||||
|
||||
//no ServletContainerInitializers found
|
||||
if (loadedInitializers == null)
|
||||
return Collections.emptyList();
|
||||
|
||||
ServletContainerInitializerOrdering initializerOrdering = getInitializerOrdering(context);
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@
|
|||
<instructions>
|
||||
<Bundle-Description>javax.websocket.server Implementation</Bundle-Description>
|
||||
<Export-Package>org.eclipse.jetty.websocket.jsr356.server.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"</Export-Package>
|
||||
<Require-Capability>osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)"</Require-Capability>
|
||||
<Provide-Capability>osgi.serviceloader; osgi.serviceloader=javax.servlet.ServletContainerInitializer</Provide-Capability>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
Loading…
Reference in New Issue