private static <T> T getRemoteProxy(Class<T> serviceInterface, Endpoint endpoint, DomainRegistry domainRegistry, ExtensionPointRegistry extensionPointRegistry, Deployer deployer) throws NoSuchServiceException {
FactoryExtensionPoint factories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
ProxyFactory proxyFactory =
new ExtensibleProxyFactory(extensionPointRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class));
CompositeContext compositeContext =
new CompositeContext(extensionPointRegistry, domainRegistry, null, null, null,
deployer.getSystemDefinitions());
if (serviceInterface == null) {
try {
serviceInterface = (Class<T>)findInterface(endpoint, domainRegistry);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
RuntimeEndpointReference epr;
try {
epr =
createEndpointReference(javaInterfaceFactory,
compositeContext,
assemblyFactory,
endpoint,
serviceInterface);
} catch (Exception e) {
throw new ServiceRuntimeException(e);
}
return proxyFactory.createProxy(serviceInterface, epr);
}