Issue #2983 less verbose
Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
458f402cf0
commit
1957e858ee
|
@ -56,7 +56,15 @@ import org.eclipse.jetty.util.annotation.Name;
|
||||||
*/
|
*/
|
||||||
public interface Configuration
|
public interface Configuration
|
||||||
{
|
{
|
||||||
public final static String ATTR="org.eclipse.jetty.webapp.configuration";
|
String ATTR="org.eclipse.jetty.webapp.configuration";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return True if the feature this configuration represents is available and has all its dependencies.
|
||||||
|
*/
|
||||||
|
default boolean isAvailable()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get a class that this class replaces/extends.
|
/** Get a class that this class replaces/extends.
|
||||||
* If this is added to {@link Configurations} collection that already contains a
|
* If this is added to {@link Configurations} collection that already contains a
|
||||||
|
@ -64,29 +72,29 @@ public interface Configuration
|
||||||
* it is replaced with this instance.
|
* it is replaced with this instance.
|
||||||
* @return The class this Configuration replaces/extends or null if it replaces no other configuration
|
* @return The class this Configuration replaces/extends or null if it replaces no other configuration
|
||||||
*/
|
*/
|
||||||
public default Class<? extends Configuration> replaces() { return null; }
|
default Class<? extends Configuration> replaces() { return null; }
|
||||||
|
|
||||||
/** Get known Configuration Dependencies.
|
/** Get known Configuration Dependencies.
|
||||||
* @return The names of Configurations that {@link TopologicalSort} must order
|
* @return The names of Configurations that {@link TopologicalSort} must order
|
||||||
* before this configuration.
|
* before this configuration.
|
||||||
*/
|
*/
|
||||||
public default Collection<String> getDependencies() { return Collections.emptyList(); }
|
default Collection<String> getDependencies() { return Collections.emptyList(); }
|
||||||
|
|
||||||
/** Get known Configuration Dependents.
|
/** Get known Configuration Dependents.
|
||||||
* @return The names of Configurations that {@link TopologicalSort} must order
|
* @return The names of Configurations that {@link TopologicalSort} must order
|
||||||
* after this configuration.
|
* after this configuration.
|
||||||
*/
|
*/
|
||||||
public default Collection<String> getDependents(){ return Collections.emptyList(); }
|
default Collection<String> getDependents(){ return Collections.emptyList(); }
|
||||||
|
|
||||||
/** Get the system classes associated with this Configuration.
|
/** Get the system classes associated with this Configuration.
|
||||||
* @return ClasspathPattern of system classes.
|
* @return ClasspathPattern of system classes.
|
||||||
*/
|
*/
|
||||||
public default ClasspathPattern getSystemClasses() { return new ClasspathPattern(); }
|
default ClasspathPattern getSystemClasses() { return new ClasspathPattern(); }
|
||||||
|
|
||||||
/** Get the system classes associated with this Configuration.
|
/** Get the system classes associated with this Configuration.
|
||||||
* @return ClasspathPattern of server classes.
|
* @return ClasspathPattern of server classes.
|
||||||
*/
|
*/
|
||||||
public default ClasspathPattern getServerClasses() { return new ClasspathPattern(); }
|
default ClasspathPattern getServerClasses() { return new ClasspathPattern(); }
|
||||||
|
|
||||||
/** Set up for configuration.
|
/** Set up for configuration.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -97,7 +105,7 @@ public interface Configuration
|
||||||
* @param context The context to configure
|
* @param context The context to configure
|
||||||
* @throws Exception if unable to pre configure
|
* @throws Exception if unable to pre configure
|
||||||
*/
|
*/
|
||||||
public void preConfigure (WebAppContext context) throws Exception;
|
void preConfigure (WebAppContext context) throws Exception;
|
||||||
|
|
||||||
/** Configure WebApp.
|
/** Configure WebApp.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -106,13 +114,13 @@ public interface Configuration
|
||||||
* @param context The context to configure
|
* @param context The context to configure
|
||||||
* @throws Exception if unable to configure
|
* @throws Exception if unable to configure
|
||||||
*/
|
*/
|
||||||
public void configure (WebAppContext context) throws Exception;
|
void configure (WebAppContext context) throws Exception;
|
||||||
|
|
||||||
/** Clear down after configuration.
|
/** Clear down after configuration.
|
||||||
* @param context The context to configure
|
* @param context The context to configure
|
||||||
* @throws Exception if unable to post configure
|
* @throws Exception if unable to post configure
|
||||||
*/
|
*/
|
||||||
public void postConfigure (WebAppContext context) throws Exception;
|
void postConfigure (WebAppContext context) throws Exception;
|
||||||
|
|
||||||
/** DeConfigure WebApp.
|
/** DeConfigure WebApp.
|
||||||
* This method is called to undo all configuration done. This is
|
* This method is called to undo all configuration done. This is
|
||||||
|
@ -120,7 +128,7 @@ public interface Configuration
|
||||||
* @param context The context to configure
|
* @param context The context to configure
|
||||||
* @throws Exception if unable to deconfigure
|
* @throws Exception if unable to deconfigure
|
||||||
*/
|
*/
|
||||||
public void deconfigure (WebAppContext context) throws Exception;
|
void deconfigure (WebAppContext context) throws Exception;
|
||||||
|
|
||||||
/** Destroy WebApp.
|
/** Destroy WebApp.
|
||||||
* This method is called to destroy a webappcontext. It is typically called when a context
|
* This method is called to destroy a webappcontext. It is typically called when a context
|
||||||
|
@ -128,23 +136,23 @@ public interface Configuration
|
||||||
* @param context The context to configure
|
* @param context The context to configure
|
||||||
* @throws Exception if unable to destroy
|
* @throws Exception if unable to destroy
|
||||||
*/
|
*/
|
||||||
public void destroy (WebAppContext context) throws Exception;
|
void destroy (WebAppContext context) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if configuration is disabled by default
|
* @return true if configuration is disabled by default
|
||||||
*/
|
*/
|
||||||
public boolean isDisabledByDefault();
|
boolean isDisabledByDefault();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if configuration should be aborted
|
* @return true if configuration should be aborted
|
||||||
*/
|
*/
|
||||||
public boolean abort(WebAppContext context);
|
boolean abort(WebAppContext context);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link Configurations}
|
* @deprecated Use {@link Configurations}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class ClassList extends Configurations
|
class ClassList extends Configurations
|
||||||
{
|
{
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void addAfter(@Name("afterClass") String afterClass,@Name("configClass")String... configClass)
|
public void addAfter(@Name("afterClass") String afterClass,@Name("configClass")String... configClass)
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.webapp;
|
package org.eclipse.jetty.webapp;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.AbstractList;
|
import java.util.AbstractList;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -78,14 +79,18 @@ public class Configurations extends AbstractList<Configuration>
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Configuration configuration = i.next();
|
Configuration configuration = i.next();
|
||||||
|
if (!configuration.isAvailable())
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Configuration unavailable: "+configuration);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
__known.add(configuration);
|
__known.add(configuration);
|
||||||
__knownByClassName.add(configuration.getClass().getName());
|
__knownByClassName.add(configuration.getClass().getName());
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
LOG.info("Configuration unavailable: "+e.getMessage());
|
LOG.warn(e);
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +118,14 @@ public class Configurations extends AbstractList<Configuration>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Class<?> clazz = Loader.loadClass(c);
|
Class<? extends Configuration> clazz = Loader.loadClass(c);
|
||||||
|
Configuration configuration = clazz.getConstructor().newInstance();
|
||||||
|
if (!configuration.isAvailable())
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.warn("Configuration unavailable: "+configuration);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
__known.add((Configuration)clazz.newInstance());
|
__known.add((Configuration)clazz.newInstance());
|
||||||
__knownByClassName.add(c);
|
__knownByClassName.add(c);
|
||||||
}
|
}
|
||||||
|
@ -232,9 +244,9 @@ public class Configurations extends AbstractList<Configuration>
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<Configuration> clazz = Loader.loadClass(classname);
|
Class<Configuration> clazz = Loader.loadClass(classname);
|
||||||
return clazz.newInstance();
|
return clazz.getConstructor().newInstance();
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException | InstantiationException | IllegalAccessException e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.webapp;
|
package org.eclipse.jetty.webapp;
|
||||||
|
|
||||||
import org.eclipse.jetty.jmx.ObjectMBean;
|
import org.eclipse.jetty.util.Loader;
|
||||||
|
import org.eclipse.jetty.util.log.Log;
|
||||||
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
|
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
|
@ -35,9 +37,25 @@ import java.util.ServiceLoader;
|
||||||
*/
|
*/
|
||||||
public class JmxConfiguration extends AbstractConfiguration
|
public class JmxConfiguration extends AbstractConfiguration
|
||||||
{
|
{
|
||||||
|
private static final Logger LOG = Log.getLogger(JmxConfiguration.class);
|
||||||
|
|
||||||
public JmxConfiguration()
|
public JmxConfiguration()
|
||||||
{
|
{
|
||||||
addDependents(WebXmlConfiguration.class, MetaInfConfiguration.class, WebInfConfiguration.class);
|
addDependents(WebXmlConfiguration.class, MetaInfConfiguration.class, WebInfConfiguration.class);
|
||||||
protectAndExpose(ObjectMBean.class.getPackage().getName()+".");
|
protectAndExpose("org.eclipse.jetty.jmx.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAvailable()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Loader.loadClass("org.eclipse.jetty.jmx.ObjectMBean")!=null;
|
||||||
|
}
|
||||||
|
catch (Throwable e)
|
||||||
|
{
|
||||||
|
LOG.ignore(e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue