commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From germu...@apache.org
Subject svn commit: r165087 - in /jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/generic: DispatchLookupCommand.java LookupCommand.java
Date Thu, 28 Apr 2005 02:11:39 GMT
Author: germuska
Date: Wed Apr 27 19:11:38 2005
New Revision: 165087

URL: http://svn.apache.org/viewcvs?rev=165087&view=rev
Log:
Refactoring to make it easier for lookups to work against a CatalogFactory of any origin,
instead of being bound to the static singleton instance returned by CatalogFactory.getInstance()

Modified:
    jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/generic/DispatchLookupCommand.java
    jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/generic/LookupCommand.java

Modified: jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/generic/DispatchLookupCommand.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/generic/DispatchLookupCommand.java?rev=165087&r1=165086&r2=165087&view=diff
==============================================================================
--- jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/generic/DispatchLookupCommand.java
(original)
+++ jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/generic/DispatchLookupCommand.java
Wed Apr 27 19:11:38 2005
@@ -16,6 +16,7 @@
 package org.apache.commons.chain.generic;
 
 
+import org.apache.commons.chain.CatalogFactory;
 import org.apache.commons.chain.Command;
 import org.apache.commons.chain.Context;
 import org.apache.commons.chain.Filter;
@@ -50,6 +51,24 @@
 
 public class DispatchLookupCommand extends LookupCommand implements Filter {
 
+    // -------------------------------------------------------------- Constructors
+
+    /**
+     * Create an instance with an unspecified <code>catalogFactory</code> property.
 
+     * This property can be set later using <code>setProperty</code>, or if it
is not set,
+     * the static singleton instance from <code>CatalogFactory.getInstance()</code>
will be used. 
+     * 
+     */
+    public DispatchLookupCommand() {  super();  };
+    
+    /**
+     * Create an instance and initialize the <code>catalogFactory</code> property
+     * to given <code>factory</code>/
+     */
+    public DispatchLookupCommand(CatalogFactory factory) {
+        super(factory);
+    }
+    
     // ------------------------------------------------------- Static Variables
     
     /**

Modified: jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/generic/LookupCommand.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/generic/LookupCommand.java?rev=165087&r1=165086&r2=165087&view=diff
==============================================================================
--- jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/generic/LookupCommand.java
(original)
+++ jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/generic/LookupCommand.java
Wed Apr 27 19:11:38 2005
@@ -45,11 +45,40 @@
 public class LookupCommand implements Filter {
 
 
+    // -------------------------------------------------------------- Constructors
+
+    /**
+     * Create an instance with an unspecified <code>catalogFactory</code> property.
 
+     * This property can be set later using <code>setProperty</code>, or if it
is not set,
+     * the static singleton instance from <code>CatalogFactory.getInstance()</code>
will be used. 
+     * 
+     */
+    public LookupCommand() {    }
+    
+    /**
+     * Create an instance and initialize the <code>catalogFactory</code> property
+     * to given <code>factory</code>/
+     */
+    public LookupCommand(CatalogFactory factory) {
+        this.catalogFactory = factory;
+    }
+    
+
     // -------------------------------------------------------------- Properties
 
 
-    private String catalogName = null;
 
+    private CatalogFactory catalogFactory = null;
+
+    /**
+     * <p>Set the {@link CatalogFactory} from which lookups will be
+     * performed.</p>
+     */
+    public void setCatalogFactory(CatalogFactory catalogFactory) {
+        this.catalogFactory = catalogFactory;
+    }
+    
+    private String catalogName = null;
 
     /**
      * <p>Return the name of the {@link Catalog} to be searched, or
@@ -268,15 +297,16 @@
      *  to <code>false</code>
      */
     protected Command getCommand(Context context) {
+        CatalogFactory lookupFactory = this.catalogFactory;
+        if (lookupFactory == null) lookupFactory = CatalogFactory.getInstance();
 
-        CatalogFactory catalogFactory = CatalogFactory.getInstance();
         String catalogName = getCatalogName();
         Catalog catalog = null;
         if (catalogName == null) {
             // use default catalog
-            catalog = catalogFactory.getCatalog();
+            catalog = lookupFactory.getCatalog();
         } else {
-            catalog = catalogFactory.getCatalog(catalogName);
+            catalog = lookupFactory.getCatalog(catalogName);
         }
         if (catalog == null) {
             if (catalogName == null) {



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


Mime
View raw message