summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/core/src
diff options
context:
space:
mode:
authorbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-08-05 17:51:41 +0000
committerbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-08-05 17:51:41 +0000
commitbaea5517f05f0313243ed0c663b59470e6693c20 (patch)
tree77aacc5ef2d07670a2f7a1a7a1ba1d447b41b2c3 /sca-java-2.x/trunk/modules/core/src
parentcbaa47ea3785db646625272b8110519cf591728d (diff)
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
Diffstat (limited to 'sca-java-2.x/trunk/modules/core/src')
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java20
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) {