* @return the EndpointReference object representing the callback
*/
private RuntimeEndpointReference createAsyncEPR( RuntimeEndpoint endpoint ){
CompositeContext compositeContext = endpoint.getCompositeContext();
RuntimeAssemblyFactory assemblyFactory = getAssemblyFactory( compositeContext );
RuntimeEndpointReference epr = (RuntimeEndpointReference)assemblyFactory.createEndpointReference();
epr.bind( compositeContext );
// Create pseudo-reference
ComponentReference reference = assemblyFactory.createComponentReference();
ExtensionPointRegistry registry = compositeContext.getExtensionPointRegistry();
FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
JavaInterfaceFactory javaInterfaceFactory = (JavaInterfaceFactory)modelFactories.getFactory(JavaInterfaceFactory.class);
JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
try {
interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(AsyncResponseHandler.class));
} catch (InvalidInterfaceException e1) {
// Nothing to do here - will not happen
} // end try
reference.setInterfaceContract(interfaceContract);
String referenceName = endpoint.getService().getName() + "_asyncCallback";
reference.setName(referenceName);
reference.setForCallback(true);
epr.setReference(reference);
// Create a binding
Binding binding = createMatchingBinding( endpoint.getBinding(), (RuntimeComponent)endpoint.getComponent(), reference, registry );
epr.setBinding(binding);
// Need to establish policies here (binding has some...)
epr.getRequiredIntents().addAll( endpoint.getRequiredIntents() );
epr.getPolicySets().addAll( endpoint.getPolicySets() );
String eprURI = endpoint.getComponent().getName() + "#reference-binding(" + referenceName + "/" + referenceName + ")";
epr.setURI(eprURI);
// Attach a dummy endpoint to the epr
RuntimeEndpoint ep = (RuntimeEndpoint)assemblyFactory.createEndpoint();
ep.setUnresolved(false);
epr.setTargetEndpoint(ep);
//epr.setStatus(EndpointReference.Status.RESOLVED_BINDING);
epr.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
epr.setUnresolved(false);
return epr;
} // end method RuntimeEndpointReference