464630 Cannot configure Configuration classlist in osgi

This commit is contained in:
Jan Bartel 2015-05-01 16:00:24 +10:00
parent 2271464406
commit be3b9497a6
3 changed files with 73 additions and 72 deletions

View File

@ -63,21 +63,25 @@
<!-- =========================================================== -->
<!-- jetty-jndi by default -->
<!-- Set up the list of default configuration classes -->
<!-- =========================================================== -->
<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>
<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.plus.webapp.EnvConfiguration</Item>
<Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
<Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
<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>
<Call class="java.lang.System" name="setProperty">
<Arg>java.naming.factory.initial</Arg>

View File

@ -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());
if (getDefaultsDescriptor() != null)
_webApp.setDefaultsDescriptor(getDefaultsDescriptor());
@ -601,9 +577,26 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
/* ------------------------------------------------------------ */
public String[] getConfigurationClasses()
{
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)
{

View File

@ -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 -->
<!-- Set up the list of default configuration classes -->
<!-- =========================================================== -->
<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>
<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.plus.webapp.EnvConfiguration</Item>
<Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
<Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
<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>
<Call class="java.lang.System" name="setProperty">
<Arg>java.naming.factory.initial</Arg>