tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r453236 - in /incubator/tuscany/sandbox/ant/container.easy/src: main/java/org/apache/tuscany/container/easy/ test/java/org/apache/tuscany/container/easy/
Date Thu, 05 Oct 2006 13:32:58 GMT
Author: antelder
Date: Thu Oct  5 06:32:57 2006
New Revision: 453236

URL: http://svn.apache.org/viewvc?view=rev&rev=453236
Log:
Keep in sync with the trunk - include the support for properties

Modified:
    incubator/tuscany/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponent.java
    incubator/tuscany/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentBuilder.java
    incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentBuilderTestCase.java
    incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTestCase.java
    incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java

Modified: incubator/tuscany/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponent.java?view=diff&rev=453236&r1=453235&r2=453236
==============================================================================
--- incubator/tuscany/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponent.java
(original)
+++ incubator/tuscany/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponent.java
Thu Oct  5 06:32:57 2006
@@ -48,7 +48,7 @@
 
     protected EasyInstanceFactory instanceFactory;
 
-    public EasyComponent(String name, EasyInstanceFactory instanceFactory, List<Class<?>>
services, CompositeComponent parent, ScopeContainer scopeContainer,
+    public EasyComponent(String name, EasyInstanceFactory instanceFactory, Map<String,
Object> properties, List<Class<?>> services, CompositeComponent parent, ScopeContainer
scopeContainer,
             WireService wireService, WorkContext workContext) {
 
         super(name, parent, scopeContainer, wireService, workContext, null, 0);
@@ -56,7 +56,7 @@
         this.instanceFactory = instanceFactory;
         this.services = services;
         this.scope = scopeContainer.getScope();
-        this.properties = new HashMap<String, Object>();
+        this.properties = properties;
     }
 
     @SuppressWarnings("unchecked")

Modified: incubator/tuscany/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentBuilder.java?view=diff&rev=453236&r1=453235&r2=453236
==============================================================================
--- incubator/tuscany/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentBuilder.java
(original)
+++ incubator/tuscany/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentBuilder.java
Thu Oct  5 06:32:57 2006
@@ -20,7 +20,9 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.tuscany.spi.builder.BuilderConfigException;
 import org.apache.tuscany.spi.component.Component;
@@ -29,6 +31,7 @@
 import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
 import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.PropertyValue;
 import org.apache.tuscany.spi.model.Scope;
 import org.apache.tuscany.spi.model.ServiceDefinition;
 
@@ -59,6 +62,12 @@
             services.add(serviceDefinition.getServiceContract().getInterfaceClass());
         }
 
+        // get the properties for the component
+        Map<String, Object> properties = new HashMap<String, Object>();
+        for (PropertyValue propertyValue : componentDefinition.getPropertyValues().values())
{
+            properties.put(propertyValue.getName(), propertyValue.getValueFactory().getInstance());
+        }
+
         // TODO: have ComponentBuilderExtension pass ScopeContainer in on build method?
         ScopeContainer scopeContainer;
         Scope scope = componentType.getLifecycleScope();
@@ -68,7 +77,7 @@
             scopeContainer = scopeRegistry.getScopeContainer(scope);
         }
 
-        return new EasyComponent(name, implementation.getScriptInstanceFactory(), services,
parent, scopeContainer, wireService, workContext);
+        return new EasyComponent(name, implementation.getScriptInstanceFactory(), properties,
services, parent, scopeContainer, wireService, workContext);
     }
 
 }

Modified: incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentBuilderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentBuilderTestCase.java?view=diff&rev=453236&r1=453235&r2=453236
==============================================================================
--- incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentBuilderTestCase.java
(original)
+++ incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentBuilderTestCase.java
Thu Oct  5 06:32:57 2006
@@ -7,12 +7,15 @@
 
 import org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory;
 import org.apache.tuscany.core.component.scope.ScopeRegistryImpl;
+import org.apache.tuscany.core.property.SimplePropertyObjectFactory;
+import org.apache.tuscany.spi.ObjectFactory;
 import org.apache.tuscany.spi.component.Component;
 import org.apache.tuscany.spi.component.ScopeContainer;
 import org.apache.tuscany.spi.component.ScopeRegistry;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.idl.java.JavaServiceContract;
 import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.PropertyValue;
 import org.apache.tuscany.spi.model.Scope;
 import org.apache.tuscany.spi.model.ServiceContract;
 import org.apache.tuscany.spi.model.ServiceDefinition;
@@ -52,6 +55,18 @@
         service.setServiceContract(serviceContract);
         componentType.add(service);
         impl.getImplementation().setComponentType(componentType);
+        
+        PropertyValue pv = new PropertyValue("foo", "", "");
+        ObjectFactory pvFactory = createMock(ObjectFactory.class);
+        expect(pvFactory.getInstance()).andStubAnswer(new IAnswer() {
+            public Object answer() throws Throwable {
+                return null;
+            }
+        });
+        replay(pvFactory);
+        pv.setValueFactory(pvFactory);
+        impl.add(pv);
+        
         Component component = builder.build(null, impl, deploymentContext);
         assertNotNull(component);
     }

Modified: incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTestCase.java?view=diff&rev=453236&r1=453235&r2=453236
==============================================================================
--- incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTestCase.java
(original)
+++ incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTestCase.java
Thu Oct  5 06:32:57 2006
@@ -7,6 +7,7 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 
 import junit.framework.TestCase;
@@ -32,7 +33,7 @@
 
     @SuppressWarnings("unchecked")
     public void testCreateTargetInvoker() {
-        EasyComponent component = new EasyComponent(null,null,null, null, scopeContainer,
null, null);
+        EasyComponent component = new EasyComponent(null,null, null, null, null, scopeContainer,
null, null);
         
         Operation operation = new Operation("hashCode", null,null,null,false,null);
         ServiceContract contract = new ServiceContract(List.class){};
@@ -44,7 +45,7 @@
 
     @SuppressWarnings("unchecked")
     public void testCreateInstance() throws IOException {
-        EasyComponent pc = new EasyComponent(null,createBSFEasy(),null, null, scopeContainer,
null, null);
+        EasyComponent pc = new EasyComponent(null,createBSFEasy(), new HashMap(), null, null,
scopeContainer, null, null);
         Object o = pc.createInstance();
         assertNotNull(o);
         assertTrue(o instanceof EasyInstance);
@@ -59,7 +60,7 @@
             }
         });
        
-        EasyComponent pc = new EasyComponent(null,createBSFEasy(),null, null, scopeContainer,
wireService, null);
+        EasyComponent pc = new EasyComponent(null,createBSFEasy(), new HashMap(), null, null,
scopeContainer, wireService, null);
         OutboundWire wire = new OutboundWireImpl();
         wire.setReferenceName("foo");
         pc.addOutboundWire(wire);
@@ -77,7 +78,7 @@
             }
         });
         replay(wireService);
-        EasyComponent pc = new EasyComponent(null,null,null, null, scopeContainer, wireService,
null);
+        EasyComponent pc = new EasyComponent(null,null, null, null, null, scopeContainer,
wireService, null);
         InboundWire wire = new InboundWireImpl();
         pc.addInboundWire(wire);
         assertEquals("foo", pc.getServiceInstance());
@@ -85,7 +86,7 @@
 
     @SuppressWarnings("unchecked")
     public void testGetServiceInstanceFail() {
-        EasyComponent pc = new EasyComponent(null,null,null, null, scopeContainer, null,
null);
+        EasyComponent pc = new EasyComponent(null,null, null, null, null, scopeContainer,
null, null);
         try {
             pc.getServiceInstance();
             fail();
@@ -96,20 +97,20 @@
 
     @SuppressWarnings("unchecked")
     public void testGetproperties() {
-        EasyComponent pc = new EasyComponent(null,null,null, null, scopeContainer, null,
null);
+        EasyComponent pc = new EasyComponent(null,null, new HashMap(), null, null, scopeContainer,
null, null);
         assertNotNull(pc.getProperties());
     }
 
     @SuppressWarnings("unchecked")
     public void testGetServiceInterfaces() {
         List services = new ArrayList();
-        EasyComponent pc = new EasyComponent(null,null,services, null, scopeContainer, null,null);
+        EasyComponent pc = new EasyComponent(null,null,null, services, null, scopeContainer,
null,null);
         assertEquals(services, pc.getServiceInterfaces());
     }
 
     @SuppressWarnings("unchecked")
     public void testCreateAsyncTargetInvoker() {
-        EasyComponent pc = new EasyComponent(null,null,new ArrayList<Class<?>>(),
null, scopeContainer, null,null);
+        EasyComponent pc = new EasyComponent(null,null,null, new ArrayList<Class<?>>(),
null, scopeContainer, null,null);
         assertNotNull(pc.createAsyncTargetInvoker(null, new Operation("foo", null,null,null)));
     }
     

Modified: incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java?view=diff&rev=453236&r1=453235&r2=453236
==============================================================================
--- incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java
(original)
+++ incubator/tuscany/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java
Thu Oct  5 06:32:57 2006
@@ -56,6 +56,6 @@
         });
         replay(scopeContainer);
 
-        this.component = new EasyComponent(null, null, null, null, scopeContainer, null,
null);
+        this.component = new EasyComponent(null, null, null, null, null, scopeContainer,
null, null);
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message