summaryrefslogtreecommitdiffstats
path: root/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding')
-rw-r--r--sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/BindingURICalculator.java35
-rw-r--r--sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/BindingURICalculatorExtensionPoint.java52
-rw-r--r--sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/DefaultBindingURICalculatorExtensionPoint.java124
-rw-r--r--sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/feed/atom/AtomBindingURICalculator.java41
-rw-r--r--sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingURICalculator.java40
-rw-r--r--sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingURICalculator.java41
-rw-r--r--sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/sca/SCABindingURICalculator.java41
-rw-r--r--sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingURICalculator.java41
8 files changed, 415 insertions, 0 deletions
diff --git a/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/BindingURICalculator.java b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/BindingURICalculator.java
new file mode 100644
index 0000000000..c37188a5dd
--- /dev/null
+++ b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/BindingURICalculator.java
@@ -0,0 +1,35 @@
+/*
+ * 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.binding;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * A class with binding specific functions related to binding URI calculation
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BindingURICalculator {
+
+ public String getBindingType();
+
+ public String getProtocol(Binding binding);
+
+}
diff --git a/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/BindingURICalculatorExtensionPoint.java b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/BindingURICalculatorExtensionPoint.java
new file mode 100644
index 0000000000..d0148381d6
--- /dev/null
+++ b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/BindingURICalculatorExtensionPoint.java
@@ -0,0 +1,52 @@
+/*
+ * 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.binding;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * An extension point for binding URI calculators
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BindingURICalculatorExtensionPoint {
+
+ /**
+ * Add a BindingURICalculator using the contribution type as the key.
+ *
+ * @param bindingURICalculator The binding URI calculator
+ */
+ void addBindingURICalculator(BindingURICalculator bindingURICalculator);
+
+ /**
+ * Remove a BindingURICalculator.
+ *
+ * @param bindingURICalculator The binding URI calculator
+ */
+ void removeBindingURICalculator(BindingURICalculator bindingURICalculator);
+
+ /**
+ * Returns the BindingURICalculator for the given contribution type.
+ *
+ * @param binding The binding for which the URI calculator is required
+ * @return The binding URI calculator
+ */
+ BindingURICalculator getBindingURICalculator(Binding binding);
+
+} \ No newline at end of file
diff --git a/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/DefaultBindingURICalculatorExtensionPoint.java b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/DefaultBindingURICalculatorExtensionPoint.java
new file mode 100644
index 0000000000..ae8b33a006
--- /dev/null
+++ b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/DefaultBindingURICalculatorExtensionPoint.java
@@ -0,0 +1,124 @@
+/*
+ * 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.binding;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.contribution.service.ContributionException;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.util.ServiceDeclaration;
+import org.apache.tuscany.sca.contribution.util.ServiceDiscovery;
+
+/**
+ * Default implementation of a binding URI calculator extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultBindingURICalculatorExtensionPoint implements BindingURICalculatorExtensionPoint {
+
+ private Map<String, BindingURICalculator> bindingURICalculators = new HashMap<String, BindingURICalculator>();
+ private boolean loaded;
+
+ public DefaultBindingURICalculatorExtensionPoint() {
+ }
+
+ public void addBindingURICalculator(BindingURICalculator bindingURICalculator) {
+ bindingURICalculators.put(bindingURICalculator.getBindingType(), bindingURICalculator);
+ }
+
+ public void removeBindingURICalculator(BindingURICalculator bindingURICalculator) {
+ bindingURICalculators.remove(bindingURICalculator.getBindingType());
+ }
+
+ public BindingURICalculator getBindingURICalculator(Binding binding) {
+ loadbindingURICalculators();
+ return bindingURICalculators.get(binding.getClass().getName());
+ }
+
+ private void loadbindingURICalculators() {
+ if (loaded)
+ return;
+
+ // Get the bindingURICalculator service declarations
+ Set<ServiceDeclaration> bindingURICalculatorDeclarations;
+ try {
+ bindingURICalculatorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(BindingURICalculator.class);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration bindingURICalculatorDeclaration: bindingURICalculatorDeclarations) {
+ Map<String, String> attributes = bindingURICalculatorDeclaration.getAttributes();
+
+ // Load a URL artifact bindingURICalculator
+ String bindingType = attributes.get("binding");
+
+ // Create a bindingURICalculator wrapper and register it
+ BindingURICalculator bindingURICalculator = new LazyBindingURICalculator(bindingType, bindingURICalculatorDeclaration);
+ addBindingURICalculator(bindingURICalculator);
+ }
+
+ loaded = true;
+ }
+
+ /**
+ * A facade for contribution bindingURICalculators.
+ */
+ private static class LazyBindingURICalculator implements BindingURICalculator {
+
+ private ServiceDeclaration bindingURICalculatorDeclaration;
+ private String bindingType;
+ private BindingURICalculator bindingURICalculator;
+
+ private LazyBindingURICalculator(String contributionType, ServiceDeclaration bindingURICalculatorDeclaration) {
+ this.bindingURICalculatorDeclaration = bindingURICalculatorDeclaration;
+ this.bindingType = contributionType;
+ }
+
+ public String getBindingType() {
+ return bindingType;
+ }
+
+ public String getProtocol(Binding binding) {
+ return getbindingURICalculator().getProtocol(binding);
+ }
+
+ private BindingURICalculator getbindingURICalculator() {
+ if (bindingURICalculator == null) {
+ try {
+ Class<BindingURICalculator> bindingURICalculatorClass = (Class<BindingURICalculator>)bindingURICalculatorDeclaration.loadClass();
+ Constructor<BindingURICalculator> constructor = bindingURICalculatorClass.getConstructor();
+ bindingURICalculator = constructor.newInstance();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return bindingURICalculator;
+ }
+ }
+}
diff --git a/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/feed/atom/AtomBindingURICalculator.java b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/feed/atom/AtomBindingURICalculator.java
new file mode 100644
index 0000000000..97aa08f744
--- /dev/null
+++ b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/feed/atom/AtomBindingURICalculator.java
@@ -0,0 +1,41 @@
+/*
+ * 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.binding.feed.atom;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.BindingURICalculator;
+import org.apache.tuscany.sca.binding.feed.AtomBinding;
+
+/**
+ * A class with binding specific functions related to binding URI calculation
+ *
+ * @version $Rev$ $Date$
+ */
+public class AtomBindingURICalculator implements BindingURICalculator {
+
+ public String getBindingType(){
+ return AtomBinding.class.getName();
+ }
+
+ public String getProtocol(Binding binding){
+ return "http";
+ }
+
+}
diff --git a/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingURICalculator.java b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingURICalculator.java
new file mode 100644
index 0000000000..7d0f8fbc26
--- /dev/null
+++ b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingURICalculator.java
@@ -0,0 +1,40 @@
+/*
+ * 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.binding.http;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.BindingURICalculator;
+
+/**
+ * A class with binding specific functions related to binding URI calculation
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPBindingURICalculator implements BindingURICalculator {
+
+ public String getBindingType(){
+ return HTTPBinding.class.getName();
+ }
+
+ public String getProtocol(Binding binding){
+ return "http";
+ }
+
+}
diff --git a/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingURICalculator.java b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingURICalculator.java
new file mode 100644
index 0000000000..1debd96286
--- /dev/null
+++ b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingURICalculator.java
@@ -0,0 +1,41 @@
+/*
+ * 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.binding.jsonrpc;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.BindingURICalculator;
+
+
+/**
+ * A class with binding specific functions related to binding URI calculation
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCBindingURICalculator implements BindingURICalculator {
+
+ public String getBindingType(){
+ return JSONRPCBinding.class.getName();
+ }
+
+ public String getProtocol(Binding binding){
+ return "http";
+ }
+
+}
diff --git a/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/sca/SCABindingURICalculator.java b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/sca/SCABindingURICalculator.java
new file mode 100644
index 0000000000..60b693f96b
--- /dev/null
+++ b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/sca/SCABindingURICalculator.java
@@ -0,0 +1,41 @@
+/*
+ * 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.binding.sca;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.binding.BindingURICalculator;
+
+/**
+ * A class with binding specific functions related to binding URI calculation
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCABindingURICalculator implements BindingURICalculator {
+
+ public String getBindingType(){
+ return SCABinding.class.getName();
+ }
+
+ public String getProtocol(Binding binding){
+ return "http";
+ }
+
+}
diff --git a/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingURICalculator.java b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingURICalculator.java
new file mode 100644
index 0000000000..515188b011
--- /dev/null
+++ b/sandbox/slaws/modules/domain-rework/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingURICalculator.java
@@ -0,0 +1,41 @@
+/*
+ * 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.binding.ws.axis2;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.BindingURICalculator;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+
+/**
+ * A class with binding specific functions related to binding URI calculation
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2BindingURICalculator implements BindingURICalculator {
+
+ public String getBindingType(){
+ return WebServiceBinding.class.getName();
+ }
+
+ public String getProtocol(Binding binding){
+ return "http";
+ }
+
+}