Author: rdonkin
Date: Thu Sep 17 09:00:18 2009
New Revision: 816101
URL: http://svn.apache.org/viewvc?rev=816101&view=rev
Log:
JAMES-921 Switch handlers to use commons logging through the LogEnabled
interface https://issues.apache.org/jira/browse/JAMES-921
Added:
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/LogEnabled.java
(with props)
Modified:
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandlerChain.java
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SMTPCommandDispatcherLineHandler.java
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/URIRBLHandler.java
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java
Added:
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/LogEnabled.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/LogEnabled.java?rev=816101&view=auto
==============================================================================
---
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/LogEnabled.java
(added)
+++
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/LogEnabled.java
Thu Sep 17 09:00:18 2009
@@ -0,0 +1,37 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.socket;
+
+import org.apache.commons.logging.Log;
+
+/**
+ * Indicates that a services requires general logging.
+ * Note that this log should only be used for general service operations.
+ * A context sensitive log should be preferred where that is available
+ * within the context of a call.
+ */
+public interface LogEnabled {
+
+ /**
+ * Sets the service log.
+ * @param log not null
+ */
+ public void setLog(Log log);
+}
Propchange:
james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/LogEnabled.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandlerChain.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandlerChain.java?rev=816101&r1=816100&r2=816101&view=diff
==============================================================================
---
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandlerChain.java
(original)
+++
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandlerChain.java
Thu Sep 17 09:00:18 2009
@@ -38,16 +38,26 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.james.api.kernel.LoaderService;
import org.apache.james.smtpserver.core.CoreCmdHandlerLoader;
import org.apache.james.smtpserver.core.CoreMessageHookLoader;
+import org.apache.james.smtpserver.core.DataLineMessageHookHandler;
+import org.apache.james.socket.LogEnabled;
/**
* The SMTPHandlerChain is per service object providing access
* ConnectHandlers, Commandhandlers and message handlers
*/
-public class SMTPHandlerChain extends AbstractLogEnabled implements
Configurable, Serviceable {
+public class SMTPHandlerChain implements Configurable, Serviceable {
+ /** This log is the fall back shared by all instances */
+ private static final Log FALLBACK_LOG =
LogFactory.getLog(DataLineMessageHookHandler.class);
+
+ /** Non context specific log should only be used when no context specific
log is available */
+ private Log log = FALLBACK_LOG;
+
/** Configuration for this chain */
private Configuration configuration;
private JamesConfiguration commonsConf;
@@ -60,6 +70,15 @@
private LoaderService loader;
/**
+ * Sets the service log.
+ * Where available, a context sensitive log should be used.
+ * @param Log not null
+ */
+ public void setLog(Log log) {
+ this.log = log;
+ }
+
+ /**
* Gets the current instance loader.
* @return the loader
*/
@@ -202,7 +221,9 @@
Object handler = loader.load(handlerClass);
// enable logging
- ContainerUtil.enableLogging(handler, getLogger());
+ if (handler instanceof LogEnabled) {
+ ((LogEnabled) handler).setLog(log);
+ }
// servicing the handler
ContainerUtil.service(handler, serviceManager);
@@ -232,8 +253,8 @@
}
- if (getLogger().isInfoEnabled()) {
- getLogger().info("Added Handler: " + className);
+ if (log.isInfoEnabled()) {
+ log.info("Added Handler: " + className);
}
// fill the big handler table
Modified:
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java?rev=816101&r1=816100&r2=816101&view=diff
==============================================================================
---
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
(original)
+++
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
Thu Sep 17 09:00:18 2009
@@ -28,6 +28,7 @@
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.commons.logging.impl.AvalonLogger;
import org.apache.james.Constants;
import org.apache.james.api.dnsservice.DNSService;
import org.apache.james.api.dnsservice.util.NetMatcher;
@@ -246,7 +247,7 @@
handlerChain = loader.load(SMTPHandlerChain.class);
//set the logger
- ContainerUtil.enableLogging(handlerChain,getLogger());
+ handlerChain.setLog(new AvalonLogger(getLogger()));
ContainerUtil.service(handlerChain,serviceManager);
Modified:
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java?rev=816101&r1=816100&r2=816101&view=diff
==============================================================================
---
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
(original)
+++
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
Thu Sep 17 09:00:18 2009
@@ -30,7 +30,8 @@
import javax.mail.MessagingException;
import org.apache.avalon.framework.container.ContainerUtil;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.james.core.MailImpl;
import org.apache.james.core.MimeMessageCopyOnWriteProxy;
import org.apache.james.core.MimeMessageInputStreamSource;
@@ -45,11 +46,18 @@
import org.apache.james.smtpserver.hook.HookResult;
import org.apache.james.smtpserver.hook.HookResultHook;
import org.apache.james.smtpserver.hook.MessageHook;
+import org.apache.james.socket.LogEnabled;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
-public final class DataLineMessageHookHandler extends AbstractLogEnabled
implements DataLineFilter, ExtensibleHandler {
+public final class DataLineMessageHookHandler implements DataLineFilter,
ExtensibleHandler, LogEnabled {
+ /** This log is the fall back shared by all instances */
+ private static final Log FALLBACK_LOG =
LogFactory.getLog(DataLineMessageHookHandler.class);
+
+ /** Non context specific log should only be used when no context specific
log is available */
+ private Log serviceLog = FALLBACK_LOG;
+
private List messageHandlers;
private List rHooks;
@@ -183,8 +191,8 @@
if (MessageHook.class.equals(interfaceName)) {
this.messageHandlers = extension;
if (messageHandlers.size() == 0) {
- if (getLogger().isErrorEnabled()) {
- getLogger().error(
+ if (serviceLog.isErrorEnabled()) {
+ serviceLog.error(
"No messageHandler configured. Check that
SendMailHandler is configured in the SMTPHandlerChain");
}
throw new WiringException("No messageHandler configured");
@@ -204,4 +212,12 @@
return classes;
}
+ /**
+ * Sets the service log.
+ * Where available, a context sensitive log should be used.
+ * @param Log not null
+ */
+ public void setLog(Log log) {
+ this.serviceLog = log;
+ }
}
\ No newline at end of file
Modified:
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SMTPCommandDispatcherLineHandler.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SMTPCommandDispatcherLineHandler.java?rev=816101&r1=816100&r2=816101&view=diff
==============================================================================
---
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SMTPCommandDispatcherLineHandler.java
(original)
+++
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SMTPCommandDispatcherLineHandler.java
Thu Sep 17 09:00:18 2009
@@ -28,7 +28,8 @@
import java.util.List;
import java.util.Locale;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.james.smtpserver.CommandHandler;
import org.apache.james.smtpserver.ExtensibleHandler;
import org.apache.james.smtpserver.LineHandler;
@@ -36,9 +37,16 @@
import org.apache.james.smtpserver.SMTPRetCode;
import org.apache.james.smtpserver.SMTPSession;
import org.apache.james.smtpserver.WiringException;
+import org.apache.james.socket.LogEnabled;
-public class SMTPCommandDispatcherLineHandler extends AbstractLogEnabled
implements LineHandler, ExtensibleHandler {
+public class SMTPCommandDispatcherLineHandler implements LogEnabled,
LineHandler, ExtensibleHandler {
+ /** This log is the fall back shared by all instances */
+ private static final Log FALLBACK_LOG =
LogFactory.getLog(SMTPCommandDispatcherLineHandler.class);
+
+ /** Non context specific log should only be used when no context specific
log is available */
+ private Log serviceLog = FALLBACK_LOG;
+
/**
* The list of available command handlers
*/
@@ -124,8 +132,8 @@
for (Iterator i = implCmds.iterator(); i.hasNext(); ) {
String commandName = ((String)
i.next()).trim().toUpperCase(Locale.US);
- if (getLogger().isInfoEnabled()) {
- getLogger().info(
+ if (serviceLog.isInfoEnabled()) {
+ serviceLog.info(
"Added Commandhandler: " + handler.getClass() + "
for command "+commandName);
}
addToMap(commandName, (CommandHandler) handler);
@@ -135,16 +143,16 @@
addToMap(UnknownCmdHandler.UNKNOWN_COMMAND, unknownHandler);
if (commandHandlerMap.size() < 2) {
- if (getLogger().isErrorEnabled()) {
- getLogger().error("No commandhandlers configured");
+ if (serviceLog.isErrorEnabled()) {
+ serviceLog.error("No commandhandlers configured");
}
throw new WiringException("No commandhandlers configured");
} else {
boolean found = true;
for (int i = 0; i < mandatoryCommands.length; i++) {
if (!commandHandlerMap.containsKey(mandatoryCommands[i])) {
- if (getLogger().isErrorEnabled()) {
- getLogger().error(
+ if (serviceLog.isErrorEnabled()) {
+ serviceLog.error(
"No commandhandlers configured for the
command:"
+ mandatoryCommands[i]);
}
@@ -202,4 +210,12 @@
return handlers;
}
+ /**
+ * Sets the service log.
+ * Where available, a context sensitive log should be used.
+ * @param Log not null
+ */
+ public void setLog(Log log) {
+ this.serviceLog = log;
+ }
}
Modified:
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java?rev=816101&r1=816100&r2=816101&view=diff
==============================================================================
---
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java
(original)
+++
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java
Thu Sep 17 09:00:18 2009
@@ -28,9 +28,10 @@
import javax.annotation.Resource;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.james.api.dnsservice.DNSService;
import org.apache.james.dsn.DSNStatus;
import org.apache.james.smtpserver.Configurable;
@@ -39,14 +40,20 @@
import org.apache.james.smtpserver.hook.HookResult;
import org.apache.james.smtpserver.hook.HookReturnCode;
import org.apache.james.smtpserver.hook.RcptHook;
+import org.apache.james.socket.LogEnabled;
import org.apache.mailet.MailAddress;
/**
* Connect handler for DNSRBL processing
*/
-public class DNSRBLHandler
- extends AbstractLogEnabled
- implements ConnectHandler, RcptHook, Configurable {
+public class DNSRBLHandler implements LogEnabled, ConnectHandler, RcptHook,
Configurable {
+
+ /** This log is the fall back shared by all instances */
+ private static final Log FALLBACK_LOG =
LogFactory.getLog(DNSRBLHandler.class);
+
+ /** Non context specific log should only be used when no context specific
log is available */
+ private Log serviceLog = FALLBACK_LOG;
+
/**
* The lists of rbl servers to be checked to limit spam
*/
@@ -63,6 +70,16 @@
public static final String RBL_DETAIL_MAIL_ATTRIBUTE_NAME =
"org.apache.james.smtpserver.rbl.detail";
+
+ /**
+ * Sets the service log.
+ * Where available, a context sensitive log should be used.
+ * @param Log not null
+ */
+ public void setLog(Log log) {
+ this.serviceLog = log;
+ }
+
/**
* Gets the DNS service.
* @return the dnsService
@@ -90,8 +107,8 @@
for ( int i = 0 ; i < whiteList.size() ; i++ ) {
String rblServerName = whiteList.get(i);
rblserverCollection.add(rblServerName);
- if (getLogger().isInfoEnabled()) {
- getLogger().info("Adding RBL server to whitelist: " +
rblServerName);
+ if (serviceLog.isInfoEnabled()) {
+ serviceLog.info("Adding RBL server to whitelist: " +
rblServerName);
}
}
if (rblserverCollection != null && rblserverCollection.size() > 0)
{
@@ -106,8 +123,8 @@
for ( int i = 0 ; i < blackList.size() ; i++ ) {
String rblServerName = blackList.get(i);
rblserverCollection.add(rblServerName);
- if (getLogger().isInfoEnabled()) {
- getLogger().info("Adding RBL server to blacklist: " +
rblServerName);
+ if (serviceLog.isInfoEnabled()) {
+ serviceLog.info("Adding RBL server to blacklist: " +
rblServerName);
}
}
if (rblserverCollection != null && rblserverCollection.size() > 0)
{
Modified:
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java?rev=816101&r1=816100&r2=816101&view=diff
==============================================================================
---
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java
(original)
+++
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java
Thu Sep 17 09:00:18 2009
@@ -37,10 +37,11 @@
import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
import org.apache.avalon.excalibur.datasource.DataSourceComponent;
import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.james.api.dnsservice.DNSService;
import org.apache.james.api.dnsservice.util.NetMatcher;
import org.apache.james.dsn.DSNStatus;
@@ -51,6 +52,7 @@
import org.apache.james.smtpserver.hook.HookResult;
import org.apache.james.smtpserver.hook.HookReturnCode;
import org.apache.james.smtpserver.hook.RcptHook;
+import org.apache.james.socket.LogEnabled;
import org.apache.james.util.TimeConverter;
import org.apache.james.util.sql.JDBCUtil;
import org.apache.james.util.sql.SqlResources;
@@ -59,8 +61,13 @@
/**
* GreylistHandler which can be used to activate Greylisting
*/
-public class GreylistHandler extends AbstractLogEnabled implements
- RcptHook, Configurable, Initializable {
+public class GreylistHandler implements LogEnabled, RcptHook, Configurable,
Initializable {
+
+ /** This log is the fall back shared by all instances */
+ private static final Log FALLBACK_LOG =
LogFactory.getLog(GreylistHandler.class);
+
+ /** Non context specific log should only be used when no context specific
log is available */
+ private Log serviceLog = FALLBACK_LOG;
private DataSourceSelector datasources = null;
@@ -100,7 +107,7 @@
/**
* Holds value of property sqlParameters.
*/
- private Map sqlParameters = new HashMap();
+ private Map<String, String> sqlParameters = new HashMap<String, String>();
/**
* The repositoryPath
@@ -111,7 +118,15 @@
private NetMatcher wNetworks;
-
+
+ /**
+ * Sets the service log.
+ * Where available, a context sensitive log should be used.
+ * @param Log not null
+ */
+ public void setLog(Log log) {
+ this.serviceLog = log;
+ }
/**
* Gets the file system service.
@@ -226,7 +241,7 @@
if (nets != null) {
wNetworks = new NetMatcher(nets,dnsService);
- getLogger().info("Whitelisted addresses: " +
wNetworks.toString());
+ serviceLog.info("Whitelisted addresses: " +
wNetworks.toString());
}
}
}
@@ -553,7 +568,7 @@
*/
private final JDBCUtil theJDBCUtil = new JDBCUtil() {
protected void delegatedLog(String logString) {
- getLogger().debug("JDBCVirtualUserTable: " + logString);
+ serviceLog.debug("JDBCVirtualUserTable: " + logString);
}
};
@@ -578,7 +593,7 @@
sqlFile = fileSystem.getFile(sqlFileUrl);
sqlFileUrl = null;
} catch (Exception e) {
- getLogger().fatalError(e.getMessage(), e);
+ serviceLog.fatal(e.getMessage(), e);
throw e;
}
@@ -624,11 +639,11 @@
createStatement =
conn.prepareStatement(sqlQueries.getSqlString(createSqlStringName, true));
createStatement.execute();
- StringBuffer logBuffer = null;
- logBuffer = new StringBuffer(64).append("Created table
'").append(tableName)
+ StringBuilder logBuffer = null;
+ logBuffer = new StringBuilder(64).append("Created table
'").append(tableName)
.append("' using sqlResources string '")
.append(createSqlStringName).append("'.");
- getLogger().info(logBuffer.toString());
+ serviceLog.info(logBuffer.toString());
} finally {
theJDBCUtil.closeJDBCStatement(createStatement);
Modified:
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java?rev=816101&r1=816100&r2=816101&view=diff
==============================================================================
---
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java
(original)
+++
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java
Thu Sep 17 09:00:18 2009
@@ -22,9 +22,10 @@
package org.apache.james.smtpserver.core.filter.fastfail;
import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.james.dsn.DSNStatus;
import org.apache.james.jspf.core.DNSService;
import org.apache.james.jspf.core.exceptions.SPFErrorConstants;
@@ -39,6 +40,7 @@
import org.apache.james.smtpserver.hook.MailHook;
import org.apache.james.smtpserver.hook.MessageHook;
import org.apache.james.smtpserver.hook.RcptHook;
+import org.apache.james.socket.LogEnabled;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
@@ -54,8 +56,13 @@
* <checkAuthNetworks>false</checkAuthNetworks>
* </handler>
*/
-public class SPFHandler extends AbstractLogEnabled implements MailHook,
RcptHook,
- MessageHook,Initializable, Configurable {
+public class SPFHandler implements LogEnabled, MailHook, RcptHook,
MessageHook,Initializable, Configurable {
+
+ /** This log is the fall back shared by all instances */
+ private static final Log FALLBACK_LOG =
LogFactory.getLog(SPFHandler.class);
+
+ /** Non context specific log should only be used when no context specific
log is available */
+ private Log serviceLog = FALLBACK_LOG;
public static final String SPF_BLOCKLISTED = "SPF_BLOCKLISTED";
@@ -81,6 +88,14 @@
private SPF spf;
+ /**
+ * Sets the service log.
+ * Where available, a context sensitive log should be used.
+ * @param Log not null
+ */
+ public void setLog(Log log) {
+ this.serviceLog = log;
+ }
/**
* @see
org.apache.james.smtpserver.Configurable#configure(org.apache.commons.configuration.Configuration)
@@ -98,9 +113,9 @@
*/
public void initialize() throws Exception {
if (dnsService == null) {
- spf = new DefaultSPF(new SPFLogger(getLogger()));
+ spf = new DefaultSPF(new SPFLogger());
} else {
- spf = new SPF(dnsService, new SPFLogger(getLogger()));
+ spf = new SPF(dnsService, new SPFLogger());
}
}
@@ -226,11 +241,9 @@
+ "Temporarily rejected: Problem on SPF lookup");
}
}
- return new HookResult(HookReturnCode.DECLINED);
-
+ return new HookResult(HookReturnCode.DECLINED);
}
-
/**
* @see
org.apache.james.smtpserver.hook.MailHook#doMail(org.apache.james.smtpserver.SMTPSession,
org.apache.mailet.MailAddress)
*/
@@ -240,132 +253,121 @@
}
/**
- * Inner class to provide a wrapper for loggin to avalon
+ * Adapts service log.
*/
- class SPFLogger implements org.apache.james.jspf.core.Logger {
-
- /**
- * Avalon Logger
- */
- org.apache.avalon.framework.logger.Logger logger;
-
- SPFLogger(org.apache.avalon.framework.logger.Logger logger) {
- this.logger = logger;
- }
-
+ private final class SPFLogger implements org.apache.james.jspf.core.Logger
{
/**
* @see org.apache.james.jspf.core.Logger#debug(String)
*/
- public void debug(String arg0) {
- logger.debug(arg0);
+ public void debug(String message) {
+ serviceLog.debug(message);
}
/**
* @see org.apache.james.jspf.core.Logger#debug(String, Throwable)
*/
- public void debug(String arg0, Throwable arg1) {
- logger.debug(arg0, arg1);
+ public void debug(String message, Throwable t) {
+ serviceLog.debug(message, t);
}
/**
* @see org.apache.james.jspf.core.Logger#error(String)
*/
- public void error(String arg0) {
- logger.error(arg0);
+ public void error(String message) {
+ serviceLog.error(message);
}
/**
* @see org.apache.james.jspf.core.Logger#error(String, Throwable)
*/
- public void error(String arg0, Throwable arg1) {
- logger.error(arg0, arg1);
+ public void error(String message, Throwable t) {
+ serviceLog.error(message, t);
}
/**
* @see org.apache.james.jspf.core.Logger#fatalError(String)
*/
- public void fatalError(String arg0) {
- logger.fatalError(arg0);
+ public void fatalError(String message) {
+ serviceLog.fatal(message);
}
/**
* @see org.apache.james.jspf.core.Logger#fatalError(String, Throwable)
*/
- public void fatalError(String arg0, Throwable arg1) {
- logger.fatalError(arg0, arg1);
+ public void fatalError(String message, Throwable t) {
+ serviceLog.fatal(message, t);
}
/**
* @see org.apache.james.jspf.core.Logger#info(String)
*/
- public void info(String arg0) {
- logger.info(arg0);
+ public void info(String message) {
+ serviceLog.info(message);
}
/**
* @see org.apache.james.jspf.core.Logger#info(String, Throwable)
*/
- public void info(String arg0, Throwable arg1) {
- logger.info(arg0, arg1);
+ public void info(String message, Throwable t) {
+ serviceLog.info(message, t);
}
/**
* @see org.apache.james.jspf.core.Logger#isDebugEnabled()
*/
public boolean isDebugEnabled() {
- return logger.isDebugEnabled();
+ return serviceLog.isDebugEnabled();
}
/**
* @see org.apache.james.jspf.core.Logger#isErrorEnabled()
*/
public boolean isErrorEnabled() {
- return logger.isErrorEnabled();
+ return serviceLog.isErrorEnabled();
}
/**
* @see org.apache.james.jspf.core.Logger#isFatalErrorEnabled()
*/
public boolean isFatalErrorEnabled() {
- return logger.isFatalErrorEnabled();
+ return serviceLog.isErrorEnabled();
}
/**
* @see org.apache.james.jspf.core.Logger#isInfoEnabled()
*/
public boolean isInfoEnabled() {
- return logger.isInfoEnabled();
+ return serviceLog.isInfoEnabled();
}
/**
* @see org.apache.james.jspf.core.Logger#isWarnEnabled()
*/
public boolean isWarnEnabled() {
- return logger.isWarnEnabled();
+ return serviceLog.isWarnEnabled();
}
/**
* @see org.apache.james.jspf.core.Logger#warn(String)
*/
- public void warn(String arg0) {
- logger.warn(arg0);
+ public void warn(String message) {
+ serviceLog.warn(message);
}
/**
* @see org.apache.james.jspf.core.Logger#warn(String, Throwable)
*/
- public void warn(String arg0, Throwable arg1) {
- logger.warn(arg0, arg1);
+ public void warn(String message, Throwable t) {
+ serviceLog.warn(message, t);
}
/**
* @see org.apache.james.jspf.core.Logger#getChildLogger(String)
*/
- public org.apache.james.jspf.core.Logger getChildLogger(String arg0) {
- return new SPFLogger(logger.getChildLogger(arg0));
+ public org.apache.james.jspf.core.Logger getChildLogger(String name) {
+ return this;
}
-
}
}
Modified:
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/URIRBLHandler.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/URIRBLHandler.java?rev=816101&r1=816100&r2=816101&view=diff
==============================================================================
---
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/URIRBLHandler.java
(original)
+++
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/URIRBLHandler.java
Thu Sep 17 09:00:18 2009
@@ -36,9 +36,10 @@
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimePart;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.james.api.dnsservice.DNSService;
import org.apache.james.dsn.DSNStatus;
import org.apache.james.smtpserver.Configurable;
@@ -46,13 +47,24 @@
import org.apache.james.smtpserver.hook.HookResult;
import org.apache.james.smtpserver.hook.HookReturnCode;
import org.apache.james.smtpserver.hook.MessageHook;
+import org.apache.james.socket.LogEnabled;
import org.apache.mailet.Mail;
/**
* Extract domains from message and check against URIRBLServer. For more
informations see http://www.surbl.org
*/
-public class URIRBLHandler extends AbstractLogEnabled implements MessageHook,
Configurable {
+public class URIRBLHandler implements LogEnabled, MessageHook, Configurable {
+ /** This log is the fall back shared by all instances */
+ private static final Log FALLBACK_LOG =
LogFactory.getLog(URIRBLHandler.class);
+
+ /** Non context specific log should only be used when no context specific
log is available */
+ private Log serviceLog = FALLBACK_LOG;
+
+ private final static String LISTED_DOMAIN ="LISTED_DOMAIN";
+
+ private final static String URBLSERVER = "URBL_SERVER";
+
private DNSService dnsService;
private Collection<String> uriRbl;
@@ -60,12 +72,17 @@
private boolean getDetail = false;
private boolean checkAuthNetworks = false;
-
- private final static String LISTED_DOMAIN ="LISTED_DOMAIN";
-
- private final static String URBLSERVER = "URBL_SERVER";
/**
+ * Sets the service log.
+ * Where available, a context sensitive log should be used.
+ * @param Log not null
+ */
+ public void setLog(Log log) {
+ this.serviceLog = log;
+ }
+
+ /**
* Gets the DNS service.
* @return the dnsService
*/
@@ -93,8 +110,8 @@
for ( int i = 0 ; i < servers.length ; i++ ) {
String rblServerName = servers[i];
serverCollection.add(rblServerName);
- if (getLogger().isInfoEnabled()) {
- getLogger().info("Adding uriRBL server: " + rblServerName);
+ if (serviceLog.isInfoEnabled()) {
+ serviceLog.info("Adding uriRBL server: " + rblServerName);
}
}
if (serverCollection != null && serverCollection.size() > 0) {
Modified:
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java?rev=816101&r1=816100&r2=816101&view=diff
==============================================================================
---
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java
(original)
+++
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java
Thu Sep 17 09:00:18 2009
@@ -28,12 +28,13 @@
import javax.annotation.Resource;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.james.api.user.UsersRepository;
import org.apache.james.api.vut.ErrorMappingException;
import org.apache.james.api.vut.VirtualUserTable;
@@ -46,6 +47,7 @@
import org.apache.james.smtpserver.hook.HookResult;
import org.apache.james.smtpserver.hook.HookReturnCode;
import org.apache.james.smtpserver.hook.RcptHook;
+import org.apache.james.socket.LogEnabled;
import org.apache.mailet.MailAddress;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
@@ -55,7 +57,14 @@
/**
* Handler which reject invalid recipients
*/
-public class ValidRcptHandler extends AbstractLogEnabled implements RcptHook,
Configurable, Serviceable {
+public class ValidRcptHandler implements LogEnabled, RcptHook, Configurable,
Serviceable {
+
+
+ /** This log is the fall back shared by all instances */
+ private static final Log FALLBACK_LOG =
LogFactory.getLog(ValidRcptHandler.class);
+
+ /** Non context specific log should only be used when no context specific
log is available */
+ private Log serviceLog = FALLBACK_LOG;
private UsersRepository users;
@@ -120,7 +129,7 @@
while (recipsIt.hasNext()) {
String recipient = recipsIt.next();
- getLogger().debug("Add recipient to valid recipients: " +
recipient);
+ serviceLog.debug("Add recipient to valid recipients: " +
recipient);
recipients.add(recipient);
}
}
@@ -135,7 +144,7 @@
while (domsIt.hasNext()) {
String domain = domsIt.next().toLowerCase();
- getLogger().debug("Add domain to valid domains: " + domain);
+ serviceLog.debug("Add domain to valid domains: " + domain);
domains.add(domain);
}
}
@@ -152,7 +161,7 @@
while (regsIt.hasNext()) {
String patternString = regsIt.next();
- getLogger().debug("Add regex to valid regex: " + patternString);
+ serviceLog.debug("Add regex to valid regex: " + patternString);
Pattern pattern = compiler.compile(patternString,
Perl5Compiler.READ_ONLY_MASK);
regex.add(pattern);
@@ -219,4 +228,13 @@
}
return new HookResult(HookReturnCode.DECLINED);
}
+
+ /**
+ * Sets the service log.
+ * Where available, a context sensitive log should be used.
+ * @param Log not null
+ */
+ public void setLog(Log log) {
+ this.serviceLog = log;
+ }
}
Modified:
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java?rev=816101&r1=816100&r2=816101&view=diff
==============================================================================
---
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java
(original)
+++
james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java
Thu Sep 17 09:00:18 2009
@@ -27,9 +27,10 @@
import javax.annotation.Resource;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.james.api.dnsservice.DNSService;
import org.apache.james.api.dnsservice.TemporaryResolutionException;
import org.apache.james.api.dnsservice.util.NetMatcher;
@@ -40,20 +41,37 @@
import org.apache.james.smtpserver.hook.HookResult;
import org.apache.james.smtpserver.hook.HookReturnCode;
import org.apache.james.smtpserver.hook.RcptHook;
+import org.apache.james.socket.LogEnabled;
import org.apache.mailet.MailAddress;
/**
* This class can be used to reject email with bogus MX which is send from a
authorized user or an authorized
* network.
*/
-public class ValidRcptMX extends AbstractLogEnabled implements RcptHook,
Configurable {
+public class ValidRcptMX implements LogEnabled, RcptHook, Configurable {
+ /** This log is the fall back shared by all instances */
+ private static final Log FALLBACK_LOG =
LogFactory.getLog(ValidRcptMX.class);
+
+ /** Non context specific log should only be used when no context specific
log is available */
+ private Log serviceLog = FALLBACK_LOG;
+
private DNSService dnsService = null;
private static final String LOCALHOST = "localhost";
private NetMatcher bNetwork = null;
+
+ /**
+ * Sets the service log.
+ * Where available, a context sensitive log should be used.
+ * @param Log not null
+ */
+ public void setLog(Log log) {
+ this.serviceLog = log;
+ }
+
/**
* Gets the DNS service.
* @return the dnsService
@@ -90,7 +108,7 @@
setBannedNetworks(bannedNetworks, dnsService);
- getLogger().info("Invalid MX Networks: " + bNetwork.toString());
+ serviceLog.info("Invalid MX Networks: " + bNetwork.toString());
} else {
throw new ConfigurationException(
@@ -108,9 +126,8 @@
public void setBannedNetworks(Collection<String> networks, DNSService
dnsServer) {
bNetwork = new NetMatcher(networks, dnsServer) {
protected void log(String s) {
- getLogger().debug(s);
+ serviceLog.debug(s);
}
-
};
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]