* @return - a RuntimeEndpoint representing the callback endpoint
*/
private RuntimeEndpoint createAsyncCallbackEndpoint(RuntimeEndpointReference epr) {
CompositeContext compositeContext = epr.getCompositeContext();
RuntimeAssemblyFactory assemblyFactory = getAssemblyFactory(compositeContext);
RuntimeEndpoint endpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
endpoint.bind(compositeContext);
// Create a pseudo-component and pseudo-service
// - need to end with a chain with an invoker into the AsyncCallbackHandler class
RuntimeComponent fakeComponent = null;
try {
fakeComponent = (RuntimeComponent)epr.getComponent().clone();
applyImplementation(fakeComponent);
} catch (CloneNotSupportedException e2) {
// will not happen
} // end try
endpoint.setComponent(fakeComponent);
// Create pseudo-service
ComponentService service = assemblyFactory.createComponentService();
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
service.setInterfaceContract(interfaceContract);
String serviceName = epr.getReference().getName() + "_asyncCallback";
service.setName(serviceName);
endpoint.setService(service);
// Set pseudo-service onto the pseudo-component
List<ComponentService> services = fakeComponent.getServices();
services.clear();
services.add(service);
// Create a binding
Binding binding = createMatchingBinding(epr.getBinding(), fakeComponent, service, registry);
endpoint.setBinding(binding);
// Need to establish policies here (binding has some...)
endpoint.getRequiredIntents().addAll(epr.getRequiredIntents());
endpoint.getPolicySets().addAll(epr.getPolicySets());
String epURI = epr.getComponent().getName() + "#service-binding(" + serviceName + "/" + serviceName + ")";
endpoint.setURI(epURI);
endpoint.setUnresolved(false);
return endpoint;
}