1 22 package org.objectweb.petals.binding.axis2.listener.soap; 23 24 import java.util.logging.Level ; 25 import java.util.logging.Logger ; 26 27 import javax.jbi.component.ComponentContext; 28 import javax.jbi.messaging.DeliveryChannel; 29 import javax.xml.namespace.QName ; 30 31 import org.apache.axis2.AxisFault; 32 import org.apache.axis2.addressing.AddressingConstants; 33 import org.apache.axis2.addressing.EndpointReference; 34 import org.apache.axis2.context.MessageContext; 35 import org.apache.axis2.description.AxisOperation; 36 import org.apache.axis2.description.AxisService; 37 import org.apache.axis2.description.HandlerDescription; 38 import org.apache.axis2.description.InOutAxisOperation; 39 import org.apache.axis2.engine.AbstractDispatcher; 40 import org.objectweb.petals.component.common.su.SimpleServiceUnitManager; 41 import org.objectweb.petals.tools.jbicommon.descriptor.Consumes; 42 43 52 public class PetalsDispatcher extends AbstractDispatcher implements 53 AddressingConstants { 54 55 protected Logger log = null; 56 57 protected ComponentContext componentContext; 58 59 protected DeliveryChannel channel; 60 61 protected SimpleServiceUnitManager bindingSUM; 62 63 protected PetalsReceiver jbiReceiver; 64 65 protected AxisService jbiService; 66 67 protected AxisOperation jbiOperation; 68 69 public static final String NAME = "PetalsDispatcher"; 70 71 private static final long serialVersionUID = 10983L; 72 73 protected static final QName OPERATION_QNAME = QName 74 .valueOf("PetalsGenericOperation"); 75 76 84 public void init(ComponentContext componentContext, 85 DeliveryChannel channel, SimpleServiceUnitManager bindingSUM, Logger log) { 86 this.bindingSUM = bindingSUM; 87 this.componentContext = componentContext; 88 this.log = log; 89 this.channel = channel; 90 91 this.jbiService = new AxisService(); 92 this.jbiReceiver = new PetalsReceiver(componentContext, channel, 93 bindingSUM, log); 94 this.jbiOperation = new InOutAxisOperation(OPERATION_QNAME); 95 this.jbiOperation.setMessageReceiver(jbiReceiver); 96 this.jbiService.addOperation(jbiOperation); 97 } 98 99 112 public AxisOperation findOperation(AxisService service, 113 MessageContext messageContext) throws AxisFault { 114 return jbiOperation; 115 } 116 117 128 public AxisService findService(MessageContext messageContext) 129 throws AxisFault { 130 AxisService axisService = null; 131 String serviceName = null; 132 133 EndpointReference toEPR = messageContext.getTo(); 135 log.log(Level.FINE, 136 "PetalsDispatcher - Checking for Service using target endpoint address : " 137 + toEPR.getAddress()); 138 String filePart = toEPR.getAddress(); 139 serviceName = extractWebServiceName(filePart); 140 141 Consumes consumes = bindingSUM.getConsumesFromAddress(serviceName); 143 if (consumes != null) { 144 axisService = messageContext.getConfigurationContext() 146 .getAxisConfiguration().getService(serviceName); 147 } 148 return axisService; 149 } 150 151 156 public void initDispatcher() { 157 init(new HandlerDescription(NAME)); 158 } 159 160 167 protected String extractWebServiceName(String serviceName) { 168 int indexOfOperation = serviceName.indexOf('?'); 169 indexOfOperation = (indexOfOperation > 0) ? indexOfOperation 170 : serviceName.length(); 171 172 int indexOfService = serviceName.lastIndexOf('/'); 173 indexOfService = (indexOfService > 0) ? indexOfService + 1 : 0; 174 175 return serviceName.substring(indexOfService, indexOfOperation); 176 } 177 } 178 | Popular Tags |