diff options
3 files changed, 61 insertions, 4 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java index 7bb1244045..d96060e10b 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java @@ -32,6 +32,13 @@ import org.apache.tuscany.sca.policy.PolicySubject; * @version $Rev$ $Date$ */ public interface EndpointReference extends Base, PolicySubject, Cloneable, Serializable { + + public static final int NOT_CONFIGURED = 0; + public static final int RESOLVED_BINDING = 1; + public static final int WIRED_TARGET_NOT_FOUND = 2; + public static final int WIRED_TARGET_FOUND_BUT_NOT_MATCHED = 3; + public static final int WIRED_TARGET_FOUND_AND_MATCHED = 4; + /** * Get the structural URI of the reference binding * @return The structural URI of the reference/binding @@ -163,4 +170,20 @@ public interface EndpointReference extends Base, PolicySubject, Cloneable, Seria * @param registry */ void setExtensionPointRegistry(ExtensionPointRegistry registry); + + /** + * Rather than relying on combinations of unresolved flags and + * other data we maintain a status enumeration + * + * @return status + */ + int getStatus(); + + /** + * Rather than relying on combinations of unresolved flags and + * other data we maintain a status enumeration + * + * @param status the new status + */ + void setStatus(int status); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java index bc8493048b..8ae7906360 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java @@ -153,7 +153,9 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI // are matched and bindings are configured later EndpointReference endpointRef = createEndpointRef( component, reference, false ); endpointRef.setTargetEndpoint( createEndpoint(targetComponent, targetComponentService, true) ); + endpointRef.setStatus(EndpointReference.WIRED_TARGET_FOUND_BUT_NOT_MATCHED); reference.getEndpointReferences().add(endpointRef); + // Stop with the first match for 0..1 and 1..1 references if (multiplicity == Multiplicity.ZERO_ONE || @@ -199,6 +201,7 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI // are matched and bindings are configured later EndpointReference endpointRef = createEndpointRef( component, reference, false ); endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true)); + endpointRef.setStatus(EndpointReference.WIRED_TARGET_FOUND_BUT_NOT_MATCHED); reference.getEndpointReferences().add(endpointRef); } else { warning(monitor, "ReferenceIncompatibleInterface", @@ -212,6 +215,7 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI EndpointReference endpointRef = createEndpointRef( component, reference, true ); endpointRef.setTargetEndpoint(createEndpoint(component, targetName)); endpointRef.setRemote(true); + endpointRef.setStatus(EndpointReference.WIRED_TARGET_NOT_FOUND); reference.getEndpointReferences().add(endpointRef); warning(monitor, "ComponentReferenceTargetNotFound", composite, @@ -242,10 +246,12 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI // Assume that the system need to resolve this binding later as // it's the SCA binding endpointRef.setTargetEndpoint(createEndpoint(true)); + endpointRef.setStatus(EndpointReference.NOT_CONFIGURED); } else { // The user has configured a binding so assume they know what // they are doing and mark in as already resolved. endpointRef.setTargetEndpoint(createEndpoint(false)); + endpointRef.setStatus(EndpointReference.RESOLVED_BINDING); } endpointRef.setRemote(true); reference.getEndpointReferences().add(endpointRef); @@ -277,6 +283,7 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI // are matched and bindings are configured later EndpointReference endpointRef = createEndpointRef( component, reference, binding, null, false ); endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true)); + endpointRef.setStatus(EndpointReference.WIRED_TARGET_FOUND_BUT_NOT_MATCHED); reference.getEndpointReferences().add(endpointRef); } else { warning(monitor, "ReferenceIncompatibleInterface", @@ -294,6 +301,7 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI endpoint.setBinding(binding); endpointRef.setTargetEndpoint(endpoint); endpointRef.setRemote(true); + endpointRef.setStatus(EndpointReference.RESOLVED_BINDING); reference.getEndpointReferences().add(endpointRef); } // end if } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java index 7ff0b45e97..f017b598bf 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java @@ -39,7 +39,10 @@ import org.apache.tuscany.sca.policy.PolicySubject; * @version $Rev$ $Date$ */ public class EndpointReferenceImpl implements EndpointReference { - private static final long serialVersionUID = 8838066441709300972L; + private static final long serialVersionUID = 8838066441709300972L; + + + protected ExtensionPointRegistry registry; protected boolean unresolved = true; protected String uri; @@ -50,6 +53,7 @@ public class EndpointReferenceImpl implements EndpointReference { protected List<Intent> requiredIntents = new ArrayList<Intent>(); protected InterfaceContract interfaceContract; protected boolean remote = false; + protected int status; // the target of the endpoint reference protected Endpoint targetEndpoint; @@ -168,9 +172,23 @@ public class EndpointReferenceImpl implements EndpointReference { if (getURI() != null) { output += " URI = " + uri; } - - if (unresolved) { - output += " [Unresolved]"; + + switch (status) { + case 0: + output += " NOT_CONFIGURED "; + break; + case 1: + output += " RESOLVED_BINDING "; + break; + case 2: + output += " WIRED_TARGET_NOT_FOUND "; + break; + case 3: + output += " WIRED_TARGET_FOUND_BUT_NOT_MATCHED "; + break; + case 4: + output += " WIRED_TARGET_FOUND_AND_MATCHED "; + break; } if (targetEndpoint != null) { @@ -219,4 +237,12 @@ public class EndpointReferenceImpl implements EndpointReference { public void setExtensionPointRegistry(ExtensionPointRegistry registry) { this.registry = registry; } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } } |