Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2014-03-10 02:41:05 +0000
committerJan Bartel2014-03-10 02:42:06 +0000
commiteacdaf70731a68b314d30b50967119082bceaa31 (patch)
treef6db3270fbd494aec7395d92354a82aafe067988 /jetty-osgi
parentb6f36dadb2d86ee92a87fd66859f1f8e1b450dda (diff)
downloadorg.eclipse.jetty.project-eacdaf70731a68b314d30b50967119082bceaa31.tar.gz
org.eclipse.jetty.project-eacdaf70731a68b314d30b50967119082bceaa31.tar.xz
org.eclipse.jetty.project-eacdaf70731a68b314d30b50967119082bceaa31.zip
Make ServiceLoader.load work with jetty-osgi-boot to support annotations.
Diffstat (limited to 'jetty-osgi')
-rw-r--r--jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java33
-rw-r--r--jetty-osgi/test-jetty-osgi/pom.xml34
-rw-r--r--jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootCore.java29
-rw-r--r--jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithJsp.java12
-rw-r--r--jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java7
5 files changed, 94 insertions, 21 deletions
diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java
index 996db907f0..6a2648291f 100644
--- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java
+++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java
@@ -20,6 +20,7 @@ package org.eclipse.jetty.osgi.boot;
import java.io.File;
import java.net.URL;
+import java.util.Arrays;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
@@ -72,7 +73,35 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
public static String[] getDefaultConfigurations ()
{
- return __defaultConfigurations;
+ if (annotationsAvailable())
+ {
+ String[] configs = new String[__defaultConfigurations.length+1];
+ System.arraycopy(__defaultConfigurations, 0, configs, 0, 4);
+ configs[4] = "org.eclipse.jetty.osgi.annotations.AnnotationConfiguration";
+ configs[5] = __defaultConfigurations[__defaultConfigurations.length-1];
+ return configs;
+ }
+
+
+ return Arrays.copyOf(__defaultConfigurations, __defaultConfigurations.length);
+ }
+
+ private static boolean annotationsAvailable()
+ {
+ boolean result = false;
+ try
+ {
+ Thread.currentThread().getContextClassLoader().loadClass("org.eclipse.jetty.annotations.AnnotationConfiguration");
+ result = true;
+ LOG.debug("Annotation support detected");
+ }
+ catch (ClassNotFoundException e)
+ {
+ result = false;
+ LOG.debug("No annotation support detected");
+ }
+
+ return result;
}
@@ -247,7 +276,7 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
if (getConfigurationClasses() != null)
_webApp.setConfigurationClasses(getConfigurationClasses());
else
- _webApp.setConfigurationClasses(__defaultConfigurations);
+ _webApp.setConfigurationClasses(getDefaultConfigurations());
if (getDefaultsDescriptor() != null)
_webApp.setDefaultsDescriptor(getDefaultsDescriptor());
diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml
index bda92cff54..239b33b1ca 100644
--- a/jetty-osgi/test-jetty-osgi/pom.xml
+++ b/jetty-osgi/test-jetty-osgi/pom.xml
@@ -66,6 +66,13 @@
<version>${exam.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.aries.spifly</groupId>
+ <artifactId>org.apache.aries.spifly.dynamic.bundle</artifactId>
+ <version>1.0.0</version>
+ <scope>test</scope>
+ </dependency>
+
<!-- Don't use the native container for now. Observed limitations:
- single test with a single configuration
@@ -149,13 +156,17 @@
<scope>test</scope>
</dependency>
-->
- <!-- Orbit Servlet Deps -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>test</scope>
</dependency>
- <!-- Orbit JSP Deps -->
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ <version>1.1.1</version>
+ <scope>test</scope>
+ </dependency>
<!-- OSGi Deps -->
<dependency>
<groupId>org.eclipse.jetty.osgi</groupId>
@@ -184,6 +195,11 @@
<!-- Jetty Deps -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-annotations</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<scope>runtime</scope>
</dependency>
@@ -271,8 +287,18 @@
<artifactId>javax.websocket-api</artifactId>
<scope>runtime</scope>
</dependency>
-
-
+ <dependency>
+ <groupId>org.eclipse.jetty.websocket</groupId>
+ <artifactId>javax-websocket-server-impl</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.websocket</groupId>
+ <artifactId>javax-websocket-client-impl</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-core</artifactId>
diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootCore.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootCore.java
index 9884b1be6e..2c2331875b 100644
--- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootCore.java
+++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootCore.java
@@ -75,11 +75,20 @@ public class TestJettyOSGiBootCore
public static List<Option> coreJettyDependencies()
{
List<Option> res = new ArrayList<Option>();
-
- res.add(mavenBundle().groupId( "org.eclipse.jetty.osgi" ).artifactId( "jetty-osgi-boot" ).versionAsInProject().start());
-
+ res.add(mavenBundle().groupId( "org.ow2.asm" ).artifactId( "asm" ).versionAsInProject().start());
+ res.add(mavenBundle().groupId( "org.ow2.asm" ).artifactId( "asm-commons" ).versionAsInProject().start());
+ res.add(mavenBundle().groupId( "org.ow2.asm" ).artifactId( "asm-tree" ).versionAsInProject().start());
+ res.add(mavenBundle().groupId( "org.apache.aries" ).artifactId( "org.apache.aries.util" ).version("1.0.0").start());
+ res.add(mavenBundle().groupId( "org.apache.aries.spifly" ).artifactId( "org.apache.aries.spifly.dynamic.bundle" ).version("1.0.0").start());
+
res.add(mavenBundle().groupId( "javax.servlet" ).artifactId( "javax.servlet-api" ).versionAsInProject().noStart());
+ res.add(mavenBundle().groupId( "javax.annotation" ).artifactId( "javax.annotation-api" ).versionAsInProject().noStart());
+ res.add(mavenBundle().groupId( "org.apache.geronimo.specs" ).artifactId( "geronimo-jta_1.1_spec" ).version("1.1.1").noStart());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "javax.mail.glassfish" ).version( "1.4.1.v201005082020" ).noStart());
+
+
res.add(mavenBundle().groupId( "org.eclipse.jetty.toolchain" ).artifactId( "jetty-schemas" ).versionAsInProject().noStart());
+
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-deploy" ).versionAsInProject().noStart());
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-server" ).versionAsInProject().noStart());
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-servlet" ).versionAsInProject().noStart());
@@ -91,12 +100,19 @@ public class TestJettyOSGiBootCore
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-continuation" ).versionAsInProject().noStart());
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-security" ).versionAsInProject().noStart());
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-servlets" ).versionAsInProject().noStart());
- res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-client" ).versionAsInProject().noStart());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-client" ).versionAsInProject().noStart());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-jndi" ).versionAsInProject().noStart());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-plus" ).versionAsInProject().noStart());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-annotations" ).versionAsInProject().start());
res.add(mavenBundle().groupId( "org.eclipse.jetty.websocket" ).artifactId( "websocket-api" ).versionAsInProject().noStart());
res.add(mavenBundle().groupId( "org.eclipse.jetty.websocket" ).artifactId( "websocket-common" ).versionAsInProject().noStart());
res.add(mavenBundle().groupId( "org.eclipse.jetty.websocket" ).artifactId( "websocket-servlet" ).versionAsInProject().noStart());
res.add(mavenBundle().groupId( "org.eclipse.jetty.websocket" ).artifactId( "websocket-server" ).versionAsInProject().noStart());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.websocket" ).artifactId( "websocket-client" ).versionAsInProject().noStart());
res.add(mavenBundle().groupId( "javax.websocket" ).artifactId( "javax.websocket-api" ).versionAsInProject().noStart());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.websocket" ).artifactId( "javax-websocket-client-impl").versionAsInProject().noStart());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.websocket" ).artifactId( "javax-websocket-server-impl").versionAsInProject().start());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.osgi" ).artifactId( "jetty-osgi-boot" ).versionAsInProject().start());
return res;
}
@@ -111,11 +127,6 @@ public class TestJettyOSGiBootCore
@Test
public void assertAllBundlesActiveOrResolved() throws Exception
{
- //TestOSGiUtil.debugBundles(bundleContext);
- //Bundle bootBundle = TestOSGiUtil.getBundle(bundleContext, "org.eclipse.jetty.osgi.boot");
- //TestOSGiUtil.diagnoseNonActiveOrNonResolvedBundle(bootBundle);
- Bundle httpservicebundle = TestOSGiUtil.getBundle(bundleContext, "org.eclipse.jetty.osgi.httpservice");
- TestOSGiUtil.diagnoseNonActiveOrNonResolvedBundle(httpservicebundle);
TestOSGiUtil.assertAllBundlesActiveOrResolved(bundleContext);
}
diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithJsp.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithJsp.java
index 34ce9d11a3..10b21f5735 100644
--- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithJsp.java
+++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWithJsp.java
@@ -44,6 +44,7 @@ import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
/**
* Pax-Exam to make sure the jetty-osgi-boot can be started along with the
@@ -70,7 +71,7 @@ public class TestJettyOSGiBootWithJsp
options.add(CoreOptions.junitBundles());
options.addAll(configureJettyHomeAndPort("jetty-selector.xml"));
- options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.xml.*"));
+ options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.xml.*", "javax.activation.*"));
options.add(CoreOptions.systemPackages("com.sun.org.apache.xalan.internal.res","com.sun.org.apache.xml.internal.utils",
"com.sun.org.apache.xml.internal.utils", "com.sun.org.apache.xpath.internal",
"com.sun.org.apache.xpath.internal.jaxp", "com.sun.org.apache.xpath.internal.objects"));
@@ -90,7 +91,7 @@ public class TestJettyOSGiBootWithJsp
// this is how you set the default log level when using pax logging
// (logProfile)
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(logLevel),
- systemProperty("org.eclipse.jetty.LEVEL").value(logLevel))));
+ systemProperty("org.eclipse.jetty.annotations.LEVEL").value(logLevel))));
options.addAll(jspDependencies());
@@ -156,11 +157,11 @@ public class TestJettyOSGiBootWithJsp
return res;
}
-
+
@Test
public void assertAllBundlesActiveOrResolved()
{
- TestOSGiUtil.assertAllBundlesActiveOrResolved(bundleContext);
+ TestOSGiUtil.assertAllBundlesActiveOrResolved(bundleContext);
}
// at the moment can't run httpservice with jsp at the same time.
@@ -172,7 +173,7 @@ public class TestJettyOSGiBootWithJsp
TestOSGiUtil.testHttpServiceGreetings(bundleContext, "http", TestJettyOSGiBootCore.DEFAULT_JETTY_HTTP_PORT);
}
-
+
@Test
public void testJspDump() throws Exception
{
@@ -185,6 +186,7 @@ public class TestJettyOSGiBootWithJsp
String content = new String(response.getContent());
assertTrue(content.contains("<tr><th>ServletPath:</th><td>/jsp/dump.jsp</td></tr>"));
+
}
finally
{
diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java
index bfa8fcb7a5..d9d63eda7d 100644
--- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java
+++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java
@@ -59,7 +59,7 @@ public class TestOSGiUtil
//options.add(CoreOptions.equinox().version("3.6.1"));
//options.add(CoreOptions.equinox().version("3.7.0"));
// options.add(CoreOptions.felix().version("3.2.2"));
- options.add(CoreOptions.felix().version("4.0.2"));
+ options.add(CoreOptions.felix().version("4.0.2"));
}
protected static Bundle getBundle(BundleContext bundleContext, String symbolicName)
@@ -149,6 +149,11 @@ public class TestOSGiUtil
System.err.println(" " + b.getSymbolicName() + " " + b.getState());
}
}
+
+ protected static ServiceReference[] getServices (String service, BundleContext bundleContext) throws Exception
+ {
+ return bundleContext.getAllServiceReferences(service, null);
+ }
protected static SslContextFactory newSslContextFactory()
{

Back to the top