hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahue...@apache.org
Subject svn commit: r447574 - in /hivemind/branches/branch-2-0-annot: library/src/java/org/apache/hivemind/lib/chain/ library/src/java/org/apache/hivemind/lib/factory/ library/src/test/hivemind/test/lib/ library/src/test/org/apache/hivemind/lib/factory/ librar...
Date Mon, 18 Sep 2006 21:31:34 GMT
Author: ahuegen
Date: Mon Sep 18 14:31:33 2006
New Revision: 447574

URL: http://svn.apache.org/viewvc?view=rev&rev=447574
Log:
Reworked ServiceImplementationFactoryParameters. Made it backward compatible.

Modified:
    hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/chain/ChainFactory.java
    hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryBuilder.java
    hivemind/branches/branch-2-0-annot/library/src/test/hivemind/test/lib/TestSpringLookupFactory.java
    hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/factory/TestBeanFactoryImpl.java
    hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java
    hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/pipeline/TestPipelineAssembler.java
    hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/strategy/TestStrategyFactory.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/ServiceImplementationFactoryParameters.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/InvokeFactoryServiceConstructor.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/ServiceImplementationFactoryParametersImpl.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/service/impl/BuilderFactory.java

Modified: hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/chain/ChainFactory.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/chain/ChainFactory.java?view=diff&rev=447574&r1=447573&r2=447574
==============================================================================
--- hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/chain/ChainFactory.java
(original)
+++ hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/chain/ChainFactory.java
Mon Sep 18 14:31:33 2006
@@ -35,7 +35,7 @@
     public Object createCoreServiceImplementation(
             ServiceImplementationFactoryParameters factoryParameters)
     {
-        List contributions = (List) factoryParameters.getParameters();
+        List contributions = (List) factoryParameters.getFirstParameter();
 
         Orderer orderer = new Orderer(factoryParameters.getErrorLog(), "command");
 

Modified: hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryBuilder.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryBuilder.java?view=diff&rev=447574&r1=447573&r2=447574
==============================================================================
--- hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryBuilder.java
(original)
+++ hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryBuilder.java
Mon Sep 18 14:31:33 2006
@@ -28,7 +28,7 @@
     public Object createCoreServiceImplementation(
             ServiceImplementationFactoryParameters factoryParameters)
     {
-        BeanFactoryParameter p = (BeanFactoryParameter) factoryParameters.getParameters();
+        BeanFactoryParameter p = (BeanFactoryParameter) factoryParameters.getFirstParameter();
 
         return new BeanFactoryImpl(factoryParameters.getErrorLog(), p.getVendClass(), p
                 .getContributions(), p.getDefaultCacheable());

Modified: hivemind/branches/branch-2-0-annot/library/src/test/hivemind/test/lib/TestSpringLookupFactory.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/library/src/test/hivemind/test/lib/TestSpringLookupFactory.java?view=diff&rev=447574&r1=447573&r2=447574
==============================================================================
--- hivemind/branches/branch-2-0-annot/library/src/test/hivemind/test/lib/TestSpringLookupFactory.java
(original)
+++ hivemind/branches/branch-2-0-annot/library/src/test/hivemind/test/lib/TestSpringLookupFactory.java
Mon Sep 18 14:31:33 2006
@@ -21,7 +21,6 @@
 import org.apache.hivemind.lib.SpringBeanFactoryHolder;
 import org.apache.hivemind.lib.impl.SpringBeanParameter;
 import org.apache.hivemind.lib.impl.SpringLookupFactory;
-import org.apache.hivemind.test.HiveMindTestCase;
 import org.apache.hivemind.xml.XmlTestCase;
 import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.xml.XmlBeanFactory;

Modified: hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/factory/TestBeanFactoryImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/factory/TestBeanFactoryImpl.java?view=diff&rev=447574&r1=447573&r2=447574
==============================================================================
--- hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/factory/TestBeanFactoryImpl.java
(original)
+++ hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/factory/TestBeanFactoryImpl.java
Mon Sep 18 14:31:33 2006
@@ -25,7 +25,6 @@
 import org.apache.hivemind.Registry;
 import org.apache.hivemind.ServiceImplementationFactoryParameters;
 import org.apache.hivemind.lib.BeanFactory;
-import org.apache.hivemind.test.HiveMindTestCase;
 import org.apache.hivemind.xml.XmlTestCase;
 import org.easymock.MockControl;
 
@@ -197,8 +196,8 @@
         ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
fpc
                 .getMock();
 
-        fp.getParameters();
-        fpc.setReturnValue(Collections.singletonList(p));
+        fp.getFirstParameter();
+        fpc.setReturnValue(p);
 
         fp.getErrorLog();
         fpc.setReturnValue(newMock(ErrorLog.class));

Modified: hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java?view=diff&rev=447574&r1=447573&r2=447574
==============================================================================
--- hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java
(original)
+++ hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java
Mon Sep 18 14:31:33 2006
@@ -17,8 +17,6 @@
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
-import java.util.Collections;
-import java.util.List;
 
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.HiveMind;
@@ -26,7 +24,6 @@
 import org.apache.hivemind.ServiceImplementationFactoryParameters;
 import org.apache.hivemind.internal.ServicePoint;
 import org.apache.hivemind.service.impl.ClassFactoryImpl;
-import org.apache.hivemind.test.HiveMindTestCase;
 import org.apache.hivemind.xml.XmlTestCase;
 import org.easymock.MockControl;
 
@@ -46,7 +43,7 @@
         return result;
     }
 
-    private List newParameters(WonkSource service, String propertyName)
+    private ServicePropertyFactoryParameter newParameters(WonkSource service, String propertyName)
     {
         ServicePropertyFactoryParameter p = new ServicePropertyFactoryParameter();
 
@@ -61,7 +58,7 @@
         p.setPropertyName(propertyName);
         p.setLocation(newLocation());
 
-        return Collections.singletonList(p);
+        return p;
     }
 
     public void testSuccess()
@@ -75,13 +72,13 @@
         ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
fpc
                 .getMock();
 
-        List parameters = newParameters(new WonkHolder(wonk), "wonk");
+        ServicePropertyFactoryParameter parameters = newParameters(new WonkHolder(wonk),
"wonk");
 
         wonk.wonkVoid();
         wonk.wonkString("zebra");
         wonkControl.setReturnValue("stripes");
 
-        fp.getParameters();
+        fp.getFirstParameter();
         fpc.setReturnValue(parameters);
 
         fp.getServiceInterface();
@@ -122,13 +119,13 @@
 					}
         	  
         		} );
-        List parameters = newParameters(jdkProxy, "wonk");
+        ServicePropertyFactoryParameter parameters = newParameters(jdkProxy, "wonk");
 
         wonk.wonkVoid();
         wonk.wonkString("zebra");
         wonkControl.setReturnValue("stripes");
 
-        fp.getParameters();
+        fp.getFirstParameter();
         fpc.setReturnValue(parameters);
 
         fp.getServiceInterface();
@@ -158,9 +155,9 @@
 
         ServicePropertyFactory f = newFactory();
 
-        List parameters = newParameters(new WonkHolder(null), "wonk");
+        ServicePropertyFactoryParameter parameters = newParameters(new WonkHolder(null),
"wonk");
 
-        fp.getParameters();
+        fp.getFirstParameter();
         fpc.setReturnValue(parameters);
 
         fp.getServiceInterface();
@@ -194,9 +191,9 @@
 
         ServicePropertyFactory f = newFactory();
 
-        List parameters = newParameters(new WonkHolder(null), "writeOnly");
+        ServicePropertyFactoryParameter parameters = newParameters(new WonkHolder(null),
"writeOnly");
 
-        fp.getParameters();
+        fp.getFirstParameter();
         fpc.setReturnValue(parameters);
 
         replayControls();
@@ -209,7 +206,7 @@
         catch (ApplicationRuntimeException ex)
         {
             assertEquals("Property 'writeOnly' of <WonkHolder> is not readable.", ex.getMessage());
-            assertEquals(HiveMind.getLocation(parameters.get(0)), ex.getLocation());
+            assertEquals(HiveMind.getLocation(parameters), ex.getLocation());
         }
 
         verifyControls();
@@ -223,9 +220,9 @@
 
         ServicePropertyFactory f = newFactory();
 
-        List parameters = newParameters(new WonkHolder(null), "class");
+        ServicePropertyFactoryParameter parameters = newParameters(new WonkHolder(null),
"class");
 
-        fp.getParameters();
+        fp.getFirstParameter();
         fpc.setReturnValue(parameters);
 
         fp.getServiceInterface();
@@ -243,7 +240,7 @@
             assertEquals(
                     "Property 'class' of <WonkHolder> is type java.lang.Class, which
does not match the expected interface org.apache.hivemind.lib.impl.Wonk.",
                     ex.getMessage());
-            assertEquals(HiveMind.getLocation(parameters.get(0)), ex.getLocation());
+            assertEquals(HiveMind.getLocation(parameters), ex.getLocation());
         }
 
         verifyControls();

Modified: hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/pipeline/TestPipelineAssembler.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/pipeline/TestPipelineAssembler.java?view=diff&rev=447574&r1=447573&r2=447574
==============================================================================
--- hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/pipeline/TestPipelineAssembler.java
(original)
+++ hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/pipeline/TestPipelineAssembler.java
Mon Sep 18 14:31:33 2006
@@ -15,7 +15,6 @@
 package org.apache.hivemind.lib.pipeline;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
 import org.apache.hivemind.ErrorLog;
@@ -24,7 +23,6 @@
 import org.apache.hivemind.lib.impl.DefaultImplementationBuilderImpl;
 import org.apache.hivemind.service.ClassFactory;
 import org.apache.hivemind.service.impl.ClassFactoryImpl;
-import org.apache.hivemind.test.HiveMindTestCase;
 import org.apache.hivemind.xml.XmlTestCase;
 import org.easymock.MockControl;
 
@@ -224,8 +222,8 @@
 
         pp.setPipelineConfiguration(l);
 
-        fp.getParameters();
-        fpc.setReturnValue(Collections.singletonList(pp));
+        fp.getFirstParameter();
+        fpc.setReturnValue(pp);
 
         fp.getServiceId();
         fpc.setReturnValue("example");
@@ -277,8 +275,8 @@
 
         pp.setPipelineConfiguration(l);
 
-        fp.getParameters();
-        fpc.setReturnValue(Collections.singletonList(pp));
+        fp.getFirstParameter();
+        fpc.setReturnValue(pp);
 
         fp.getServiceId();
         fpc.setReturnValue("example");

Modified: hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/strategy/TestStrategyFactory.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/strategy/TestStrategyFactory.java?view=diff&rev=447574&r1=447573&r2=447574
==============================================================================
--- hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/strategy/TestStrategyFactory.java
(original)
+++ hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/strategy/TestStrategyFactory.java
Mon Sep 18 14:31:33 2006
@@ -22,10 +22,6 @@
 import org.apache.hivemind.Location;
 import org.apache.hivemind.Registry;
 import org.apache.hivemind.ServiceImplementationFactoryParameters;
-import org.apache.hivemind.lib.strategy.StrategyContribution;
-import org.apache.hivemind.lib.strategy.StrategyMessages;
-import org.apache.hivemind.lib.strategy.StrategyParameter;
-import org.apache.hivemind.lib.strategy.StrategyFactory;
 import org.apache.hivemind.lib.util.StrategyRegistry;
 import org.apache.hivemind.service.ClassFab;
 import org.apache.hivemind.service.ClassFabUtils;
@@ -35,7 +31,6 @@
 import org.apache.hivemind.test.AggregateArgumentsMatcher;
 import org.apache.hivemind.test.ArgumentMatcher;
 import org.apache.hivemind.test.ArrayMatcher;
-import org.apache.hivemind.test.HiveMindTestCase;
 import org.apache.hivemind.test.TypeMatcher;
 import org.apache.hivemind.xml.XmlTestCase;
 import org.easymock.MockControl;

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/ServiceImplementationFactoryParameters.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/ServiceImplementationFactoryParameters.java?view=diff&rev=447574&r1=447573&r2=447574
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/ServiceImplementationFactoryParameters.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/ServiceImplementationFactoryParameters.java
Mon Sep 18 14:31:33 2006
@@ -14,6 +14,8 @@
 
 package org.apache.hivemind;
 
+import java.util.List;
+
 import org.apache.commons.logging.Log;
 import org.apache.hivemind.internal.Module;
 
@@ -58,13 +60,22 @@
     /**
      * The parameters passed to the factory to guide the construction of the service. In
most cases,
      * there will only be a single element in the list.
+     * Since HiveMind 2.0 schemas and thus parameters are no longer restricted to lists 
+     * as root element. The parameters can be contained in any other type.
+     * 
+     * @deprecated  use #getParametersContainer instead 
      */
-    public Object getParameters();
+    public List getParameters();
     
     /**
-     * Returns the first parameter passed to the factory (since most factories
-     * take exactly one parameter, this is the most common usage).  If no parameters exist,
-     * returns null.
+     * The parameters passed to the factory to guide the construction of the service.
+     * The concrete type depends on the underlying schema definition. 
+     */
+    public Object getParametersContainer();
+
+    /**
+     * Returns the first parameter passed to the factory. Works only if the parameters
+     * are contained in a list. If no parameters exist, returns null.
      */
     public Object getFirstParameter();
 

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/InvokeFactoryServiceConstructor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/InvokeFactoryServiceConstructor.java?view=diff&rev=447574&r1=447573&r2=447574
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/InvokeFactoryServiceConstructor.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/InvokeFactoryServiceConstructor.java
Mon Sep 18 14:31:33 2006
@@ -120,9 +120,14 @@
         _parameters = list;
     }
 
-    public void setFactoryServiceId(String string)
+    public void setFactoryServiceId(String factoryServiceId)
     {
-        _factoryServiceId = string;
+        _factoryServiceId = factoryServiceId;
+    }
+
+    public String getFactoryServiceId()
+    {
+        return _factoryServiceId;
     }
     
     public Object constructParametersContainer(String containerClassName, Module definingModule)
@@ -149,5 +154,6 @@
 
         log.error(message, getLocation(), null);
     }
+
 
 }

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/ServiceImplementationFactoryParametersImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/ServiceImplementationFactoryParametersImpl.java?view=diff&rev=447574&r1=447573&r2=447574
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/ServiceImplementationFactoryParametersImpl.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/ServiceImplementationFactoryParametersImpl.java
Mon Sep 18 14:31:33 2006
@@ -17,6 +17,7 @@
 import java.util.List;
 
 import org.apache.commons.logging.Log;
+import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.ServiceImplementationFactoryParameters;
 import org.apache.hivemind.ErrorLog;
 import org.apache.hivemind.internal.Module;
@@ -87,7 +88,18 @@
         return _invokingModule;
     }
 
-    public Object getParameters()
+    public List getParameters()
+    {
+        // For backward compatibility lists are handled specially. The behaviour
+        // of hivemind 1.x is emulated
+        if (_parameters instanceof List) {
+            return (List) _parameters;
+        } else {
+            throw new ApplicationRuntimeException("Parameters are not contained in a list.
Use getParametersContainer instead.");
+        }
+    }
+    
+    public Object getParametersContainer()
     {
         return _parameters;
     }

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/service/impl/BuilderFactory.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/service/impl/BuilderFactory.java?view=diff&rev=447574&r1=447573&r2=447574
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/service/impl/BuilderFactory.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/service/impl/BuilderFactory.java
Mon Sep 18 14:31:33 2006
@@ -35,7 +35,7 @@
     public Object createCoreServiceImplementation(
             ServiceImplementationFactoryParameters factoryParameters)
     {
-        BuilderParameter parameter = (BuilderParameter) factoryParameters.getParameters();
+        BuilderParameter parameter = (BuilderParameter) factoryParameters.getFirstParameter();
 
         BuilderFactoryLogic logic = new BuilderFactoryLogic(factoryParameters, parameter);
 



Mime
View raw message