You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/12/24 08:31:42 UTC

svn commit: r489997 - in /incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core: builder/ wire/

Author: jmarino
Date: Sat Dec 23 23:31:41 2006
New Revision: 489997

URL: http://svn.apache.org/viewvc?view=rev&rev=489997
Log:
simplify exception throwing in connector

Modified:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WireConnectException.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java?view=diff&rev=489997&r1=489996&r2=489997
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java Sat Dec 23 23:31:41 2006
@@ -104,23 +104,16 @@
             }
             return;
         } else if (optimizable && sourceWire.getContainer().isSystem() && targetWire.getContainer().isSystem()) {
+            // system services are directly wired withut invocation chains
             // JFM FIXME test this
             sourceWire.setTargetWire(targetWire);
             return;
         }
         for (InboundInvocationChain inboundChain : sourceWire.getInvocationChains().values()) {
-            // match wire chains
+            // match invocation chains
             OutboundInvocationChain outboundChain = targetChains.get(inboundChain.getOperation());
             if (outboundChain == null) {
-                String serviceName = sourceWire.getServiceName();
-                String sourceName = sourceWire.getContainer().getName();
-                String refName = targetWire.getReferenceName();
-                String targetName = targetWire.getContainer().getName();
-                throw new IncompatibleInterfacesException("Incompatible source and target interfaces",
-                    sourceName,
-                    refName,
-                    targetName,
-                    serviceName);
+                throw new IncompatibleInterfacesException(sourceWire, targetWire);
             }
             connect(inboundChain, outboundChain);
         }
@@ -164,30 +157,16 @@
             Operation<?> operation = outboundChain.getOperation();
             InboundInvocationChain inboundChain = targetChains.get(operation);
             if (inboundChain == null) {
-                String sourceName = sourceWire.getContainer().getName();
-                String refName = sourceWire.getReferenceName();
-                String targetName = targetWire.getContainer().getName();
-                String serviceName = targetWire.getServiceName();
-                throw new IncompatibleInterfacesException("Incompatible interfaces",
-                    sourceName,
-                    refName,
-                    targetName,
-                    serviceName);
+                throw new IncompatibleInterfacesException(sourceWire, targetWire);
             }
             Operation<?> inboundOperation = inboundChain.getOperation();
             boolean isOneWayOperation = operation.isNonBlocking();
             boolean operationHasCallback = contract.getCallbackName() != null;
             if (isOneWayOperation && operationHasCallback) {
-                String sourceName = sourceWire.getContainer().getName();
-                String refName = sourceWire.getReferenceName();
-                String targetName = targetWire.getContainer().getName();
-                String serviceName = targetWire.getServiceName();
                 throw new IllegalCallbackException("Operation cannot be marked one-way and have a callback",
                     inboundOperation.getName(),
-                    sourceName,
-                    refName,
-                    targetName,
-                    serviceName);
+                    sourceWire,
+                    targetWire);
             }
             TargetInvoker invoker = null;
             if (target instanceof Component) {
@@ -200,16 +179,7 @@
                 try {
                     invoker = component.createTargetInvoker(portName, inboundOperation, targetWire);
                 } catch (TargetInvokerCreationException e) {
-                    String sourceName = sourceWire.getContainer().getName();
-                    String refName = sourceWire.getReferenceName();
-                    String targetName = targetWire.getContainer().getName();
-                    String serviceName = targetWire.getServiceName();
-                    throw new WireConnectException("Error connecting source and target",
-                        sourceName,
-                        refName,
-                        targetName,
-                        serviceName,
-                        e);
+                    throw new WireConnectException("Error connecting source and target", sourceWire, targetWire, e);
                 }
             } else if (target instanceof Reference) {
                 Reference reference = (Reference) target;
@@ -252,16 +222,9 @@
             Operation<?> operation = inboundChain.getOperation();
             if (sourceCallbackChains != null && sourceCallbackChains.get(operation) != null) {
                 String opName = operation.getName();
-                String sourceName = sourceWire.getContainer().getName();
-                String refName = sourceWire.getReferenceName();
-                String targetName = targetWire.getContainer().getName();
-                String serviceName = targetWire.getServiceName();
                 throw new IllegalCallbackException("Source callback chain should not exist for operation",
                     opName,
-                    sourceName,
-                    refName,
-                    targetName,
-                    serviceName);
+                    sourceWire, targetWire);
             }
 
             Operation targetOp =
@@ -274,15 +237,9 @@
                 try {
                     invoker = component.createTargetInvoker(null, operation, null);
                 } catch (TargetInvokerCreationException e) {
-                    String sourceName = sourceWire.getContainer().getName();
-                    String refName = sourceWire.getReferenceName();
-                    String targetName = targetWire.getContainer().getName();
-                    String serviceName = targetWire.getServiceName();
                     throw new WireConnectException("Error connecting source and target",
-                        sourceName,
-                        refName,
-                        targetName,
-                        serviceName,
+                        sourceWire,
+                        targetWire,
                         e);
                 }
                 connect(outboundChain, inboundChain, invoker, false);
@@ -624,15 +581,7 @@
             Class<?> sourceInterface = sourceWire.getServiceContract().getInterfaceClass();
             Class<?> targetInterface = targetWire.getServiceContract().getInterfaceClass();
             if (!sourceInterface.isAssignableFrom(targetInterface)) {
-                String sourceName = sourceWire.getContainer().getName();
-                String refName = sourceWire.getReferenceName();
-                String targetName = targetWire.getContainer().getName();
-                String serviceName = targetWire.getServiceName();
-                throw new IncompatibleInterfacesException("Incompatible interfaces",
-                    sourceName,
-                    refName,
-                    targetName,
-                    serviceName);
+                throw new IncompatibleInterfacesException(sourceWire, targetWire);
             }
         } else {
             try {
@@ -640,15 +589,7 @@
                 ServiceContract targetContract = targetWire.getServiceContract();
                 wireService.checkCompatibility(sourceContract, targetContract, false);
             } catch (IncompatibleServiceContractException e) {
-                String sourceName = sourceWire.getContainer().getName();
-                String refName = sourceWire.getReferenceName();
-                String targetName = targetWire.getContainer().getName();
-                String serviceName = targetWire.getServiceName();
-                throw new IncompatibleInterfacesException("Incompatible interfaces",
-                    sourceName,
-                    refName,
-                    targetName,
-                    serviceName, e);
+                throw new IncompatibleInterfacesException(sourceWire, targetWire, e);
             }
         }
     }

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java?view=diff&rev=489997&r1=489996&r2=489997
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java Sat Dec 23 23:31:41 2006
@@ -19,6 +19,8 @@
 package org.apache.tuscany.core.builder;
 
 import org.apache.tuscany.spi.builder.WiringException;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
 
 /**
  * Denotes an illegal callback
@@ -39,4 +41,14 @@
         setTargetName(targetName);
         setTargetServiceName(serviceName);
     }
+
+
+    public IllegalCallbackException(String message, String identifier, OutboundWire source, InboundWire target) {
+        super(message, identifier);
+        setSourceName(source.getContainer().getName());
+        setReferenceName(source.getReferenceName());
+        setTargetName(target.getContainer().getName());
+        setTargetServiceName(target.getServiceName());
+    }
+
 }

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java?view=diff&rev=489997&r1=489996&r2=489997
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java Sat Dec 23 23:31:41 2006
@@ -19,6 +19,8 @@
 package org.apache.tuscany.core.builder;
 
 import org.apache.tuscany.spi.builder.WiringException;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
 
 /**
  * Denotes an attempt to wire incompatible interfaces
@@ -29,10 +31,10 @@
 
 
     public IncompatibleInterfacesException(String message,
-                                          String sourceName,
-                                          String referenceName,
-                                          String targetName,
-                                          String targetServiceName) {
+                                           String sourceName,
+                                           String referenceName,
+                                           String targetName,
+                                           String targetServiceName) {
         super(message);
         setSourceName(sourceName);
         setReferenceName(referenceName);
@@ -41,14 +43,39 @@
     }
 
     public IncompatibleInterfacesException(String message, String sourceName,
-                                          String referenceName,
-                                          String targetName,
-                                          String serviceName,
-                                          Throwable cause) {
+                                           String referenceName,
+                                           String targetName,
+                                           String serviceName,
+                                           Throwable cause) {
         super(message, cause);
         setSourceName(sourceName);
         setReferenceName(referenceName);
         setTargetName(targetName);
         setTargetServiceName(serviceName);
     }
+
+    public IncompatibleInterfacesException(InboundWire source, OutboundWire target) {
+        super("Incompatible source and target interfaces");
+        setTargetServiceName(source.getServiceName());
+        setSourceName(source.getContainer().getName());
+        setReferenceName(target.getReferenceName());
+        setTargetName(target.getContainer().getName());
+    }
+
+    public IncompatibleInterfacesException(OutboundWire source, InboundWire target) {
+        super("Incompatible source and target interfaces");
+        setTargetServiceName(target.getServiceName());
+        setSourceName(source.getContainer().getName());
+        setReferenceName(source.getReferenceName());
+        setTargetName(target.getContainer().getName());
+    }
+
+    public IncompatibleInterfacesException(OutboundWire source, InboundWire target, Throwable throwable) {
+        super("Incompatible source and target interfaces", throwable);
+        setTargetServiceName(target.getServiceName());
+        setSourceName(source.getContainer().getName());
+        setReferenceName(source.getReferenceName());
+        setTargetName(target.getContainer().getName());
+    }
+
 }

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WireConnectException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WireConnectException.java?view=diff&rev=489997&r1=489996&r2=489997
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WireConnectException.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WireConnectException.java Sat Dec 23 23:31:41 2006
@@ -19,6 +19,8 @@
 package org.apache.tuscany.core.builder;
 
 import org.apache.tuscany.spi.builder.WiringException;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
 
 /**
  * Denotes a general error connecting two wires
@@ -39,4 +41,14 @@
         setTargetName(targetName);
         setTargetServiceName(serviceName);
     }
+
+
+    public WireConnectException(String message, OutboundWire source, InboundWire target, Throwable throwable) {
+        super(message, throwable);
+        setSourceName(source.getContainer().getName());
+        setReferenceName(source.getReferenceName());
+        setTargetName(target.getContainer().getName());
+        setTargetServiceName(target.getServiceName());
+    }
+
 }

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java?view=diff&rev=489997&r1=489996&r2=489997
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java Sat Dec 23 23:31:41 2006
@@ -56,7 +56,6 @@
  * @version $Rev$ $Date$
  */
 public abstract class WireServiceExtension implements WireService {
-
     protected PolicyBuilderRegistry policyRegistry;
     protected WorkContext context;
 
@@ -204,7 +203,7 @@
         }
 
         // Notice that we skip inboundWire.setCallbackReferenceName
-        // First, an inbound inboundWire's callbackReferenceName is only retrieved by JavaAtomicComponent
+        // First, an inbound wire's callbackReferenceName is only retrieved by JavaAtomicComponent
         // to create a callback injector based on the callback reference member; a composite reference
         // should not need to do that
         // Second, a reference definition does not have a callback reference name like a service



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org