From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/calculator/AddService.java | 31 +++++++ .../src/main/java/calculator/AddServiceImpl.java | 31 +++++++ .../main/java/calculator/CalculatorService.java | 35 ++++++++ .../java/calculator/CalculatorServiceImpl.java | 74 +++++++++++++++++ .../src/main/java/calculator/DivideService.java | 28 +++++++ .../main/java/calculator/DivideServiceImpl.java | 30 +++++++ .../src/main/java/calculator/MultiplyService.java | 28 +++++++ .../main/java/calculator/MultiplyServiceImpl.java | 30 +++++++ .../src/main/java/calculator/SubtractService.java | 31 +++++++ .../main/java/calculator/SubtractServiceImpl.java | 31 +++++++ ...ny.sca.endpointresolver.EndpointResolverFactory | 19 +++++ .../src/main/resources/nodeA/Calculator.composite | 41 +++++++++ .../resources/nodeA/META-INF/sca-contribution.xml | 24 ++++++ .../src/main/resources/nodeB/Calculator.composite | 32 +++++++ .../resources/nodeB/META-INF/sca-contribution.xml | 24 ++++++ .../src/main/resources/nodeC/Calculator.composite | 32 +++++++ .../resources/nodeC/META-INF/sca-contribution.xml | 24 ++++++ .../sca/BindingScaEndpointResolverFactoryImpl.java | 50 +++++++++++ .../sca/BindingScaEndpointResolverImpl.java | 72 ++++++++++++++++ .../LateReferenceResolutionTestCase.java | 97 ++++++++++++++++++++++ .../src/test/java/calculator/TestRegistryImpl.java | 40 +++++++++ 21 files changed, 804 insertions(+) create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/AddService.java create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/AddServiceImpl.java create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/CalculatorService.java create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/DivideService.java create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/MultiplyService.java create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/SubtractService.java create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactory create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeA/Calculator.composite create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeA/META-INF/sca-contribution.xml create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeB/Calculator.composite create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeB/META-INF/sca-contribution.xml create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeC/Calculator.composite create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeC/META-INF/sca-contribution.xml create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/binding/sca/BindingScaEndpointResolverFactoryImpl.java create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/binding/sca/BindingScaEndpointResolverImpl.java create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/calculator/LateReferenceResolutionTestCase.java create mode 100644 sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/calculator/TestRegistryImpl.java (limited to 'sandbox/axis2-1.4/itest/late-reference-resolution/src') diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/AddService.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..d7dc4473ad --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/AddService.java @@ -0,0 +1,31 @@ +/* + * 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 calculator; + +import org.osoa.sca.annotations.Remotable; + +/** + * The Add service interface + */ +@Remotable +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/AddServiceImpl.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..e9b7e254e5 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,31 @@ +/* + * 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 calculator; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + System.out.println("AddService - add " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/CalculatorService.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/CalculatorService.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 calculator; + + +/** + * The Calculator service interface. + */ +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); + +} diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..da869e00fd --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,74 @@ +/* + * 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 calculator; + +import org.osoa.sca.annotations.Reference; + + +/** + * An implementation of the Calculator service. + */ +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + public double add(double n1, double n2) { + System.out.println("CalculatorService - add " + n1 + " and " + n2); + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + System.out.println("CalculatorService - subtract " + n1 + " and " + n2); + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + System.out.println("CalculatorService - multiply " + n1 + " and " + n2); + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + System.out.println("CalculatorService - divide " + n1 + " and " + n2); + return divideService.divide(n1, n2); + } + +} diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/DivideService.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/DivideService.java @@ -0,0 +1,28 @@ +/* + * 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 calculator; + +/** + * The divide service interface + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/DivideServiceImpl.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..f7ac0b7287 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,30 @@ +/* + * 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 calculator; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + return n1 / n2; + } + +} diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/MultiplyService.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,28 @@ +/* + * 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 calculator; + +/** + * The interface for the multiply service + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/MultiplyServiceImpl.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..b7dca792b2 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,30 @@ +/* + * 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 calculator; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + return n1 * n2; + } + +} diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/SubtractService.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..78ab9c6ee0 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/SubtractService.java @@ -0,0 +1,31 @@ +/* + * 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 calculator; + +import org.osoa.sca.annotations.Remotable; + +/** + * The interface for the multiply service + */ +@Remotable +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/SubtractServiceImpl.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1010207154 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,31 @@ +/* + * 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 calculator; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + System.out.println("SubtractService - subtract " + n1 + " and " + n2); + return n1 - n2; + } + +} diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactory b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactory new file mode 100644 index 0000000000..c53b55aacf --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactory @@ -0,0 +1,19 @@ +# 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. + +# Implementation class for the binding extension +binding.sca.BindingScaEndpointResolverFactoryImpl;model=org.apache.tuscany.sca.assembly.SCABinding diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeA/Calculator.composite b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeA/Calculator.composite new file mode 100644 index 0000000000..378d6e9706 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeA/Calculator.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeA/META-INF/sca-contribution.xml b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeA/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..db255e0232 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeA/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeB/Calculator.composite b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeB/Calculator.composite new file mode 100644 index 0000000000..3fb16fa619 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeB/Calculator.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeB/META-INF/sca-contribution.xml b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeB/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..130157ac04 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeB/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeC/Calculator.composite b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeC/Calculator.composite new file mode 100644 index 0000000000..c615b4355a --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeC/Calculator.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeC/META-INF/sca-contribution.xml b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeC/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..cba0a5c281 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/main/resources/nodeC/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/binding/sca/BindingScaEndpointResolverFactoryImpl.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/binding/sca/BindingScaEndpointResolverFactoryImpl.java new file mode 100644 index 0000000000..e4bd3035e2 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/binding/sca/BindingScaEndpointResolverFactoryImpl.java @@ -0,0 +1,50 @@ +/* + * 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 binding.sca; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.SCABinding; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.endpointresolver.EndpointResolver; +import org.apache.tuscany.sca.endpointresolver.EndpointResolverFactory; + +/** + * The factory for creating endpoint Binding providers + * + * @version $Rev$ $Date$ + */ +public class BindingScaEndpointResolverFactoryImpl implements EndpointResolverFactory { + + private ExtensionPointRegistry extensionPoints; + + public BindingScaEndpointResolverFactoryImpl(ExtensionPointRegistry extensionPoints) { + this.extensionPoints = extensionPoints; + } + + public EndpointResolver createEndpointResolver(Endpoint endpoint, Binding binding) { + + return new BindingScaEndpointResolverImpl(extensionPoints, endpoint, binding); + } + + public Class getModelType() { + return SCABinding.class; + } +} diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/binding/sca/BindingScaEndpointResolverImpl.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/binding/sca/BindingScaEndpointResolverImpl.java new file mode 100644 index 0000000000..c6e0689837 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/binding/sca/BindingScaEndpointResolverImpl.java @@ -0,0 +1,72 @@ +/* + * 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 binding.sca; + + +import java.util.logging.Logger; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.SCABinding; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.endpointresolver.EndpointResolver; + +import calculator.LateReferenceResolutionTestCase; + +/** + * The endpoint resolver allows unresolved endpoints to be plumbed into + * the runtime start and message send processing as a hook to late resolution + * of target services + * + * @version $Rev$ $Date$ + */ +public class BindingScaEndpointResolverImpl implements EndpointResolver { + + private final static Logger logger = Logger.getLogger(BindingScaEndpointResolverImpl.class.getName()); + + private Endpoint endpoint; + private SCABinding binding; + + public BindingScaEndpointResolverImpl(ExtensionPointRegistry extensionPoints, + Endpoint endpoint, + Binding binding) { + this.endpoint = endpoint; + this.binding = (SCABinding)binding; + } + + public void start(){ + // do nothing + } + + public void resolve() { + if (endpoint.isUnresolved()){ + // I can cheat here because I know this test only has + // SCA Bindings in it so all I have to do it find the URL + // of the endpoint + String targetURL = LateReferenceResolutionTestCase.registry.locateService(endpoint.getTargetName()); + binding.setURI(targetURL); + endpoint.setSourceBinding(binding); + } + } + + public void stop(){ + // do nothing + } +} diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/calculator/LateReferenceResolutionTestCase.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/calculator/LateReferenceResolutionTestCase.java new file mode 100644 index 0000000000..94270edd91 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/calculator/LateReferenceResolutionTestCase.java @@ -0,0 +1,97 @@ +/* + * 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 calculator; + + +import java.io.File; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCANode2; +import org.apache.tuscany.sca.node.SCANode2Factory; +import org.apache.tuscany.sca.node.SCANode2Factory.SCAContribution; +import org.apache.tuscany.sca.node.launcher.DomainManagerLauncher; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Runs a distributed domain in a single VM by using and in memory + * implementation of the distributed domain + */ +public class LateReferenceResolutionTestCase { + + private static SCANode2 nodeA; + private static SCANode2 nodeB; + private static SCANode2 nodeC; + + private static CalculatorService calculatorService; + + public static TestRegistryImpl registry = new TestRegistryImpl(); + + @BeforeClass + public static void init() throws Exception { + + try { + System.out.println("Setting up domain"); + + + SCANode2Factory nodeFactory = SCANode2Factory.newInstance(); + nodeC = nodeFactory.createSCANode(new File("src/main/resources/nodeC/Calculator.composite").toURL().toString(), + new SCAContribution("NodeC", + new File("src/main/resources/nodeC").toURL().toString())); + nodeB = nodeFactory.createSCANode(new File("src/main/resources/nodeB/Calculator.composite").toURL().toString(), + new SCAContribution("NodeB", + new File("src/main/resources/nodeB").toURL().toString())); + nodeA = nodeFactory.createSCANode(new File("src/main/resources/nodeA/Calculator.composite").toURL().toString(), + new SCAContribution("NodeA", + new File("src/main/resources/nodeA").toURL().toString())); + + nodeC.start(); + nodeB.start(); + nodeA.start(); + + SCAClient client = (SCAClient)nodeA; + calculatorService = + client.getService(CalculatorService.class, "CalculatorServiceComponentA"); + + } catch(Exception ex){ + System.err.println(ex.toString()); + } + + } + + @AfterClass + public static void destroy() throws Exception { + nodeC.stop(); + nodeB.stop(); + nodeA.stop(); + } + + @Test + public void testCalculator() throws Exception { + + // Calculate + Assert.assertEquals(calculatorService.add(3, 2), 5.0); + Assert.assertEquals(calculatorService.subtract(3, 2), 1.0); + Assert.assertEquals(calculatorService.multiply(3, 2), 6.0); + Assert.assertEquals(calculatorService.divide(3, 2), 1.5); + } +} diff --git a/sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/calculator/TestRegistryImpl.java b/sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/calculator/TestRegistryImpl.java new file mode 100644 index 0000000000..57afc9ea50 --- /dev/null +++ b/sandbox/axis2-1.4/itest/late-reference-resolution/src/test/java/calculator/TestRegistryImpl.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 calculator; + +/** + * A dummy domain registry component + */ +public class TestRegistryImpl { + + public String locateService(String targetServiceName){ + String targetURL = null; + + // In reality of course a registry would have to be initialized + // with the real target service endpoints but in this test + // we know what they are going to be ahead of time + if (targetServiceName.equals("AddServiceComponentB")){ + targetURL = "http://localhost:8085/" + targetServiceName; + } else if (targetServiceName.equals("SubtractServiceComponentC")){ + targetURL = "http://localhost:8086/" + targetServiceName; + } + + return targetURL; + } +} -- cgit v1.2.3