1 17 package org.apache.servicemix.http; 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.apache.servicemix.http.jetty.JCLLogger; 25 import org.w3c.dom.DocumentFragment ; 26 27 34 public class HttpSpringComponent extends BaseComponent { 35 36 private HttpEndpoint[] endpoints; 37 38 static { 39 JCLLogger.init(); 40 } 41 42 45 protected BaseLifeCycle createLifeCycle() { 46 return new LifeCycle(); 47 } 48 49 52 public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) { 53 return HttpResolvedEndpoint.resolveEndpoint(epr); 54 } 55 56 public HttpEndpoint[] getEndpoints() { 57 return endpoints; 58 } 59 60 public void setEndpoints(HttpEndpoint[] endpoints) { 61 this.endpoints = endpoints; 62 } 63 64 public class LifeCycle extends HttpLifeCycle { 65 66 protected ServiceUnit su; 67 68 public LifeCycle() { 69 super(HttpSpringComponent.this); 70 } 71 72 75 protected void doInit() throws Exception { 76 super.doInit(); 77 su = new ServiceUnit(); 78 su.setComponent(HttpSpringComponent.this); 79 if (endpoints != null) { 80 for (int i = 0; i < endpoints.length; i++) { 81 endpoints[i].setServiceUnit(su); 82 su.addEndpoint(endpoints[i]); 83 } 84 } 85 getRegistry().registerServiceUnit(su); 86 } 87 88 91 protected void doStart() throws Exception { 92 super.doStart(); 93 su.start(); 94 } 95 96 99 protected void doStop() throws Exception { 100 su.stop(); 101 super.doStop(); 102 } 103 104 107 protected void doShutDown() throws Exception { 108 su.shutDown(); 109 super.doShutDown(); 110 } 111 } 112 113 117 public HttpConfiguration getConfiguration() { 118 return ((HttpLifeCycle) getLifeCycle()).getConfiguration(); 119 } 120 121 124 public void setConfiguration(HttpConfiguration configuration) { 125 ((HttpLifeCycle) getLifeCycle()).setConfiguration(configuration); 126 } 127 128 public HttpProcessor getMainProcessor() { 129 return ((HttpLifeCycle) getLifeCycle()).getMainProcessor(); 130 } 131 132 } 133 | Popular Tags |