1 17 package org.apache.servicemix.jsr181.packaging; 18 19 import java.util.ArrayList ; 20 import java.util.List ; 21 import java.util.MissingResourceException ; 22 import java.util.logging.Logger ; 23 24 import javax.jbi.JBIException; 25 import javax.jbi.component.ComponentContext; 26 import javax.jbi.management.MBeanNames; 27 import javax.jbi.messaging.DeliveryChannel; 28 import javax.jbi.messaging.MessagingException; 29 import javax.jbi.servicedesc.ServiceEndpoint; 30 import javax.management.MBeanServer ; 31 import javax.naming.InitialContext ; 32 import javax.xml.namespace.QName ; 33 34 import org.apache.servicemix.common.Endpoint; 35 import org.apache.servicemix.common.xbean.AbstractXBeanServiceUnitAnalyzer; 36 import org.apache.servicemix.jsr181.Jsr181Endpoint; 37 import org.apache.servicemix.jsr181.Jsr181SpringComponent; 38 import org.w3c.dom.Document ; 39 import org.w3c.dom.DocumentFragment ; 40 41 public class Jsr181ServiceUnitAnalyzer extends AbstractXBeanServiceUnitAnalyzer { 42 43 protected List getConsumes(Endpoint endpoint) { 44 return new ArrayList (); 45 } 46 47 protected List getProvides(Endpoint endpoint) { 48 49 Jsr181Endpoint jsr181Endpoint = (Jsr181Endpoint) endpoint; 51 try { 52 Jsr181SpringComponent componentDummy = new Jsr181SpringComponent(); 53 componentDummy 54 .setEndpoints(new Jsr181Endpoint[] { jsr181Endpoint }); 55 componentDummy.getLifeCycle().init(new DummyComponentContext()); 56 } catch (Exception e) { 57 throw new RuntimeException ("Unable to register JSR-181 service, " 58 + e.getMessage(), e); 59 } 60 return super.getProvides(endpoint); 61 } 62 63 protected String getXBeanFile() { 64 return "xbean.xml"; 65 } 66 67 protected boolean isValidEndpoint(Object bean) { 68 if (bean instanceof Jsr181Endpoint) 69 return true; 70 else 71 return false; 72 } 73 74 public class DummyComponentContext implements ComponentContext { 75 76 public ServiceEndpoint activateEndpoint(QName serviceName, 77 String endpointName) throws JBIException { 78 return null; 79 } 80 81 public void deactivateEndpoint(ServiceEndpoint endpoint) 82 throws JBIException { 83 } 84 85 public void deregisterExternalEndpoint(ServiceEndpoint externalEndpoint) 86 throws JBIException { 87 88 } 89 90 public String getComponentName() { 91 return null; 92 } 93 94 public DeliveryChannel getDeliveryChannel() throws MessagingException { 95 return null; 96 } 97 98 public ServiceEndpoint getEndpoint(QName service, String name) { 99 return null; 100 } 101 102 public Document getEndpointDescriptor(ServiceEndpoint endpoint) 103 throws JBIException { 104 return null; 105 } 106 107 public ServiceEndpoint[] getEndpoints(QName interfaceName) { 108 return null; 109 } 110 111 public ServiceEndpoint[] getEndpointsForService(QName serviceName) { 112 return null; 113 } 114 115 public ServiceEndpoint[] getExternalEndpoints(QName interfaceName) { 116 return null; 117 } 118 119 public ServiceEndpoint[] getExternalEndpointsForService( 120 QName serviceName) { 121 return null; 122 } 123 124 public String getInstallRoot() { 125 return null; 126 } 127 128 public Logger getLogger(String suffix, String resourceBundleName) 129 throws MissingResourceException , JBIException { 130 return null; 131 } 132 133 public MBeanNames getMBeanNames() { 134 return null; 135 } 136 137 public MBeanServer getMBeanServer() { 138 return null; 139 } 140 141 public InitialContext getNamingContext() { 142 return null; 143 } 144 145 public Object getTransactionManager() { 146 return null; 147 } 148 149 public String getWorkspaceRoot() { 150 return null; 151 } 152 153 public void registerExternalEndpoint(ServiceEndpoint externalEndpoint) 154 throws JBIException { 155 } 156 157 public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) { 158 return null; 159 } 160 161 } 162 163 } 164 | Popular Tags |