james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r690758 - in /james/jsieve/trunk/src: main/java/org/apache/jsieve/ main/java/org/apache/jsieve/commands/ test/java/org/apache/jsieve/ test/java/org/apache/jsieve/junit/
Date Sun, 31 Aug 2008 18:51:53 GMT
Author: rdonkin
Date: Sun Aug 31 11:51:53 2008
New Revision: 690758

URL: http://svn.apache.org/viewvc?rev=690758&view=rev
Log:
Moved TestManager into SieveFactory

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/SieveContext.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveFactory.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/commands/Require.java
    james/jsieve/trunk/src/test/java/org/apache/jsieve/SieveParserVisitorImplQuoteTest.java
    james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/AddressParseTest.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=690758&r1=690757&r2=690758&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 Sun Aug 31 11:51:53
2008
@@ -21,6 +21,7 @@
 
 import org.apache.jsieve.comparators.Comparator;
 import org.apache.jsieve.exception.LookupException;
+import org.apache.jsieve.tests.ExecutableTest;
 
 /**
  * Bean based implementation of context.
@@ -34,11 +35,14 @@
     private final CommandStateManager commandStateManager;
     private final CommandManager commandManager;
     private final ComparatorManager comparatorManager;
+    private final TestManager testManager;
     
-    public BaseSieveContext(final CommandManager commandManager, final ComparatorManager
comparatorManager) 
+    public BaseSieveContext(final CommandManager commandManager, final ComparatorManager
comparatorManager,
+            final TestManager testManager) 
     {
         this.commandStateManager = new CommandStateManager();
         this.conditionManager = new ConditionManager();
+        this.testManager = testManager;
         this.commandManager = commandManager;
         this.comparatorManager = comparatorManager;
     }
@@ -75,11 +79,15 @@
         this.conditionManager = conditionManager;
     }
 
-    public ExecutableCommand getExecutable(String name) throws LookupException {
+    public ExecutableCommand getExecutableManager(String name) throws LookupException {
         return commandManager.newInstance(name);
     }
 
     public Comparator getComparator(String name) throws LookupException {
         return comparatorManager.newInstance(name);
     }
+
+    public ExecutableTest getExecutableTest(String name) throws LookupException {
+        return testManager.newInstance(name);
+    }
 }

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=690758&r1=690757&r2=690758&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 Sun Aug 31 11:51:53 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.getExecutable(getName());
+        final ExecutableCommand executable = context.getExecutableManager(getName());
         final Object result = executable.execute(
                         mail, getArguments(), getBlock(), context);
         return result;

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=690758&r1=690757&r2=690758&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 Sun Aug 31 11:51:53
2008
@@ -21,6 +21,7 @@
 
 import org.apache.jsieve.comparators.Comparator;
 import org.apache.jsieve.exception.LookupException;
+import org.apache.jsieve.tests.ExecutableTest;
 
 /**
  * Context for sieve operations.
@@ -51,7 +52,9 @@
     //TODO: simplify interface
     public abstract void setConditionManager(final ConditionManager manager);
     //TODO: consider whether API can be consolidated
-    public abstract ExecutableCommand getExecutable(String name) throws LookupException;
+    public abstract ExecutableCommand getExecutableManager(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;
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveFactory.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveFactory.java?rev=690758&r1=690757&r2=690758&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveFactory.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveFactory.java Sun Aug 31 11:51:53
2008
@@ -86,7 +86,8 @@
         try {
             final SimpleNode node = new SieveParser(inputStream, "UTF-8").start();
             final CommandManager commandManager = CommandManager.getInstance();
-            SieveValidationVisitor visitor = new SieveValidationVisitor(commandManager);
+            final TestManager testManager = TestManager.getInstance();
+            SieveValidationVisitor visitor = new SieveValidationVisitor(commandManager, testManager);
             node.jjtAccept(visitor, null);
             return node;
         } catch (ParseException ex) {
@@ -130,7 +131,8 @@
             throws SieveException {
         final CommandManager commandManager = CommandManager.getInstance();
         final ComparatorManager comparatorManager = ComparatorManager.getInstance();
-        SieveContext context = new BaseSieveContext(commandManager, comparatorManager);
+        final TestManager testManager = TestManager.getInstance();
+        SieveContext context = new BaseSieveContext(commandManager, comparatorManager, testManager);
         SieveParserVisitor visitor = new SieveParserVisitorImpl(context);
         try {
             // Evaluate the Nodes

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=690758&r1=690757&r2=690758&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 Sun Aug
31 11:51:53 2008
@@ -45,13 +45,15 @@
 public class SieveValidationVisitor implements SieveParserVisitor {
 
     private final CommandManager commandManager;
+    private final TestManager testManager;
     
     private boolean requireAllowed = true;
     private boolean isInRequire = false;
     
-    protected SieveValidationVisitor(final CommandManager commandManager) {
+    protected SieveValidationVisitor(final CommandManager commandManager, final TestManager
testManager) {
         super();
         this.commandManager = commandManager;
+        this.testManager = testManager;
     }
 
     public Object visit(SimpleNode node, Object data) throws SieveException {
@@ -119,7 +121,7 @@
                     commandManager.newInstance(name);
                 } catch (LookupException e) {
                     //TODO: catching is inefficient, should just check
-                    TestManager.getInstance().newInstance(name);
+                    testManager.newInstance(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=690758&r1=690757&r2=690758&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 Sun Aug 31 11:51:53 2008
@@ -49,7 +49,7 @@
             log.debug(toString());
         }
         final String name = getName();
-        final ExecutableTest test = TestManager.getInstance().newInstance(name);
+        final ExecutableTest test = context.getExecutableTest(name);
         final boolean result = test.execute(mail, getArguments(), context);
         return new Boolean(result);
     }

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=690758&r1=690757&r2=690758&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 Sun Aug 31 11:51:53
2008
@@ -26,7 +26,6 @@
 import org.apache.jsieve.Block;
 import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.StringListArgument;
-import org.apache.jsieve.TestManager;
 import org.apache.jsieve.exception.FeatureException;
 import org.apache.jsieve.exception.LookupException;
 import org.apache.jsieve.exception.SieveException;
@@ -88,7 +87,7 @@
 
         // Validate as a Test
         try {
-            validateTest(name);
+            validateTest(name, context);
         } catch (LookupException e) {
             throw new FeatureException("Feature \"" + name
                     + "\" is not supported.");
@@ -102,17 +101,18 @@
      * @throws LookupException
      */
     protected void validateCommand(String name, SieveContext context) throws LookupException
{
-        context.getExecutable(name);
+        context.getExecutableManager(name);
     }
 
     /**
      * Method validateTest.
      * 
      * @param name
+     * @param context TODO
      * @throws LookupException
      */
-    protected void validateTest(String name) throws LookupException {
-        TestManager.getInstance().lookup(name);
+    protected void validateTest(String name, SieveContext context) throws LookupException
{
+        context.getExecutableTest(name);
     }
 
     /**

Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/SieveParserVisitorImplQuoteTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/SieveParserVisitorImplQuoteTest.java?rev=690758&r1=690757&r2=690758&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/SieveParserVisitorImplQuoteTest.java
(original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/SieveParserVisitorImplQuoteTest.java
Sun Aug 31 11:51:53 2008
@@ -34,7 +34,8 @@
     
     protected void setUp() throws Exception {
         super.setUp();
-        visitor = new SieveParserVisitorImpl(new BaseSieveContext(CommandManager.getInstance(),
ComparatorManager.getInstance()));
+        visitor = new SieveParserVisitorImpl(new BaseSieveContext(CommandManager.getInstance(),
ComparatorManager.getInstance(),
+                TestManager.getInstance()));
         data = new ArrayList();
         node = new ASTstring(100);
     }

Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/AddressParseTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/AddressParseTest.java?rev=690758&r1=690757&r2=690758&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/AddressParseTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/AddressParseTest.java Sun Aug
31 11:51:53 2008
@@ -24,6 +24,7 @@
 import org.apache.jsieve.BaseSieveContext;
 import org.apache.jsieve.CommandManager;
 import org.apache.jsieve.ComparatorManager;
+import org.apache.jsieve.TestManager;
 import org.apache.jsieve.junit.utils.JUnitUtils;
 import org.apache.jsieve.junit.utils.SieveMailAdapter;
 
@@ -40,7 +41,7 @@
 
     protected void setUp() throws Exception {
         super.setUp();
-        context = new BaseSieveContext(CommandManager.getInstance(), ComparatorManager.getInstance());
+        context = new BaseSieveContext(CommandManager.getInstance(), ComparatorManager.getInstance(),
TestManager.getInstance());
         mail = (SieveMailAdapter) JUnitUtils.createMail();
         address = new OpenedAddress();
     }



---------------------------------------------------------------------
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