summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/sca-client-impl/src
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-05-06 09:40:17 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-05-06 09:40:17 +0000
commit8ec67f4a7e114d8bbaaa0346578b79560bde475c (patch)
treed2968f108f52847c688dc46f70f02b9928d1621a /java/sca/modules/sca-client-impl/src
parent11088b40c732b601dbe6e96400d13d9a0715059e (diff)
Continue exploring sca client api with a new module for the client implementation
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@772115 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/sca-client-impl/src')
-rw-r--r--java/sca/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java32
-rw-r--r--java/sca/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientImpl.java57
-rw-r--r--java/sca/modules/sca-client-impl/src/main/resources/META-INF/services/org.oasisopen.sca.client.SCAClientFactory1
3 files changed, 90 insertions, 0 deletions
diff --git a/java/sca/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java b/java/sca/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java
new file mode 100644
index 0000000000..390e370a48
--- /dev/null
+++ b/java/sca/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.client.impl;
+
+import org.oasisopen.sca.client.SCAClient;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+public class SCAClientFactoryImpl extends SCAClientFactory {
+
+ @Override
+ protected SCAClient createSCAClient() {
+ return new SCAClientImpl();
+ }
+
+}
diff --git a/java/sca/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientImpl.java b/java/sca/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientImpl.java
new file mode 100644
index 0000000000..e49f5faf2f
--- /dev/null
+++ b/java/sca/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientImpl.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.client.impl;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.node.Node;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClient;
+
+public class SCAClientImpl implements SCAClient {
+
+ private static Map<URI, Node> nodes = new HashMap<URI, Node>();
+
+ public static void addDomain(URI domainName, Node node) {
+ nodes.put(domainName, node);
+ }
+
+ public static Node removeDomain(URI domainName) {
+ return nodes.remove(domainName);
+ }
+
+ public <T> T getService(Class<T> serviceInterface, String serviceName, URI domainURI) throws NoSuchServiceException, NoSuchDomainException {
+ Node node = nodes.get(domainURI);
+ if (node == null) {
+ throw new NoSuchDomainException(domainURI.toString());
+ }
+
+ T service = node.getService(serviceInterface, serviceName);
+ if (service == null) {
+ throw new NoSuchServiceException(serviceName);
+ }
+
+ return service;
+ }
+
+}
diff --git a/java/sca/modules/sca-client-impl/src/main/resources/META-INF/services/org.oasisopen.sca.client.SCAClientFactory b/java/sca/modules/sca-client-impl/src/main/resources/META-INF/services/org.oasisopen.sca.client.SCAClientFactory
new file mode 100644
index 0000000000..00a35d8d41
--- /dev/null
+++ b/java/sca/modules/sca-client-impl/src/main/resources/META-INF/services/org.oasisopen.sca.client.SCAClientFactory
@@ -0,0 +1 @@
+org.apache.tuscany.sca.client.impl.SCAClientFactoryImpl