cvs commit: spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty AvalonLogSink.java CommonsLoggingLogSink.java SimpleLogSink.java AvalonJettyJervlet.java BeanJettyJervlet.java PicoJettyJervlet.java PhoenixLogSink.java
Paul Hammant <[email protected]> Thu, 06 Nov 2003 14:06:04 -0800
| Newsgroups | gmane.comp.java.spice.cvs |
|---|---|
| Message-ID | <[email protected]> |
paul-h 03/11/06 14:06:04
Modified: sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty
AvalonJettyJervlet.java BeanJettyJervlet.java
PicoJettyJervlet.java
Added: sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty
AvalonLogSink.java CommonsLoggingLogSink.java
SimpleLogSink.java
Removed: sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty
PhoenixLogSink.java
Log:
LogSink work
Revision Changes Path
1.2 +5 -3 spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/AvalonJettyJervlet.java
Index: AvalonJettyJervlet.java
===================================================================
RCS file: /cvsroot/spice/spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/AvalonJettyJervlet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AvalonJettyJervlet.java 6 Nov 2003 20:25:46 -0000 1.1
+++ AvalonJettyJervlet.java 6 Nov 2003 22:06:03 -0000 1.2
@@ -155,9 +155,11 @@
m_server = createHttpServer();
m_server.addListener( createSocketListener() );
- PhoenixLogSink phoenixLogSink = new PhoenixLogSink();
- phoenixLogSink.enableLogging( getLogger() );
- Log.instance().add( phoenixLogSink );
+ AvalonLogSink logSink = new AvalonLogSink();
+ logSink.enableLogging( getLogger() );
+
+ // unsatisfactory as is static
+ Log.instance().add( logSink );
RequestLogger logger = (RequestLogger)
m_jervletContext.getServiceManager().lookup( RequestLogger.ROLE );
1.2 +10 -4 spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/BeanJettyJervlet.java
Index: BeanJettyJervlet.java
===================================================================
RCS file: /cvsroot/spice/spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/BeanJettyJervlet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BeanJettyJervlet.java 6 Nov 2003 21:13:55 -0000 1.1
+++ BeanJettyJervlet.java 6 Nov 2003 22:06:03 -0000 1.2
@@ -51,6 +51,8 @@
import org.jcomponent.jervlet.*;
import org.mortbay.jetty.Server;
+import org.mortbay.util.Log;
+import org.mortbay.util.LogSink;
import java.io.File;
import java.net.UnknownHostException;
@@ -84,6 +86,7 @@
private HashMap m_webcontexts = new HashMap();
private RequestLogger requestLogger;
+ private LogSink logSink;
public void setJervletConfig(JervletConfig config) {
super.config = config;
@@ -101,6 +104,11 @@
this.monitor = jervletMonitor;
}
+ public void setLogSink(LogSink logSink) {
+ this.logSink = logSink;
+ }
+
+
public void initialize() throws UnknownHostException {
this.jervletContext = new SimpleJervletContext();
@@ -108,10 +116,8 @@
m_server = createHttpServer();
m_server.addListener( createSocketListener() );
- //TODO
- //PhoenixLogSink phoenixLogSink = new PhoenixLogSink();
- //phoenixLogSink.enableLogging( getLogger() );
- //Log.instance().add( phoenixLogSink );
+ // unsatisfactory as is static
+ Log.instance().add( logSink );
m_server.setRequestLog( new JettyRequestLogAdapter( requestLogger ) );
}
1.3 +8 -5 spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/PicoJettyJervlet.java
Index: PicoJettyJervlet.java
===================================================================
RCS file: /cvsroot/spice/spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/PicoJettyJervlet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PicoJettyJervlet.java 6 Nov 2003 21:13:55 -0000 1.2
+++ PicoJettyJervlet.java 6 Nov 2003 22:06:03 -0000 1.3
@@ -51,6 +51,8 @@
import org.jcomponent.jervlet.*;
import org.mortbay.jetty.Server;
+import org.mortbay.util.LogSink;
+import org.mortbay.util.Log;
import org.picocontainer.MutablePicoContainer;
import org.picocontainer.lifecycle.Disposable;
import org.picocontainer.lifecycle.Startable;
@@ -81,6 +83,7 @@
{
private final JervletMonitor monitor;
private final File appRootDir;
+ private final LogSink logSink;
private final JervletContext jervletContext;
private Server m_server;
@@ -88,19 +91,19 @@
private HashMap m_webcontexts = new HashMap();
public PicoJettyJervlet(JervletConfig config, JervletMonitor monitor, MutablePicoContainer parentContainer,
- File appRootDir, RequestLogger requestLogger) throws UnknownHostException {
+ File appRootDir, RequestLogger requestLogger,
+ LogSink logSink) throws UnknownHostException {
super.config = config;
this.monitor = monitor;
this.appRootDir = appRootDir;
+ this.logSink = logSink;
this.jervletContext = new PicoJervletContext(parentContainer);
m_server = createHttpServer();
m_server.addListener( createSocketListener() );
- //TODO
- //PhoenixLogSink phoenixLogSink = new PhoenixLogSink();
- //phoenixLogSink.enableLogging( getLogger() );
- //Log.instance().add( phoenixLogSink );
+ // unsatisfactory as is static
+ Log.instance().add( logSink );
m_server.setRequestLog( new JettyRequestLogAdapter( requestLogger ) );
}
1.1 spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/AvalonLogSink.java
Index: AvalonLogSink.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
must not be used to endorse or promote products derived from this software
without prior written permission. For written permission, please contact
[email protected]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.jcomponent.jervlet.blocks.jetty;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.mortbay.util.Frame;
import org.mortbay.util.Log;
/**
* Jetty Log redirection
*
*
* @see <a href="http://jetty.mortbay.com/">Jetty Project Page</a>
*
* @author Bruno Dumon & Paul Hammant
* @version 1.0
*/
public class AvalonLogSink extends SimpleLogSink implements LogEnabled
{
private Logger logger;
public void enableLogging(Logger logger) {
this.logger = logger;
}
/**
* Log something
* @param type the type of message
* @param message the message
* @param frame the frame
* @param time the time
*/
public void log( String type, Object message, Frame frame, long time )
{
if( type.equals( Log.DEBUG ) )
{
if( getLogger().isDebugEnabled() )
getLogger().debug( "time=" + time + " message=" + message + " frame=" + frame );
}
else if( type.equals( Log.FAIL ) )
{
if( getLogger().isErrorEnabled() )
getLogger().error( "time=" + time + " message=" + message + " frame=" + frame );
}
else if( type.equals( Log.WARN ) )
{
if( getLogger().isWarnEnabled() )
getLogger().warn( "time=" + time + " message=" + message + " frame=" + frame );
}
else if( type.equals( Log.ASSERT ) )
{
if( getLogger().isInfoEnabled() )
getLogger().info( "ASSERT time=" + time + " message=" + message + " frame=" + frame );
}
else
{
getLogger().info( "time=" + time + " message=" + message + " frame=" + frame );
}
}
private Logger getLogger() {
return logger;
}
/**
* Log a message
* @param message the Message
*/
public void log( String message )
{
getLogger().info( message );
}
}
1.1 spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/CommonsLoggingLogSink.java
Index: CommonsLoggingLogSink.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 2002,2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
must not be used to endorse or promote products derived from this software
without prior written permission. For written permission, please contact
[email protected]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.jcomponent.jervlet.blocks.jetty;
import org.apache.commons.logging.LogFactory;
import org.mortbay.util.Frame;
import org.mortbay.util.Log;
/**
* Jetty Log redirection
*
*
* @see <a href="http://jetty.mortbay.com/">Jetty Project Page</a>
*
* @author Bruno Dumon & Paul Hammant
* @version 1.0
*/
public class CommonsLoggingLogSink extends SimpleLogSink
{
private org.apache.commons.logging.Log log = LogFactory.getFactory().getInstance(CommonsLoggingLogSink.class);
/**
* Log something
* @param type the type of message
* @param message the message
* @param frame the frame
* @param time the time
*/
public void log( String type, Object message, Frame frame, long time )
{
if( type.equals( Log.DEBUG ) )
{
if( log.isDebugEnabled() )
log.debug( "time=" + time + " message=" + message + " frame=" + frame );
}
else if( type.equals( Log.FAIL ) )
{
if( log.isErrorEnabled() )
log.error( "time=" + time + " message=" + message + " frame=" + frame );
}
else if( type.equals( Log.WARN ) )
{
if( log.isWarnEnabled() )
log.warn( "time=" + time + " message=" + message + " frame=" + frame );
}
else if( type.equals( Log.ASSERT ) )
{
if( log.isInfoEnabled() )
log.info( "ASSERT time=" + time + " message=" + message + " frame=" + frame );
}
else
{
log.info( "time=" + time + " message=" + message + " frame=" + frame );
}
}
/**
* Log a message
* @param message the Message
*/
public void log( String message )
{
log.info( message );
}
}
1.1 spice/sandbox/jervlet/jervlet-jetty/src/java/org/jcomponent/jervlet/blocks/jetty/SimpleLogSink.java
Index: SimpleLogSink.java
===================================================================
package org.jcomponent.jervlet.blocks.jetty;
import org.mortbay.util.LogSink;
import org.mortbay.util.Frame;
public class SimpleLogSink implements LogSink {
/**
* Stop (unimpled)
* @throws InterruptedException
*/
public void stop() throws InterruptedException
{
}
/**
* Is this started (always)
* @return
*/
public boolean isStarted()
{
return true;
}
/**
* Set Options (un implemented)
* @param s the options
*/
public void setOptions( String s )
{
}
/**
* Get Option (unimplemented)
* @return the options
*/
public String getOptions()
{
return "";
}
/**
* Start a logger (unimpled)
* @throws Exception
*/
public void start() throws Exception
{
}
public void log(String string) {
}
public void log(String string, Object object, Frame frame, long l) {
}
}
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/