1 17 package org.apache.servicemix.sca.builder; 18 19 import org.apache.servicemix.sca.config.ExternalJbiServiceContextFactory; 20 import org.apache.servicemix.sca.handler.ExternalJbiServiceTargetInvoker; 21 import org.apache.tuscany.core.builder.BuilderConfigException; 22 import org.apache.tuscany.core.builder.WireBuilder; 23 import org.apache.tuscany.core.context.ScopeContext; 24 import org.apache.tuscany.core.invocation.InvocationConfiguration; 25 import org.apache.tuscany.core.invocation.spi.ProxyFactory; 26 import org.apache.tuscany.core.runtime.RuntimeContext; 27 import org.apache.tuscany.core.system.annotation.Autowire; 28 import org.osoa.sca.annotations.Init; 29 import org.osoa.sca.annotations.Scope; 30 31 @Scope("MODULE") 32 public class ExternalJbiServiceWireBuilder implements WireBuilder { 33 34 private RuntimeContext runtimeContext; 35 36 39 public ExternalJbiServiceWireBuilder() { 40 super(); 41 } 42 43 @Autowire 44 public void setRuntimeContext(RuntimeContext context) { 45 runtimeContext = context; 46 } 47 48 @Init(eager=true) 49 public void init() { 50 runtimeContext.addBuilder(this); 51 } 52 53 public void connect(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope, ScopeContext targetScopeContext) throws BuilderConfigException { 54 if (!(ExternalJbiServiceContextFactory.class.isAssignableFrom(targetType))) { 55 return; 56 } 57 for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration().getInvocationConfigurations().values()) { 58 ExternalJbiServiceTargetInvoker invoker = new ExternalJbiServiceTargetInvoker(sourceFactory.getProxyConfiguration().getTargetName(), sourceInvocationConfig.getMethod(), targetScopeContext); 59 sourceInvocationConfig.setTargetInvoker(invoker); 60 } 61 } 62 63 public void completeTargetChain(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext) 64 throws BuilderConfigException { 65 } 67 68 } 69 | Popular Tags |