1 17 package org.apache.servicemix.components.util; 18 19 import org.w3c.dom.Document ; 20 import org.w3c.dom.DocumentFragment ; 21 22 import javax.jbi.JBIException; 23 import javax.jbi.component.Component; 24 import javax.jbi.component.ComponentContext; 25 import javax.jbi.component.ComponentLifeCycle; 26 import javax.jbi.component.ServiceUnitManager; 27 import javax.jbi.messaging.MessageExchange; 28 import javax.jbi.servicedesc.ServiceEndpoint; 29 import javax.xml.namespace.QName ; 30 31 37 public class ComponentAdaptor implements Component { 38 39 private ComponentLifeCycle lifeCycle; 40 private QName service; 41 private String endpoint; 42 private ComponentContext context; 43 private ServiceUnitManager serviceManager; 44 45 46 public ComponentAdaptor(ComponentLifeCycle lifeCycle) { 47 this.lifeCycle = lifeCycle; 48 } 49 50 public ComponentAdaptor(ComponentLifeCycle lifeCycle, QName service, String endpoint) { 51 this.lifeCycle = lifeCycle; 52 this.service = service; 53 this.endpoint = endpoint; 54 } 55 56 62 public void init(ComponentContext context) throws JBIException { 63 this.context = context; 64 if (service != null && endpoint != null) { 65 context.activateEndpoint(service, endpoint); 66 } 67 } 68 69 72 public ComponentLifeCycle getLifeCycle() { 73 return lifeCycle; 74 } 75 76 public ServiceUnitManager getServiceUnitManager() { 77 initializeServiceUnitManager(); 78 return serviceManager; 79 } 80 81 public void setServiceManager(ServiceUnitManager serviceManager) { 82 this.serviceManager = serviceManager; 83 } 84 85 86 public ComponentContext getContext() { 87 return context; 88 } 89 90 public String toString() { 91 return getClass().getName() + " for " + lifeCycle; 92 } 93 94 protected synchronized void initializeServiceUnitManager() { 95 if (this.serviceManager == null) { 96 this.serviceManager = createServiceUnitManager(); 97 } 98 } 99 100 protected ServiceUnitManager createServiceUnitManager() { 101 return new ServiceUnitManagerSupport(); 102 } 103 104 105 public Document getServiceDescription(ServiceEndpoint endpoint) { 106 return null; 108 } 109 110 111 public boolean isExchangeWithConsumerOkay(ServiceEndpoint endpoint, MessageExchange exchange) { 112 return true; 114 } 115 116 117 public boolean isExchangeWithProviderOkay(ServiceEndpoint endpoint, MessageExchange exchange) { 118 return true; 120 } 121 122 123 public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) { 124 return null; 126 } 127 128 } 129 | Popular Tags |