public void build(AssemblyModelObject object) throws BuilderException {
if (!(object instanceof ExternalService)) {
return;
}
ExternalService externalService = (ExternalService) object;
if (externalService.getBindings().size() < 1 || !(externalService.getBindings().get(0) instanceof JbiBinding)) {
return;
}
ExternalJbiServiceClient externalJbiServiceClient = new ExternalJbiServiceClient(externalService);
ExternalJbiServiceContextFactory config = new ExternalJbiServiceContextFactory(externalService.getName(), new SingletonObjectFactory<ExternalJbiServiceClient>(externalJbiServiceClient));
ConfiguredService configuredService = externalService.getConfiguredService();
Service service = configuredService.getService();
ServiceContract serviceContract = service.getServiceContract();
Map<Method, InvocationConfiguration> iConfigMap = new MethodHashMap();
ProxyFactory proxyFactory = proxyFactoryFactory.createProxyFactory();
Set<Method> javaMethods = JavaIntrospectionHelper.getAllUniqueMethods(serviceContract.getInterface());
for (Method method : javaMethods) {
InvocationConfiguration iConfig = new InvocationConfiguration(method);
iConfigMap.put(method, iConfig);
}
QualifiedName qName = new QualifiedName(externalService.getName() + "/" + service.getName());
ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, serviceContract.getInterface().getClassLoader(), messageFactory);
proxyFactory.setBusinessInterface(serviceContract.getInterface());
proxyFactory.setProxyConfiguration(pConfiguration);
config.addTargetProxyFactory(service.getName(), proxyFactory);
configuredService.setProxyFactory(proxyFactory);
if (policyBuilder != null) {
// invoke the reference builder to handle additional policy metadata
policyBuilder.build(configuredService);
}
// add tail interceptor
for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
iConfig.addTargetInterceptor(new InvokerInterceptor());
}
externalService.getConfiguredService().setContextFactory(config);
}