From baea5517f05f0313243ed0c663b59470e6693c20 Mon Sep 17 00:00:00 2001 From: bdaniel Date: Thu, 5 Aug 2010 17:51:41 +0000 Subject: Throw IllegalArgumentExceptions on various ComponentContext methods to fix JCA 9006, 9008, 9009 9010, and 9012 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@982710 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/core/context/impl/ComponentContextImpl.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'sca-java-2.x/trunk/modules/core/src') 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 getProperty(Class 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(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(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> serviceRefs = new ArrayList>(); 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) { -- cgit v1.2.3