1 17 package org.apache.servicemix.components.util; 18 19 import org.apache.commons.logging.Log; 20 import org.apache.commons.logging.LogFactory; 21 import org.apache.servicemix.jbi.NotInitialisedYetException; 22 import org.apache.servicemix.jbi.container.ActivationSpec; 23 import org.springframework.beans.BeansException; 24 import org.springframework.context.ApplicationContext; 25 import org.springframework.context.ApplicationContextAware; 26 import org.w3c.dom.DocumentFragment ; 27 28 import javax.jbi.JBIException; 29 import javax.jbi.component.Bootstrap; 30 import javax.jbi.component.InstallationContext; 31 import javax.management.ObjectName ; 32 33 import java.util.Iterator ; 34 import java.util.Map ; 35 36 41 public class SpringBootstrap implements Bootstrap, ApplicationContextAware { 42 private InstallationContext installContext; 43 private ObjectName extensionMBeanName; 44 private ApplicationContext applicationContext; 45 private static Log log = LogFactory.getLog(SpringBootstrap.class); 46 47 public void init(InstallationContext installContext) throws JBIException { 48 this.installContext = installContext; 49 } 50 51 public void cleanUp() throws JBIException { 52 } 53 54 public ObjectName getExtensionMBeanName() { 55 return extensionMBeanName; 56 } 57 58 public void onInstall() throws JBIException { 59 if (installContext == null) { 60 throw new NotInitialisedYetException(); 61 } 62 DocumentFragment fragment = installContext.getInstallationDescriptorExtension(); 63 if (fragment != null) { 64 log.debug("Installation Descriptor Extension Found"); 65 } else { 66 log.debug("Installation Descriptor Extension Not Found !"); 67 } 68 Map map = applicationContext.getBeansOfType(ActivationSpec.class, false, false); 70 for (Iterator iter = map.values().iterator(); iter.hasNext(); ) { 71 ActivationSpec spec = (ActivationSpec) iter.next(); 72 log.debug("Registering "+spec.getComponentName()); 73 } 74 } 75 76 public void onUninstall() throws JBIException { 77 } 78 79 public InstallationContext getInstallContext() { 80 return installContext; 81 } 82 83 public void setApplicationContext(ApplicationContext appCtx) throws BeansException { 84 this.applicationContext = appCtx; 85 } 86 } 87 | Popular Tags |