* @param epr - the RuntimeEndpointReference for which the callback is created
* @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(AsyncResponseService.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);
// MJE 06/12/2010 - fixup for JMS binding code which looks at the implementation service
// as well as the component service...
// Create a pseudo implementation service...
Service implService = assemblyFactory.createService();
implService.setName(serviceName);
implService.setInterfaceContract(interfaceContract);
service.setService(implService);
//
endpoint.setService(service);