diff options
Diffstat (limited to '')
-rw-r--r-- | sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java index bf74482a1e..f8df72241c 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java @@ -219,7 +219,8 @@ public class ComponentContextImpl implements RuntimeComponentContext { public <B> B getProperty(Class<B> type, String propertyName) { for (ComponentProperty p : component.getProperties()) { if (propertyName.equals(p.getName())) { - return propertyFactory.createPropertyValue(p, type); + B o = propertyFactory.createPropertyValue(p, type); + return o; } } throw new ServiceRuntimeException("Property not found: " + propertyName); @@ -283,7 +284,9 @@ public class ComponentContextImpl implements RuntimeComponentContext { return getServiceReference(businessInterface, (RuntimeEndpoint)endpoint); } } - throw new ServiceRuntimeException("Service not found: " + serviceName); + throw new IllegalArgumentException("Service not found: " + serviceName); + } catch (IllegalArgumentException iae) { + throw iae; } catch (ServiceRuntimeException e) { throw e; } catch (Exception e) { @@ -349,6 +352,8 @@ public class ComponentContextImpl implements RuntimeComponentContext { ref.setComponent(component); result = new ServiceReferenceImpl<B>(businessInterface, endpointReference, component.getComponentContext().getCompositeContext()); } + } catch (IllegalArgumentException iae ) { + throw iae; } catch (Exception e) { throw new ServiceRuntimeException(e); } @@ -366,6 +371,8 @@ public class ComponentContextImpl implements RuntimeComponentContext { (RuntimeEndpointReference)createEndpointReference(endpoint, businessInterface); ref.setComponent(component); return new ServiceReferenceImpl<B>(businessInterface, ref, compositeContext); + } catch (IllegalArgumentException iae) { + throw iae; } catch (Exception e) { throw new ServiceRuntimeException(e); } @@ -504,6 +511,11 @@ public class ComponentContextImpl implements RuntimeComponentContext { try { for (ComponentReference ref : component.getReferences()) { if (referenceName.equals(ref.getName())) { + if ( ref.getMultiplicity() == Multiplicity.ONE_ONE ) + throw new IllegalArgumentException("Reference " + referenceName + " is not a valid argument for getServiceReferences because it has a multiplicity of 1..1"); + if (ref.getMultiplicity() == Multiplicity.ZERO_ONE) + throw new IllegalArgumentException("Reference " + referenceName + " is not a valid argument for getServiceReferences because it has a multiplicity of 0..1"); + ArrayList<ServiceReference<B>> serviceRefs = new ArrayList<ServiceReference<B>>(); for (EndpointReference endpointReference : ref.getEndpointReferences()) { RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference; @@ -512,7 +524,9 @@ public class ComponentContextImpl implements RuntimeComponentContext { return serviceRefs; } } - throw new ServiceRuntimeException("Reference not found: " + referenceName); + throw new IllegalArgumentException("Reference not found: " + referenceName); + } catch (IllegalArgumentException iae) { + throw iae; } catch (ServiceRuntimeException e) { throw e; } catch (Exception e) { |