1 17 package org.apache.servicemix.jms; 18 19 import javax.jbi.servicedesc.ServiceEndpoint; 20 21 import org.apache.servicemix.common.BaseComponent; 22 import org.apache.servicemix.common.BaseLifeCycle; 23 import org.apache.servicemix.common.ServiceUnit; 24 import org.w3c.dom.DocumentFragment ; 25 26 33 public class JmsSpringComponent extends BaseComponent { 34 35 private JmsEndpoint[] endpoints; 36 37 40 protected BaseLifeCycle createLifeCycle() { 41 return new LifeCycle(); 42 } 43 44 47 public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) { 48 return JmsResolvedEndpoint.resolveEndpoint(epr); 49 } 50 51 public JmsEndpoint[] getEndpoints() { 52 return endpoints; 53 } 54 55 public void setEndpoints(JmsEndpoint[] endpoints) { 56 this.endpoints = endpoints; 57 } 58 59 63 public JmsConfiguration getConfiguration() { 64 return ((JmsLifeCycle) getLifeCycle()).getConfiguration(); 65 } 66 67 70 public void setConfiguration(JmsConfiguration configuration) { 71 ((JmsLifeCycle) getLifeCycle()).setConfiguration(configuration); 72 } 73 74 public class LifeCycle extends JmsLifeCycle { 75 76 protected ServiceUnit su; 77 78 public LifeCycle() { 79 super(JmsSpringComponent.this); 80 } 81 82 85 protected void doInit() throws Exception { 86 super.doInit(); 87 su = new ServiceUnit(); 88 su.setComponent(JmsSpringComponent.this); 89 if (endpoints != null) { 90 for (int i = 0; i < endpoints.length; i++) { 91 endpoints[i].setServiceUnit(su); 92 su.addEndpoint(endpoints[i]); 93 } 94 } 95 getRegistry().registerServiceUnit(su); 96 } 97 98 101 protected void doStart() throws Exception { 102 super.doStart(); 103 su.start(); 104 } 105 106 109 protected void doStop() throws Exception { 110 su.stop(); 111 super.doStop(); 112 } 113 114 117 protected void doShutDown() throws Exception { 118 su.shutDown(); 119 super.doShutDown(); 120 } 121 } 122 123 } 124 | Popular Tags |