1 17 package org.apache.servicemix.eip; 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 EIPSpringComponent extends BaseComponent { 32 33 private EIPEndpoint[] endpoints; 34 35 38 public EIPEndpoint[] getEndpoints() { 39 return endpoints; 40 } 41 42 45 public void setEndpoints(EIPEndpoint[] endpoints) { 46 this.endpoints = endpoints; 47 } 48 49 52 protected BaseLifeCycle createLifeCycle() { 53 return new LifeCycle(); 54 } 55 56 59 public class LifeCycle extends EIPLifeCycle { 60 61 protected ServiceUnit su; 62 63 public LifeCycle() { 64 super(EIPSpringComponent.this); 65 } 66 67 70 protected void doInit() throws Exception { 71 super.doInit(); 72 su = new XBeanServiceUnit(); 73 su.setComponent(EIPSpringComponent.this); 74 for (int i = 0; i < endpoints.length; i++) { 75 endpoints[i].setServiceUnit(su); 76 endpoints[i].validate(); 77 su.addEndpoint(endpoints[i]); 78 } 79 getRegistry().registerServiceUnit(su); 80 } 81 82 85 protected void doStart() throws Exception { 86 super.doStart(); 87 su.start(); 88 } 89 90 93 protected void doStop() throws Exception { 94 su.stop(); 95 super.doStop(); 96 } 97 98 101 protected void doShutDown() throws Exception { 102 su.shutDown(); 103 super.doShutDown(); 104 } 105 } 106 107 } 108 | Popular Tags |