Modified: webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java?rev=373804&r1=373803&r2=373804&view=diff ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java Tue Jan 31 04:25:53 2006 @@ -21,13 +21,20 @@ import javax.xml.namespace.QName; import org.apache.axis2.AxisFault; -import org.apache.axis2.addressing.AnyContentType; +import org.apache.axis2.addressing.AddressingConstants; import org.apache.axis2.addressing.EndpointReference; -import org.apache.axis2.client.MessageSender; +import org.apache.axis2.client.OperationClient; +import org.apache.axis2.client.Options; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.context.ServiceContext; +import org.apache.axis2.context.ServiceGroupContext; +import org.apache.axis2.deployment.DeploymentException; import org.apache.axis2.description.AxisOperation; import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.AxisServiceGroup; import org.apache.axis2.description.InOnlyAxisOperation; -import org.apache.axis2.description.OutInAxisOperation; +import org.apache.axis2.description.OutOnlyAxisOperation; import org.apache.axis2.description.ParameterImpl; import org.apache.axis2.om.OMAbstractFactory; import org.apache.axis2.om.OMElement; @@ -37,131 +44,129 @@ import org.apache.kandula.Constants; import org.apache.kandula.faults.AbstractKandulaException; import org.apache.kandula.faults.KandulaGeneralException; +import org.apache.kandula.utility.EPRHandlingUtils; import org.apache.kandula.utility.KandulaListener; -import org.apache.kandula.utility.KandulaUtils; + /** * @author <a href="mailto:[EMAIL PROTECTED]"> Thilina Gunarathne </a> */ public class RegistrationCoordinatorPortTypeRawXMLStub extends - org.apache.axis2.client.Stub { - public static final String AXIS2_HOME = "."; + org.apache.axis2.client.Stub { + public static final String AXIS2_HOME = "."; + + protected static org.apache.axis2.description.AxisOperation[] _operations; - protected static org.apache.axis2.description.AxisOperation[] _operations; + protected AxisService service; - static { + protected ConfigurationContext configurationContext; - //creating the Service - _service = new AxisService( - new javax.xml.namespace.QName( - "http://schemas.xmlsoap.org/ws/2003/09/wscoor", - "RegistrationCoordinatorPortType")); - - //creating the operations - org.apache.axis2.description.AxisOperation __operation; - _operations = new org.apache.axis2.description.AxisOperation[1]; - - __operation = new OutInAxisOperation(); - __operation.setName(new javax.xml.namespace.QName( - "http://schemas.xmlsoap.org/ws/2003/09/wscoor", - "RegisterOperation")); - _operations[0] = __operation; - _service.addOperation(__operation); - - } - - /** - * Constructor - */ - public RegistrationCoordinatorPortTypeRawXMLStub(String axis2Home, - EndpointReference targetEndpoint) throws AbstractKandulaException { - this.toEPR = targetEndpoint; - try { - //creating the configuration - _configurationContext = new org.apache.axis2.context.ConfigurationContextFactory() - .buildClientConfigurationContext(axis2Home); - - _configurationContext.getAxisConfiguration().addService(_service); - } catch (AxisFault e1) { - throw new KandulaGeneralException(e1); - } - - _serviceContext = _service.getParent().getServiceGroupContext( - _configurationContext).getServiceContext( - _service.getName().getLocalPart()); - } - - public void registerOperation(String protocolType, EndpointReference epr, - String id) throws IOException { - - EndpointReference replyToEpr; - - org.apache.axis2.context.MessageContext messageContext = getMessageContext(); - org.apache.axis2.soap.SOAPEnvelope env = createSOAPEnvelope( - protocolType, epr); - messageContext.setEnvelope(env); - - replyToEpr = setupListener(); - AnyContentType refParameters = new AnyContentType(); - refParameters.addReferenceValue(Constants.REQUESTER_ID_PARAMETER, id); - replyToEpr.setReferenceParameters(refParameters); - - MessageSender messageSender = new MessageSender(_serviceContext); - messageSender.setReplyTo(replyToEpr); - messageSender.setTo(this.toEPR); - messageSender.setWsaAction(Constants.WS_COOR_REGISTER); - - messageSender - .setSenderTransport(org.apache.axis2.Constants.TRANSPORT_HTTP); - messageSender.send(_operations[0], messageContext); - } - - private org.apache.axis2.soap.SOAPEnvelope createSOAPEnvelope( - String protocolType, EndpointReference epr) { - org.apache.axis2.soap.SOAPEnvelope env = super.createEnvelope(); - org.apache.axis2.soap.SOAPFactory factory = OMAbstractFactory - .getSOAP12Factory(); - OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR, - "wscoor"); - OMElement request = factory.createOMElement("Register", wsCoor); - OMElement protocolTypeElement = factory.createOMElement( - "ProtocolIdentifier", wsCoor); - protocolTypeElement.setText(protocolType); - request.addChild(protocolTypeElement); - - OMElement protocolService = factory.createOMElement( - "ParticipantProtocolService", wsCoor); - KandulaUtils.endpointToOM(epr, protocolService, factory); - request.addChild(protocolService); - env.getBody().addChild(request); - return env; - } - - private EndpointReference setupListener() throws IOException { - QName serviceName = new QName("RegistrationRequesterPortType"); - QName operationName = new QName(Constants.WS_COOR, - "registerResponseOperation"); - AxisOperation responseOperationDesc; - String className = RegistrationRequesterPortTypeRawXMLSkeleton.class - .getName(); - String mapping = Constants.WS_COOR_REGISTER_RESPONSE; - - KandulaListener listener = KandulaListener.getInstance(); - AxisService service = new AxisService(serviceName); - service.addParameter(new ParameterImpl( - AbstractMessageReceiver.SERVICE_CLASS, className)); - service.setFileName(className); - - responseOperationDesc = new InOnlyAxisOperation(); - responseOperationDesc.setName(operationName); - responseOperationDesc - .setMessageReceiver(new RawXMLINOnlyMessageReceiver()); - - // Adding the WSA Action mapping to the operation - service.addMapping(mapping, responseOperationDesc); - service.addOperation(responseOperationDesc); - listener.addService(service); - listener.start(); - return new EndpointReference(listener.getHost() - + serviceName.getLocalPart()); - } + private ServiceContext serviceContext; + + private EndpointReference toEPR; + + private AxisOperation operation; + + /** + * Constructor + */ + public RegistrationCoordinatorPortTypeRawXMLStub(String axis2Home, + String axis2Xml, EndpointReference targetEndpoint) + throws AbstractKandulaException { + this.toEPR = targetEndpoint; + service = new AxisService("RegistrationCoordinatorPortType"); + try { + configurationContext = new org.apache.axis2.context.ConfigurationContextFactory() + .createConfigurationContextFromFileSystem(axis2Home, + axis2Xml); + configurationContext.getAxisConfiguration().addService(service); + } catch (DeploymentException e) { + throw new KandulaGeneralException(e); + } catch (AxisFault e1) { + throw new KandulaGeneralException(e1); + } + ServiceGroupContext sgc = new ServiceGroupContext( + this.configurationContext, (AxisServiceGroup) this.service + .getParent()); + this.serviceContext = new ServiceContext(service, sgc); + + operation = new OutOnlyAxisOperation(); + operation.setName(new javax.xml.namespace.QName( + "http://schemas.xmlsoap.org/ws/2003/09/wscoor", + "RegisterOperation")); + service.addOperation(operation); + + } + + public void registerOperation(String protocolType, EndpointReference epr, + String id) throws IOException { + EndpointReference replyToEpr; + MessageContext messageContext = new MessageContext(); + Options options = new Options(); + messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, + AddressingConstants.Submission.WSA_NAMESPACE); + org.apache.axis2.soap.SOAPEnvelope env = createSOAPEnvelope( + protocolType, epr); + messageContext.setEnvelope(env); + replyToEpr = setupListener(); + EPRHandlingUtils.addReferenceProperty(replyToEpr, + Constants.REQUESTER_ID_PARAMETER, id); + options.setReplyTo(replyToEpr); + options.setTo(this.toEPR); + options.setAction(Constants.WS_COOR_REGISTER); + OperationClient client = operation + .createClient(serviceContext, options); + client.addMessageContext(messageContext); + client.execute(false); + + } + + private org.apache.axis2.soap.SOAPEnvelope createSOAPEnvelope( + String protocolType, EndpointReference epr) { + + org.apache.axis2.soap.SOAPFactory factory = OMAbstractFactory + .getSOAP12Factory(); + org.apache.axis2.soap.SOAPEnvelope env = factory.getDefaultEnvelope(); + OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR, + "wscoor"); + OMElement request = factory.createOMElement("Register", wsCoor); + OMElement protocolTypeElement = factory.createOMElement( + "ProtocolIdentifier", wsCoor); + protocolTypeElement.setText(protocolType); + request.addChild(protocolTypeElement); + + OMElement protocolService = factory.createOMElement( + "ParticipantProtocolService", wsCoor); + EPRHandlingUtils.endpointToOM(epr, protocolService, factory); + request.addChild(protocolService); + env.getBody().addChild(request); + return env; + } + + private EndpointReference setupListener() throws IOException { + String serviceName = "RegistrationRequesterPortType"; + QName operationName = new QName(Constants.WS_COOR, + "registerResponseOperation"); + AxisOperation responseOperationDesc; + String className = RegistrationRequesterPortTypeRawXMLSkeleton.class + .getName(); + String mapping = Constants.WS_COOR_REGISTER_RESPONSE; + + KandulaListener listener = KandulaListener.getInstance(); + AxisService service = new AxisService(serviceName); + service.addParameter(new ParameterImpl( + AbstractMessageReceiver.SERVICE_CLASS, className)); + service.setFileName(className); + + responseOperationDesc = new InOnlyAxisOperation(); + responseOperationDesc.setName(operationName); + responseOperationDesc + .setMessageReceiver(new RawXMLINOnlyMessageReceiver()); + + // Adding the WSA Action mapping to the operation + service.mapActionToOperation(mapping, responseOperationDesc); + service.addOperation(responseOperationDesc); + listener.addService(service); + listener.start(); + return new EndpointReference(listener.getHost() + serviceName); + } }
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java?rev=373804&r1=373803&r2=373804&view=diff ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java Tue Jan 31 04:25:53 2006 @@ -26,55 +26,55 @@ * @author <a href="mailto:[EMAIL PROTECTED]"> Thilina Gunarathne </a> */ public class RegistrationPortTypeRawXMLAsyncMessageReceiver extends - org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver { + org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver { - public void invokeBusinessLogic( - org.apache.axis2.context.MessageContext msgContext, - org.apache.axis2.context.MessageContext newMsgContext) - throws org.apache.axis2.AxisFault { - - try { - - // get the implementation class for the Web Service - Object obj = getTheImplementationObject(msgContext); - - //Inject the Message Context if it is asked for - DependencyManager.configureBusinessLogicProvider(obj, msgContext, - newMsgContext); - - RegistrationPortTypeRawXMLSkeleton skel = (RegistrationPortTypeRawXMLSkeleton) obj; - //Out Envelop - org.apache.axis2.soap.SOAPEnvelope envelope = null; - //Find the operation that has been set by the Dispatch phase. - AxisOperation op = msgContext - .getOperationContext().getAxisOperation(); - - String methodName; - if (op.getName() != null - & (methodName = op.getName().getLocalPart()) != null) { - if (("registerOperation").equals(methodName)) { - OMElement response = null; - - //doc style - response = skel - .registerOperation((org.apache.axis2.om.OMElement) msgContext - .getEnvelope().getBody().getFirstElement() - .detach()); - - //Create a default envelop - envelope = getSOAPFactory().getDefaultEnvelope(); - //Create a Omelement of the result if a result exist - - envelope.getBody().setFirstChild(response); - } - newMsgContext.setEnvelope(envelope); - newMsgContext.setWSAAction(Constants.WS_COOR_REGISTER_RESPONSE); - newMsgContext.setRelatesTo(null); - } - } catch (Exception e) { - throw AxisFault.makeFault(e); - } + public void invokeBusinessLogic( + org.apache.axis2.context.MessageContext msgContext, + org.apache.axis2.context.MessageContext newMsgContext) + throws org.apache.axis2.AxisFault { + + try { + + // get the implementation class for the Web Service + Object obj = getTheImplementationObject(msgContext); + + //Inject the Message Context if it is asked for + DependencyManager.configureBusinessLogicProvider(obj, msgContext, + newMsgContext); + + RegistrationPortTypeRawXMLSkeleton skel = (RegistrationPortTypeRawXMLSkeleton) obj; + //Out Envelop + org.apache.axis2.soap.SOAPEnvelope envelope = null; + //Find the operation that has been set by the Dispatch phase. + AxisOperation op = msgContext.getOperationContext() + .getAxisOperation(); + + String methodName; + if (op.getName() != null + & (methodName = op.getName().getLocalPart()) != null) { + if (("registerOperation").equals(methodName)) { + OMElement response = null; + + //doc style + response = skel + .registerOperation((org.apache.axis2.om.OMElement) msgContext + .getEnvelope().getBody().getFirstElement() + .detach()); + + //Create a default envelop + envelope = getSOAPFactory(msgContext).getDefaultEnvelope(); + //Create a Omelement of the result if a result exist + + envelope.getBody().setFirstChild(response); + } + newMsgContext.setEnvelope(envelope); + newMsgContext.setWSAAction(Constants.WS_COOR_REGISTER_RESPONSE); + newMsgContext.setRelatesTo(null); + } + } catch (Exception e) { + throw AxisFault.makeFault(e); + } - } + } } Modified: webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java?rev=373804&r1=373803&r2=373804&view=diff ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java Tue Jan 31 04:25:53 2006 @@ -29,72 +29,73 @@ import org.apache.kandula.coordinator.Coordinator; import org.apache.kandula.faults.AbstractKandulaException; import org.apache.kandula.storage.StorageFactory; -import org.apache.kandula.utility.KandulaUtils; +import org.apache.kandula.utility.EPRHandlingUtils; /** * @author <a href="mailto:[EMAIL PROTECTED]"> Thilina Gunarathne </a> */ public class RegistrationPortTypeRawXMLSkeleton { - private MessageContext msgContext; + private MessageContext msgContext; - public void init(MessageContext msgContext) { - this.msgContext = msgContext; - } - - public OMElement registerOperation(OMElement request) throws AxisFault { - - String protocolIdentifier; - EndpointReference participantEPR; - String activityId; - StorageFactory.getInstance().setConfigurationContext(msgContext.getServiceContext().getConfigurationContext()); - /* - * Extracting data from the received message - */ - protocolIdentifier = request.getFirstChildWithName( - new QName("ProtocolIdentifier")).getText(); - OMElement participantEPRElement = request - .getFirstChildWithName(new QName("ParticipantProtocolService")); - //Extracting the participant EPR - participantEPR = KandulaUtils.endpointFromOM(participantEPRElement); - - OMElement header = msgContext.getEnvelope().getHeader(); - activityId = header.getFirstChildWithName( - Constants.TRANSACTION_ID_PARAMETER).getText(); - /* - * Registering the participant for the activity for the given protocol - */ - try { - Coordinator coordinator = new Coordinator(); - EndpointReference epr = coordinator.registerParticipant(activityId, - protocolIdentifier, participantEPR); - SOAPFactory factory = OMAbstractFactory.getSOAP12Factory(); - OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR, - "wscoor"); - OMElement responseEle = factory.createOMElement("RegisterResponse", - wsCoor); - responseEle.addChild(toOM(epr)); - return responseEle; - } catch (AbstractKandulaException e) { - AxisFault fault = new AxisFault(e); - fault.setFaultCode(e.getFaultCode()); - throw fault; - } - } - - /** - * Serializes an EndpointRefrence to OM Nodes - */ - private OMElement toOM(EndpointReference epr) { - SOAPFactory factory = OMAbstractFactory.getSOAP12Factory(); - OMNamespace wsCoor = factory.createOMNamespace( - org.apache.kandula.Constants.WS_COOR, "wscoor"); - OMElement protocolService = factory.createOMElement( - "CoordinatorProtocolService", wsCoor); - OMElement coordinatorProtocolService = factory.createOMElement( - "CoordinatorProtocolService", wsCoor); - KandulaUtils.endpointToOM(epr, coordinatorProtocolService, factory); - protocolService.addChild(coordinatorProtocolService); - return protocolService; - } + public void init(MessageContext msgContext) { + this.msgContext = msgContext; + } + + public OMElement registerOperation(OMElement request) throws AxisFault { + + String protocolIdentifier; + EndpointReference participantEPR; + String activityId; + StorageFactory.getInstance().setConfigurationContext( + msgContext.getServiceContext().getConfigurationContext()); + /* + * Extracting data from the received message + */ + protocolIdentifier = request.getFirstChildWithName( + new QName("ProtocolIdentifier")).getText(); + OMElement participantEPRElement = request + .getFirstChildWithName(new QName("ParticipantProtocolService")); + //Extracting the participant EPR + participantEPR = EPRHandlingUtils.endpointFromOM(participantEPRElement); + + OMElement header = msgContext.getEnvelope().getHeader(); + activityId = header.getFirstChildWithName( + Constants.TRANSACTION_ID_PARAMETER).getText(); + /* + * Registering the participant for the activity for the given protocol + */ + try { + Coordinator coordinator = new Coordinator(); + EndpointReference epr = coordinator.registerParticipant(activityId, + protocolIdentifier, participantEPR); + SOAPFactory factory = OMAbstractFactory.getSOAP12Factory(); + OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR, + "wscoor"); + OMElement responseEle = factory.createOMElement("RegisterResponse", + wsCoor); + responseEle.addChild(toOM(epr)); + return responseEle; + } catch (AbstractKandulaException e) { + AxisFault fault = new AxisFault(e); + fault.setFaultCode(e.getFaultCode()); + throw fault; + } + } + + /** + * Serializes an EndpointRefrence to OM Nodes + */ + private OMElement toOM(EndpointReference epr) { + SOAPFactory factory = OMAbstractFactory.getSOAP12Factory(); + OMNamespace wsCoor = factory.createOMNamespace( + org.apache.kandula.Constants.WS_COOR, "wscoor"); + OMElement protocolService = factory.createOMElement( + "CoordinatorProtocolService", wsCoor); + OMElement coordinatorProtocolService = factory.createOMElement( + "CoordinatorProtocolService", wsCoor); + EPRHandlingUtils.endpointToOM(epr, coordinatorProtocolService, factory); + protocolService.addChild(coordinatorProtocolService); + return protocolService; + } } Modified: webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java?rev=373804&r1=373803&r2=373804&view=diff ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java Tue Jan 31 04:25:53 2006 @@ -17,50 +17,50 @@ package org.apache.kandula.wscoor; import org.apache.axis2.addressing.EndpointReference; -import org.apache.axis2.context.MessageContext; import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; import org.apache.axis2.om.OMElement; import org.apache.kandula.Constants; import org.apache.kandula.context.AbstractContext; import org.apache.kandula.context.at.ATActivityContext; import org.apache.kandula.storage.StorageFactory; -import org.apache.kandula.utility.KandulaUtils; +import org.apache.kandula.utility.EPRHandlingUtils; /** * @author <a href="mailto:[EMAIL PROTECTED]"> Thilina Gunarathne </a> */ public class RegistrationRequesterPortTypeRawXMLSkeleton { - private MessageContext msgContext; + private MessageContext msgContext; + + public void init(MessageContext context) { + this.msgContext = context; + } + + public OMElement registerResponseOperation(OMElement responseElement) { + + OMElement response = responseElement.getFirstElement(); + if ("CoordinatorProtocolService".equals(response.getLocalName())) { + OMElement header = msgContext.getEnvelope().getHeader(); + String requesterID = header.getFirstChildWithName( + Constants.REQUESTER_ID_PARAMETER).getText(); + EndpointReference coordinatorService = EPRHandlingUtils + .endpointFromOM(response.getFirstElement()); + // TODO: remove this + ConfigurationContext configurationContext = StorageFactory + .getInstance().getConfigurationContext(); + AbstractContext context; + + context = (AbstractContext) StorageFactory.getInstance() + .getInitiatorStore().get(requesterID); + if (context == null) { + context = (AbstractContext) StorageFactory.getInstance() + .getStore().get(requesterID); + } - public void init(MessageContext context) { - this.msgContext = context; - } - - public OMElement registerResponseOperation(OMElement responseElement) { - - OMElement response = responseElement.getFirstElement(); - if ("CoordinatorProtocolService".equals(response.getLocalName())) { - OMElement header = msgContext.getEnvelope().getHeader(); - String requesterID = header.getFirstChildWithName( - Constants.REQUESTER_ID_PARAMETER).getText(); - EndpointReference coordinatorService = KandulaUtils - .endpointFromOM(response.getFirstElement()); - // TODO: remove this - ConfigurationContext configurationContext = StorageFactory.getInstance().getConfigurationContext(); - AbstractContext context; - if (configurationContext==null) - { - context = (AbstractContext) StorageFactory - .getInstance().getInitiatorStore().get(requesterID); - } - else - { - context = (AbstractContext) StorageFactory.getInstance().getStore().get(requesterID); - } - context.setProperty(ATActivityContext.COORDINATION_EPR, - coordinatorService); - } - return null; - } + context.setProperty(ATActivityContext.COORDINATION_EPR, + coordinatorService); + } + return null; + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
