Author: rdonkin
Date: Wed Aug 19 12:59:39 2009
New Revision: 805783

URL: http://svn.apache.org/viewvc?rev=805783&view=rev
Log:
Push constants down which are only used by subclasses. Move wrapper to top 
level.

Modified:
    
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/AbstractLoader.java
    
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/JamesMailetLoader.java
    
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/JamesMatcherLoader.java

Modified: 
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/AbstractLoader.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/AbstractLoader.java?rev=805783&r1=805782&r2=805783&view=diff
==============================================================================
--- 
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/AbstractLoader.java
 (original)
+++ 
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/AbstractLoader.java
 Wed Aug 19 12:59:39 2009
@@ -19,39 +19,26 @@
 
 
 package org.apache.james.transport;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
 import java.util.Vector;
 
+
 import org.apache.avalon.framework.activity.Initializable;
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.DefaultServiceManager;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
-import org.apache.james.services.FileSystem;
-import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.MailetException;
 
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-
 /**
  * Common services for loaders.
  */
 public abstract class AbstractLoader extends AbstractLogEnabled implements 
Serviceable, Configurable, Initializable {
 
-    protected String baseDirectory = null;
-    protected final String MAILET_PACKAGE = "mailetpackage";
-    protected final String MATCHER_PACKAGE = "matcherpackage";
     /**
      * The list of packages that may contain Mailets or matchers
      */
@@ -102,13 +89,6 @@
      */
     public void service(ServiceManager sm) throws ServiceException {
         serviceManager = new DefaultServiceManager(sm);
-        try {
-            baseDirectory = ((FileSystem) 
serviceManager.lookup(FileSystem.ROLE)).getBasedir().getCanonicalPath();
-        } catch (FileNotFoundException e) {
-            throw new ServiceException(FileSystem.ROLE, "Cannot find the base 
directory of the application", e);
-        } catch (IOException e) {
-            throw new ServiceException(FileSystem.ROLE, "Cannot find the base 
directory of the application", e);
-        }
     }
 
     /**
@@ -164,188 +144,4 @@
         return mailetException;
     }
 
-    /**
-     * Wrapper for a MailetContext that simply override the used logger.
-     */
-    protected final static class MailetContextWrapper implements MailetContext 
{
-        
-        /** the mailetContext */
-        private MailetContext mailetContext;
-        /** the logger */
-        private Logger logger;
-
-        /**
-         * Create a mailetContext wrapper that use a different logger for the 
log
-         * operations
-         * 
-         * @param mailetContext the mailet context to be wrapped
-         * @param logger the logger to be used instead of the parent one. 
-         */
-        public MailetContextWrapper(MailetContext mailetContext, Logger 
logger) {
-            this.mailetContext = mailetContext;
-            this.logger = logger;
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#bounce(org.apache.mailet.Mail, 
java.lang.String)
-         */
-        public void bounce(Mail mail, String message) throws 
MessagingException {
-            mailetContext.bounce(mail, message);
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#bounce(org.apache.mailet.Mail, 
java.lang.String, org.apache.mailet.MailAddress)
-         */
-        public void bounce(Mail mail, String message, MailAddress bouncer) 
throws MessagingException {
-            mailetContext.bounce(mail, message, bouncer);
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#getAttribute(java.lang.String)
-         */
-        public Object getAttribute(String name) {
-            return mailetContext.getAttribute(name);
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#getAttributeNames()
-         */
-        @SuppressWarnings("unchecked")
-        public Iterator getAttributeNames() {
-            return mailetContext.getAttributeNames();
-        }
-
-        /**
-         * @see 
org.apache.mailet.MailetContext#getMailServers(java.lang.String)
-         */
-        @SuppressWarnings("unchecked")
-        public Collection getMailServers(String host) {
-            return mailetContext.getMailServers(host);
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#getMajorVersion()
-         */
-        public int getMajorVersion() {
-            return mailetContext.getMajorVersion();
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#getMinorVersion()
-         */
-        public int getMinorVersion() {
-            return mailetContext.getMinorVersion();
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#getPostmaster()
-         */
-        public MailAddress getPostmaster() {
-            return mailetContext.getPostmaster();
-        }
-
-        /**
-         * @see 
org.apache.mailet.MailetContext#getSMTPHostAddresses(java.lang.String)
-         */
-        @SuppressWarnings("unchecked")
-        public Iterator getSMTPHostAddresses(String domainName) {
-            return mailetContext.getSMTPHostAddresses(domainName);
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#getServerInfo()
-         */
-        public String getServerInfo() {
-            return mailetContext.getServerInfo();
-        }
-
-        /**
-         * @see 
org.apache.mailet.MailetContext#isLocalEmail(org.apache.mailet.MailAddress)
-         */
-        public boolean isLocalEmail(MailAddress mailAddress) {
-            return mailetContext.isLocalEmail(mailAddress);
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#isLocalServer(java.lang.String)
-         */
-        public boolean isLocalServer(String serverName) {
-            return mailetContext.isLocalServer(serverName);
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#isLocalUser(java.lang.String)
-         */
-        @SuppressWarnings("deprecation")
-        public boolean isLocalUser(String userAccount) {
-            return mailetContext.isLocalUser(userAccount);
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#log(java.lang.String)
-         */
-        public void log(String message) {
-            logger.info(message);
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#log(java.lang.String, 
java.lang.Throwable)
-         */
-        public void log(String message, Throwable t) {
-            logger.info(message, t);
-        }
-
-        /**
-         * @see 
org.apache.mailet.MailetContext#removeAttribute(java.lang.String)
-         */
-        public void removeAttribute(String name) {
-            mailetContext.removeAttribute(name);
-        }
-
-        /**
-         * @see 
org.apache.mailet.MailetContext#sendMail(javax.mail.internet.MimeMessage)
-         */
-        public void sendMail(MimeMessage msg) throws MessagingException {
-            mailetContext.sendMail(msg);
-        }
-
-        /**
-         * @see 
org.apache.mailet.MailetContext#sendMail(org.apache.mailet.MailAddress, 
java.util.Collection, javax.mail.internet.MimeMessage)
-         */
-        @SuppressWarnings("unchecked")
-        public void sendMail(MailAddress sender, Collection recipients, 
MimeMessage msg) throws MessagingException {
-            mailetContext.sendMail(sender, recipients, msg);
-        }
-
-        /**
-         * @see 
org.apache.mailet.MailetContext#sendMail(org.apache.mailet.MailAddress, 
java.util.Collection, javax.mail.internet.MimeMessage, java.lang.String)
-         */
-        @SuppressWarnings("unchecked")
-        public void sendMail(MailAddress sender, Collection recipients, 
MimeMessage msg, String state) throws MessagingException {
-            mailetContext.sendMail(sender, recipients, msg, state);
-        }
-
-        /**
-         * @see 
org.apache.mailet.MailetContext#sendMail(org.apache.mailet.Mail)
-         */
-        public void sendMail(Mail mail) throws MessagingException {
-            mailetContext.sendMail(mail);
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#setAttribute(java.lang.String, 
java.lang.Object)
-         */
-        public void setAttribute(String name, Object object) {
-            mailetContext.setAttribute(name, object);
-        }
-
-        /**
-         * @see org.apache.mailet.MailetContext#storeMail(MailAddress, 
MailAddress, MimeMessage)
-         */
-        @SuppressWarnings("deprecation")
-        public void storeMail(MailAddress sender, MailAddress recipient, 
MimeMessage msg) throws MessagingException {
-            mailetContext.storeMail(sender, recipient, msg);
-        }
-    }
-
 }

Modified: 
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/JamesMailetLoader.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/JamesMailetLoader.java?rev=805783&r1=805782&r2=805783&view=diff
==============================================================================
--- 
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/JamesMailetLoader.java
 (original)
+++ 
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/JamesMailetLoader.java
 Wed Aug 19 12:59:39 2009
@@ -37,6 +37,7 @@
     
     private static final String DISPLAY_NAME = "mailet";
     private ServiceLocator serviceLocator;
+    private final String MAILET_PACKAGE = "mailetpackage";
      
     /**
      * Gets the service locator.

Modified: 
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/JamesMatcherLoader.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/JamesMatcherLoader.java?rev=805783&r1=805782&r2=805783&view=diff
==============================================================================
--- 
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/JamesMatcherLoader.java
 (original)
+++ 
james/server/trunk/spoolmanager-function/src/main/java/org/apache/james/transport/JamesMatcherLoader.java
 Wed Aug 19 12:59:39 2009
@@ -31,6 +31,7 @@
  */
 public class JamesMatcherLoader extends AbstractLoader implements 
MatcherLoader {
     private static final String DISPLAY_NAME = "matcher";
+    private final String MATCHER_PACKAGE = "matcherpackage";
 
     /**
      * @see 
org.apache.avalon.framework.configuration.Configurable#configure(Configuration)



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to