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:58:59 UTC
svn commit: r358454 - in
/webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/wsat:
CoordinatorPort.java ParticipantEndpoint.java
Author: dasarath
Date: Wed Dec 21 18:58:58 2005
New Revision: 358454
URL: http://svn.apache.org/viewcvs?rev=358454&view=rev
Log: (empty)
Added:
webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/wsat/CoordinatorPort.java
webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/wsat/ParticipantEndpoint.java
Added: webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/wsat/CoordinatorPort.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/wsat/CoordinatorPort.java?rev=358454&view=auto
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/wsat/CoordinatorPort.java (added)
+++ webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/wsat/CoordinatorPort.java Wed Dec 21 18:58:58 2005
@@ -0,0 +1,65 @@
+/*
+ * 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.wsat;
+
+import java.net.URL;
+import java.rmi.RemoteException;
+
+import org.apache.ws.transaction.utility.Service;
+
+/**
+ * @author Dasarath Weeratunge
+ *
+ * Created on Jun 14, 2004
+ */
+public class CoordinatorPort {
+ CoordinatorStub stub;
+
+ public CoordinatorPort(
+ org.apache.axis.message.addressing.EndpointReference epr) {
+ try {
+ // FIXME:
+ String url = epr.getAddress().toString();
+ url= url.replaceAll("wsi\\.alphaworks\\.ibm\\.com:8080", "localhost:8082");
+
+ stub = new CoordinatorStub(new URL(url),
+ new Service(epr));
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e.toString());
+ }
+ }
+
+ public void preparedOperation() throws RemoteException {
+ stub.preparedOperation(null);
+ }
+
+ public void abortedOperation() throws RemoteException {
+ stub.abortedOperation(null);
+ }
+
+ public void readOnlyOperation() throws RemoteException {
+ stub.readOnlyOperation(null);
+ }
+
+ public void committedOperation() throws RemoteException {
+ stub.committedOperation(null);
+ }
+
+ public void replayOperation() throws RemoteException {
+ stub.replayOperation(null);
+ }
+}
\ No newline at end of file
Added: webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/wsat/ParticipantEndpoint.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/wsat/ParticipantEndpoint.java?rev=358454&view=auto
==============================================================================
--- webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/wsat/ParticipantEndpoint.java (added)
+++ webservices/kandula/branches/Kandula_1/src/java/org/apache/ws/transaction/wsat/ParticipantEndpoint.java Wed Dec 21 18:58:58 2005
@@ -0,0 +1,102 @@
+/*
+ * 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.wsat;
+
+import java.rmi.RemoteException;
+
+import org.apache.axis.MessageContext;
+import org.apache.axis.message.MessageElement;
+import org.apache.axis.message.addressing.AddressingHeaders;
+import org.apache.axis.message.addressing.Constants;
+import org.apache.axis.message.addressing.PortType;
+import org.apache.axis.message.addressing.ReferencePropertiesType;
+import org.apache.ws.transaction.coordinator.Identifier;
+import org.apache.ws.transaction.participant.j2ee.ImportedTransaction;
+import org.apache.ws.transaction.participant.j2ee.TransactionBridge;
+
+public class ParticipantEndpoint implements ParticipantPortType {
+ public static final PortType PORT_TYPE = new PortType(
+ "http://schemas.xmlsoap.org/ws/2004/10/wsat", "ParticipantPortType");
+
+ public void prepareOperation(Notification parameters)
+ throws java.rmi.RemoteException {
+ try {
+ Identifier activityId = getActivityId();
+ ImportedTransaction tx = TransactionBridge.getInstance()
+ .getImportedTransaction(activityId);
+ Vote vote = tx.prepare();
+ CoordinatorPort coord = new CoordinatorPort(tx.getCoordinator());
+ if (vote == Vote.VoteCommit)
+ coord.preparedOperation();
+ else if (vote == Vote.VoteReadOnly)
+ coord.readOnlyOperation();
+ else
+ coord.abortedOperation();
+ } catch (Exception e) {
+ if (e instanceof RemoteException)
+ throw (RemoteException) e;
+ else
+ throw new RemoteException(e.toString());
+ }
+ }
+
+ public void commitOperation(Notification parameters)
+ throws java.rmi.RemoteException {
+ try {
+ Identifier activityId = getActivityId();
+ ImportedTransaction tx = TransactionBridge.getInstance()
+ .getImportedTransaction(activityId);
+ tx.commit();
+ CoordinatorPort coord = new CoordinatorPort(tx.getCoordinator());
+ coord.committedOperation();
+ } catch (Exception e) {
+ if (e instanceof RemoteException)
+ throw (RemoteException) e;
+ else
+ throw new RemoteException(e.toString());
+ }
+ }
+
+ public void rollbackOperation(Notification parameters)
+ throws java.rmi.RemoteException {
+ try {
+ Identifier activityId = getActivityId();
+ ImportedTransaction tx = TransactionBridge.getInstance()
+ .getImportedTransaction(activityId);
+ tx.rollback();
+ CoordinatorPort coord = new CoordinatorPort(tx.getCoordinator());
+ coord.abortedOperation();
+ } catch (Exception e) {
+ if (e instanceof RemoteException)
+ throw (RemoteException) e;
+ else
+ throw new RemoteException(e.toString());
+ }
+ }
+
+ private static Identifier getActivityId() throws RemoteException {
+ AddressingHeaders header = (AddressingHeaders) MessageContext
+ .getCurrentContext().getProperty(
+ Constants.ENV_ADDRESSING_REQUEST_HEADERS);
+ ReferencePropertiesType refprop = header.getReferenceProperties();
+ MessageElement e = refprop.get(Identifier.QNAME_IDENTIFIER);
+ if (e != null)
+ return new Identifier(e);
+ else
+ throw new RemoteException();
+ }
+}
\ 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