Start adding a more meaningful (compared to unresolved) status field to endpoint reference. not used in processing yet but gets printed out.

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@789359 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
slaws 2009-06-29 15:21:27 +00:00
parent aa9506ef7f
commit bf01346e47
3 changed files with 61 additions and 4 deletions

View file

@ -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);
}

View file

@ -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
}

View file

@ -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;
}
}