Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2015-05-01 06:00:24 +0000
committerJan Bartel2015-05-01 06:01:27 +0000
commitbe3b9497a6fa88db39cd96a196576b81b6f044d7 (patch)
tree17a71696b096d25afff9fa340ec39e3e8173c5b6
parent22714644063eab5aa07d7baa135899af7176da15 (diff)
downloadorg.eclipse.jetty.project-be3b9497a6fa88db39cd96a196576b81b6f044d7.tar.gz
org.eclipse.jetty.project-be3b9497a6fa88db39cd96a196576b81b6f044d7.tar.xz
org.eclipse.jetty.project-be3b9497a6fa88db39cd96a196576b81b6f044d7.zip
464630 Cannot configure Configuration classlist in osgi
-rw-r--r--jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml32
-rw-r--r--jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java79
-rw-r--r--jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty.xml34
3 files changed, 73 insertions, 72 deletions
diff --git a/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml b/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml
index 881e69cafc..a4bc2fe4c1 100644
--- a/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml
+++ b/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml
@@ -63,21 +63,25 @@
<!-- =========================================================== -->
- <!-- jetty-jndi by default -->
- <!-- =========================================================== -->
- <Call class="org.eclipse.jetty.webapp.Configuration$ClassList" name="setServerDefault">
- <Arg><Ref refid="Server" /></Arg>
- <Call name="addAfter">
- <Arg name="afterClass">org.eclipse.jetty.webapp.FragmentConfiguration</Arg>
- <Arg>
- <Array type="String">
- <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item>
- <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
- <Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
- </Array>
- </Arg>
- </Call>
+ <!-- Set up the list of default configuration classes -->
+ <!-- =========================================================== -->
+ <Call name="setAttribute">
+ <Arg>org.eclipse.jetty.webapp.configuration</Arg>
+ <Arg>
+ <New class="org.eclipse.jetty.webapp.Configuration$ClassList">
+ <Arg>
+ <Array type="String">
+ <Item>org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration</Item>
+ <Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
+ <Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
+ <Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
+ <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
+ </Array>
+ </Arg>
+ </New>
+ </Arg>
</Call>
+
<Call class="java.lang.System" name="setProperty">
<Arg>java.naming.factory.initial</Arg>
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 69010e11f8..9bb74c50f2 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
@@ -23,7 +23,6 @@ import java.net.URL;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.List;
import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.AppProvider;
@@ -32,13 +31,13 @@ import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper;
import org.eclipse.jetty.osgi.boot.internal.webapp.OSGiWebappClassLoader;
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelperFactory;
import org.eclipse.jetty.server.handler.ContextHandler;
-import org.eclipse.jetty.util.ArrayUtil;
import org.eclipse.jetty.util.Loader;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.JarResource;
import org.eclipse.jetty.util.resource.Resource;
+import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.xml.XmlConfiguration;
import org.osgi.framework.Bundle;
@@ -56,40 +55,12 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
{
private static final Logger LOG = Log.getLogger(AbstractWebAppProvider.class);
- public static String __defaultConfigurations[] = {
- "org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration",
- "org.eclipse.jetty.webapp.WebXmlConfiguration",
- "org.eclipse.jetty.webapp.MetaInfConfiguration",
- "org.eclipse.jetty.webapp.FragmentConfiguration",
- "org.eclipse.jetty.webapp.JettyWebXmlConfiguration"
- };
-
- public static void setDefaultConfigurations (String[] defaultConfigs)
- {
- __defaultConfigurations = defaultConfigs;
- }
-
- public static String[] getDefaultConfigurations ()
- {
- List<String> configs = ArrayUtil.asMutableList(__defaultConfigurations);
- if (annotationsAvailable())
- {
- //add before JettyWebXmlConfiguration
- int i = configs.indexOf("org.eclipse.jetty.webapp.JettyWebXmlConfiguration");
- configs.add(i, "org.eclipse.jetty.osgi.annotations.AnnotationConfiguration");
- }
-
- if (jndiAvailable())
- {
- //add in EnvConfiguration and PlusConfiguration just after FragmentConfiguration
- int i = configs.indexOf("org.eclipse.jetty.webapp.FragmentConfiguration");
- configs.add(++i, "org.eclipse.jetty.plus.webapp.EnvConfiguration");
- configs.add(++i, "org.eclipse.jetty.plus.webapp.PlusConfiguration");
- }
-
- return configs.toArray(new String[configs.size()]);
- }
-
+ /* ------------------------------------------------------------ */
+ /**
+ * Check if we should be enabling annotation processing
+ *
+ * @return true if the jetty-annotations.jar is present, false otherwise
+ */
private static boolean annotationsAvailable()
{
boolean result = false;
@@ -108,7 +79,12 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
return result;
}
-
+ /* ------------------------------------------------------------ */
+ /**
+ * Check if jndi is support is present.
+ *
+ * @return true if the jetty-jndi.jar is present, false otherwise
+ */
private static boolean jndiAvailable()
{
try
@@ -140,11 +116,13 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
private ServerInstanceWrapper _serverWrapper;
+
+
/* ------------------------------------------------------------ */
/**
* OSGiApp
*
- *
+ * Represents a deployable webapp.
*/
public class OSGiApp extends AbstractOSGiApp
{
@@ -310,10 +288,8 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
// Set up what has been configured on the provider
_webApp.setParentLoaderPriority(isParentLoaderPriority());
_webApp.setExtractWAR(isExtract());
- if (getConfigurationClasses() != null)
- _webApp.setConfigurationClasses(getConfigurationClasses());
- else
- _webApp.setConfigurationClasses(getDefaultConfigurations());
+ _webApp.setConfigurationClasses(getConfigurationClasses());
+
if (getDefaultsDescriptor() != null)
_webApp.setDefaultsDescriptor(getDefaultsDescriptor());
@@ -601,8 +577,25 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
/* ------------------------------------------------------------ */
public String[] getConfigurationClasses()
{
- return _configurationClasses;
+ if (_configurationClasses != null)
+ return _configurationClasses;
+
+ Configuration.ClassList defaults = Configuration.ClassList.serverDefault(_serverWrapper.getServer());
+
+ //add before JettyWebXmlConfiguration
+ if (annotationsAvailable())
+ defaults.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
+ "org.eclipse.jetty.osgi.annotations.AnnotationConfiguration");
+
+ //add in EnvConfiguration and PlusConfiguration just after FragmentConfiguration
+ if (jndiAvailable())
+ defaults.addAfter("org.eclipse.jetty.webapp.FragmentConfiguration",
+ "org.eclipse.jetty.plus.webapp.EnvConfiguration",
+ "org.eclipse.jetty.plus.webapp.PlusConfiguration");
+ String[] asArray = new String[defaults.size()];
+ return defaults.toArray(asArray);
}
+
/* ------------------------------------------------------------ */
public void setServerInstanceWrapper(ServerInstanceWrapper wrapper)
diff --git a/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty.xml b/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty.xml
index bf96e21807..a4bc2fe4c1 100644
--- a/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty.xml
+++ b/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty.xml
@@ -15,11 +15,11 @@
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Get name="ThreadPool">
- <!-- Default queued blocking threadpool -->
<Set name="minThreads">10</Set>
<Set name="maxThreads">200</Set>
</Get>
+
<!-- =========================================================== -->
<!-- Set handler Collection Structure -->
<!-- =========================================================== -->
@@ -63,21 +63,25 @@
<!-- =========================================================== -->
- <!-- jetty-jndi by default -->
- <!-- =========================================================== -->
- <Call class="org.eclipse.jetty.webapp.Configuration$ClassList" name="setServerDefault">
- <Arg><Ref refid="Server" /></Arg>
- <Call name="addAfter">
- <Arg name="afterClass">org.eclipse.jetty.webapp.FragmentConfiguration</Arg>
- <Arg>
- <Array type="String">
- <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item>
- <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
- <Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
- </Array>
- </Arg>
- </Call>
+ <!-- Set up the list of default configuration classes -->
+ <!-- =========================================================== -->
+ <Call name="setAttribute">
+ <Arg>org.eclipse.jetty.webapp.configuration</Arg>
+ <Arg>
+ <New class="org.eclipse.jetty.webapp.Configuration$ClassList">
+ <Arg>
+ <Array type="String">
+ <Item>org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration</Item>
+ <Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
+ <Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
+ <Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
+ <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
+ </Array>
+ </Arg>
+ </New>
+ </Arg>
</Call>
+
<Call class="java.lang.System" name="setProperty">
<Arg>java.naming.factory.initial</Arg>

Back to the top