はい、 webappsの展開ライフサイクルに参加するクラスを持つことができます。
クラスの例:
package example.deploy.logging.config;
import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.AppLifeCycle;
import org.eclipse.jetty.deploy.graph.Node;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.webapp.WebAppContext;
public class LoggingConfigBinding implements AppLifeCycle.Binding
{
public String[] getBindingTargets()
{
return new String[]
{ "deploying" };
}
public void processBinding(Node node, App app) throws Exception
{
ContextHandler handler = app.getContextHandler();
if (handler == null)
{
throw new NullPointerException("No Handler created for App: " + app);
}
if (handler instanceof WebAppContext)
{
WebAppContext webapp = (WebAppContext)handler;
webapp.addSystemClass("org.slf4j.");
}
}
}
次に、それをDeploymentManagerにロードする XML の一部を取得します。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Ref id="DeploymentManager">
<Call name="addLifeCycleBinding">
<Arg>
<New class="example.deploy.logging.config.LoggingConfigBinding">
</New>
</Arg>
</Call>
</Ref>
</Configure>
より完全な例については、Jetty の Logback でのログのふるい分けを参照してください(注: logback は slf4j ロギングの実装です)。