1 17 package org.apache.servicemix.sca.loader; 18 19 import javax.xml.namespace.QName ; 20 import javax.xml.stream.XMLStreamException; 21 import javax.xml.stream.XMLStreamReader; 22 23 import org.apache.servicemix.sca.assembly.JbiAssemblyFactory; 24 import org.apache.servicemix.sca.assembly.JbiBinding; 25 import org.apache.servicemix.sca.assembly.impl.JbiAssemblyFactoryImpl; 26 import org.apache.tuscany.common.resource.ResourceLoader; 27 import org.apache.tuscany.core.config.ConfigurationLoadException; 28 import org.apache.tuscany.core.loader.StAXElementLoader; 29 import org.apache.tuscany.core.loader.StAXLoaderRegistry; 30 import org.apache.tuscany.core.system.annotation.Autowire; 31 import org.osoa.sca.annotations.Destroy; 32 import org.osoa.sca.annotations.Init; 33 import org.osoa.sca.annotations.Scope; 34 35 @Scope("MODULE") 36 public class JbiBindingLoader implements StAXElementLoader<JbiBinding>{ 37 38 public static final QName BINDING_JBI = new QName ("http://www.osoa.org/xmlns/sca/0.9", "binding.jbi"); 39 40 private static final JbiAssemblyFactory jbiFactory = new JbiAssemblyFactoryImpl(); 41 42 private StAXLoaderRegistry registry; 43 44 @Autowire 45 public void setRegistry(StAXLoaderRegistry registry) { 46 this.registry = registry; 47 } 48 49 @Init(eager = true) 50 public void start() { 51 registry.registerLoader(this); 52 } 53 54 @Destroy 55 public void stop() { 56 registry.unregisterLoader(this); 57 } 58 59 public QName getXMLType() { 60 return BINDING_JBI; 61 } 62 63 public Class <JbiBinding> getModelType() { 64 return JbiBinding.class; 65 } 66 67 public JbiBinding load(XMLStreamReader reader, ResourceLoader resourceLoader) throws XMLStreamException, ConfigurationLoadException { 68 JbiBinding binding = jbiFactory.createJbiBinding(); 69 binding.setURI(reader.getAttributeValue(null, "uri")); 70 binding.setPortURI(reader.getAttributeValue(null, "port")); 71 return binding; 72 } 73 } 74 | Popular Tags |