1 17 package org.apache.servicemix.jbi.management; 18 19 import javax.jbi.JBIException; 20 21 import org.apache.servicemix.jbi.container.JBIContainer; 22 23 public abstract class BaseSystemService extends BaseLifeCycle { 24 25 protected JBIContainer container; 26 27 32 public String getName() { 33 String name = getClass().getName(); 34 int index = name.lastIndexOf("."); 35 if (index >= 0 && (index + 1) < name.length()) { 36 name = name.substring(index + 1); 37 } 38 return name; 39 } 40 41 46 public String getType() { 47 return "SystemService"; 48 } 49 50 public void init(JBIContainer container) throws JBIException { 51 this.container = container; 52 container.getManagementContext().registerSystemService(this, getServiceMBean()); 53 super.init(); 54 } 55 56 public void shutDown() throws JBIException { 57 stop(); 58 super.shutDown(); 59 if (container != null && container.getManagementContext() != null) { 60 container.getManagementContext().unregisterSystemService(this); 61 } 62 } 63 64 protected abstract Class getServiceMBean(); 65 66 public JBIContainer getContainer() { 67 return container; 68 } 69 70 } 71 | Popular Tags |