james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r691051 - in /james/jsieve/trunk/src/main/java/org/apache/jsieve: ./ commands/
Date Mon, 01 Sep 2008 20:32:12 GMT
Author: rdonkin
Date: Mon Sep  1 13:32:11 2008
New Revision: 691051

URL: http://svn.apache.org/viewvc?rev=691051&view=rev
Log:
Factored out interfaces. JSIEVE-25 JSIEVE-27 JSIEVE-32

Added:
    james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManagerImpl.java   (contents,
props changed)
      - copied, changed from r691027, james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManager.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManagerImpl.java   (contents,
props changed)
      - copied, changed from r691025, james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManager.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManagerImpl.java   (contents, props
changed)
      - copied, changed from r691028, james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManager.java
Modified:
    james/jsieve/trunk/src/main/java/org/apache/jsieve/BaseSieveContext.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/Command.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManager.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManager.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/ConfigurationManager.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveContext.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveValidationVisitor.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/Test.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManager.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Require.java

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/BaseSieveContext.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/BaseSieveContext.java?rev=691051&r1=691050&r2=691051&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/BaseSieveContext.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/BaseSieveContext.java Mon Sep  1 13:32:11
2008
@@ -85,16 +85,16 @@
         this.conditionManager = conditionManager;
     }
 
-    public ExecutableCommand getExecutableManager(String name) throws LookupException {
-        return commandManager.newInstance(name);
+    public ExecutableCommand getCommand(String name) throws LookupException {
+        return commandManager.getCommand(name);
     }
 
     public Comparator getComparator(String name) throws LookupException {
-        return comparatorManager.newInstance(name);
+        return comparatorManager.getComparator(name);
     }
 
-    public ExecutableTest getExecutableTest(String name) throws LookupException {
-        return testManager.newInstance(name);
+    public ExecutableTest getTest(String name) throws LookupException {
+        return testManager.getTest(name);
     }
 
     public Log getLog() {

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/Command.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/Command.java?rev=691051&r1=691050&r2=691051&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/Command.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/Command.java Mon Sep  1 13:32:11 2008
@@ -153,7 +153,7 @@
         // recursively from the top level block
         // so need to use the coordinate recorded from the parse
         context.setCoordinate(coordinate);
-        final ExecutableCommand executable = context.getExecutableManager(getName());
+        final ExecutableCommand executable = context.getCommand(getName());
         final Object result = executable.execute(
                         mail, getArguments(), getBlock(), context);
         return result;

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManager.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManager.java?rev=691051&r1=691050&r2=691051&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManager.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManager.java Mon Sep  1 13:32:11
2008
@@ -19,49 +19,12 @@
 
 package org.apache.jsieve;
 
-import java.util.Map;
-
 import org.apache.jsieve.exception.LookupException;
 
 /**
- * Singleton class <code>CommandManager</code> maps Command names to
- * configured Command implementation classes.
+ * Maps Command names to configured Command implementation classes.
  */
-public class CommandManager {
-
-    private final Map commandMap;
-    
-    /**
-     * Constructor for CommandManager.
-     */
-    public CommandManager(final Map commandMap) {
-        super();
-        this.commandMap = commandMap;
-    }
-
-    /**
-     * <p>
-     * Method lookup answers the class to which a Command name is mapped.
-     * </p>
-     * 
-     * @param name -
-     *                The name of the Command
-     * @return Class - The class of the Command
-     * @throws LookupException
-     */
-    public Class lookup(String name) throws LookupException {
-        Class cmdClass = null;
-        try {
-            cmdClass = getClass().getClassLoader()
-                    .loadClass(getClassName(name));
-        } catch (ClassNotFoundException e) {
-            throw new LookupException("Command named '" + name + "' not found.");
-        }
-        if (!ExecutableCommand.class.isAssignableFrom(cmdClass))
-            throw new LookupException("Class " + cmdClass.getName()
-                    + " must implement " + ExecutableCommand.class.getName());
-        return cmdClass;
-    }
+public interface CommandManager {
 
     /**
      * <p>
@@ -74,15 +37,7 @@
      * @return Class - The class of the Command
      * @throws LookupException
      */
-    public ExecutableCommand newInstance(String name) throws LookupException {
-        try {
-            return (ExecutableCommand) lookup(name).newInstance();
-        } catch (InstantiationException e) {
-            throw new LookupException(e.getMessage());
-        } catch (IllegalAccessException e) {
-            throw new LookupException(e.getMessage());
-        }
-    }
+    public ExecutableCommand getCommand(String name) throws LookupException;
 
     /**
      * Method isSupported answers a boolean indicating if a Command name is
@@ -92,50 +47,5 @@
      *                The Command name
      * @return boolean - True if the Command name is configured.
      */
-    public boolean isSupported(String name) {
-        boolean isSupported = false;
-        try {
-            lookup(name);
-            isSupported = true;
-        } catch (LookupException e) {
-        }
-        return isSupported;
-    }
-
-    /**
-     * <p>
-     * Method getClassName answers the name of the class to which a Command name
-     * is mapped.
-     * </p>
-     * 
-     * @param name -
-     *                The name of the Command
-     * @return String - The name of the class
-     * @throws LookupException
-     */
-    protected String getClassName(String name) throws LookupException {
-        String className;
-        try {
-            className = (String) getClassNameMap().get(name.toLowerCase());
-        } catch (SieveConfigurationException e) {
-            throw new LookupException(
-                    "Lookup failed due to a Configuration Exception: "
-                            + e.getMessage());
-        }
-        if (null == className)
-            throw new LookupException("Command named '" + name
-                    + "' not mapped.");
-        return className;
-    }
-
-    /**
-     * Method getClassNameMap answers a Map of Command names and their class
-     * names.
-     * 
-     * @return Map
-     * @throws SieveConfigurationException
-     */
-    protected Map getClassNameMap() throws SieveConfigurationException {
-        return commandMap;
-    }
+    public boolean isCommandSupported(String name);
 }

Copied: james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManagerImpl.java (from r691027,
james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManager.java)
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManagerImpl.java?p2=james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManagerImpl.java&p1=james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManager.java&r1=691027&r2=691051&rev=691051&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManager.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManagerImpl.java Mon Sep  1
13:32:11 2008
@@ -27,16 +27,16 @@
  * Singleton class <code>CommandManager</code> maps Command names to
  * configured Command implementation classes.
  */
-public class CommandManager {
+public class CommandManagerImpl implements CommandManager {
 
-    private final Map commandMap;
+    private final Map classNameMap;
     
     /**
      * Constructor for CommandManager.
      */
-    public CommandManager(final Map commandMap) {
+    public CommandManagerImpl(final Map classNameMap) {
         super();
-        this.commandMap = commandMap;
+        this.classNameMap = classNameMap;
     }
 
     /**
@@ -49,7 +49,7 @@
      * @return Class - The class of the Command
      * @throws LookupException
      */
-    public Class lookup(String name) throws LookupException {
+    private Class lookup(String name) throws LookupException {
         Class cmdClass = null;
         try {
             cmdClass = getClass().getClassLoader()
@@ -74,7 +74,7 @@
      * @return Class - The class of the Command
      * @throws LookupException
      */
-    public ExecutableCommand newInstance(String name) throws LookupException {
+    public ExecutableCommand getCommand(String name) throws LookupException {
         try {
             return (ExecutableCommand) lookup(name).newInstance();
         } catch (InstantiationException e) {
@@ -92,7 +92,7 @@
      *                The Command name
      * @return boolean - True if the Command name is configured.
      */
-    public boolean isSupported(String name) {
+    public boolean isCommandSupported(String name) {
         boolean isSupported = false;
         try {
             lookup(name);
@@ -114,28 +114,10 @@
      * @throws LookupException
      */
     protected String getClassName(String name) throws LookupException {
-        String className;
-        try {
-            className = (String) getClassNameMap().get(name.toLowerCase());
-        } catch (SieveConfigurationException e) {
-            throw new LookupException(
-                    "Lookup failed due to a Configuration Exception: "
-                            + e.getMessage());
-        }
+        final String className = (String) classNameMap.get(name.toLowerCase());
         if (null == className)
             throw new LookupException("Command named '" + name
                     + "' not mapped.");
         return className;
     }
-
-    /**
-     * Method getClassNameMap answers a Map of Command names and their class
-     * names.
-     * 
-     * @return Map
-     * @throws SieveConfigurationException
-     */
-    protected Map getClassNameMap() throws SieveConfigurationException {
-        return commandMap;
-    }
 }

Propchange: james/jsieve/trunk/src/main/java/org/apache/jsieve/CommandManagerImpl.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManager.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManager.java?rev=691051&r1=691050&r2=691051&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManager.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManager.java Mon Sep  1 13:32:11
2008
@@ -19,52 +19,15 @@
 
 package org.apache.jsieve;
 
-import java.util.Map;
-
 import org.apache.jsieve.comparators.Comparator;
 import org.apache.jsieve.exception.LookupException;
 
 /**
- * Singleton class <code>ComparatorManager</code> maps Comparator names to
+ * Maps Comparator names to
  * configured Comparator implementation classes.
  */
-public class ComparatorManager {
-    
-    private final Map comparators;
-
-    /**
-     * Constructor for ComparatorManager.
-     */
-    public ComparatorManager(final Map comparators) {
-        super();
-        this.comparators = comparators;
-    }
-
-    /**
-     * <p>
-     * Method lookup answers the class to which a Comparator name is mapped.
-     * </p>
-     * 
-     * @param name -
-     *                The name of the Comparator
-     * @return Class - The class of the Comparator
-     * @throws LookupException
-     */
-    public Class lookup(String name) throws LookupException {
-        Class comparatorClass = null;
-        try {
-            comparatorClass = getClass().getClassLoader().loadClass(
-                    getClassName(name));
-        } catch (ClassNotFoundException e) {
-            throw new LookupException("Comparator named '" + name
-                    + "' not found.");
-        }
-        if (!Comparator.class.isAssignableFrom(comparatorClass))
-            throw new LookupException("Class " + comparatorClass.getName()
-                    + " must implement " + Comparator.class.getName());
-        return comparatorClass;
-    }
-
+public interface ComparatorManager {
+   
     /**
      * <p>
      * Method newInstance answers an instance of the class to which a Comparator
@@ -76,51 +39,5 @@
      * @return Class - The class of the Comparator
      * @throws LookupException
      */
-    public Comparator newInstance(String name) throws LookupException {
-        try {
-            return (Comparator) lookup(name).newInstance();
-        } catch (InstantiationException e) {
-            throw new LookupException(e.getMessage());
-        } catch (IllegalAccessException e) {
-            throw new LookupException(e.getMessage());
-        }
-    }
-
-    /**
-     * <p>
-     * Method getClassName answers the name of the class to which a Comparator
-     * name is mapped.
-     * </p>
-     * 
-     * @param name -
-     *                The name of the Comparator
-     * @return String - The name of the class
-     * @throws LookupException
-     */
-    protected String getClassName(String name) throws LookupException {
-        String className;
-        try {
-            className = (String) getClassNameMap().get(name.toLowerCase());
-        } catch (SieveConfigurationException e) {
-            throw new LookupException(
-                    "Lookup failed due to a Configuration Exception: "
-                            + e.getMessage());
-        }
-        if (null == className)
-            throw new LookupException("Command named '" + name
-                    + "' not mapped.");
-        return className;
-    }
-
-    /**
-     * Method getClassNameMap answers a Map of Comparator names and their class
-     * names.
-     * 
-     * @return Map
-     * @throws SieveConfigurationException
-     */
-    protected Map getClassNameMap() throws SieveConfigurationException {
-        return comparators;
-    }
-
+    public Comparator getComparator(String name) throws LookupException;
 }

Copied: james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManagerImpl.java (from
r691025, james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManager.java)
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManagerImpl.java?p2=james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManagerImpl.java&p1=james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManager.java&r1=691025&r2=691051&rev=691051&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManager.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManagerImpl.java Mon Sep
 1 13:32:11 2008
@@ -28,16 +28,16 @@
  * Singleton class <code>ComparatorManager</code> maps Comparator names to
  * configured Comparator implementation classes.
  */
-public class ComparatorManager {
+public class ComparatorManagerImpl implements ComparatorManager {
     
-    private final Map comparators;
+    private final Map classNameMap;
 
     /**
      * Constructor for ComparatorManager.
      */
-    public ComparatorManager(final Map comparators) {
+    public ComparatorManagerImpl(final Map classNameMap) {
         super();
-        this.comparators = comparators;
+        this.classNameMap = classNameMap;
     }
 
     /**
@@ -76,7 +76,7 @@
      * @return Class - The class of the Comparator
      * @throws LookupException
      */
-    public Comparator newInstance(String name) throws LookupException {
+    public Comparator getComparator(String name) throws LookupException {
         try {
             return (Comparator) lookup(name).newInstance();
         } catch (InstantiationException e) {
@@ -97,30 +97,11 @@
      * @return String - The name of the class
      * @throws LookupException
      */
-    protected String getClassName(String name) throws LookupException {
-        String className;
-        try {
-            className = (String) getClassNameMap().get(name.toLowerCase());
-        } catch (SieveConfigurationException e) {
-            throw new LookupException(
-                    "Lookup failed due to a Configuration Exception: "
-                            + e.getMessage());
-        }
+    private String getClassName(String name) throws LookupException {
+        String className = (String) classNameMap.get(name.toLowerCase());
         if (null == className)
             throw new LookupException("Command named '" + name
                     + "' not mapped.");
         return className;
     }
-
-    /**
-     * Method getClassNameMap answers a Map of Comparator names and their class
-     * names.
-     * 
-     * @return Map
-     * @throws SieveConfigurationException
-     */
-    protected Map getClassNameMap() throws SieveConfigurationException {
-        return comparators;
-    }
-
 }

Propchange: james/jsieve/trunk/src/main/java/org/apache/jsieve/ComparatorManagerImpl.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/ConfigurationManager.java?rev=691051&r1=691050&r2=691051&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/ConfigurationManager.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/ConfigurationManager.java Mon Sep 
1 13:32:11 2008
@@ -278,14 +278,14 @@
     }
     
     public ComparatorManager getComparatorManager() {
-        return new ComparatorManager(fieldComparatorMap);
+        return new ComparatorManagerImpl(fieldComparatorMap);
     }
 
     public CommandManager getCommandManager() {
-        return new CommandManager(fieldCommandMap);
+        return new CommandManagerImpl(fieldCommandMap);
     }
     
     public TestManager getTestManager() {
-        return new TestManager(fieldTestMap);
+        return new TestManagerImpl(fieldTestMap);
     }
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveContext.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveContext.java?rev=691051&r1=691050&r2=691051&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveContext.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveContext.java Mon Sep  1 13:32:11
2008
@@ -53,11 +53,11 @@
     //TODO: simplify interface
     public abstract void setConditionManager(final ConditionManager manager);
     //TODO: consider whether API can be consolidated
-    public abstract ExecutableCommand getExecutableManager(String name) throws LookupException;
+    public abstract ExecutableCommand getCommand(String name) throws LookupException;
     //TODO: consider whether API can be consolidated
     public abstract Comparator getComparator(String name) throws LookupException;
     //TODO: consider whether API can be consolidated
-    public abstract ExecutableTest getExecutableTest(String name) throws LookupException;
+    public abstract ExecutableTest getTest(String name) throws LookupException;
     
     public abstract Log getLog();
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveValidationVisitor.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveValidationVisitor.java?rev=691051&r1=691050&r2=691051&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveValidationVisitor.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveValidationVisitor.java Mon Sep
 1 13:32:11 2008
@@ -76,7 +76,7 @@
 
     public Object visit(ASTcommand node, Object data) throws SieveException {
         final String name = node.getName();
-        commandManager.newInstance(name);
+        commandManager.getCommand(name);
         if ("require".equalsIgnoreCase(name)) {
             if (requireAllowed) {
                 isInRequire = true;
@@ -118,10 +118,10 @@
                 final String quotedName = (String) value;
                 final String name = quotedName.substring(1, quotedName.length()-1);
                 try {
-                    commandManager.newInstance(name);
+                    commandManager.getCommand(name);
                 } catch (LookupException e) {
                     //TODO: catching is inefficient, should just check
-                    testManager.newInstance(name);
+                    testManager.getTest(name);
                 }
             }
         }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/Test.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/Test.java?rev=691051&r1=691050&r2=691051&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/Test.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/Test.java Mon Sep  1 13:32:11 2008
@@ -49,7 +49,7 @@
             log.debug(toString());
         }
         final String name = getName();
-        final ExecutableTest test = context.getExecutableTest(name);
+        final ExecutableTest test = context.getTest(name);
         final boolean result = test.execute(mail, getArguments(), context);
         return new Boolean(result);
     }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManager.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManager.java?rev=691051&r1=691050&r2=691051&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManager.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManager.java Mon Sep  1 13:32:11
2008
@@ -19,51 +19,14 @@
 
 package org.apache.jsieve;
 
-import java.util.Map;
-
 import org.apache.jsieve.exception.LookupException;
 import org.apache.jsieve.tests.ExecutableTest;
 
 /**
- * Singleton class <code>TestManager</code> maps Test names to configured Test
+ * Maps Test names to configured Test
  * implementation classes.
  */
-public class TestManager {
-
-    private final Map classNameMap;
-    
-    /**
-     * TestManager is instanciated with getInstance
-     */
-    public TestManager(final Map classNameMap) {
-        super();
-        this.classNameMap = classNameMap;
-    }
-
-    /**
-     * <p>
-     * Method lookup answers the class to which a Test name is mapped.
-     * </p>
-     * 
-     * @param name -
-     *                The name of the Test
-     * @return Class - The class of the Test
-     * @throws LookupException
-     */
-    public Class lookup(String name) throws LookupException {
-        Class testClass = null;
-
-        try {
-            testClass = getClass().getClassLoader().loadClass(
-                    getClassName(name));
-        } catch (ClassNotFoundException e) {
-            throw new LookupException("Test named '" + name + "' not found.");
-        }
-        if (!ExecutableTest.class.isAssignableFrom(testClass))
-            throw new LookupException("Class " + testClass.getName()
-                    + " must implement " + ExecutableTest.class.getName());
-        return testClass;
-    }
+public interface TestManager {
 
     /**
      * <p>
@@ -76,49 +39,5 @@
      * @return Class - The class of the Test
      * @throws LookupException
      */
-    public ExecutableTest newInstance(String name) throws LookupException {
-        try {
-            return (ExecutableTest) lookup(name).newInstance();
-        } catch (InstantiationException e) {
-            throw new LookupException(e.getMessage());
-        } catch (IllegalAccessException e) {
-            throw new LookupException(e.getMessage());
-        }
-    }
-
-    /**
-     * <p>
-     * Method getClassName answers the name of the class to which a Test name is
-     * mapped.
-     * </p>
-     * 
-     * @param name -
-     *                The name of the Test
-     * @return String - The name of the class
-     * @throws LookupException
-     */
-    protected String getClassName(String name) throws LookupException {
-        String className;
-        try {
-            className = (String) getClassNameMap().get(name.toLowerCase());
-        } catch (SieveConfigurationException e) {
-            throw new LookupException(
-                    "Lookup failed due to a Configuration Exception: "
-                            + e.getMessage());
-        }
-        if (null == className)
-            throw new LookupException("Test named '" + name + "' not mapped.");
-        return className;
-    }
-
-    /**
-     * Method getClassNameMap answers a Map of Test names and their class names.
-     * 
-     * @return Map
-     * @throws SieveConfigurationException
-     */
-    protected Map getClassNameMap() throws SieveConfigurationException {
-        return classNameMap;
-    }
-
+    public ExecutableTest getTest(String name) throws LookupException;
 }

Copied: james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManagerImpl.java (from r691028,
james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManager.java)
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManagerImpl.java?p2=james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManagerImpl.java&p1=james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManager.java&r1=691028&r2=691051&rev=691051&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManager.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManagerImpl.java Mon Sep  1 13:32:11
2008
@@ -28,14 +28,14 @@
  * Singleton class <code>TestManager</code> maps Test names to configured Test
  * implementation classes.
  */
-public class TestManager {
+public class TestManagerImpl implements TestManager {
 
     private final Map classNameMap;
     
     /**
      * TestManager is instanciated with getInstance
      */
-    public TestManager(final Map classNameMap) {
+    public TestManagerImpl(final Map classNameMap) {
         super();
         this.classNameMap = classNameMap;
     }
@@ -76,7 +76,7 @@
      * @return Class - The class of the Test
      * @throws LookupException
      */
-    public ExecutableTest newInstance(String name) throws LookupException {
+    public ExecutableTest getTest(String name) throws LookupException {
         try {
             return (ExecutableTest) lookup(name).newInstance();
         } catch (InstantiationException e) {
@@ -97,28 +97,10 @@
      * @return String - The name of the class
      * @throws LookupException
      */
-    protected String getClassName(String name) throws LookupException {
-        String className;
-        try {
-            className = (String) getClassNameMap().get(name.toLowerCase());
-        } catch (SieveConfigurationException e) {
-            throw new LookupException(
-                    "Lookup failed due to a Configuration Exception: "
-                            + e.getMessage());
-        }
+    private String getClassName(String name) throws LookupException {
+        final String className = (String) classNameMap.get(name.toLowerCase());
         if (null == className)
             throw new LookupException("Test named '" + name + "' not mapped.");
         return className;
     }
-
-    /**
-     * Method getClassNameMap answers a Map of Test names and their class names.
-     * 
-     * @return Map
-     * @throws SieveConfigurationException
-     */
-    protected Map getClassNameMap() throws SieveConfigurationException {
-        return classNameMap;
-    }
-
 }

Propchange: james/jsieve/trunk/src/main/java/org/apache/jsieve/TestManagerImpl.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Require.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Require.java?rev=691051&r1=691050&r2=691051&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Require.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Require.java Mon Sep  1 13:32:11
2008
@@ -101,7 +101,7 @@
      * @throws LookupException
      */
     protected void validateCommand(String name, SieveContext context) throws LookupException
{
-        context.getExecutableManager(name);
+        context.getCommand(name);
     }
 
     /**
@@ -112,7 +112,7 @@
      * @throws LookupException
      */
     protected void validateTest(String name, SieveContext context) throws LookupException
{
-        context.getExecutableTest(name);
+        context.getTest(name);
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message