public QName getArtifactType() {
return ENDPOINT_REFERENCE_QNAME;
}
public EndpointReference read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
EndpointReference endpointReference = assemblyFactory.createEndpointReference();
if (reader.getEventType() == XMLStreamConstants.START_DOCUMENT) {
reader.nextTag();
}
Object model = extensionProcessor.read(reader, context);
if (model instanceof Composite) {
Composite composite = (Composite)model;
Component component = composite.getComponents().get(0);
ComponentReference reference = component.getReferences().get(0);
Binding binding = reference.getBindings().get(0);
endpointReference.setComponent(component);
endpointReference.setReference(reference);
reference.getEndpointReferences().add(endpointReference);
endpointReference.setBinding(binding);
// set up the EPR so that resolution will happen
// at wire creation time if needs be
Endpoint endpoint = assemblyFactory.createEndpoint();
endpointReference.setTargetEndpoint(endpoint);
if (reference.getTargets().size() > 0){
// create a dummy endpoint with the URI set so that
// the endpoint registry will be consulted
endpoint.setUnresolved(true);
endpoint.setURI(reference.getTargets().get(0).getName());
endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_NOT_FOUND);
endpointReference.setUnresolved(true);
} else {
endpoint.setUnresolved(false);
endpoint.setBinding(reference.getBindings().get(0));
endpointReference.setStatus(EndpointReference.Status.RESOLVED_BINDING);
endpointReference.setUnresolved(false);
}
}
return endpointReference;
}