summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/node-impl-osgi/src/main
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-04-14 04:15:42 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-04-14 04:15:42 +0000
commitd4743525775f0d49ab021887e7402967d12d32be (patch)
tree7fff56c2496760ad6bd25e324d577b6daee7288a /sca-java-2.x/trunk/modules/node-impl-osgi/src/main
parent4c7135a02179116fa07dd11df28a7885f5369273 (diff)
Add duplication check for SCA configurations
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@933854 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/node-impl-osgi/src/main')
-rw-r--r--sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java6
-rw-r--r--sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java9
-rw-r--r--sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java3
-rw-r--r--sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java50
4 files changed, 65 insertions, 3 deletions
diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java
index ffd619a4c2..22bcb5af41 100644
--- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java
+++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java
@@ -478,8 +478,10 @@ public class EndpointIntrospector {
.getNamespaceURI())) {
for (Binding binding : sc.getBindings()) {
if (bindingName.getLocalPart().equals(binding.getName())) {
- bindingMap.put(bindingName, binding);
- break;
+ // We need to check duplications
+ if (bindingMap.put(bindingName, binding) != null) {
+ throw new ServiceRuntimeException("Duplicate binding found: " + bindingName);
+ }
}
}
}
diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
index 56e17a5642..00eb45f3c1 100644
--- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
+++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
@@ -265,7 +265,14 @@ public class RemoteServiceAdminImpl implements RemoteServiceAdmin, ManagedServic
if (bindings != null) {
props.put("org.osgi.sca.bindings", bindings);
}
- }
+ Object config = ep.getProperties().get("org.osgi.sca.config.url");
+ if (config != null) {
+ props.put("org.osgi.sca.config.url", config);
+ }
+ config = ep.getProperties().get("org.osgi.sca.config.xml");
+ if (config != null) {
+ props.put("org.osgi.sca.config.xml", config);
+ } }
props.put("timestamp", Long.valueOf(System.currentTimeMillis()));
props.put("event", rsaEvent);
return new Event(topic, props);
diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
index 34c72933e9..0cbdda7b56 100644
--- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
+++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
@@ -80,9 +80,12 @@ public class DomainDiscoveryService extends AbstractDiscoveryService implements
public void endpointAdded(Endpoint endpoint) {
Implementation impl = endpoint.getComponent().getImplementation();
+
+ /*
if (!(impl instanceof OSGiImplementation)) {
return;
}
+ */
BundleContext bundleContext = null;
// Remote endpoint doesn't have a bundle
diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java
index 320443c399..dc9ae096dd 100644
--- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java
+++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java
@@ -34,12 +34,17 @@ import java.util.UUID;
import java.util.Map.Entry;
import java.util.logging.Level;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.deployment.Deployer;
import org.apache.tuscany.sca.implementation.osgi.SCAConfig;
import org.apache.tuscany.sca.implementation.osgi.ServiceDescription;
import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions;
import org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiHelper;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
import org.oasisopen.sca.ServiceRuntimeException;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -159,6 +164,7 @@ public class LocalDiscoveryService extends AbstractDiscoveryService implements B
}
// Add to the extenders before notifying the listeners (the endpoints may references to the config)
+ ExtenderConfiguration.validate(extenders, extender);
this.extenders.add(extender);
// Notify
@@ -200,6 +206,50 @@ public class LocalDiscoveryService extends AbstractDiscoveryService implements B
return scaConfigs;
}
+ public static void validate(Collection<ExtenderConfiguration> configs, ExtenderConfiguration newConfig) {
+ Map<QName, Binding> bindings = new HashMap<QName, Binding>();
+ Map<QName, Intent> intents = new HashMap<QName, Intent>();
+ Map<QName, PolicySet> policySets = new HashMap<QName, PolicySet>();
+
+ for (ExtenderConfiguration config : configs) {
+ for (SCAConfig c : config.getSCAConfigs()) {
+ addBindings(bindings, c);
+ addIntents(intents, c);
+ addPolicySets(policySets, c);
+ }
+ }
+ for (SCAConfig c : newConfig.getSCAConfigs()) {
+ addBindings(bindings, c);
+ addIntents(intents, c);
+ addPolicySets(policySets, c);
+ }
+ }
+
+ private static void addIntents(Map<QName, Intent> intents, SCAConfig c) {
+ for (Intent i: c.getIntents()) {
+ if (intents.put(i.getName(), i) != null) {
+ throw new ServiceRuntimeException("Duplicate intent: " + i.getName());
+ }
+ }
+ }
+
+ private static void addPolicySets(Map<QName, PolicySet> policySets, SCAConfig c) {
+ for (PolicySet ps: c.getPolicySets()) {
+ if (policySets.put(ps.getName(), ps) != null) {
+ throw new ServiceRuntimeException("Duplicate policySet: " + ps.getName());
+ }
+ }
+ }
+
+ private static void addBindings(Map<QName, Binding> bindings, SCAConfig c) {
+ for (Binding b : c.getBindings()) {
+ QName name = new QName(c.getTargetNamespace(), b.getName());
+ if (bindings.put(name, b) != null) {
+ throw new ServiceRuntimeException("Duplicate binding: " + name);
+ }
+ }
+ }
+
}
@Override