Fix features for jsp with osgi
This commit is contained in:
parent
22d2b251e9
commit
70cca692cc
|
@ -62,19 +62,7 @@
|
||||||
<Set name="dumpBeforeStop">false</Set>
|
<Set name="dumpBeforeStop">false</Set>
|
||||||
|
|
||||||
|
|
||||||
<!-- =========================================================== -->
|
|
||||||
<!-- Update the list of default configuration classes -->
|
|
||||||
<!-- =========================================================== -->
|
|
||||||
<Call class="org.eclipse.jetty.webapp.Configurations" name="setServerDefault">
|
|
||||||
<Arg><Ref refid="Server"/></Arg>
|
|
||||||
<Call name="add">
|
|
||||||
<Arg>
|
|
||||||
<Array type="String">
|
|
||||||
<Item>org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration</Item>
|
|
||||||
</Array>
|
|
||||||
</Arg>
|
|
||||||
</Call>
|
|
||||||
</Call>
|
|
||||||
|
|
||||||
<Call class="java.lang.System" name="setProperty">
|
<Call class="java.lang.System" name="setProperty">
|
||||||
<Arg>java.naming.factory.initial</Arg>
|
<Arg>java.naming.factory.initial</Arg>
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.osgi.boot;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Dictionary;
|
import java.util.Dictionary;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -40,6 +41,7 @@ import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.util.resource.JarResource;
|
import org.eclipse.jetty.util.resource.JarResource;
|
||||||
import org.eclipse.jetty.util.resource.Resource;
|
import org.eclipse.jetty.util.resource.Resource;
|
||||||
|
import org.eclipse.jetty.webapp.Configuration;
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
|
@ -57,51 +59,21 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(AbstractWebAppProvider.class);
|
private static final Logger LOG = Log.getLogger(AbstractWebAppProvider.class);
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
public static final String[] CONFIGURATION_CLASSES = {
|
||||||
/**
|
"org.eclipse.jetty.webapp.FragmentConfiguration",
|
||||||
* Check if we should be enabling annotation processing
|
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
|
||||||
*
|
"org.eclipse.jetty.webapp.WebXmlConfiguration",
|
||||||
* @return true if the jetty-annotations.jar is present, false otherwise
|
"org.eclipse.jetty.webapp.WebAppConfiguration",
|
||||||
*/
|
"org.eclipse.jetty.webapp.ServletsConfiguration",
|
||||||
private static boolean annotationsAvailable()
|
"org.eclipse.jetty.webapp.JspConfiguration",
|
||||||
{
|
"org.eclipse.jetty.webapp.JaasConfiguration",
|
||||||
boolean result = false;
|
"org.eclipse.jetty.webapp.JndiConfiguration",
|
||||||
try
|
"org.eclipse.jetty.webapp.JmxConfiguration",
|
||||||
{
|
"org.eclipse.jetty.webapp.WebSocketConfiguration",
|
||||||
Loader.loadClass(AbstractWebAppProvider.class,"org.eclipse.jetty.annotations.AnnotationConfiguration");
|
"org.eclipse.jetty.osgi.annotations.AnnotationConfiguration",
|
||||||
result = true;
|
"org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration",
|
||||||
LOG.debug("Annotation support detected");
|
"org.eclipse.jetty.osgi.boot.OSGiMetaInfConfiguration"
|
||||||
}
|
};
|
||||||
catch (ClassNotFoundException e)
|
|
||||||
{
|
|
||||||
result = false;
|
|
||||||
LOG.debug("No annotation support detected");
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
{
|
|
||||||
Loader.loadClass(AbstractWebAppProvider.class, "org.eclipse.jetty.plus.jndi.Resource");
|
|
||||||
Loader.loadClass(AbstractWebAppProvider.class, "org.eclipse.jetty.plus.webapp.EnvConfiguration");
|
|
||||||
LOG.debug("JNDI support detected");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException e)
|
|
||||||
{
|
|
||||||
LOG.debug("No JNDI support detected");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private boolean _parentLoaderPriority;
|
private boolean _parentLoaderPriority;
|
||||||
|
@ -113,8 +85,7 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
||||||
private String _tldBundles;
|
private String _tldBundles;
|
||||||
|
|
||||||
private DeploymentManager _deploymentManager;
|
private DeploymentManager _deploymentManager;
|
||||||
|
|
||||||
private String[] _configurationClasses;
|
|
||||||
|
|
||||||
private ServerInstanceWrapper _serverWrapper;
|
private ServerInstanceWrapper _serverWrapper;
|
||||||
|
|
||||||
|
@ -290,18 +261,8 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
||||||
// Set up what has been configured on the provider
|
// Set up what has been configured on the provider
|
||||||
_webApp.setParentLoaderPriority(isParentLoaderPriority());
|
_webApp.setParentLoaderPriority(isParentLoaderPriority());
|
||||||
_webApp.setExtractWAR(isExtract());
|
_webApp.setExtractWAR(isExtract());
|
||||||
|
|
||||||
_webApp.addConfiguration(new OSGiWebInfConfiguration(),new OSGiMetaInfConfiguration());
|
|
||||||
if (annotationsAvailable())
|
|
||||||
_webApp.addConfiguration(new AnnotationConfiguration());
|
|
||||||
|
|
||||||
//add in EnvConfiguration and PlusConfiguration just after FragmentConfiguration
|
|
||||||
if (jndiAvailable())
|
|
||||||
_webApp.addConfiguration(new EnvConfiguration(),new PlusConfiguration());
|
|
||||||
|
|
||||||
if (getDefaultsDescriptor() != null)
|
|
||||||
_webApp.setDefaultsDescriptor(getDefaultsDescriptor());
|
|
||||||
|
|
||||||
//Set up configuration from manifest headers
|
//Set up configuration from manifest headers
|
||||||
//extra classpath
|
//extra classpath
|
||||||
String tmp = (String)_properties.get(OSGiWebappConstants.JETTY_EXTRA_CLASSPATH);
|
String tmp = (String)_properties.get(OSGiWebappConstants.JETTY_EXTRA_CLASSPATH);
|
||||||
|
@ -346,6 +307,23 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
||||||
webAppLoader.addClassPath(pathsToTldBundles);
|
webAppLoader.addClassPath(pathsToTldBundles);
|
||||||
_webApp.setClassLoader(webAppLoader);
|
_webApp.setClassLoader(webAppLoader);
|
||||||
|
|
||||||
|
//set up the configurations appropriate for osgi
|
||||||
|
for (String classname:CONFIGURATION_CLASSES)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_webApp.addConfiguration((Configuration)(Thread.currentThread().getContextClassLoader().loadClass(classname).newInstance()));
|
||||||
|
// if (LOG.isDebugEnabled())
|
||||||
|
LOG.info("Using Configuration {}", classname);
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException cnfe)
|
||||||
|
{
|
||||||
|
//not present, ignore
|
||||||
|
// if (LOG.isDebugEnabled())
|
||||||
|
LOG.info("Ignoring unavailable Configuration {}", classname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// apply any META-INF/context.xml file that is found to configure
|
// apply any META-INF/context.xml file that is found to configure
|
||||||
// the webapp first
|
// the webapp first
|
||||||
|
|
|
@ -92,7 +92,11 @@ public class OSGiMetaInfConfiguration extends MetaInfConfiguration
|
||||||
public void preConfigure(final WebAppContext context) throws Exception
|
public void preConfigure(final WebAppContext context) throws Exception
|
||||||
{
|
{
|
||||||
super.preConfigure(context);
|
super.preConfigure(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void scanJars(final WebAppContext context) throws Exception
|
||||||
|
{
|
||||||
//Check to see if there have been any bundle symbolic names added of bundles that should be
|
//Check to see if there have been any bundle symbolic names added of bundles that should be
|
||||||
//regarded as being on the container classpath, and scanned for fragments, tlds etc etc.
|
//regarded as being on the container classpath, and scanned for fragments, tlds etc etc.
|
||||||
//This can be defined in:
|
//This can be defined in:
|
||||||
|
@ -137,6 +141,8 @@ public class OSGiMetaInfConfiguration extends MetaInfConfiguration
|
||||||
{
|
{
|
||||||
context.getMetaData().addContainerResource(r);
|
context.getMetaData().addContainerResource(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.scanJars(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -60,19 +60,6 @@
|
||||||
<Set name="dumpAfterStart">false</Set>
|
<Set name="dumpAfterStart">false</Set>
|
||||||
<Set name="dumpBeforeStop">false</Set>
|
<Set name="dumpBeforeStop">false</Set>
|
||||||
|
|
||||||
<!-- =========================================================== -->
|
|
||||||
<!-- Update the list of default configuration classes -->
|
|
||||||
<!-- =========================================================== -->
|
|
||||||
<Call class="org.eclipse.jetty.webapp.Configurations" name="setServerDefault">
|
|
||||||
<Arg><Ref refid="Server"/></Arg>
|
|
||||||
<Call name="add">
|
|
||||||
<Arg>
|
|
||||||
<Array type="String">
|
|
||||||
<Item>org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration</Item>
|
|
||||||
</Array>
|
|
||||||
</Arg>
|
|
||||||
</Call>
|
|
||||||
</Call>
|
|
||||||
|
|
||||||
|
|
||||||
<Call class="java.lang.System" name="setProperty">
|
<Call class="java.lang.System" name="setProperty">
|
||||||
|
|
|
@ -46,29 +46,37 @@ public class Configurations extends AbstractList<Configuration>
|
||||||
|
|
||||||
private static final List<Configuration> __known = new ArrayList<>();
|
private static final List<Configuration> __known = new ArrayList<>();
|
||||||
private static final Set<String> __knownByClassName = new HashSet<>();
|
private static final Set<String> __knownByClassName = new HashSet<>();
|
||||||
static
|
|
||||||
{
|
|
||||||
ServiceLoader<Configuration> configs = ServiceLoader.load(Configuration.class);
|
|
||||||
for (Configuration configuration : configs)
|
|
||||||
{
|
|
||||||
__known.add(configuration);
|
|
||||||
__knownByClassName.add(configuration.getClass().getName());
|
|
||||||
}
|
|
||||||
sort(__known);
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
{
|
|
||||||
for (Configuration c: __known)
|
|
||||||
LOG.debug("known {}",c);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG.debug("Known Configurations {}",__knownByClassName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static List<Configuration> getKnown()
|
public static List<Configuration> getKnown()
|
||||||
{
|
{
|
||||||
|
synchronized (Configurations.class)
|
||||||
|
{
|
||||||
|
if (__known.isEmpty())
|
||||||
|
{
|
||||||
|
ServiceLoader<Configuration> configs = ServiceLoader.load(Configuration.class);
|
||||||
|
for (Configuration configuration : configs)
|
||||||
|
{
|
||||||
|
__known.add(configuration);
|
||||||
|
__knownByClassName.add(configuration.getClass().getName());
|
||||||
|
}
|
||||||
|
sort(__known);
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
{
|
||||||
|
for (Configuration c: __known)
|
||||||
|
LOG.debug("known {}",c);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG.debug("Known Configurations {}",__knownByClassName);
|
||||||
|
}
|
||||||
|
}
|
||||||
return __known;
|
return __known;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/** Get/Set/Create the server default Configuration ClassList.
|
/** Get/Set/Create the server default Configuration ClassList.
|
||||||
* <p>Get the class list from: a Server bean; or the attribute (which can
|
* <p>Get the class list from: a Server bean; or the attribute (which can
|
||||||
|
@ -149,9 +157,12 @@ public class Configurations extends AbstractList<Configuration>
|
||||||
|
|
||||||
protected static Configuration newConfiguration(String classname)
|
protected static Configuration newConfiguration(String classname)
|
||||||
{
|
{
|
||||||
if (!__knownByClassName.contains(classname))
|
if (LOG.isDebugEnabled())
|
||||||
LOG.warn("Unknown configuration {}. Not declared for ServiceLoader!",classname);
|
{
|
||||||
|
if (!__knownByClassName.contains(classname))
|
||||||
|
LOG.warn("Unknown configuration {}. Not declared for ServiceLoader!",classname);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -300,8 +311,11 @@ public class Configurations extends AbstractList<Configuration>
|
||||||
{
|
{
|
||||||
String name=configuration.getClass().getName();
|
String name=configuration.getClass().getName();
|
||||||
// Is this configuration known?
|
// Is this configuration known?
|
||||||
if (!__knownByClassName.contains(name))
|
if (LOG.isDebugEnabled())
|
||||||
LOG.warn("Unknown configuration {}. Not declared for ServiceLoader!",name);
|
{
|
||||||
|
if (!__knownByClassName.contains(name))
|
||||||
|
LOG.warn("Unknown configuration {}. Not declared for ServiceLoader!",name);
|
||||||
|
}
|
||||||
|
|
||||||
// Do we need to replace any existing configuration?
|
// Do we need to replace any existing configuration?
|
||||||
Class<? extends Configuration> replaces = configuration.replaces();
|
Class<? extends Configuration> replaces = configuration.replaces();
|
||||||
|
|
|
@ -164,6 +164,12 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
||||||
//No pattern to appy to classes, just add to metadata
|
//No pattern to appy to classes, just add to metadata
|
||||||
context.getMetaData().setWebInfClassesDirs(findClassDirs(context));
|
context.getMetaData().setWebInfClassesDirs(findClassDirs(context));
|
||||||
|
|
||||||
|
scanJars(context);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void scanJars (WebAppContext context) throws Exception
|
||||||
|
{
|
||||||
boolean useContainerCache = DEFAULT_USE_CONTAINER_METAINF_CACHE;
|
boolean useContainerCache = DEFAULT_USE_CONTAINER_METAINF_CACHE;
|
||||||
Boolean attr = (Boolean)context.getServer().getAttribute(USE_CONTAINER_METAINF_CACHE);
|
Boolean attr = (Boolean)context.getServer().getAttribute(USE_CONTAINER_METAINF_CACHE);
|
||||||
if (attr != null)
|
if (attr != null)
|
||||||
|
@ -185,7 +191,6 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
||||||
scanJars(context, context.getMetaData().getWebInfJars(), false);
|
scanJars(context, context.getMetaData().getWebInfJars(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(WebAppContext context) throws Exception
|
public boolean configure(WebAppContext context) throws Exception
|
||||||
|
|
Loading…
Reference in New Issue