You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by bd...@apache.org on 2010/08/05 19:51:41 UTC

svn commit: r982710 - /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java

Author: bdaniel
Date: Thu Aug  5 17:51:41 2010
New Revision: 982710

URL: http://svn.apache.org/viewvc?rev=982710&view=rev
Log:
Throw IllegalArgumentExceptions on various ComponentContext methods to fix JCA 9006, 9008, 9009 9010, and 9012

Modified:
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java?rev=982710&r1=982709&r2=982710&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java Thu Aug  5 17:51:41 2010
@@ -219,7 +219,8 @@ public class ComponentContextImpl implem
     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 implem
                     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 implem
 	            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 implem
                 (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 implem
         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 implem
                     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) {