Return-Path: Delivered-To: apmail-ws-kandula-dev-archive@www.apache.org Received: (qmail 85104 invoked from network); 14 Sep 2005 13:36:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Sep 2005 13:36:59 -0000 Received: (qmail 14792 invoked by uid 500); 14 Sep 2005 13:36:55 -0000 Delivered-To: apmail-ws-kandula-dev-archive@ws.apache.org Received: (qmail 14722 invoked by uid 500); 14 Sep 2005 13:36:54 -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 14698 invoked by uid 500); 14 Sep 2005 13:36:54 -0000 Delivered-To: apmail-ws-kandula-cvs@ws.apache.org Received: (qmail 14684 invoked by uid 99); 14 Sep 2005 13:36:54 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 14 Sep 2005 06:36:54 -0700 Received: (qmail 84968 invoked by uid 65534); 14 Sep 2005 13:36:53 -0000 Message-ID: <20050914133653.84967.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r280850 - in /webservices/kandula/trunk/java/src/org/apache/kandula: ./ initiator/ initiator/TransactionManager.java initiator/handler/ initiator/handler/TransactionHandler.java Date: Wed, 14 Sep 2005 13:36:53 -0000 To: kandula-cvs@ws.apache.org From: thilina@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: thilina Date: Wed Sep 14 06:36:44 2005 New Revision: 280850 URL: http://svn.apache.org/viewcvs?rev=280850&view=rev Log: Moving Transaction manager to the correct place Added: webservices/kandula/trunk/java/src/org/apache/kandula/initiator/ webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java webservices/kandula/trunk/java/src/org/apache/kandula/initiator/handler/ webservices/kandula/trunk/java/src/org/apache/kandula/initiator/handler/TransactionHandler.java Modified: webservices/kandula/trunk/java/src/org/apache/kandula/ (props changed) Propchange: webservices/kandula/trunk/java/src/org/apache/kandula/ ('svn:ignore' removed) Added: webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java?rev=280850&view=auto ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java (added) +++ webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java Wed Sep 14 06:36:44 2005 @@ -0,0 +1,130 @@ +/* + * 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.participant.standalone; + +import java.rmi.RemoteException; + +import org.apache.axis2.addressing.EndpointReference; +import org.apache.kandula.KandulaException; +import org.apache.kandula.context.ActivityContext; +import org.apache.kandula.context.ContextFactory; +import org.apache.kandula.context.at.ATActivityContext; +import org.apache.kandula.storage.StorageFactory; +import org.apache.kandula.storage.Store; +import org.apache.kandula.utility.EndpointReferenceFactory; +import org.apache.kandula.wscoor.ActivationCoordinatorPortTypeRawXMLStub; +import org.apache.kandula.wscoor.RegistrationCoordinatorPortTypeRawXMLStub; + +/** + * @author Dasarath Weeratunge + * @author Thilina Gunarathne + */ + +public class TransactionManager { + + private ThreadLocal threadInfo; + + //till we get reply to reference properties correctly in Axis 2 Addressing + public static String tempID; + + public TransactionManager(String coordinationType, + EndpointReference coordEPR) throws KandulaException { + threadInfo = new ThreadLocal(); + ActivityContext context = ContextFactory.getInstance().createActivity( + coordinationType, coordEPR); + if (threadInfo.get() != null) + throw new IllegalStateException(); + threadInfo.set(context.getProperty(ATActivityContext.REQUESTER_ID)); + //TODO remove this when we get replyTo reference properties correctly + tempID = (String) context.getProperty(ATActivityContext.REQUESTER_ID); + Store store = StorageFactory.getInstance().getStore(); + store.putContext(context.getProperty(ATActivityContext.REQUESTER_ID), + context); + } + + /** + * @throws Exception + */ + public void begin() throws Exception { + ActivityContext context = getTransaction(); + String id = (String) context + .getProperty(ATActivityContext.REQUESTER_ID); + threadInfo.set(id); + ActivationCoordinatorPortTypeRawXMLStub activationCoordinator = new ActivationCoordinatorPortTypeRawXMLStub( + ".", (EndpointReference) context + .getProperty(ATActivityContext.ACTIVATION_EPR)); + activationCoordinator.createCoordinationContextOperation( + org.apache.kandula.Constants.WS_AT, id); + while (context.getCoordinationContext() == null) { + //allow other threads to execute + Thread.sleep(10); + } + RegistrationCoordinatorPortTypeRawXMLStub registrationCoordinator = new RegistrationCoordinatorPortTypeRawXMLStub( + ".", context.getCoordinationContext().getRegistrationService()); + EndpointReference registrationRequeterPortEPR = EndpointReferenceFactory + .getInstance().getCompletionParticipantEndpoint(id); + registrationCoordinator.RegisterOperation( + org.apache.kandula.Constants.WS_AT_COMPLETION, + registrationRequeterPortEPR, id); + while (true) { + Thread.sleep(10); + } + } + + public void commit() throws RemoteException { + // Transaction tx= getTransaction(); + // if (tx == null) + // throw new IllegalStateException(); + // forget(); + // tx.commit(); + } + + public void rollback() throws RemoteException { + // Transaction tx= getTransaction(); + // if (tx == null) + // throw new IllegalStateException(); + // forget(); + // tx.rollback(); + } + + // public Transaction suspend() { + // Transaction tx= getTransaction(); + // forget(); + // return tx; + // } + // + // public void resume(Transaction tx) { + // if (threadInfo.get() != null) + // throw new IllegalStateException(); + // else + // threadInfo.set(tx); + // } + // + // public void forget() { + // threadInfo.set(null); + // } + + public ActivityContext getTransaction() throws KandulaException { + Object key = threadInfo.get(); + ActivityContext context = StorageFactory.getInstance().getStore() + .getContext(key); + if (context == null) { + throw new KandulaException("IllegalState"); + } + return context; + } +} \ No newline at end of file Added: webservices/kandula/trunk/java/src/org/apache/kandula/initiator/handler/TransactionHandler.java URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/initiator/handler/TransactionHandler.java?rev=280850&view=auto ============================================================================== --- webservices/kandula/trunk/java/src/org/apache/kandula/initiator/handler/TransactionHandler.java (added) +++ webservices/kandula/trunk/java/src/org/apache/kandula/initiator/handler/TransactionHandler.java Wed Sep 14 06:36:44 2005 @@ -0,0 +1,39 @@ +/* + * 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.participant.standalone.handler; + + + + +/** + * @author Dasarath Weeratunge + */ +//public class TransactionHandler extends BasicHandler { +//// TransactionManager tm= TransactionManager.getInstance(); +//// public void invoke(MessageContext msgContext) throws AxisFault { +//// Transaction tx= tm.getTransaction(); +//// if (tx != null) { +//// try { +//// SOAPHeader header= msgContext.getCurrentMessage().getSOAPEnvelope().getHeader(); +//// tx.getCoordinationContex().toSOAPHeaderElement(header); +//// } +//// catch (Exception e) { +//// throw AxisFault.makeFault(e); +//// } +//// } +//// } +//} --------------------------------------------------------------------- To unsubscribe, e-mail: kandula-dev-unsubscribe@ws.apache.org For additional commands, e-mail: kandula-dev-help@ws.apache.org