Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lbaccess 12 #6

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
import ch.qos.logback.access.pattern.ResponseHeaderConverter;
import ch.qos.logback.access.pattern.ServerNameConverter;
import ch.qos.logback.access.pattern.StatusCodeConverter;
import ch.qos.logback.access.spi.AccessEvent;
import ch.qos.logback.access.spi.IAccessEvent;
import ch.qos.logback.core.pattern.PatternLayoutBase;
import ch.qos.logback.core.pattern.parser.Parser;

/**
* <p>
* This class is a module-specific implementation of
* {@link ch.qos.logback.classic.PatternLayout} to allow http-specific patterns
* {@link ch.qos.logback.access.PatternLayout} to allow http-specific patterns
* to be used. The <code>ch.qos.logback.access.PatternLayout</code> provides a
* way to format the logging output that is just as easy and flexible as the
* usual <code>PatternLayout</code>.
Expand All @@ -60,7 +60,7 @@
* @author Ceki G&uuml;lc&uuml;
* @author S&eacute;bastien Pennec
*/
public class PatternLayout extends PatternLayoutBase<AccessEvent> {
public class PatternLayout extends PatternLayoutBase<IAccessEvent> {

public static final Map<String, String> defaultConverterMap = new HashMap<String, String>();

Expand Down Expand Up @@ -167,7 +167,7 @@ public Map<String, String> getDefaultConverterMap() {
return defaultConverterMap;
}

public String doLayout(AccessEvent event) {
public String doLayout(IAccessEvent event) {
if (!isStarted()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package ch.qos.logback.access;

import ch.qos.logback.access.spi.AccessEvent;
import ch.qos.logback.access.spi.IAccessEvent;
import ch.qos.logback.core.pattern.PatternLayoutEncoderBase;


public class PatternLayoutEncoder extends PatternLayoutEncoderBase<AccessEvent> {
public class PatternLayoutEncoder extends PatternLayoutEncoderBase<IAccessEvent> {

@Override
public void start() {
Expand All @@ -16,4 +16,4 @@ public void start() {
super.start();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
import java.util.ArrayList;
import java.util.List;

import ch.qos.logback.access.spi.AccessEvent;
import ch.qos.logback.access.spi.IAccessEvent;
import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.boolex.JaninoEventEvaluatorBase;
import ch.qos.logback.core.boolex.Matcher;

public class JaninoEventEvaluator extends JaninoEventEvaluatorBase<AccessEvent> {
public class JaninoEventEvaluator extends JaninoEventEvaluatorBase<IAccessEvent> {

public final static List<String> DEFAULT_PARAM_NAME_LIST = new ArrayList<String>();
public final static List<Class> DEFAULT_PARAM_TYPE_LIST = new ArrayList<Class>();

static {
DEFAULT_PARAM_NAME_LIST.add("event");
DEFAULT_PARAM_TYPE_LIST.add(AccessEvent.class);
DEFAULT_PARAM_TYPE_LIST.add(IAccessEvent.class);
}


Expand Down Expand Up @@ -67,8 +67,7 @@ protected Class[] getParameterTypes() {
return (Class[]) fullTypeList.toArray(CoreConstants.EMPTY_CLASS_ARRAY);
}

protected Object[] getParameterValues(AccessEvent event) {
AccessEvent accessEvent = (AccessEvent) event;
protected Object[] getParameterValues(IAccessEvent accessEvent) {
final int matcherListSize = matcherList.size();

int i = 0;
Expand All @@ -77,7 +76,7 @@ protected Object[] getParameterValues(AccessEvent event) {
values[i++] = accessEvent;

for (int j = 0; j < matcherListSize; j++) {
values[i++] = (Matcher) matcherList.get(j);
values[i++] = matcherList.get(j);
}

return values;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.sql.SQLException;
import java.util.Enumeration;

import ch.qos.logback.access.spi.AccessEvent;
import ch.qos.logback.access.spi.IAccessEvent;
import ch.qos.logback.core.db.DBAppenderBase;

/**
Expand All @@ -33,7 +33,7 @@
* @author Ray DeCampo
* @author S&eacute;bastien Pennec
*/
public class DBAppender extends DBAppenderBase<AccessEvent> {
public class DBAppender extends DBAppenderBase<IAccessEvent> {
protected static final String insertSQL;
protected final String insertHeaderSQL = "INSERT INTO access_event_header (event_id, header_key, header_value) VALUES (?, ?, ?)";
protected static final Method GET_GENERATED_KEYS_METHOD;
Expand Down Expand Up @@ -70,7 +70,7 @@ public DBAppender() {
}

@Override
protected void subAppend(AccessEvent event, Connection connection,
protected void subAppend(IAccessEvent event, Connection connection,
PreparedStatement insertStatement) throws Throwable {

addAccessEvent(insertStatement, event);
Expand All @@ -81,14 +81,14 @@ protected void subAppend(AccessEvent event, Connection connection,
}
}

protected void secondarySubAppend(AccessEvent event, Connection connection,
protected void secondarySubAppend(IAccessEvent event, Connection connection,
long eventId) throws Throwable {
if (insertHeaders) {
addRequestHeaders(event, connection, eventId);
}
}

void addAccessEvent(PreparedStatement stmt, AccessEvent event)
void addAccessEvent(PreparedStatement stmt, IAccessEvent event)
throws SQLException {
stmt.setLong(1, event.getTimeStamp());
stmt.setString(2, event.getRequestURI());
Expand All @@ -102,7 +102,7 @@ void addAccessEvent(PreparedStatement stmt, AccessEvent event)
stmt.setString(10, event.getRequestContent());
}

void addRequestHeaders(AccessEvent event,
void addRequestHeaders(IAccessEvent event,
Connection connection, long eventId) throws SQLException {
Enumeration names = event.getRequestHeaderNames();
if (names.hasMoreElements()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.Map;

import ch.qos.logback.access.PatternLayout;
import ch.qos.logback.access.spi.AccessEvent;
import ch.qos.logback.access.spi.IAccessEvent;
import ch.qos.logback.core.html.HTMLLayoutBase;
import ch.qos.logback.core.pattern.Converter;

Expand All @@ -37,7 +37,7 @@
* @author Ceki G&uuml;lc&uuml;
* @author S&eacute;bastien Pennec
*/
public class HTMLLayout extends HTMLLayoutBase<AccessEvent> {
public class HTMLLayout extends HTMLLayoutBase<IAccessEvent> {

/**
* Default pattern string for log output.
Expand All @@ -58,7 +58,7 @@ protected Map<String, String> getDefaultConverterMap() {
return PatternLayout.defaultConverterMap;
}

public String doLayout(AccessEvent event) {
public String doLayout(IAccessEvent event) {
StringBuilder buf = new StringBuilder();
startNewTableIfLimitReached(buf);

Expand All @@ -76,7 +76,7 @@ public String doLayout(AccessEvent event) {
}
buf.append(LINE_SEPARATOR);

Converter<AccessEvent> c = head;
Converter<IAccessEvent> c = head;
while (c != null) {
appendEventToBuffer(buf, c, event);
c = c.getNext();
Expand All @@ -87,8 +87,8 @@ public String doLayout(AccessEvent event) {
return buf.toString();
}

private void appendEventToBuffer(StringBuilder buf, Converter<AccessEvent> c,
AccessEvent event) {
private void appendEventToBuffer(StringBuilder buf, Converter<IAccessEvent> c,
IAccessEvent event) {
buf.append("<td class=\"");
buf.append(computeConverterName(c));
buf.append("\">");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import ch.qos.logback.access.joran.JoranConfigurator;
import ch.qos.logback.access.spi.AccessEvent;
import ch.qos.logback.access.spi.IAccessEvent;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.CoreConstants;
Expand Down Expand Up @@ -108,13 +109,13 @@
* @author S&eacute;bastien Pennec
*/
public class RequestLogImpl extends ContextBase implements RequestLog,
AppenderAttachable<AccessEvent>, FilterAttachable<AccessEvent> {
AppenderAttachable<IAccessEvent>, FilterAttachable<IAccessEvent> {

public final static String DEFAULT_CONFIG_FILE = "etc" + File.separatorChar
+ "logback-access.xml";

AppenderAttachableImpl<AccessEvent> aai = new AppenderAttachableImpl<AccessEvent>();
FilterAttachableImpl<AccessEvent> fai = new FilterAttachableImpl<AccessEvent>();
AppenderAttachableImpl<IAccessEvent> aai = new AppenderAttachableImpl<IAccessEvent>();
FilterAttachableImpl<IAccessEvent> fai = new FilterAttachableImpl<IAccessEvent>();
String filename;
boolean started = false;

Expand All @@ -125,7 +126,7 @@ public RequestLogImpl() {
public void log(Request jettyRequest, Response jettyResponse) {
JettyServerAdapter adapter = new JettyServerAdapter(jettyRequest,
jettyResponse);
AccessEvent accessEvent = new AccessEvent(jettyRequest, jettyResponse,
IAccessEvent accessEvent = new AccessEvent(jettyRequest, jettyResponse,
adapter);
if (getFilterChainDecision(accessEvent) == FilterReply.DENY) {
return;
Expand Down Expand Up @@ -203,19 +204,19 @@ public boolean isFailed() {
return false;
}

public void addAppender(Appender<AccessEvent> newAppender) {
public void addAppender(Appender<IAccessEvent> newAppender) {
aai.addAppender(newAppender);
}

public Iterator<Appender<AccessEvent>> iteratorForAppenders() {
public Iterator<Appender<IAccessEvent>> iteratorForAppenders() {
return aai.iteratorForAppenders();
}

public Appender<AccessEvent> getAppender(String name) {
public Appender<IAccessEvent> getAppender(String name) {
return aai.getAppender(name);
}

public boolean isAttached(Appender<AccessEvent> appender) {
public boolean isAttached(Appender<IAccessEvent> appender) {
return aai.isAttached(appender);
}

Expand All @@ -224,27 +225,27 @@ public void detachAndStopAllAppenders() {

}

public boolean detachAppender(Appender<AccessEvent> appender) {
public boolean detachAppender(Appender<IAccessEvent> appender) {
return aai.detachAppender(appender);
}

public boolean detachAppender(String name) {
return aai.detachAppender(name);
}

public void addFilter(Filter<AccessEvent> newFilter) {
public void addFilter(Filter<IAccessEvent> newFilter) {
fai.addFilter(newFilter);
}

public void clearAllFilters() {
fai.clearAllFilters();
}

public List<Filter<AccessEvent>> getCopyOfAttachedFiltersList() {
public List<Filter<IAccessEvent>> getCopyOfAttachedFiltersList() {
return fai.getCopyOfAttachedFiltersList();
}

public FilterReply getFilterChainDecision(AccessEvent event) {
public FilterReply getFilterChainDecision(IAccessEvent event) {
return fai.getFilterChainDecision(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import ch.qos.logback.access.joran.JoranConfigurator;
import ch.qos.logback.access.spi.AccessEvent;
import ch.qos.logback.access.spi.IAccessEvent;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.CoreConstants;
Expand Down Expand Up @@ -107,12 +108,12 @@
* @author S&eacute;bastien Pennec
*/
public class RequestLogImpl extends ContextBase implements RequestLog,
AppenderAttachable<AccessEvent>, FilterAttachable<AccessEvent> {
AppenderAttachable<IAccessEvent>, FilterAttachable<IAccessEvent> {

public final static String DEFAULT_CONFIG_FILE = "etc" + File.separatorChar + "logback-access.xml";

AppenderAttachableImpl<AccessEvent> aai = new AppenderAttachableImpl<AccessEvent>();
FilterAttachableImpl<AccessEvent> fai = new FilterAttachableImpl<AccessEvent>();
AppenderAttachableImpl<IAccessEvent> aai = new AppenderAttachableImpl<IAccessEvent>();
FilterAttachableImpl<IAccessEvent> fai = new FilterAttachableImpl<IAccessEvent>();
String filename;
boolean started = false;

Expand All @@ -122,7 +123,7 @@ public RequestLogImpl() {

public void log(Request jettyRequest, Response jettyResponse) {
JettyServerAdapter adapter = new JettyServerAdapter(jettyRequest, jettyResponse);
AccessEvent accessEvent = new AccessEvent(jettyRequest, jettyResponse, adapter);
IAccessEvent accessEvent = new AccessEvent(jettyRequest, jettyResponse, adapter);
if (getFilterChainDecision(accessEvent) == FilterReply.DENY) {
return;
}
Expand Down Expand Up @@ -205,19 +206,19 @@ public void removeLifeCycleListener(Listener listener) {
//no support for listeners yet
}

public void addAppender(Appender<AccessEvent> newAppender) {
public void addAppender(Appender<IAccessEvent> newAppender) {
aai.addAppender(newAppender);
}

public Iterator<Appender<AccessEvent>> iteratorForAppenders() {
public Iterator<Appender<IAccessEvent>> iteratorForAppenders() {
return aai.iteratorForAppenders();
}

public Appender<AccessEvent> getAppender(String name) {
public Appender<IAccessEvent> getAppender(String name) {
return aai.getAppender(name);
}

public boolean isAttached(Appender<AccessEvent> appender) {
public boolean isAttached(Appender<IAccessEvent> appender) {
return aai.isAttached(appender);
}

Expand All @@ -226,27 +227,27 @@ public void detachAndStopAllAppenders() {

}

public boolean detachAppender(Appender<AccessEvent> appender) {
public boolean detachAppender(Appender<IAccessEvent> appender) {
return aai.detachAppender(appender);
}

public boolean detachAppender(String name) {
return aai.detachAppender(name);
}

public void addFilter(Filter<AccessEvent> newFilter) {
public void addFilter(Filter<IAccessEvent> newFilter) {
fai.addFilter(newFilter);
}

public void clearAllFilters() {
fai.clearAllFilters();
}

public List<Filter<AccessEvent>> getCopyOfAttachedFiltersList() {
public List<Filter<IAccessEvent>> getCopyOfAttachedFiltersList() {
return fai.getCopyOfAttachedFiltersList();
}

public FilterReply getFilterChainDecision(AccessEvent event) {
public FilterReply getFilterChainDecision(IAccessEvent event) {
return fai.getFilterChainDecision(event);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
import java.io.Serializable;

import ch.qos.logback.access.spi.AccessEvent;
import ch.qos.logback.access.spi.IAccessEvent;
import ch.qos.logback.core.spi.PreSerializationTransformer;

public class AccessEventPreSerializationTransformer implements
PreSerializationTransformer<AccessEvent> {
PreSerializationTransformer<IAccessEvent> {

public Serializable transform(AccessEvent event) {
return event;
public Serializable transform(IAccessEvent event) {
if (event instanceof AccessEvent) {
return (AccessEvent)event;
} else {
throw new IllegalArgumentException("Unsupported type "+event.getClass().getName());
}
}

}
Loading