1 17 package org.apache.servicemix.jsr181; 18 19 import org.apache.servicemix.common.BaseComponent; 20 import org.apache.servicemix.common.BaseLifeCycle; 21 import org.apache.servicemix.common.ServiceUnit; 22 import org.apache.servicemix.common.xbean.XBeanServiceUnit; 23 24 31 public class Jsr181SpringComponent extends BaseComponent { 32 33 private Jsr181Endpoint[] endpoints; 34 35 38 protected BaseLifeCycle createLifeCycle() { 39 return new LifeCycle(); 40 } 41 42 public Jsr181Endpoint[] getEndpoints() { 43 return endpoints; 44 } 45 46 public void setEndpoints(Jsr181Endpoint[] endpoints) { 47 this.endpoints = endpoints; 48 } 49 50 public class LifeCycle extends Jsr181LifeCycle { 51 52 protected ServiceUnit su; 53 54 public LifeCycle() { 55 super(Jsr181SpringComponent.this); 56 } 57 58 61 protected void doInit() throws Exception { 62 super.doInit(); 63 su = new XBeanServiceUnit(); 64 su.setComponent(Jsr181SpringComponent.this); 65 for (int i = 0; i < endpoints.length; i++) { 66 endpoints[i].setServiceUnit(su); 67 endpoints[i].registerService(); 68 su.addEndpoint(endpoints[i]); 69 } 70 getRegistry().registerServiceUnit(su); 71 } 72 73 76 protected void doStart() throws Exception { 77 super.doStart(); 78 su.start(); 79 } 80 81 84 protected void doStop() throws Exception { 85 su.stop(); 86 super.doStop(); 87 } 88 89 92 protected void doShutDown() throws Exception { 93 su.shutDown(); 94 super.doShutDown(); 95 } 96 } 97 98 } 99 | Popular Tags |