Return-Path: Delivered-To: apmail-ws-kandula-dev-archive@www.apache.org Received: (qmail 15808 invoked from network); 29 Jan 2007 12:59:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Jan 2007 12:59:50 -0000 Received: (qmail 36184 invoked by uid 500); 29 Jan 2007 12:59:56 -0000 Delivered-To: apmail-ws-kandula-dev-archive@ws.apache.org Received: (qmail 35997 invoked by uid 500); 29 Jan 2007 12:59:55 -0000 Mailing-List: contact kandula-dev-help@ws.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list kandula-dev@ws.apache.org Received: (qmail 35962 invoked by uid 500); 29 Jan 2007 12:59:55 -0000 Delivered-To: apmail-ws-kandula-cvs@ws.apache.org Received: (qmail 35775 invoked by uid 99); 29 Jan 2007 12:59:54 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Jan 2007 04:59:54 -0800 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Jan 2007 04:59:45 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 236071A981D; Mon, 29 Jan 2007 04:59:25 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r501030 [2/2] - in /webservices/kandula/trunk/java/src/org/apache/kandula: ./ context/ context/impl/ coordinator/ coordinator/at/ coordinator/ba/ initiator/ participant/ storage/ utility/ wsat/completion/ wsat/twopc/ wscoor/ Date: Mon, 29 Jan 2007 12:59:24 -0000 To: kandula-cvs@ws.apache.org From: thilina@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070129125925.236071A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java?view=diff&rev=501030&r1=501029&r2=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java Mon Jan 29 04:59:22 2007 @@ -16,22 +16,36 @@ */ package org.apache.kandula.initiator; +import java.io.IOException; +import java.rmi.RemoteException; + import org.apache.axis2.AxisFault; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.ConfigurationContextFactory; +import org.apache.axis2.databinding.types.URI; +import org.apache.axis2.databinding.types.URI.MalformedURIException; import org.apache.axis2.deployment.DeploymentException; import org.apache.kandula.Constants; import org.apache.kandula.Status; +import org.apache.kandula.context.CoordinationContext; +import org.apache.kandula.context.impl.ADBCoordinationContext; import org.apache.kandula.faults.AbstractKandulaException; -import org.apache.kandula.faults.InvalidStateException; import org.apache.kandula.faults.KandulaGeneralException; -import org.apache.kandula.storage.StorageFactory; -import org.apache.kandula.storage.Store; import org.apache.kandula.utility.EndpointReferenceFactory; import org.apache.kandula.wsat.completion.CompletionCoordinatorPortTypeRawXMLStub; -import org.apache.kandula.wscoor.ActivationCoordinatorPortTypeRawXMLStub; -import org.apache.kandula.wscoor.RegistrationCoordinatorPortTypeRawXMLStub; +import org.apache.kandula.wsat.completion.CompletionInitiatorServiceListener; +import org.apache.kandula.wscoor.ActivationServiceStub; +import org.apache.kandula.wscoor.RegistrationServiceStub; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContext; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextResponse; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextResponseType; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.Register; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponse; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType; +import org.xmlsoap.schemas.ws._2004._08.addressing.AttributedURI; +import org.xmlsoap.schemas.ws._2004._08.addressing.EndpointReferenceType; /** * @author Dasarath Weeratunge @@ -39,15 +53,12 @@ */ public class TransactionManager { - - private static ThreadLocal threadInfo; - + + private static ThreadLocal threadInfo = new ThreadLocal(); private ConfigurationContext configurationContext; - public TransactionManager(String coordinationType, - EndpointReference coordinatorEPR, String axis2Home, String axis2Xml) + public TransactionManager(String axis2Home, String axis2Xml) throws AbstractKandulaException { - try { configurationContext = ConfigurationContextFactory .createConfigurationContextFromFileSystem(axis2Home, @@ -57,74 +68,57 @@ } catch (AxisFault e1) { throw new KandulaGeneralException(e1); } - - threadInfo = new ThreadLocal(); - InitiatorTransaction initiatorTransaction = new InitiatorTransaction( - coordinationType, coordinatorEPR); - if (threadInfo.get() != null) - throw new IllegalStateException(); - threadInfo.set(initiatorTransaction.getRequesterID()); - Store store = StorageFactory.getInstance().getInitiatorStore(); - store.put(initiatorTransaction.getRequesterID(), initiatorTransaction); - } - - public void begin() throws Exception { - begin(false); } /** * @throws Exception */ - public void begin(boolean async) throws Exception { + public void begin(String coordinatorAddress) throws Exception { - InitiatorTransaction initiatorTransaction = getTransaction(); - String id = initiatorTransaction.getRequesterID(); - ActivationCoordinatorPortTypeRawXMLStub activationCoordinator = new ActivationCoordinatorPortTypeRawXMLStub( - configurationContext, initiatorTransaction.getActivationEPR()); - activationCoordinator.createCoordinationContextOperation( - initiatorTransaction, async); - while (async & initiatorTransaction.getCoordinationContext() == null) { - // allow other threads to execute - Thread.sleep(10); - } - RegistrationCoordinatorPortTypeRawXMLStub registrationCoordinator = new RegistrationCoordinatorPortTypeRawXMLStub( - configurationContext, initiatorTransaction - .getCoordinationContext().getRegistrationService()); - // TODO make this unaware of the protocol - EndpointReference registrationRequeterPortEPR = EndpointReferenceFactory - .getInstance().getCompletionInitiatorEndpoint(id); - registrationCoordinator.registerOperation(Constants.WS_AT_COMPLETION, - initiatorTransaction.getRequesterID(), - registrationRequeterPortEPR, async); - while (async & initiatorTransaction.getCoordinationEPR() == null) { - Thread.sleep(10); + if (threadInfo.get()!=null) + { + throw new IllegalStateException(); } + InitiatorContext initiatorTransaction = new InitiatorContext(Constants.WS_AT,coordinatorAddress); + CoordinationContext coordinationContext = createTransaction(initiatorTransaction); + initiatorTransaction.setCoordinationContext(coordinationContext); + threadInfo.set(initiatorTransaction); } + + public void commit() throws Exception { - InitiatorTransaction initiatorTransaction = getTransaction(); - EndpointReference coordinationEPR = initiatorTransaction - .getCoordinationEPR(); + InitiatorContext initiatorTransaction = getTransaction(); + CompletionCallback completionCallback = new CompletionCallback(initiatorTransaction); + // Register for completion + EndpointReference coordinationEPR = registerForCompletion(initiatorTransaction,completionCallback); + initiatorTransaction.setCoordinationEPR(coordinationEPR); + CompletionCoordinatorPortTypeRawXMLStub stub = new CompletionCoordinatorPortTypeRawXMLStub( configurationContext, coordinationEPR); stub.commitOperation(); - while ((initiatorTransaction.getStatus() != Status.CoordinatorStatus.STATUS_COMMITTING) - & (initiatorTransaction.getStatus() != Status.CoordinatorStatus.STATUS_ABORTING)) { + while (!completionCallback.isComplete()) Thread.sleep(10); - } - if ((initiatorTransaction.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING)) { + + if ((completionCallback.getResult() == Status.CoordinatorStatus.STATUS_ABORTING)) { + forgetTransaction(); throw new Exception("Aborted"); } forgetTransaction(); } public void rollback() throws Exception { - InitiatorTransaction initiatorTransaction = getTransaction(); - EndpointReference coordinationEPR = initiatorTransaction - .getCoordinationEPR(); + InitiatorContext initiatorTransaction = getTransaction(); + // Register for completion + CompletionCallback completionCallback = new CompletionCallback(initiatorTransaction); + // Register for completion + EndpointReference coordinationEPR = registerForCompletion(initiatorTransaction,completionCallback); + initiatorTransaction.setCoordinationEPR(coordinationEPR); CompletionCoordinatorPortTypeRawXMLStub stub = new CompletionCoordinatorPortTypeRawXMLStub( configurationContext, coordinationEPR); stub.rollbackOperation(); + while (!completionCallback.isComplete()) + Thread.sleep(10); forgetTransaction(); } @@ -145,18 +139,53 @@ // threadInfo.set(null); // } - public static InitiatorTransaction getTransaction() + private static InitiatorContext getTransaction() throws AbstractKandulaException { Object key = threadInfo.get(); - InitiatorTransaction context = (InitiatorTransaction) StorageFactory - .getInstance().getInitiatorStore().get(key); - if (context == null) { - throw new InvalidStateException("No Activity Found"); + if (key!= null) + { + return (InitiatorContext)key; } - return context; + return null; } public static void forgetTransaction() { threadInfo.set(null); + } + + private EndpointReference registerForCompletion(InitiatorContext initiatorTransaction, CompletionCallback completionCallback) throws AxisFault, IOException, MalformedURIException, RemoteException { + RegistrationServiceStub registrationCoordinator = new RegistrationServiceStub( + configurationContext,null); + registrationCoordinator._getServiceClient().setTargetEPR(initiatorTransaction + .getCoordinationContext().getRegistrationService()); + //setup the listener + CompletionInitiatorServiceListener listener = new CompletionInitiatorServiceListener(); + EndpointReference registrationRequeterPortEPR =listener.getEpr(completionCallback); + + Register register = new Register(); + RegisterType registerType = new RegisterType(); + registerType.setProtocolIdentifier(new URI(Constants.WS_AT_COMPLETION)); + registerType.setParticipantProtocolService(EndpointReferenceFactory.getADBEPRTypeFromEPR(registrationRequeterPortEPR)); + register.setRegister(registerType); + //Actual WS call for registeration + RegisterResponse registerResponse = registrationCoordinator + .RegisterOperation(register); + EndpointReference coordinationEPR = EndpointReferenceFactory + .getEPR(registerResponse.getRegisterResponse() + .getCoordinatorProtocolService()); + return coordinationEPR; + } + + private CoordinationContext createTransaction(InitiatorContext initiatorTransaction) throws AxisFault, MalformedURIException, RemoteException { + ActivationServiceStub activationCoordinator = new ActivationServiceStub( + configurationContext,initiatorTransaction.getActivationEPR()); + CreateCoordinationContext context = new CreateCoordinationContext(); + CreateCoordinationContextType createCoordinationContextType = new CreateCoordinationContextType(); + createCoordinationContextType.setCoordinationType(new URI(initiatorTransaction.getCoordinationType())); + context.setCreateCoordinationContext(createCoordinationContextType); + CreateCoordinationContextResponse response = activationCoordinator.CreateCoordinationContextOperation(context); + CreateCoordinationContextResponseType createCoordinationContextResponse = response.getCreateCoordinationContextResponse(); + CoordinationContext coordinationContext = new ADBCoordinationContext(createCoordinationContextResponse.getCoordinationContext()); + return coordinationContext; } } Modified: webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java?view=diff&rev=501030&r1=501029&r2=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java Mon Jan 29 04:59:22 2007 @@ -20,31 +20,45 @@ import org.apache.axis2.AxisFault; import org.apache.axis2.context.MessageContext; import org.apache.axis2.handlers.AbstractHandler; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.kandula.Constants; +import org.apache.kandula.context.AbstractContext; import org.apache.kandula.context.CoordinationContext; -import org.apache.kandula.faults.AbstractKandulaException; public class TransactionOutHandler extends AbstractHandler { - + + /** + * Field log + */ + private static final Log log = LogFactory.getLog(TransactionOutHandler.class); + + private static ThreadLocal threadInfo = new ThreadLocal(); + private static final long serialVersionUID = 4133392345837905499L; - + public InvocationResponse invoke(MessageContext msgContext) throws AxisFault { - - InitiatorTransaction initiatorTransaction; - try { - String wsaAction = msgContext.getWSAAction(); - if ((wsaAction != Constants.WS_COOR_CREATE_COORDINATIONCONTEXT) - && (wsaAction != Constants.WS_COOR_REGISTER) - && (wsaAction != Constants.WS_AT_COMMIT) - && (wsaAction != Constants.WS_AT_ROLLBACK)) { - initiatorTransaction = TransactionManager.getTransaction(); + + InitiatorContext initiatorTransaction; + String wsaAction = msgContext.getWSAAction(); + if ((wsaAction != Constants.WS_COOR_CREATE_COORDINATIONCONTEXT) + && (wsaAction != Constants.WS_COOR_REGISTER) + && (wsaAction != Constants.WS_AT_COMMIT) && (wsaAction != Constants.WS_AT_ROLLBACK)) { + Object context = threadInfo.get(); + if (context==null) + { + context = msgContext.getProperty(Constants.TRANSACTION_CONTEXT); + } + // We let the message to pass through if no transaction is found in the thread or in msgContext + if (context != null) { + AbstractContext txContext = (AbstractContext) context; SOAPHeader soapHeader = msgContext.getEnvelope().getHeader(); - CoordinationContext coorContext = initiatorTransaction - .getCoordinationContext(); + CoordinationContext coorContext = txContext.getCoordinationContext(); soapHeader.addChild(coorContext.toOM()); + } else { + log.debug("Transaction Handler Engaged. " + + "But no transaction information was found in the thread."); } - } catch (AbstractKandulaException e) { - throw new AxisFault(e); } return InvocationResponse.CONTINUE; } Modified: webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantUtility.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantUtility.java?view=diff&rev=501030&r1=501029&r2=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantUtility.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantUtility.java Mon Jan 29 04:59:22 2007 @@ -1,32 +1,74 @@ package org.apache.kandula.participant; import java.io.IOException; +import java.util.Map; +import org.apache.axiom.om.OMElement; import org.apache.axis2.AxisFault; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.databinding.types.URI; +import org.apache.kandula.Constants; import org.apache.kandula.context.impl.ATParticipantContext; import org.apache.kandula.faults.AbstractKandulaException; import org.apache.kandula.utility.EndpointReferenceFactory; import org.apache.kandula.utility.KandulaConfiguration; -import org.apache.kandula.wscoor.RegistrationCoordinatorPortTypeRawXMLStub; +import org.apache.kandula.wscoor.RegistrationServiceStub; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.Register; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponse; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType; +import org.xmlsoap.schemas.ws._2004._08.addressing.AttributedURI; +import org.xmlsoap.schemas.ws._2004._08.addressing.EndpointReferenceType; +import org.xmlsoap.schemas.ws._2004._08.addressing.ReferenceParametersType; public class ParticipantUtility { public static void registerParticipant( - ATParticipantContext participantContext) throws AxisFault { + ATParticipantContext participantContext, + MessageContext messageContext) throws AxisFault { try { ConfigurationContext axis2ConfigurationContext = KandulaConfiguration .getInstance().getPariticipantAxis2ConfigurationContext(); - RegistrationCoordinatorPortTypeRawXMLStub stub = new RegistrationCoordinatorPortTypeRawXMLStub( - axis2ConfigurationContext, participantContext - .getCoordinationContext().getRegistrationService()); + if (axis2ConfigurationContext == null) { + axis2ConfigurationContext = messageContext + .getConfigurationContext(); + } EndpointReference participantProtocolService = EndpointReferenceFactory .getInstance().get2PCParticipantEndpoint( participantContext.getID()); - stub.registerOperation( - participantContext.getRegistrationProtocol(), - participantContext.getID(), participantProtocolService, - false); + + RegistrationServiceStub registrationCoordinator = new RegistrationServiceStub( + axis2ConfigurationContext, null); + registrationCoordinator._getServiceClient().setTargetEPR( + participantContext.getCoordinationContext() + .getRegistrationService()); + + Register register = new Register(); + RegisterType registerType = new RegisterType(); + registerType.setProtocolIdentifier(new URI(participantContext + .getRegistrationProtocol())); + EndpointReferenceType endpointReferenceType = new EndpointReferenceType(); + AttributedURI attributedURI = new AttributedURI(); + attributedURI.setAnyURI(new URI(participantProtocolService + .getAddress())); + endpointReferenceType.setAddress(attributedURI); + // setting reference parameters + ReferenceParametersType referenceParametersType = new ReferenceParametersType(); + Map map = participantProtocolService.getAllReferenceParameters(); + OMElement element = (OMElement) map + .get(Constants.REQUESTER_ID_PARAMETER); + referenceParametersType.addExtraElement(element); + endpointReferenceType + .setReferenceParameters(referenceParametersType); + registerType.setParticipantProtocolService(endpointReferenceType); + register.setRegister(registerType); + // Actual WS call for registeration + RegisterResponse registerResponse = registrationCoordinator + .RegisterOperation(register); + participantContext.setCoordinationEPR(EndpointReferenceFactory + .getEPR(registerResponse.getRegisterResponse() + .getCoordinatorProtocolService())); + } catch (IOException e) { throw new AxisFault(e); } catch (AbstractKandulaException e) { Modified: webservices/kandula/trunk/java/src/org/apache/kandula/participant/TransactionInHandler.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/participant/TransactionInHandler.java?view=diff&rev=501030&r1=501029&r2=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/participant/TransactionInHandler.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/participant/TransactionInHandler.java Mon Jan 29 04:59:22 2007 @@ -29,8 +29,8 @@ import org.apache.kandula.context.CoordinationContext; import org.apache.kandula.context.impl.ATParticipantContext; import org.apache.kandula.context.impl.SimpleCoordinationContext; -import org.apache.kandula.storage.StorageFactory; import org.apache.kandula.storage.Store; +import org.apache.kandula.storage.StorageUtils; public class TransactionInHandler extends AbstractHandler { @@ -45,8 +45,6 @@ && (wsaAction != Constants.WS_COOR_REGISTER) && (wsaAction != Constants.WS_AT_COMMIT) && (wsaAction != Constants.WS_AT_ROLLBACK)) { - StorageFactory.getInstance().setConfigurationContext( - msgContext.getServiceContext().getConfigurationContext()); ATParticipantContext context = new ATParticipantContext(); SOAPHeader header = msgContext.getEnvelope().getHeader(); OMElement coordinationElement = header @@ -60,15 +58,13 @@ coordinationElement); context.setCoordinationContext(coorContext); - Store store = StorageFactory.getInstance().getStore(); - store.put(context.getID(), context); + StorageUtils.putContext(context,context.getID(),msgContext); msgContext.setProperty(AbstractContext.REQUESTER_ID,context.getID()); Parameter resourceFile = msgContext.getParameter( Constants.KANDULA_RESOURCE); //Resource not given. Registration delayed to the business logic if (resourceFile != null) { - try { resource = (KandulaResource) Class.forName((String)resourceFile.getValue()) .newInstance(); @@ -76,7 +72,7 @@ throw new AxisFault(e); } context.setResource(resource); - ParticipantUtility.registerParticipant(context); + ParticipantUtility.registerParticipant(context,msgContext); } } return InvocationResponse.CONTINUE; Added: webservices/kandula/trunk/java/src/org/apache/kandula/storage/StorageUtils.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/storage/StorageUtils.java?view=auto&rev=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/storage/StorageUtils.java (added) +++ webservices/kandula/trunk/java/src/org/apache/kandula/storage/StorageUtils.java Mon Jan 29 04:59:22 2007 @@ -0,0 +1,57 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.kandula.storage; + +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; +import org.apache.kandula.Constants; +import org.apache.kandula.context.AbstractContext; + +public class StorageUtils { + public static AbstractContext getContext(String id) + { + Store store = getStore(MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); + return (AbstractContext)store.get(id); + } + + public static void putContext(AbstractContext context) + { + Store store = getStore(MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); + store.put(context.getCoordinationContext().getActivityID(),context); + } + + public static void putContext(AbstractContext context, String id, MessageContext messageContext) + { + Store store = getStore(messageContext.getServiceContext().getConfigurationContext()); + store.put(id,context); + } + + public static Store getStore(ConfigurationContext configurationContext) { + if (configurationContext == null) + return null; + Store store; + Object storeObect = configurationContext + .getProperty(Constants.KANDULA_STORE); + if (storeObect == null) { + store = new SimpleStore(); + configurationContext.setProperty(Constants.KANDULA_STORE, store); + }else{ + store = (Store)storeObect; + } + return store; + } +} Modified: webservices/kandula/trunk/java/src/org/apache/kandula/utility/EndpointReferenceFactory.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/utility/EndpointReferenceFactory.java?view=diff&rev=501030&r1=501029&r2=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/utility/EndpointReferenceFactory.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/utility/EndpointReferenceFactory.java Mon Jan 29 04:59:22 2007 @@ -1,22 +1,19 @@ /* * Copyright 2004 The Apache Software Foundation. * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under * the License. - * + * */ package org.apache.kandula.utility; -import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.security.MessageDigest; @@ -28,15 +25,21 @@ import javax.xml.namespace.QName; +import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory; import org.apache.axiom.soap.SOAPFactory; import org.apache.axis2.addressing.AddressingConstants; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.addressing.AddressingConstants.Final; +import org.apache.axis2.databinding.types.URI; +import org.apache.axis2.databinding.types.URI.MalformedURIException; import org.apache.kandula.Constants; -import org.apache.kandula.wsat.completion.CompletionInitiatorServiceListener; +import org.xmlsoap.schemas.ws._2004._08.addressing.AttributedURI; +import org.xmlsoap.schemas.ws._2004._08.addressing.EndpointReferenceType; +import org.xmlsoap.schemas.ws._2004._08.addressing.ReferenceParametersType; /** * @author Thilina Gunarathne @@ -62,68 +65,43 @@ public EndpointReference getRegistrationEndpoint(String id) { - EndpointReference epr = new EndpointReference(configuration - .getLocationForEPR() + EndpointReference epr = new EndpointReference(configuration.getLocationForEPR() + "/axis2/services/RegistrationCoordinator"); - EndpointReferenceFactory.addReferenceProperty(epr, - Constants.TRANSACTION_ID_PARAMETER, id); - return epr; - } - - /** - * Sets up a listener in the transaction initiator to recieve notify - * messages mentioning the outcome of the transaction These messages include - * "aborted" and "commited". - * - * @throws IOException - */ - public EndpointReference getCompletionInitiatorEndpoint(String id) - throws IOException { - CompletionInitiatorServiceListener serviceListener = CompletionInitiatorServiceListener - .getInstance(); - EndpointReference epr = serviceListener.getEpr(); - EndpointReferenceFactory.addReferenceProperty(epr, - Constants.REQUESTER_ID_PARAMETER, id); + EndpointReferenceFactory.addReferenceProperty(epr, Constants.TRANSACTION_ID_PARAMETER, id); return epr; } public EndpointReference getCompletionEndpoint(String id) { - EndpointReference epr = new EndpointReference(configuration - .getLocationForEPR() + EndpointReference epr = new EndpointReference(configuration.getLocationForEPR() + "/axis2/services/CompletionCoordinator"); - EndpointReferenceFactory.addReferenceProperty(epr, - Constants.TRANSACTION_ID_PARAMETER, id); + EndpointReferenceFactory.addReferenceProperty(epr, Constants.TRANSACTION_ID_PARAMETER, id); return epr; } - public EndpointReference get2PCCoordinatorEndpoint(String activityId, - String enlistmentId) { + public EndpointReference get2PCCoordinatorEndpoint(String activityId, String enlistmentId) { // Activity ID to find Activity Context , EnlistmentID to find // participant in activity - EndpointReference epr = new EndpointReference(configuration - .getLocationForEPR() + EndpointReference epr = new EndpointReference(configuration.getLocationForEPR() + "/axis2/services/AtomicTransactionCoordinator"); - EndpointReferenceFactory.addReferenceProperty(epr, - Constants.TRANSACTION_ID_PARAMETER, activityId); - EndpointReferenceFactory.addReferenceProperty(epr, - Constants.ENLISTMENT_ID_PARAMETER, enlistmentId); + EndpointReferenceFactory.addReferenceProperty(epr, Constants.TRANSACTION_ID_PARAMETER, + activityId); + EndpointReferenceFactory.addReferenceProperty(epr, Constants.ENLISTMENT_ID_PARAMETER, + enlistmentId); return epr; } public EndpointReference get2PCParticipantEndpoint(String id) { - EndpointReference epr = new EndpointReference(configuration - .getLocationForEPR() + EndpointReference epr = new EndpointReference(configuration.getLocationForEPR() + "/axis2/services/AtomicTransactionParticipant"); - EndpointReferenceFactory.addReferenceProperty(epr, - Constants.REQUESTER_ID_PARAMETER, id); + EndpointReferenceFactory.addReferenceProperty(epr, Constants.REQUESTER_ID_PARAMETER, id); return epr; } /** - * MD5 a random string with localhost/date etc will return 128 bits - * construct a string of 18 characters from those bits. + * MD5 a random string with localhost/date etc will return 128 bits construct a string of 18 + * characters from those bits. * * @return string */ @@ -161,12 +139,10 @@ if (begin < 0) begin = begin * -1; begin = begin % 8; - return new String(sb2.toString().substring(begin, begin + 18)) - .toUpperCase(); + return new String(sb2.toString().substring(begin, begin + 18)).toUpperCase(); } - public static void addReferenceProperty(EndpointReference epr, QName key, - String Value) { + public static void addReferenceProperty(EndpointReference epr, QName key, String Value) { // We'll have to live with reference parameters for the moment // Since Axis2 Addressing does not support ref properties well HashMap refProperties; @@ -182,38 +158,38 @@ public static EndpointReference endpointFromOM(OMElement eprElement) { EndpointReference epr; + epr = new EndpointReference(eprElement.getFirstChildWithName( - new QName("Address")).getText()); + new QName(AddressingConstants.Submission.WSA_NAMESPACE, + AddressingConstants.EPR_ADDRESS)).getText()); HashMap referenceProperties = new HashMap(); - OMElement referencePropertiesElement = eprElement - .getFirstChildWithName(new QName("ReferenceParameters")); - Iterator propertyIter = referencePropertiesElement.getChildElements(); - while (propertyIter.hasNext()) { - OMElement element = (OMElement) propertyIter.next(); - - // TODO do we need to detach the OMElement - referenceProperties.put(element.getQName(), element - .cloneOMElement()); + OMElement referencePropertiesElement = eprElement.getFirstChildWithName(new QName( + "ReferenceParameters")); + if (referencePropertiesElement != null) { + Iterator propertyIter = referencePropertiesElement.getChildElements(); + while (propertyIter.hasNext()) { + OMElement element = (OMElement) propertyIter.next(); + + // TODO do we need to detach the OMElement + referenceProperties.put(element.getQName(), element.cloneOMElement()); + } } - // will have to live with Ref parameters for some time :: Till axis2 - // @ing gets stable + epr.setReferenceParameters(referenceProperties); return epr; } - public static void endpointToOM(EndpointReference epr, OMElement parentEPR, - SOAPFactory factory) { + public static void endpointToOM(EndpointReference epr, OMElement parentEPR, SOAPFactory factory) { OMNamespace wsAddressing = factory.createOMNamespace( AddressingConstants.Submission.WSA_NAMESPACE, AddressingConstants.WSA_DEFAULT_PREFIX); - OMElement addressElement = factory.createOMElement("Address", - wsAddressing); + OMElement addressElement = factory.createOMElement("Address", wsAddressing); addressElement.setText(epr.getAddress()); parentEPR.addChild(addressElement); Map referenceValues = epr.getAllReferenceParameters(); if (referenceValues != null) { - OMElement refPropertyElement = factory.createOMElement( - "ReferenceParameters", wsAddressing); + OMElement refPropertyElement = factory.createOMElement("ReferenceParameters", + wsAddressing); parentEPR.addChild(refPropertyElement); Iterator iterator = referenceValues.keySet().iterator(); while (iterator.hasNext()) { @@ -221,11 +197,89 @@ OMElement omElement = (OMElement) referenceValues.get(key); refPropertyElement.addChild(omElement); if (Final.WSA_NAMESPACE.equals(wsAddressing)) { - omElement.addAttribute( - Final.WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE, + omElement.addAttribute(Final.WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE, Final.WSA_TYPE_ATTRIBUTE_VALUE, wsAddressing); } } } } + + public static OMElement endpointToOM(EndpointReference epr) { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMNamespace wsAddressing = factory.createOMNamespace( + AddressingConstants.Submission.WSA_NAMESPACE, + AddressingConstants.WSA_DEFAULT_PREFIX); + OMElement addressElement = factory.createOMElement("Address", wsAddressing); + addressElement.setText(epr.getAddress()); + + return addressElement; + } + + // bims + public EndpointReference getAtoimcOutcomeCoordinatorEndpoint(String activityId, + String enlistmentId) { + // Activity ID to find Activity Context , EnlistmentID to find + // participant in activity + EndpointReference epr = new EndpointReference(configuration.getLocationForEPR() + + "/axis2/services/AtomicBACoordinator"); + EndpointReferenceFactory.addReferenceProperty(epr, Constants.BA_ID_PARAMETER, activityId); + EndpointReferenceFactory.addReferenceProperty(epr, Constants.ENLISTMENT_ID_PARAMETER, + enlistmentId); + return epr; + } + + // bims + public EndpointReference getMixedOutcomeCoordinatorEndpoint(String activityId, + String enlistmentId) { + // Activity ID to find Activity Context , EnlistmentID to find + // participant in activity + EndpointReference epr = new EndpointReference(configuration.getLocationForEPR() + + "/axis2/services/MixedBACoordinator"); + EndpointReferenceFactory.addReferenceProperty(epr, Constants.BA_ID_PARAMETER, activityId); + EndpointReferenceFactory.addReferenceProperty(epr, Constants.ENLISTMENT_ID_PARAMETER, + enlistmentId); + return epr; + } + + public static EndpointReference getEPR(EndpointReferenceType endpointReferenceType) { + EndpointReference endpointReference = new EndpointReference(endpointReferenceType + .getAddress().getAnyURI().toString()); + ReferenceParametersType parametersType = endpointReferenceType.getReferenceParameters(); + if (parametersType != null) { + OMElement[] elements = parametersType.getExtraElement(); + for (int i = 0; i < elements.length; i++) { + endpointReference.addReferenceParameter(elements[i].getQName(), elements[i] + .getText()); + } + } + return endpointReference; + } + + /** + * Util method to convert org.apache.axis2.addressing.EndpointReference to a ADB generated EPR + * @param endpointReference + * @return + * @throws MalformedURIException + */ + public static EndpointReferenceType getADBEPRTypeFromEPR(EndpointReference endpointReference) + throws MalformedURIException { + EndpointReferenceType endpointReferenceType = new EndpointReferenceType(); + AttributedURI attributedURI = new AttributedURI(); + attributedURI.setAnyURI(new URI(endpointReference.getAddress())); + endpointReferenceType.setAddress(attributedURI); + // setting reference parameters + + Map map = endpointReference.getAllReferenceParameters(); + if (map != null) { + ReferenceParametersType referenceParametersType = new ReferenceParametersType(); + Iterator iterator = map.values().iterator(); + while (iterator.hasNext()) { + OMElement element = (OMElement) iterator.next(); + referenceParametersType.addExtraElement(element); + } + endpointReferenceType.setReferenceParameters(referenceParametersType); + } + return endpointReferenceType; + } + } Modified: webservices/kandula/trunk/java/src/org/apache/kandula/utility/KandulaConfiguration.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/utility/KandulaConfiguration.java?view=diff&rev=501030&r1=501029&r2=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/utility/KandulaConfiguration.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/utility/KandulaConfiguration.java Mon Jan 29 04:59:22 2007 @@ -26,11 +26,14 @@ import org.apache.axis2.deployment.DeploymentException; import org.apache.kandula.faults.AbstractKandulaException; import org.apache.kandula.faults.KandulaGeneralException; -import org.apache.kandula.storage.StorageFactory; /** * @author Thilina Gunarathne */ +/** + * @author thilina + * + */ public class KandulaConfiguration { static final String PROPERTY_FILE = "endpoints.conf"; @@ -157,22 +160,27 @@ return instance; } + + /** + * @return a ConfigurationContext according to the coordinator Axis2.xml & repository configured. + * @throws AbstractKandulaException + */ public ConfigurationContext getPariticipantAxis2ConfigurationContext() throws AbstractKandulaException { try { if (coordinatorAxis2Conf != null && coordinatorAxis2Conf != "") - + { return ConfigurationContextFactory .createConfigurationContextFromFileSystem( participantRepository, participantAxis2Xml); - else { - return StorageFactory.getInstance().getConfigurationContext(); } + } catch (DeploymentException e) { throw new KandulaGeneralException(e); } catch (AxisFault e1) { throw new KandulaGeneralException(e1); } + return null; } public String getParticipantRepository() { @@ -187,18 +195,17 @@ throws AbstractKandulaException { try { if (coordinatorAxis2Conf != null && coordinatorAxis2Conf != "") - + { return ConfigurationContextFactory .createConfigurationContextFromFileSystem( coordinatorRepo, coordinatorAxis2Conf); - else { - return StorageFactory.getInstance().getConfigurationContext(); } } catch (DeploymentException e) { throw new KandulaGeneralException(e); } catch (AxisFault e1) { throw new KandulaGeneralException(e1); } + return null; } public String getCoordinatorRepo() { Modified: webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLSkeleton.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLSkeleton.java?view=diff&rev=501030&r1=501029&r2=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLSkeleton.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLSkeleton.java Mon Jan 29 04:59:22 2007 @@ -20,9 +20,11 @@ import org.apache.axis2.AxisFault; import org.apache.axis2.context.MessageContext; import org.apache.kandula.Constants; +import org.apache.kandula.context.impl.ATActivityContext; import org.apache.kandula.coordinator.at.ATCoordinator; import org.apache.kandula.faults.AbstractKandulaException; -import org.apache.kandula.storage.StorageFactory; +import org.apache.kandula.storage.StorageUtils; + /** * @author Thilina Gunarathne @@ -36,14 +38,13 @@ public void commitOperation(OMElement requestElement) throws AxisFault { String activityId; // log.info("Visited Commit operation"); - StorageFactory.getInstance().setConfigurationContext( - MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader(); activityId = header.getFirstChildWithName( Constants.TRANSACTION_ID_PARAMETER).getText(); try { ATCoordinator coordinator = new ATCoordinator(); - coordinator.commitOperation(activityId); + ATActivityContext atContext = (ATActivityContext) StorageUtils.getContext(activityId); + coordinator.commitOperation(atContext); } catch (AbstractKandulaException e) { e.printStackTrace(); AxisFault fault = new AxisFault(e); @@ -54,17 +55,20 @@ public void rollbackOperation(OMElement requestElement) throws AxisFault { - String activityId; - StorageFactory.getInstance().setConfigurationContext( - MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); // log.info("Visited rollback operation"); OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader(); activityId = header.getFirstChildWithName( Constants.TRANSACTION_ID_PARAMETER).getText(); try { ATCoordinator coordinator = new ATCoordinator(); - coordinator.rollbackOperation(activityId); + ATActivityContext atContext = (ATActivityContext) StorageUtils.getContext(activityId); + // if store throws a Exception capture it + if (atContext == null) { + throw new IllegalStateException( + "No Activity Found for this Activity ID"); + } + coordinator.rollbackOperation(atContext); } catch (AbstractKandulaException e) { AxisFault fault = new AxisFault(e); fault.setFaultCode(e.getFaultCode()); Modified: webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLSkeleton.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLSkeleton.java?view=diff&rev=501030&r1=501029&r2=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLSkeleton.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLSkeleton.java Mon Jan 29 04:59:22 2007 @@ -19,37 +19,41 @@ import org.apache.axiom.om.OMElement; import org.apache.axis2.AxisFault; import org.apache.axis2.context.MessageContext; -import org.apache.kandula.Constants; +import org.apache.axis2.description.Parameter; import org.apache.kandula.Status; -import org.apache.kandula.initiator.InitiatorTransaction; -import org.apache.kandula.storage.StorageFactory; +import org.apache.kandula.initiator.CompletionCallback; /** * @author Thilina Gunarathne */ public class CompletionInitiatorPortTypeRawXMLSkeleton { - public void committedOperation(OMElement requestElement) - throws AxisFault { - StorageFactory.getInstance().setConfigurationContext( - MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); - OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader(); - String requesterID = header.getFirstChildWithName( - Constants.REQUESTER_ID_PARAMETER).getText(); - InitiatorTransaction transaction = (InitiatorTransaction) StorageFactory - .getInstance().getInitiatorStore().get(requesterID); - transaction.setStatus(Status.CoordinatorStatus.STATUS_COMMITTING); + + public void committedOperation(OMElement requestElement) throws AxisFault { + Parameter parameter = MessageContext.getCurrentMessageContext() + .getAxisService().getParameter( + CompletionInitiatorServiceListener.COMPLETION_CALLBACK); + if (parameter != null) { + CompletionCallback callback = (CompletionCallback) parameter + .getValue(); + callback.setStatus(Status.CoordinatorStatus.STATUS_COMMITTING); + callback.setComplete(true); + } else { + // TODO let's do something + } } - public void abortedOperation(OMElement requestElement) - throws AxisFault { - StorageFactory.getInstance().setConfigurationContext( - MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); - OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader(); - String requesterID = header.getFirstChildWithName( - Constants.REQUESTER_ID_PARAMETER).getText(); - InitiatorTransaction transaction = (InitiatorTransaction) StorageFactory - .getInstance().getInitiatorStore().get(requesterID); - transaction.setStatus(Status.CoordinatorStatus.STATUS_ABORTING); + public void abortedOperation(OMElement requestElement) throws AxisFault { + Parameter parameter = MessageContext.getCurrentMessageContext() + .getAxisService().getParameter( + CompletionInitiatorServiceListener.COMPLETION_CALLBACK); + if (parameter != null) { + CompletionCallback callback = (CompletionCallback) parameter + .getValue(); + callback.setStatus(Status.CoordinatorStatus.STATUS_ABORTING); + callback.setComplete(true); + } else { + // TODO let's do something + } } } Modified: webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionInitiatorServiceListener.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionInitiatorServiceListener.java?view=diff&rev=501030&r1=501029&r2=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionInitiatorServiceListener.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionInitiatorServiceListener.java Mon Jan 29 04:59:22 2007 @@ -28,6 +28,8 @@ import org.apache.axis2.description.Parameter; import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver; import org.apache.kandula.Constants; +import org.apache.kandula.initiator.CompletionCallback; +import org.apache.kandula.utility.EndpointReferenceFactory; import org.apache.kandula.utility.KandulaListener; /** @@ -38,34 +40,30 @@ private static CompletionInitiatorServiceListener instance = null; private EndpointReference epr = null; + + public static final String COMPLETION_CALLBACK="completionCallback"; - private CompletionInitiatorServiceListener() { + public CompletionInitiatorServiceListener() { super(); } - public static CompletionInitiatorServiceListener getInstance() { - if (instance == null) { - instance = new CompletionInitiatorServiceListener(); - } - return instance; - } - - public EndpointReference getEpr() throws IOException { + public EndpointReference getEpr(CompletionCallback callback) throws IOException { if (epr == null) { - this.epr = setupListener(); + this.epr = setupListener(callback); } return this.epr; } - private EndpointReference setupListener() throws IOException { + private EndpointReference setupListener(CompletionCallback callback) throws IOException { String className = CompletionInitiatorPortTypeRawXMLSkeleton.class .getName(); - String serviceName = "CompletionInitiatorPortType"; + String serviceName = "CompletionInitiatorPortType"+EndpointReferenceFactory.getRandomStringOf18Characters(); AxisService service = new AxisService(serviceName); service.addParameter(new Parameter( org.apache.axis2.Constants.SERVICE_CLASS, className)); + service.addParameter(new Parameter(COMPLETION_CALLBACK, callback)); service.setFileName((new File(className)).toURL()); - + QName committedOperationName = new QName(Constants.WS_COOR, "committedOperation"); AxisOperation committedOperationDesc; Modified: webservices/kandula/trunk/java/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java?view=diff&rev=501030&r1=501029&r2=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java Mon Jan 29 04:59:22 2007 @@ -20,10 +20,11 @@ import org.apache.axis2.AxisFault; import org.apache.axis2.context.MessageContext; import org.apache.kandula.Constants; +import org.apache.kandula.context.impl.ATActivityContext; import org.apache.kandula.coordinator.at.ATCoordinator; import org.apache.kandula.faults.AbstractKandulaException; import org.apache.kandula.participant.Vote; -import org.apache.kandula.storage.StorageFactory; +import org.apache.kandula.storage.StorageUtils; /** * @author Thilina Gunarathne @@ -35,8 +36,6 @@ */ public void preparedOperation(OMElement requestElement) throws AxisFault { - StorageFactory.getInstance().setConfigurationContext( - MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader(); String activityId = header.getFirstChildWithName( Constants.TRANSACTION_ID_PARAMETER).getText(); @@ -44,7 +43,8 @@ Constants.ENLISTMENT_ID_PARAMETER).getText(); ATCoordinator coordinator = new ATCoordinator(); try { - coordinator.countVote(activityId, Vote.PREPARED, enlistmentId); + ATActivityContext atContext = (ATActivityContext) StorageUtils.getContext(activityId); + coordinator.countVote(atContext, Vote.PREPARED, enlistmentId); } catch (AbstractKandulaException e) { e.printStackTrace(); AxisFault fault = new AxisFault(e); @@ -59,8 +59,6 @@ */ public void abortedOperation(OMElement requestElement) throws AxisFault { - StorageFactory.getInstance().setConfigurationContext( - MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader(); String activityId = header.getFirstChildWithName( Constants.TRANSACTION_ID_PARAMETER).getText(); @@ -68,7 +66,8 @@ Constants.ENLISTMENT_ID_PARAMETER).getText(); ATCoordinator coordinator = new ATCoordinator(); try { - coordinator.abortedOperation(activityId, enlistmentId); + ATActivityContext atContext = (ATActivityContext) StorageUtils.getContext(activityId); + coordinator.abortedOperation(atContext, enlistmentId); } catch (AbstractKandulaException e) { AxisFault fault = new AxisFault(e); fault.setFaultCode(e.getFaultCode()); @@ -82,8 +81,6 @@ */ public void readOnlyOperation(OMElement requestElement) throws AxisFault { - StorageFactory.getInstance().setConfigurationContext( - MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader(); String activityId = header.getFirstChildWithName( Constants.TRANSACTION_ID_PARAMETER).getText(); @@ -91,7 +88,8 @@ Constants.ENLISTMENT_ID_PARAMETER).getText(); ATCoordinator coordinator = new ATCoordinator(); try { - coordinator.countVote(activityId, Vote.READ_ONLY, enlistmentId); + ATActivityContext atContext = (ATActivityContext) StorageUtils.getContext(activityId); + coordinator.countVote(atContext, Vote.READ_ONLY, enlistmentId); } catch (AbstractKandulaException e) { AxisFault fault = new AxisFault(e); fault.setFaultCode(e.getFaultCode()); @@ -105,8 +103,6 @@ */ public void committedOperation(OMElement requestElement) throws AxisFault { - StorageFactory.getInstance().setConfigurationContext( - MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader(); String activityId = header.getFirstChildWithName( Constants.TRANSACTION_ID_PARAMETER).getText(); @@ -114,7 +110,8 @@ Constants.ENLISTMENT_ID_PARAMETER).getText(); ATCoordinator coordinator = new ATCoordinator(); try { - coordinator.countParticipantOutcome(activityId, enlistmentId); + ATActivityContext atContext = (ATActivityContext) StorageUtils.getContext(activityId); + coordinator.countParticipantOutcome(atContext, enlistmentId); } catch (AbstractKandulaException e) { AxisFault fault = new AxisFault(e); fault.setFaultCode(e.getFaultCode()); @@ -127,8 +124,6 @@ * @throws AbstractKandulaException */ public void replayOperation(OMElement requestElement) throws AxisFault { - StorageFactory.getInstance().setConfigurationContext( - MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); System.out.println("Visited Replay operation"); } Modified: webservices/kandula/trunk/java/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java?view=diff&rev=501030&r1=501029&r2=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java (original) +++ webservices/kandula/trunk/java/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java Mon Jan 29 04:59:22 2007 @@ -23,8 +23,7 @@ import org.apache.kandula.context.AbstractContext; import org.apache.kandula.faults.AbstractKandulaException; import org.apache.kandula.participant.ParticipantTransactionCoordinator; -import org.apache.kandula.storage.StorageFactory; -import org.apache.kandula.storage.Store; +import org.apache.kandula.storage.StorageUtils; /** * @author Thilina Gunarathne @@ -32,13 +31,10 @@ public class ParticipantPortTypeRawXMLSkeleton { public void prepareOperation(OMElement requestEle) throws AxisFault { - StorageFactory.getInstance().setConfigurationContext( - MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader(); String requesterID = header.getFirstChildWithName( Constants.REQUESTER_ID_PARAMETER).getText(); - Store store = StorageFactory.getInstance().getStore(); - AbstractContext context = (AbstractContext) store.get(requesterID); + AbstractContext context = StorageUtils.getContext(requesterID); ParticipantTransactionCoordinator txManager = new ParticipantTransactionCoordinator(); try { txManager.prepare(context); @@ -51,13 +47,10 @@ } public void commitOperation(OMElement requestEle) throws AxisFault { - StorageFactory.getInstance().setConfigurationContext( - MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader(); String requesterID = header.getFirstChildWithName( Constants.REQUESTER_ID_PARAMETER).getText(); - Store store = StorageFactory.getInstance().getStore(); - AbstractContext context = (AbstractContext) store.get(requesterID); + AbstractContext context = StorageUtils.getContext(requesterID); ParticipantTransactionCoordinator participantTxManager = new ParticipantTransactionCoordinator(); try { participantTxManager.commit(context); @@ -69,13 +62,10 @@ } public void rollbackOperation(OMElement requestEle) throws AxisFault { - StorageFactory.getInstance().setConfigurationContext( - MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext()); OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader(); String requesterID = header.getFirstChildWithName( Constants.REQUESTER_ID_PARAMETER).getText(); - Store store = StorageFactory.getInstance().getStore(); - AbstractContext context = (AbstractContext) store.get(requesterID); + AbstractContext context = StorageUtils.getContext(requesterID); ParticipantTransactionCoordinator txManager = new ParticipantTransactionCoordinator(); try { txManager.rollback(context); Added: webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/ActivationServiceSkeleton.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/ActivationServiceSkeleton.java?view=auto&rev=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/ActivationServiceSkeleton.java (added) +++ webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/ActivationServiceSkeleton.java Mon Jan 29 04:59:22 2007 @@ -0,0 +1,106 @@ +/** + * ActivationServiceSkeleton.java + * + * This file was auto-generated from WSDL by the Apache Axis2 version: 1.1.1 Jan 09, 2007 (06:20:51 + * LKT) + */ +package org.apache.kandula.wscoor; + +import java.util.Map; + +import org.apache.axiom.om.OMElement; +import org.apache.axis2.AxisFault; +import org.apache.axis2.context.ServiceContext; +import org.apache.axis2.databinding.types.URI; +import org.apache.axis2.databinding.types.UnsignedInt; +import org.apache.axis2.databinding.types.URI.MalformedURIException; +import org.apache.kandula.Constants; +import org.apache.kandula.context.AbstractContext; +import org.apache.kandula.context.CoordinationContext; +import org.apache.kandula.coordinator.Coordinator; +import org.apache.kandula.faults.AbstractKandulaException; +import org.apache.kandula.storage.StorageUtils; +import org.apache.kandula.utility.EndpointReferenceFactory; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext_type3; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextResponse; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextResponseType; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires_type0; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.Identifier_type1; +import org.xmlsoap.schemas.ws._2004._08.addressing.AttributedURI; +import org.xmlsoap.schemas.ws._2004._08.addressing.EndpointReferenceType; +import org.xmlsoap.schemas.ws._2004._08.addressing.ReferenceParametersType; + +/** + * ActivationServiceSkeleton java skeleton for the axisService + */ +public class ActivationServiceSkeleton { + + public void init(ServiceContext serviceContext) + { + + } + /** + * Auto generated method signature + * + * @param param0 + * @throws AxisFault + * + */ + public org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextResponse CreateCoordinationContextOperation( + org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContext param0) + throws AxisFault { + /* + * Extracting data from the incoming message + */ + CreateCoordinationContextType createCoordinationContext = param0 + .getCreateCoordinationContext(); + String coordinationType = createCoordinationContext.getCoordinationType().toString(); + Expires_type0 expires = createCoordinationContext.getExpires(); + long expiresL = 0; + if (expires != null) { + expiresL = expires.getUnsignedInt().longValue(); + } + + /* + * Creating the Coordination Context + */ + try { + Coordinator coordinator = new Coordinator(); + AbstractContext context = coordinator.createCoordinationContext(coordinationType, + expiresL); + StorageUtils.putContext(context); + + CoordinationContext coordinationContext = context.getCoordinationContext(); + + // filling the data bounded coordination context + CoordinationContext_type3 coordinationContext_type3 = new CoordinationContext_type3(); + coordinationContext_type3.setCoordinationType(new URI(coordinationContext + .getCoordinationType())); + Expires_type0 expires_type0 = new Expires_type0(); + expires_type0.setUnsignedInt(new UnsignedInt(coordinationContext.getExpires())); + coordinationContext_type3.setExpires(expires_type0); + + coordinationContext_type3.setRegistrationService(EndpointReferenceFactory + .getADBEPRTypeFromEPR(coordinationContext.getRegistrationService())); + + Identifier_type1 identifier_type1 = new Identifier_type1(); + identifier_type1.setAnyURI(new URI("http", "thilina")); + coordinationContext_type3.setIdentifier(identifier_type1); + + CreateCoordinationContextResponse response = new CreateCoordinationContextResponse(); + CreateCoordinationContextResponseType createCoordinationContextResponseType = new CreateCoordinationContextResponseType(); + createCoordinationContextResponseType.setCoordinationContext(coordinationContext_type3); + response.setCreateCoordinationContextResponse(createCoordinationContextResponseType); + return response; + } catch (AbstractKandulaException e) { + AxisFault fault = new AxisFault(e); + fault.setFaultCode(e.getFaultCode()); + throw fault; + } catch (MalformedURIException e) { + AxisFault fault = new AxisFault(e); + throw fault; + } + + } +} Added: webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationServiceSkeleton.java URL: http://svn.apache.org/viewvc/webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationServiceSkeleton.java?view=auto&rev=501030 ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationServiceSkeleton.java (added) +++ webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationServiceSkeleton.java Mon Jan 29 04:59:22 2007 @@ -0,0 +1,95 @@ +/** + * RegistrationServiceSkeleton.java + * + * This file was auto-generated from WSDL + * by the Apache Axis2 version: 1.1.1 Jan 09, 2007 (06:20:51 LKT) + */ +package org.apache.kandula.wscoor; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMNamespace; +import org.apache.axiom.soap.SOAPFactory; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.context.ServiceContext; +import org.apache.axis2.databinding.types.URI.MalformedURIException; +import org.apache.kandula.Constants; +import org.apache.kandula.context.AbstractContext; +import org.apache.kandula.coordinator.Coordinator; +import org.apache.kandula.faults.AbstractKandulaException; +import org.apache.kandula.storage.StorageUtils; +import org.apache.kandula.utility.EndpointReferenceFactory; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponse; +import org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType; + +/** + * RegistrationServiceSkeleton java skeleton for the axisService + */ +public class RegistrationServiceSkeleton { + + public void init(ServiceContext serviceContext) + { + + } + + /** + * Auto generated method signature + + * @param param0 + * @throws AxisFault + + */ + public org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponse RegisterOperation( + org.oasis_open.docs.ws_tx.wscoor._2006._06.Register param0) throws AxisFault + + { + + String protocolIdentifier; + EndpointReference participantEPR; + String activityId; + /* + * Extracting data from the received message + */ + protocolIdentifier = param0.getRegister().getProtocolIdentifier().toString(); + // Extracting the participant EPR + participantEPR = EndpointReferenceFactory + .getEPR(param0.getRegister().getParticipantProtocolService()); + + OMElement header = MessageContext.getCurrentMessageContext() + .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(); + AbstractContext context = (AbstractContext) StorageUtils + .getContext(activityId); + if (context == null) { + throw new IllegalStateException( + "No Activity Found for this Activity ID"); + } + EndpointReference epr = coordinator.registerParticipant(context, + protocolIdentifier, participantEPR); + + RegisterResponseType registerResponseType = new RegisterResponseType(); + registerResponseType.setCoordinatorProtocolService(EndpointReferenceFactory.getADBEPRTypeFromEPR(epr)); + RegisterResponse registerResponse = new RegisterResponse(); + registerResponse.setRegisterResponse(registerResponseType); + return registerResponse; + } catch (AbstractKandulaException e) { + AxisFault fault = new AxisFault(e); + fault.setFaultCode(e.getFaultCode()); + throw fault; + } catch (MalformedURIException e) { + AxisFault fault = new AxisFault(e); + throw fault; + } + } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: kandula-dev-unsubscribe@ws.apache.org For additional commands, e-mail: kandula-dev-help@ws.apache.org