1 17 package org.apache.servicemix.geronimo; 18 19 import java.io.File ; 20 import java.net.URI ; 21 import java.net.URL ; 22 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 import org.apache.geronimo.gbean.GBeanInfo; 26 import org.apache.geronimo.gbean.GBeanInfoBuilder; 27 import org.apache.geronimo.gbean.GBeanLifecycle; 28 import org.apache.servicemix.jbi.deployment.Descriptor; 29 import org.apache.servicemix.jbi.deployment.DescriptorFactory; 30 31 public class ServiceAssembly implements GBeanLifecycle { 32 33 private static final Log log = LogFactory.getLog(ServiceAssembly.class); 34 35 private String name; 36 private Container container; 37 private URI rootDir; 38 39 public ServiceAssembly(String name, 40 Container container, 41 URL configurationBaseUrl) throws Exception { 42 this.name = name; 43 this.container = container; 44 if (configurationBaseUrl.getProtocol().equalsIgnoreCase("file")) { 46 this.rootDir = new URI ("file", configurationBaseUrl.getPath(), null); 47 } else { 48 this.rootDir = URI.create(configurationBaseUrl.toString()); 49 } 50 log.info("Created JBI service assembly: " + name); 51 } 52 53 public void doStart() throws Exception { 54 log.info("doStart called for JBI service assembly: " + name); 55 container.register(this); 56 } 57 58 public void doStop() throws Exception { 59 log.info("doStop called for JBI service assembly: " + name); 60 container.unregister(this); 61 } 62 63 public void doFail() { 64 log.info("doFail called for JBI service assembly: " + name); 65 } 66 67 public URI getRootDir() { 68 return rootDir; 69 } 70 71 public String getName() { 72 return name; 73 } 74 75 public Descriptor getDescriptor() throws Exception { 76 return DescriptorFactory.buildDescriptor(new File (new File (rootDir), "install")); 77 } 78 79 public static final GBeanInfo GBEAN_INFO; 80 81 static { 82 GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("JBIServiceAssembly", ServiceAssembly.class, "JBIServiceAssembly"); 83 infoFactory.addAttribute("name", String .class, true); 84 infoFactory.addReference("container", Container.class); 85 infoFactory.addAttribute("configurationBaseUrl", URL .class, true); 86 infoFactory.setConstructor(new String [] {"name", "container", "configurationBaseUrl" }); 87 GBEAN_INFO = infoFactory.getBeanInfo(); 88 } 89 90 public static GBeanInfo getGBeanInfo() { 91 return GBEAN_INFO; 92 } 93 94 } 95 | Popular Tags |