From 7122c1e316fdaf40f849dc095fee6b646e889cd2 Mon Sep 17 00:00:00 2001 From: slaws Date: Wed, 25 May 2011 12:39:38 +0000 Subject: TUSCANY-3868 - allow binding to be retrieved by name git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1127498 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/tuscany/sca/assembly/Contract.java | 7 +++++++ .../java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java | 9 +++++++++ .../java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java | 9 +++++++++ .../corba/testing/service/mocks/TestRuntimeComponentService.java | 5 +++++ 4 files changed, 30 insertions(+) (limited to 'sca-java-2.x/trunk') diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java index 0c57c74ec0..b3a1bf9b16 100644 --- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java +++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java @@ -37,6 +37,13 @@ public interface Contract extends AbstractContract, PolicySubject, Cloneable { * @return the bindings supported by this contract */ List getBindings(); + + /** + * Return the named binding + * + * @return the named binding or null if it can't be found + */ + Binding getBinding(String name); /** * Returns a binding of the specified type or null if there is no such diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java index f0c884797c..e157b78a7c 100644 --- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java +++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java @@ -70,6 +70,15 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C public List getBindings() { return bindings; } + + public Binding getBinding(String name) { + for (Binding binding : bindings) { + if (binding.getName().equals(name)) { + return binding; + } + } + return null; + } public B getBinding(Class bindingClass) { for (Binding binding : bindings) { diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java index f8eb0fa6ec..618d0d6e7b 100644 --- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java +++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java @@ -57,6 +57,15 @@ public class ServiceImpl extends AbstractServiceImpl implements Service, Cloneab public List getBindings() { return bindings; } + + public Binding getBinding(String name) { + for (Binding binding : bindings) { + if (binding.getName().equals(name)) { + return binding; + } + } + return null; + } public B getBinding(Class bindingClass) { for (Binding binding : bindings) { diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java index 175d81b7f0..e582ba0352 100644 --- a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java @@ -109,6 +109,11 @@ public class TestRuntimeComponentService implements RuntimeComponentService { // TODO Auto-generated method stub return null; } + + public Binding getBinding(String name) { + // TODO Auto-generated method stub + return null; + } public List getBindings() { // TODO Auto-generated method stub -- cgit v1.2.3