1 17 package org.apache.servicemix.common.xbean; 18 19 import org.apache.servicemix.common.ServiceUnit; 20 import org.apache.xbean.kernel.Kernel; 21 import org.apache.xbean.kernel.ServiceFactory; 22 import org.apache.xbean.kernel.ServiceName; 23 import org.apache.xbean.kernel.ServiceNotFoundException; 24 25 import javax.jbi.JBIException; 26 27 public class XBeanServiceUnit extends ServiceUnit { 28 29 private Kernel kernel; 30 private ServiceName configuration; 31 32 35 public Kernel getKernel() { 36 return kernel; 37 } 38 39 42 public void setKernel(Kernel kernel) { 43 this.kernel = kernel; 44 } 45 46 public ServiceName getConfiguration() { 47 return configuration; 48 } 49 50 public void setConfiguration(ServiceName configuration) { 51 this.configuration = configuration; 52 } 53 54 57 public void shutDown() throws JBIException { 58 super.shutDown(); 59 if (kernel != null) { 60 kernel.destroy(); 61 } 62 } 63 64 public ClassLoader getConfigurationClassLoader() throws ServiceNotFoundException { 65 ClassLoader cl = null; 66 if (kernel != null) { 67 ServiceFactory sf = kernel.getServiceFactory(configuration); 68 cl = sf.getClassLoader(); 69 } 70 if (cl == null) { 71 cl = Thread.currentThread().getContextClassLoader(); 72 } 73 if (cl == null) { 74 cl = getClass().getClassLoader(); 75 } 76 return cl; 77 } 78 79 } 80 | Popular Tags |