diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/node-impl/src')
2 files changed, 42 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java index 32aaf91b23..20984a9d6b 100644 --- a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java +++ b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java @@ -67,6 +67,7 @@ import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint; import org.apache.tuscany.sca.deployment.Deployer; +import org.apache.tuscany.sca.extensibility.ServiceDiscovery; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; @@ -210,6 +211,11 @@ public class NodeFactoryImpl extends NodeFactory { } public ExtensionPointRegistry getExtensionPoints() { + if (registry == null) { + // Create extension point registry + registry = createExtensionPointRegistry(); + registry.start(); + } return registry; } @@ -219,11 +225,7 @@ public class NodeFactoryImpl extends NodeFactory { } long start = currentTimeMillis(); - if (registry == null) { - // Create extension point registry - registry = createExtensionPointRegistry(); - registry.start(); - } + getExtensionPoints(); // Use the runtime-enabled assembly factory FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class); @@ -461,5 +463,14 @@ public class NodeFactoryImpl extends NodeFactory { return buf.toString(); } } + + @Override + protected void configure(Map<String, Map<String, String>> attributes) { + ServiceDiscovery discovery = getExtensionPoints().getServiceDiscovery(); + for (Map.Entry<String, Map<String, String>> e : attributes.entrySet()) { + discovery.setAttribute(e.getKey(), e.getValue()); + } + super.configure(attributes); + } } diff --git a/sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java b/sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java index 3fff10328f..f0e6675e8d 100644 --- a/sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java +++ b/sca-java-2.x/trunk/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java @@ -25,12 +25,16 @@ import java.io.File; import java.io.StringReader; import java.net.MalformedURLException; import java.net.URI; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint; import org.apache.tuscany.sca.node.Contribution; import org.apache.tuscany.sca.node.Node; import org.apache.tuscany.sca.node.NodeFactory; +import org.apache.tuscany.sca.runtime.DomainRegistryFactoryExtensionPoint; import org.junit.Assert; import org.junit.Test; @@ -115,4 +119,26 @@ public class NodeImplTestCase { Assert.assertEquals("Hello, Node", hw.hello("Node")); node.stop(); } + + @Test + public void testNodeFactoryAttributes() { + Map<String, Map<String, String>> attrs = new HashMap<String, Map<String, String>>(); + Map<String, String> map = new HashMap<String, String>(); + map.put("enabled", "false"); + attrs.put(ValidationSchemaExtensionPoint.class.getName(), map); + + Map<String, String> map2 = new HashMap<String, String>(); + map2.put("urn:MyDomain", "multicast://200.0.0.100:50000/MyDomain"); + attrs.put(DomainRegistryFactoryExtensionPoint.class.getName(), map2); + + NodeFactoryImpl factory = (NodeFactoryImpl)NodeFactory.newInstance(attrs); + Assert.assertFalse(factory.getExtensionPoints().getExtensionPoint(ValidationSchemaExtensionPoint.class) + .isEnabled()); + + DomainRegistryFactoryExtensionPoint domainRegistryFactoryExtensionPoint = + factory.getExtensionPoints().getExtensionPoint(DomainRegistryFactoryExtensionPoint.class); + Map<String, String> mapping = domainRegistryFactoryExtensionPoint.getDomainRegistryMapping(); + Assert.assertEquals(1, mapping.size()); + Assert.assertEquals("multicast://200.0.0.100:50000/MyDomain", mapping.get("urn:MyDomain")); + } } |