* @param endpoint - the endpoint which has the async server operations
* @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-component
epr.setComponent(component);
// 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(AsyncResponseService.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);
// Add in "implementation" reference (really a dummy, but with correct interface)
Reference implReference = assemblyFactory.createReference();
implReference.setInterfaceContract(interfaceContract);
implReference.setName(referenceName);
implReference.setForCallback(true);
reference.setReference(implReference);
// Set the created ComponentReference into the EPR
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() );
// 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);