From 07b7dfd1a70ba222b899d9813f8c449dbf3b785f Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:07:28 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835124 13f79535-47bb-0310-9956-ffa450edef68 --- .../transaction/IncompatibleIntentException.java | 44 ---- .../sca/policy/transaction/TransactionIntent.java | 24 -- .../policy/transaction/TransactionInterceptor.java | 122 ----------- .../transaction/TransactionManagerHelper.java | 243 --------------------- .../transaction/TransactionManagerWrapper.java | 90 -------- .../transaction/TransactionModuleActivator.java | 80 ------- .../sca/policy/transaction/TransactionPolicy.java | 45 ---- .../transaction/TransactionPolicyHandler.java | 70 ------ .../policy/transaction/TransactionPolicyImpl.java | 44 ---- .../transaction/TransactionPolicyProcessor.java | 95 -------- .../TransactionRuntimeWireProcessor.java | 78 ------- .../policy/transaction/TransactionalAction.java | 31 --- 12 files changed, 966 deletions(-) delete mode 100644 branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/IncompatibleIntentException.java delete mode 100644 branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionIntent.java delete mode 100644 branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionInterceptor.java delete mode 100644 branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelper.java delete mode 100644 branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerWrapper.java delete mode 100644 branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionModuleActivator.java delete mode 100644 branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicy.java delete mode 100644 branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyHandler.java delete mode 100644 branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyImpl.java delete mode 100644 branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyProcessor.java delete mode 100644 branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionRuntimeWireProcessor.java delete mode 100644 branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionalAction.java (limited to 'branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction') diff --git a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/IncompatibleIntentException.java b/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/IncompatibleIntentException.java deleted file mode 100644 index 8a242924ee..0000000000 --- a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/IncompatibleIntentException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.policy.transaction; - -/** - * @version $Rev$ $Date$ - */ -public class IncompatibleIntentException extends Exception { - private static final long serialVersionUID = -2993825019200280397L; - - public IncompatibleIntentException() { - super(); - } - - public IncompatibleIntentException(String message, Throwable cause) { - super(message, cause); - } - - public IncompatibleIntentException(String message) { - super(message); - } - - public IncompatibleIntentException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionIntent.java b/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionIntent.java deleted file mode 100644 index ab142bfc1c..0000000000 --- a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionIntent.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.policy.transaction; - -public enum TransactionIntent { - managedTransactionLocal, managedTransactionGlobal, noManagedTransaction, propagatesTransacton, suspendsTransaction, transactedOneWay, immediateOneWay -} diff --git a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionInterceptor.java b/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionInterceptor.java deleted file mode 100644 index 0de98592cb..0000000000 --- a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionInterceptor.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.policy.transaction; - -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; - -/** - * @version $Rev$ $Date$ - */ -public class TransactionInterceptor implements Interceptor { - private Invoker next; - private TransactionManagerHelper helper; - private boolean outbound; - private TransactionPolicy interactionPolicy; - private TransactionPolicy implementationPolicy; - - public TransactionInterceptor(TransactionManagerHelper helper, - boolean outbound, - TransactionPolicy interactionPolicy, - TransactionPolicy implementationPolicy) { - super(); - this.helper = helper; - this.outbound = outbound; - this.interactionPolicy = interactionPolicy; - this.implementationPolicy = implementationPolicy; - } - - /** - * @see org.apache.tuscany.sca.invocation.Interceptor#getNext() - */ - public Invoker getNext() { - return next; - } - - /** - * @see org.apache.tuscany.sca.invocation.Interceptor#setNext(org.apache.tuscany.sca.invocation.Invoker) - */ - public void setNext(Invoker next) { - this.next = next; - } - - /** - * @see org.apache.tuscany.sca.invocation.Invoker#invoke(org.apache.tuscany.sca.invocation.Message) - */ - public Message invoke(Message msg) { - TransactionalInvocation invocation = new TransactionalInvocation(next, msg); - - Message result = null; - if (msg.getOperation().isNonBlocking()) { - - } - TransactionIntent interactionIntent = TransactionIntent.propagatesTransacton; - if (interactionPolicy != null) { - if (interactionPolicy.getAction() == TransactionPolicy.Action.PROPAGATE) { - interactionIntent = TransactionIntent.propagatesTransacton; - } else { - interactionIntent = TransactionIntent.suspendsTransaction; - } - } - TransactionIntent implementationIntent = TransactionIntent.managedTransactionGlobal; - if (implementationPolicy != null) { - switch (implementationPolicy.getAction()) { - case REQUIRE_GLOBAL: - implementationIntent = TransactionIntent.managedTransactionGlobal; - break; - case REQUIRE_LOCAL: - implementationIntent = TransactionIntent.managedTransactionLocal; - break; - default: - implementationIntent = TransactionIntent.noManagedTransaction; - break; - } - } - try { - if (outbound) { - result = helper.handlesOutbound(interactionIntent, implementationIntent, invocation); - } else { - result = helper.handlesInbound(interactionIntent, implementationIntent, invocation); - } - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return result; - } - - private static class TransactionalInvocation implements TransactionalAction { - private final Invoker invoker; - private final Message message; - - public TransactionalInvocation(Invoker invoker, Message message) { - super(); - this.invoker = invoker; - this.message = message; - } - - public Message run() throws Exception { - return invoker.invoke(message); - } - - } - -} diff --git a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelper.java b/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelper.java deleted file mode 100644 index defe12967e..0000000000 --- a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerHelper.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.policy.transaction; - -import java.lang.reflect.InvocationTargetException; - -import javax.transaction.HeuristicMixedException; -import javax.transaction.HeuristicRollbackException; -import javax.transaction.InvalidTransactionException; -import javax.transaction.NotSupportedException; -import javax.transaction.RollbackException; -import javax.transaction.Status; -import javax.transaction.SystemException; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; - -/** - * @version $Rev$ $Date$ - */ -public class TransactionManagerHelper { - // private static final Logger logger = Logger.getLogger(TransactionManagerHelper.class.getName()); - - private TransactionManager tm; - - public TransactionManagerHelper(TransactionManager tm) { - super(); - this.tm = tm; - } - - public Transaction managedGlobalTransactionPreInvoke() throws SystemException, NotSupportedException { - int status = tm.getStatus(); - if (status == Status.STATUS_COMMITTED || status == Status.STATUS_NO_TRANSACTION - || status == Status.STATUS_ROLLEDBACK) { - tm.begin(); - return tm.getTransaction(); - } - return null; - } - - public void managedGlobalTransactionPostInvoke(Transaction created, boolean rollback) - throws InvalidTransactionException, IllegalStateException, SystemException, SecurityException, - HeuristicMixedException, HeuristicRollbackException, RollbackException { - if (created != null) { - int status = created.getStatus(); - if (status == Status.STATUS_MARKED_ROLLBACK) { - created.rollback(); - } else if (status == Status.STATUS_ACTIVE) { - if (rollback) { - created.rollback(); - } else { - created.commit(); - } - } - } - } - - public Transaction suspendsTransactionPreInvoke() throws SystemException { - if (tm.getTransaction() != null) { - return tm.suspend(); - } else { - return null; - } - } - - public void suspendsTransactionPostInvoke(Transaction suspended) throws InvalidTransactionException, - IllegalStateException, SystemException { - if (suspended != null) { - tm.resume(suspended); - } - } - - public TransactionManager getTransactionManager() { - return tm; - } - - public void setTransactionManager(TransactionManager tm) { - this.tm = tm; - } - - public void validateOneway(TransactionIntent onewayIntent, TransactionIntent implIntent) - throws IncompatibleIntentException { - if (onewayIntent == TransactionIntent.transactedOneWay) { - if (implIntent != TransactionIntent.managedTransactionGlobal) { - throw new IncompatibleIntentException(onewayIntent + "<-X->" + implIntent); - } - } - } - - public void validateInbound(TransactionIntent serviceIntent, TransactionIntent implIntent) - throws IncompatibleIntentException { - if (serviceIntent == TransactionIntent.propagatesTransacton) { - if (implIntent != TransactionIntent.managedTransactionGlobal) { - throw new IncompatibleIntentException(serviceIntent + "<-X->" + implIntent); - } - } - } - - public void validateOutbound(TransactionIntent referenceIntent, TransactionIntent implIntent) - throws IncompatibleIntentException { - if (referenceIntent == TransactionIntent.propagatesTransacton) { - if (implIntent != TransactionIntent.managedTransactionGlobal) { - throw new IncompatibleIntentException(referenceIntent + "<-X->" + implIntent); - } - } - } - - public T handlesOutbound(TransactionIntent referenceIntent, - TransactionIntent implIntent, - TransactionalAction action) throws Exception { - - if (implIntent == null) { - implIntent = TransactionIntent.noManagedTransaction; - } - - if (referenceIntent == TransactionIntent.propagatesTransacton) { - if (implIntent != TransactionIntent.managedTransactionGlobal) { - throw new IncompatibleIntentException(referenceIntent + "<-X->" + implIntent); - } else { - // propagates the current TX - return run(action); - } - } else if (referenceIntent == TransactionIntent.suspendsTransaction) { - Transaction tx = suspendsTransactionPreInvoke(); - try { - return run(action); - } finally { - suspendsTransactionPostInvoke(tx); - } - } else { - return run(action); - } - } - - private T run(TransactionalAction action) throws Exception { - // Make sure a global TX is in place - Transaction tx = managedGlobalTransactionPreInvoke(); - boolean rollback = false; - try { - return action.run(); - } catch (InvocationTargetException e) { - throw e; - } catch (Throwable e) { - rollback = true; - if (e instanceof Error) { - throw (Error)e; - } else if (e instanceof RuntimeException) { - throw (RuntimeException)e; - } else { - throw (Exception)e; - } - } finally { - managedGlobalTransactionPostInvoke(tx, rollback); - } - } - - public T handlesInbound(TransactionIntent serviceIntent, - TransactionIntent implIntent, - TransactionalAction action) throws Exception { - if (serviceIntent == null && implIntent == null) { - return run(action); - } - - if (implIntent == null) { - implIntent = TransactionIntent.noManagedTransaction; - } - - if (serviceIntent == TransactionIntent.propagatesTransacton) { - if (implIntent != TransactionIntent.managedTransactionGlobal) { - throw new IncompatibleIntentException(serviceIntent + "<-X->" + implIntent); - } else { - return run(action); - } - } else if (serviceIntent == TransactionIntent.suspendsTransaction) { - Transaction tx1 = suspendsTransactionPreInvoke(); - try { - if (implIntent == TransactionIntent.managedTransactionGlobal) { - return run(action); - } else { - return action.run(); - } - } finally { - suspendsTransactionPostInvoke(tx1); - } - } else { - if (implIntent == TransactionIntent.managedTransactionGlobal) { - // Start a new TX - return run(action); - } else { - return action.run(); - } - } - } - - public void handlesOneWay(TransactionIntent onewayIntent, - TransactionIntent implIntent, - TransactionalAction action) throws Exception { - if (implIntent == null) { - implIntent = TransactionIntent.noManagedTransaction; - } - - if (onewayIntent == null) { - // Assume transactedOneWay - run(action); - return; - } - - if (onewayIntent == TransactionIntent.transactedOneWay) { - if (implIntent != TransactionIntent.managedTransactionGlobal) { - throw new IncompatibleIntentException(onewayIntent + "<-X->" + implIntent); - } else { - run(action); - return; - } - } else { - // TransactionIntent.immediateOneWay - Transaction tx = suspendsTransactionPreInvoke(); - try { - run(action); - return; - } finally { - suspendsTransactionPostInvoke(tx); - } - } - } - -} diff --git a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerWrapper.java b/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerWrapper.java deleted file mode 100644 index 31beab4fca..0000000000 --- a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionManagerWrapper.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.policy.transaction; - -import java.io.File; - -import javax.transaction.TransactionManager; - -import org.apache.geronimo.transaction.log.HOWLLog; -import org.apache.geronimo.transaction.manager.GeronimoTransactionManager; -import org.apache.geronimo.transaction.manager.XidFactory; -import org.apache.geronimo.transaction.manager.XidFactoryImpl; - -/** - * @version $Rev$ $Date$ - */ -public class TransactionManagerWrapper { - private TransactionManager transactionManager; - private HOWLLog howlLog; - - private String logFileDir = "target/logs"; - private String bufferClassName = "org.objectweb.howl.log.BlockLogBuffer"; - private int bufferSizeKBytes = 32; - private boolean checksumEnabled = true; - private boolean adler32Checksum = true; - private int flushSleepTimeMilliseconds = 50; - private String logFileExt = "log"; - private String logFileName = "transaction"; - private int maxBlocksPerFile = -1; - private int maxLogFiles = 2; - private int maxBuffers = 0; - private int minBuffers = 4; - private int threadsWaitingForceThreshold = -1; - private File serverBaseDir = new File(System.getProperty("basedir", System.getProperty("user.dir"))); - - public TransactionManagerWrapper() { - super(); - } - - public void start() { - try { - XidFactory xidFactory = new XidFactoryImpl(); - howlLog = - new HOWLLog(bufferClassName, bufferSizeKBytes, checksumEnabled, adler32Checksum, - flushSleepTimeMilliseconds, logFileDir, logFileExt, logFileName, maxBlocksPerFile, - maxBuffers, maxLogFiles, minBuffers, threadsWaitingForceThreshold, xidFactory, - serverBaseDir); - - howlLog.doStart(); - transactionManager = new GeronimoTransactionManager(1200, xidFactory, howlLog); - } catch (Exception e) { - throw new IllegalStateException(e); - } - } - - /** - * @see org.apache.tuscany.sca.core.ModuleActivator#stop(org.apache.tuscany.sca.core.ExtensionPointRegistry) - */ - public void stop() { - try { - if (howlLog != null) { - howlLog.doStop(); - } - } catch (Exception e) { - throw new IllegalStateException(e); - } - } - - public TransactionManager getTransactionManager() { - return transactionManager; - } - -} diff --git a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionModuleActivator.java b/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionModuleActivator.java deleted file mode 100644 index d51b986d65..0000000000 --- a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionModuleActivator.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.policy.transaction; - -import javax.transaction.TransactionManager; - -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.ModuleActivator; -import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint; - -/** - * @version $Rev$ $Date$ - */ -public class TransactionModuleActivator implements ModuleActivator { - private TransactionManagerWrapper wrapper; - - /** - * @see org.apache.tuscany.sca.core.ModuleActivator#start(org.apache.tuscany.sca.core.ExtensionPointRegistry) - */ - public void start(ExtensionPointRegistry registry) { - if (registry != null) { - TransactionManager transactionManager = registry.getExtensionPoint(TransactionManager.class); - if (transactionManager != null) { - // The transaction manage is provided by the hosting environment - RuntimeWireProcessorExtensionPoint wireProcessorExtensionPoint = - registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class); - TransactionManagerHelper helper = new TransactionManagerHelper(transactionManager); - wireProcessorExtensionPoint.addWireProcessor(new TransactionRuntimeWireProcessor(helper)); - return; - } - } - try { - wrapper = new TransactionManagerWrapper(); - wrapper.start(); - } catch (Exception e) { - throw new IllegalStateException(e); - } - if (registry != null) { - registry.addExtensionPoint(wrapper.getTransactionManager()); - RuntimeWireProcessorExtensionPoint wireProcessorExtensionPoint = - registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class); - TransactionManagerHelper helper = new TransactionManagerHelper(wrapper.getTransactionManager()); - wireProcessorExtensionPoint.addWireProcessor(new TransactionRuntimeWireProcessor(helper)); - } - } - - /** - * @see org.apache.tuscany.sca.core.ModuleActivator#stop(org.apache.tuscany.sca.core.ExtensionPointRegistry) - */ - public void stop(ExtensionPointRegistry registry) { - try { - if (wrapper != null) { - wrapper.stop(); - } - if (registry != null && wrapper != null) { - registry.removeExtensionPoint(wrapper.getTransactionManager()); - } - } catch (Exception e) { - throw new IllegalStateException(e); - } - } - -} diff --git a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicy.java b/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicy.java deleted file mode 100644 index bd27f27e1a..0000000000 --- a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicy.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.policy.transaction; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.xml.Constants; - -/** - * The model for Tuscany transaction policy - * - * @version $Rev$ $Date$ - */ -public interface TransactionPolicy { - QName NAME = new QName(Constants.SCA10_TUSCANY_NS, "transactionPolicy"); - - enum Action { - PROPAGATE, SUSPEND, REQUIRE_GLOBAL, REQUIRE_LOCAL, REQUIRE_NONE - }; - - int getTransactionTimeout(); - - void setTransactionTimeout(int seconds); - - void setAction(Action action); - - Action getAction(); -} diff --git a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyHandler.java b/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyHandler.java deleted file mode 100644 index cee92fe243..0000000000 --- a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyHandler.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.policy.transaction; - -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.util.PolicyHandler; - -/** - * @version $Rev$ $Date$ - */ -public class TransactionPolicyHandler implements PolicyHandler { - protected PolicySet policySet; - /** - * @see org.apache.tuscany.sca.policy.util.PolicyHandler#afterInvoke(java.lang.Object[]) - */ - public void afterInvoke(Object... context) { - System.out.println("afterInvoke"); - } - - /** - * @see org.apache.tuscany.sca.policy.util.PolicyHandler#beforeInvoke(java.lang.Object[]) - */ - public void beforeInvoke(Object... context) { - System.out.println("beforeInvoke"); - } - - /** - * @see org.apache.tuscany.sca.policy.util.PolicyHandler#cleanUp(java.lang.Object[]) - */ - public void cleanUp(Object... context) { - } - - /** - * @see org.apache.tuscany.sca.policy.util.PolicyHandler#getApplicablePolicySet() - */ - public PolicySet getApplicablePolicySet() { - return policySet; - } - - /** - * @see org.apache.tuscany.sca.policy.util.PolicyHandler#setApplicablePolicySet(org.apache.tuscany.sca.policy.PolicySet) - */ - public void setApplicablePolicySet(PolicySet context) { - this.policySet = context; - } - - /** - * @see org.apache.tuscany.sca.policy.util.PolicyHandler#setUp(java.lang.Object[]) - */ - public void setUp(Object... context) { - } - -} diff --git a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyImpl.java b/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyImpl.java deleted file mode 100644 index f934fbbdb9..0000000000 --- a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.policy.transaction; - -/** - * @version $Rev$ $Date$ - */ -public class TransactionPolicyImpl implements TransactionPolicy { - private int transactionTimeout = 1200; - private Action action = Action.PROPAGATE; - - public int getTransactionTimeout() { - return transactionTimeout; - } - - public void setTransactionTimeout(int transactionTimeout) { - this.transactionTimeout = transactionTimeout; - } - - public Action getAction() { - return action; - } - - public void setAction(Action policy) { - this.action = policy; - } -} diff --git a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyProcessor.java b/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyProcessor.java deleted file mode 100644 index 27cfbea2b2..0000000000 --- a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyProcessor.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.policy.transaction; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; - -/** - * @version $Rev$ $Date$ - */ -public class TransactionPolicyProcessor implements StAXArtifactProcessor { - public static final String TIMEOUT = "transactionTimeout"; - public static final String ACTION = "action"; - - public QName getArtifactType() { - return TransactionPolicy.NAME; - } - - public TransactionPolicyProcessor(ModelFactoryExtensionPoint modelFactories) { - } - - public TransactionPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - TransactionPolicy txPolicy = new TransactionPolicyImpl(); - int event = reader.getEventType(); - while (reader.hasNext()) { - event = reader.getEventType(); - switch (event) { - case START_ELEMENT: { - String timeout = reader.getAttributeValue(null, TIMEOUT); - if (timeout != null) { - txPolicy.setTransactionTimeout(Integer.parseInt(timeout)); - } - String action = reader.getAttributeValue(null, ACTION); - if (action != null) { - txPolicy.setAction(TransactionPolicy.Action.valueOf(action)); - } - break; - } - } - - if (event == END_ELEMENT) { - if (TransactionPolicy.NAME.equals(reader.getName())) { - break; - } - } - - //Read the next element - if (reader.hasNext()) { - reader.next(); - } - } - - return txPolicy; - } - - public void write(TransactionPolicy policy, XMLStreamWriter writer) throws ContributionWriteException, - XMLStreamException { - } - - public Class getModelType() { - return TransactionPolicy.class; - } - - public void resolve(TransactionPolicy policy, ModelResolver resolver) throws ContributionResolveException { - - } -} diff --git a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionRuntimeWireProcessor.java b/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionRuntimeWireProcessor.java deleted file mode 100644 index 5991535261..0000000000 --- a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionRuntimeWireProcessor.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.policy.transaction; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.apache.tuscany.sca.runtime.RuntimeWireProcessor; - -/** - * @version $Rev$ $Date$ - */ -public class TransactionRuntimeWireProcessor implements RuntimeWireProcessor { - private TransactionManagerHelper helper; - - public TransactionRuntimeWireProcessor(TransactionManagerHelper helper) { - super(); - this.helper = helper; - } - - /** - * @see org.apache.tuscany.sca.runtime.RuntimeWireProcessor#process(org.apache.tuscany.sca.runtime.RuntimeWire) - */ - public void process(RuntimeWire wire) { - boolean outbound = (wire.getSource().getContract() instanceof Reference); - Component component = outbound ? wire.getSource().getComponent() : wire.getTarget().getComponent(); - Binding binding = outbound ? wire.getSource().getBinding() : wire.getTarget().getBinding(); - - TransactionPolicy interactionPolicy = null; - TransactionPolicy implementationPolicy = null; - for (PolicySet ps : component.getPolicySets()) { - // TODO: Test operations - if (ps.getName().equals(TransactionPolicy.NAME)) { - implementationPolicy = (TransactionPolicy)ps.getPolicies().get(0); - } - } - if (binding instanceof PolicySetAttachPoint) { - PolicySetAttachPoint pap = (PolicySetAttachPoint)binding; - for (PolicySet ps : pap.getPolicySets()) { - if (ps.getName().equals(TransactionPolicy.NAME)) { - interactionPolicy = (TransactionPolicy)ps.getPolicies().get(0); - - } - } - } - for (InvocationChain chain : wire.getInvocationChains()) { - Operation operation = chain.getSourceOperation(); - - TransactionInterceptor interceptor = - new TransactionInterceptor(helper, outbound, interactionPolicy, implementationPolicy); - chain.addInterceptor(interceptor); - } - - } - -} diff --git a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionalAction.java b/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionalAction.java deleted file mode 100644 index 5a7ae5c4cc..0000000000 --- a/branches/sca-java-1.1/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionalAction.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.policy.transaction; - -/** - * @version $Rev$ $Date$ - */ -public interface TransactionalAction { - /** - * @return - * @throws Exception - */ - T run() throws Exception; -} -- cgit v1.2.3