Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2014-03-09 22:41:05 -0400
committerJan Bartel2014-03-09 22:42:06 -0400
commiteacdaf70731a68b314d30b50967119082bceaa31 (patch)
treef6db3270fbd494aec7395d92354a82aafe067988 /jetty-osgi/jetty-osgi-boot/src
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/jetty-osgi-boot/src')
-rw-r--r--jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java33
1 files changed, 31 insertions, 2 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());

Back to the top