hammant 2002/10/01 12:58:47
Modified: sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty
JettySevak.java
Added: sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty
PhoenixLogSink.java
Log:
Logging for Jetty patched thru Phoenix
Revision Changes Path
1.4 +39 -2
jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettySevak.java
Index: JettySevak.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettySevak.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JettySevak.java 30 Sep 2002 23:08:48 -0000 1.3
+++ JettySevak.java 1 Oct 2002 19:58:47 -0000 1.4
@@ -27,6 +27,7 @@
import org.mortbay.jetty.servlet.WebApplicationContext;
import org.mortbay.util.MultiException;
import org.mortbay.util.InetAddrPort;
+import org.mortbay.util.Log;
/**
@@ -51,27 +52,50 @@
private int m_port;
+ /**
+ * Contruct a Jetty block
+ */
public JettySevak()
{
- m_server = new Server();
}
+ /**
+ * Contextualize
+ * @param context the context
+ */
+
public void contextualize(final Context context)
{
//this.m_context = (BlockContext) context;
}
+ /**
+ * Configure
+ * @param configuration the configuration
+ * @throws ConfigurationException if a problem
+ */
public void configure(final Configuration configuration) throws
ConfigurationException
{
m_hostName = configuration.getChild("hostname").getValue("localhost");
m_port = configuration.getChild("port").getValueAsInteger(8080);
}
+ /**
+ * Initialize
+ * @throws Exception if a problem
+ */
public void initialize() throws Exception
{
+ m_server = new Server();
m_server.addListener(new InetAddrPort(m_hostName, m_port));
+ PhoenixLogSink phoenixLogSink = new PhoenixLogSink();
+ phoenixLogSink.enableLogging(getLogger());
+ Log.instance().add(phoenixLogSink);
}
+ /**
+ * Start
+ */
public final void start()
{
try
@@ -84,6 +108,9 @@
}
}
+ /**
+ * Stop
+ */
public void stop()
{
try
@@ -96,6 +123,12 @@
}
}
+ /**
+ * Deploy a webapp
+ * @param context the contxct for the webapp
+ * @param pathToWebAppFolder the pathc to it
+ * @throws SevakException if a problem
+ */
public void deploy(String context, File pathToWebAppFolder) throws
SevakException
{
try
@@ -112,12 +145,16 @@
}
}
+ /**
+ * Undeploy a webapp.
+ * @param context the context
+ * @throws SevakException if a problem
+ */
public void undeploy(String context) throws SevakException
{
WebApplicationContext ctx = (WebApplicationContext) m_webapps.get(context);
ctx.destroy();
m_webapps.remove(context);
}
-
}
1.1
jakarta-avalon-apps/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/PhoenixLogSink.java
Index: PhoenixLogSink.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.apps.sevak.blocks.jetty;
import org.mortbay.util.LogSink;
import org.mortbay.util.Frame;
import org.mortbay.util.Log;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
/**
* Jetty Log redirection
*
*
* @see <a href="http://jetty.mortbay.com/">Jetty Project Page</a>
*
* @author Bruno Dumon & Paul Hammant
* @version 1.0
*/
public class PhoenixLogSink extends AbstractLogEnabled implements LogSink
{
public void setOptions(String s)
{
}
public String getOptions()
{
return "";
}
public void log(String type, Object message, Frame frame, long time)
{
if (type.equals(Log.DEBUG))
{
getLogger().info("time=" + time + " message=" + message + " frame=" +
frame);
}
else if (type.equals(Log.FAIL))
{
getLogger().error("time=" + time + " message=" + message + " frame=" +
frame);
}
else if (type.equals(Log.WARN))
{
getLogger().warn("time=" + time + " message=" + message + " frame=" +
frame);
}
else if (type.equals(Log.ASSERT))
{
getLogger().info("ASSERT time=" + time + " message=" + message + "
frame=" + frame);
}
else
{
getLogger().info("time=" + time + " message=" + message + " frame=" +
frame);
}
}
public void log(String message)
{
getLogger().info(message);
}
public void start() throws Exception
{
}
public void stop() throws InterruptedException
{
}
public boolean isStarted()
{
return true;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>