forked from I2P_Developers/i2p.i2p
jetty 7 first cut
This commit is contained in:
@@ -17,13 +17,13 @@ package net.i2p.jetty;
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.log.Logger;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* Modified from Jetty 6.1.26 StdErrLog.java and Slf4jLog.java
|
||||
*
|
||||
* Usage: org.mortbay.log.Log.setLog(new I2PLogger(ctx));
|
||||
* Usage: org.eclipse.log.Log.setLog(new I2PLogger(ctx));
|
||||
*
|
||||
* @since Jetty 6
|
||||
*/
|
||||
@@ -182,5 +182,80 @@ public class I2PLogger implements Logger
|
||||
return "I2PLogger";
|
||||
}
|
||||
|
||||
/**
|
||||
* @since Jetty 7
|
||||
*/
|
||||
public void ignore(Throwable ignored)
|
||||
{
|
||||
warn("IGNORED", ignored);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since Jetty 7
|
||||
*/
|
||||
public void debug(Throwable thrown)
|
||||
{
|
||||
debug("", thrown);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since Jetty 7
|
||||
*/
|
||||
public void debug(String msg, Object... args)
|
||||
{
|
||||
Object a1 = args.length > 0 ? args[0] : null;
|
||||
Object a2 = args.length > 1 ? args[1] : null;
|
||||
debug(msg, a1, a2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since Jetty 7
|
||||
*/
|
||||
public void info(Throwable thrown)
|
||||
{
|
||||
info("", thrown);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since Jetty 7
|
||||
*/
|
||||
public void info(String msg, Object... args)
|
||||
{
|
||||
Object a1 = args.length > 0 ? args[0] : null;
|
||||
Object a2 = args.length > 1 ? args[1] : null;
|
||||
info(msg, a1, a2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since Jetty 7
|
||||
*/
|
||||
public void info(String msg, Throwable th)
|
||||
{
|
||||
_log.info(msg,th);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since Jetty 7
|
||||
*/
|
||||
public void warn(Throwable thrown)
|
||||
{
|
||||
warn("", thrown);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since Jetty 7
|
||||
*/
|
||||
public void warn(String msg, Object... args)
|
||||
{
|
||||
Object a1 = args.length > 0 ? args[0] : null;
|
||||
Object a2 = args.length > 1 ? args[1] : null;
|
||||
warn(msg, a1, a2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since Jetty 7
|
||||
*/
|
||||
public String getName() {
|
||||
return "net.i2p.jetty.I2PLogger";
|
||||
}
|
||||
}
|
||||
|
@@ -24,18 +24,18 @@ import java.util.TimeZone;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
|
||||
import org.mortbay.component.AbstractLifeCycle;
|
||||
import org.mortbay.jetty.HttpHeaders;
|
||||
import org.mortbay.jetty.Request;
|
||||
import org.mortbay.jetty.RequestLog;
|
||||
import org.mortbay.jetty.Response;
|
||||
import org.mortbay.jetty.servlet.PathMap;
|
||||
import org.mortbay.log.Log;
|
||||
import org.mortbay.util.DateCache;
|
||||
import org.mortbay.util.RolloverFileOutputStream;
|
||||
import org.mortbay.util.StringUtil;
|
||||
import org.mortbay.util.TypeUtil;
|
||||
import org.mortbay.util.Utf8StringBuffer;
|
||||
import org.eclipse.jetty.http.HttpHeaders;
|
||||
import org.eclipse.jetty.http.PathMap;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.RequestLog;
|
||||
import org.eclipse.jetty.server.Response;
|
||||
import org.eclipse.jetty.util.DateCache;
|
||||
import org.eclipse.jetty.util.RolloverFileOutputStream;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.Utf8StringBuilder;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
||||
/**
|
||||
* This {@link RequestLog} implementation outputs logs in the pseudo-standard NCSA common log format.
|
||||
@@ -56,8 +56,6 @@ import org.mortbay.util.Utf8StringBuffer;
|
||||
*
|
||||
* So that we will work with system Jetty 6 packages, we just copy the whole thing
|
||||
* and modify log() as required.
|
||||
* We leave the package as org.mortbay.http for compatibility with old
|
||||
* jetty.xml files.
|
||||
*
|
||||
* @author Greg Wilkins
|
||||
* @author Nigel Canonizado
|
||||
@@ -259,13 +257,13 @@ public class I2PRequestLog extends AbstractLifeCycle implements RequestLog
|
||||
if (_fileOut == null)
|
||||
return;
|
||||
|
||||
Utf8StringBuffer u8buf;
|
||||
StringBuffer buf;
|
||||
Utf8StringBuilder u8buf;
|
||||
StringBuilder buf;
|
||||
synchronized(_writer)
|
||||
{
|
||||
int size=_buffers.size();
|
||||
u8buf = size==0?new Utf8StringBuffer(160):(Utf8StringBuffer)_buffers.remove(size-1);
|
||||
buf = u8buf.getStringBuffer();
|
||||
u8buf = size==0?new Utf8StringBuilder(160):(Utf8StringBuilder)_buffers.remove(size-1);
|
||||
buf = u8buf.getStringBuilder();
|
||||
}
|
||||
|
||||
synchronized(buf) // for efficiency until we can use StringBuilder
|
||||
@@ -398,7 +396,7 @@ public class I2PRequestLog extends AbstractLifeCycle implements RequestLog
|
||||
if (_logLatency)
|
||||
{
|
||||
_writer.write(' ');
|
||||
_writer.write(TypeUtil.toString(System.currentTimeMillis() - request.getTimeStamp()));
|
||||
_writer.write(Long.toString(System.currentTimeMillis() - request.getTimeStamp()));
|
||||
}
|
||||
|
||||
_writer.write(StringUtil.__LINE_SEPARATOR);
|
||||
|
@@ -19,15 +19,16 @@ package net.i2p.jetty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.app.*;
|
||||
import static net.i2p.app.ClientAppState.*;
|
||||
|
||||
import org.mortbay.component.LifeCycle;
|
||||
import org.mortbay.resource.Resource;
|
||||
import org.mortbay.xml.XmlConfiguration;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
/**
|
||||
* Start Jetty where the args are one or more XML files.
|
||||
@@ -73,8 +74,11 @@ public class JettyStart implements ClientApp {
|
||||
XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(args[i]).getURL());
|
||||
if (last!=null)
|
||||
configuration.getIdMap().putAll(last.getIdMap());
|
||||
if (properties.size()>0)
|
||||
configuration.setProperties(properties);
|
||||
if (properties.size()>0) {
|
||||
// to avoid compiler errror
|
||||
Map foo = configuration.getProperties();
|
||||
foo.putAll(properties);
|
||||
}
|
||||
Object o = configuration.configure();
|
||||
if (o instanceof LifeCycle)
|
||||
_jettys.add((LifeCycle)o);
|
||||
|
Reference in New Issue
Block a user