You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kandula-dev@ws.apache.org by da...@apache.org on 2005/12/22 03:59:40 UTC

svn commit: r358456 - /webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/participant/j2ee/ImportedTransaction.java

Author: dasarath
Date: Wed Dec 21 18:59:39 2005
New Revision: 358456

URL: http://svn.apache.org/viewcvs?rev=358456&view=rev
Log: (empty)

Modified:
    webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/participant/j2ee/ImportedTransaction.java

Modified: webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/participant/j2ee/ImportedTransaction.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/participant/j2ee/ImportedTransaction.java?rev=358456&r1=358455&r2=358456&view=diff
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/participant/j2ee/ImportedTransaction.java (original)
+++ webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/participant/j2ee/ImportedTransaction.java Wed Dec 21 18:59:39 2005
@@ -1,18 +1,18 @@
 /*
- * 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.
- *
+ * 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.ws.transaction.participant.j2ee;
 
@@ -30,36 +30,38 @@
 import org.apache.ws.transaction.wscoor._CoordinationContext;
 
 public class ImportedTransaction extends InterposedTransaction {
-	static final String DURABLE_2PC_PROTOCOL= "http://schemas.xmlsoap.org/ws/2004/10/wsat/Durable2PC";
-	static XATerminator xaTerminator=
-		TransactionManagerGlueFactory.getInstance().getTransactionManagerGlue().getXATerminator();
+	static final String DURABLE_2PC_PROTOCOL = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Durable2PC";
+
+	static XATerminator xaTerminator = TransactionManagerGlueFactory
+			.getInstance().getTransactionManagerGlue().getXATerminator();
+
 	EndpointReference coordinator;
-	Xid xid= new XidImpl();
+
+	Xid xid = new XidImpl();
 
 	public ImportedTransaction(_CoordinationContext ctx) {
-		super.ctx= ctx;
-		System.out.println("[ImportedTransaction]"+ctx.toCoordinationContext().getRegistrationService().getAddress().getHost());
+		super.ctx = ctx;
+		System.out.println("[ImportedTransaction]"
+				+ ctx.toCoordinationContext().getRegistrationService()
+						.getAddress().getHost());
 		try {
-			coordinator=
-				ctx.register(
-					DURABLE_2PC_PROTOCOL,
-					EndpointReferenceFactory.getInstance().getEndpointReference(
-						ParticipantRPCEndpoint.PORT_TYPE,
-						ctx.getActivityId().toReferencePropertiesType()));
-			TransactionImporter importer=
-				TransactionManagerGlueFactory
-					.getInstance()
-					.getTransactionManagerGlue()
+			coordinator = ctx.register(DURABLE_2PC_PROTOCOL,
+					EndpointReferenceFactory.getInstance()
+							.getEndpointReference(
+									ParticipantRPCEndpoint.PORT_TYPE,
+									ctx.getActivityId()
+											.toReferencePropertiesType()));
+			TransactionImporter importer = TransactionManagerGlueFactory
+					.getInstance().getTransactionManagerGlue()
 					.getTransactionImporter();
 			// TODO: implement timeout
-			localTx= importer.importExternalTransaction(xid, Integer.MAX_VALUE);
-		}
-		catch (Exception e) {
+			localTx = importer
+					.importExternalTransaction(xid, Integer.MAX_VALUE);
+		} catch (Exception e) {
 			if (localTx != null) {
 				try {
 					xaTerminator.forget(xid);
-				}
-				catch (Exception _e) {
+				} catch (Exception _e) {
 					_e.printStackTrace();
 				}
 			}
@@ -71,33 +73,31 @@
 		lock();
 		try {
 			switch (status) {
-				case Status.STATUS_ACTIVE :
-					break;
-				case Status.STATUS_PREPARED :
-					return Vote.VoteCommit;
-				case Status.STATUS_COMMITTED :
-					return Vote.VoteReadOnly;
-				case Status.STATUS_ROLLEDBACK :
-					return Vote.VoteRollback;
-				default :
-					throw new IllegalStateException();
+			case Status.STATUS_ACTIVE:
+				break;
+			case Status.STATUS_PREPARED:
+				return Vote.VoteCommit;
+			case Status.STATUS_COMMITTED:
+				return Vote.VoteReadOnly;
+			case Status.STATUS_ROLLEDBACK:
+				return Vote.VoteRollback;
+			default:
+				throw new IllegalStateException();
 			}
-			status= Status.STATUS_PREPARING;
+			status = Status.STATUS_PREPARING;
 			try {
 				if (xaTerminator.prepare(xid) == XAResource.XA_RDONLY) {
-					status= Status.STATUS_COMMITTED;
+					status = Status.STATUS_COMMITTED;
 					return Vote.VoteReadOnly;
 				}
-				status= Status.STATUS_PREPARED;
+				status = Status.STATUS_PREPARED;
 				return Vote.VoteCommit;
-			}
-			catch (XAException e) {
+			} catch (XAException e) {
 				//	TODO: do we need to do a rollback for jotm ???
-				status= Status.STATUS_ROLLEDBACK;
+				status = Status.STATUS_ROLLEDBACK;
 				return Vote.VoteRollback;
 			}
-		}
-		finally {
+		} finally {
 			unlock();
 		}
 	}
@@ -106,18 +106,17 @@
 		lock();
 		try {
 			switch (status) {
-				case Status.STATUS_PREPARED :
-					break;
-				case Status.STATUS_COMMITTED :
-					return;
-				default :
-					throw new IllegalStateException();
+			case Status.STATUS_PREPARED:
+				break;
+			case Status.STATUS_COMMITTED:
+				return;
+			default:
+				throw new IllegalStateException();
 			}
-			status= Status.STATUS_COMMITTING;
+			status = Status.STATUS_COMMITTING;
 			xaTerminator.commit(xid, false);
-			status= Status.STATUS_COMMITTED;
-		}
-		finally {
+			status = Status.STATUS_COMMITTED;
+		} finally {
 			unlock();
 		}
 	}
@@ -126,20 +125,26 @@
 		lock();
 		try {
 			switch (status) {
-				case Status.STATUS_ACTIVE :
-				case Status.STATUS_PREPARED :
-					break;
-				case Status.STATUS_ROLLEDBACK :
-					return;
-				default :
-					throw new IllegalStateException();
+			case Status.STATUS_ACTIVE:
+			case Status.STATUS_PREPARED:
+				break;
+			case Status.STATUS_ROLLEDBACK:
+				return;
+			default:
+				throw new IllegalStateException();
 			}
-			status= Status.STATUS_ROLLING_BACK;
+			status = Status.STATUS_ROLLING_BACK;
 			xaTerminator.rollback(xid);
-			status= Status.STATUS_ROLLEDBACK;
-		}
-		finally {
+			status = Status.STATUS_ROLLEDBACK;
+		} finally {
 			unlock();
 		}
 	}
-}
+
+	/**
+	 * @return Returns the coordinator.
+	 */
+	public EndpointReference getCoordinator() {
+		return coordinator;
+	}
+}
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: kandula-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: kandula-dev-help@ws.apache.org