From cbaa47ea3785db646625272b8110519cf591728d Mon Sep 17 00:00:00 2001 From: bdaniel Date: Thu, 5 Aug 2010 16:59:31 +0000 Subject: Throw an IllegalArgumentException if createSelfReference is called with a businessInterface that is not valid for any service in the component (JCA-9011) git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@982693 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/sca/core/context/impl/ComponentContextImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sca-java-2.x/trunk/modules/core/src/main') 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 a246393803..bf74482a1e 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 @@ -256,6 +256,8 @@ public class ComponentContextImpl implements RuntimeComponentContext { ComponentService service = getSingleService(component); try { return createSelfReference(businessInterface, service); + } catch (IllegalArgumentException iae) { + throw iae; } catch (Exception e) { throw new ServiceRuntimeException(e.getMessage(), e); } @@ -301,6 +303,8 @@ public class ComponentContextImpl implements RuntimeComponentContext { (RuntimeEndpointReference)createEndpointReference(component, service, null, businessInterface); ref.setComponent(component); return getServiceReference(businessInterface, ref); + } catch (IllegalArgumentException iae) { + throw iae; } catch (Exception e) { throw new ServiceRuntimeException(e); } @@ -465,7 +469,8 @@ public class ComponentContextImpl implements RuntimeComponentContext { } if(!compatible) { - interfaceContract = null; + // JCA-9011 + throw new IllegalArgumentException("Business interface " + businessInterface.getName() + " is not compatible with " + interfaceContract.getInterface().getClass().getName()); } return interfaceContract; -- cgit v1.2.3