djencks 2005/03/15 00:27:09
Modified: modules/core/src/java/org/openejb/transaction
TransactionPolicyManager.java
Added: modules/core/src/java/org/openejb/transaction
TransactionPolicies.java TransactionPolicyType.java
Removed: modules/core/src/java/org/openejb/transaction
TransactionPolicySource.java
Log:
Make transaction policy mapping more generic and implement the
no-distributed-transactions corba tx propagation polices. CORBA operation name
to method signature mapping is not yet really implemented
Revision Changes Path
1.6 +4 -18
openejb/modules/core/src/java/org/openejb/transaction/TransactionPolicyManager.java
Index: TransactionPolicyManager.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/transaction/TransactionPolicyManager.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TransactionPolicyManager.java 28 Oct 2004 21:21:27 -0000 1.5
+++ TransactionPolicyManager.java 15 Mar 2005 05:27:09 -0000 1.6
@@ -57,28 +57,14 @@
* @version $Revision$ $Date$
*/
public final class TransactionPolicyManager implements Serializable {
- private final TransactionPolicy[][] transactionPolicy = new
TransactionPolicy[EJBInterfaceType.MAX_ORDINAL][];
+ private final TransactionPolicy[][] transactionPolicy;
- public TransactionPolicyManager(TransactionPolicySource
transactionPolicySource, InterfaceMethodSignature[] signatures) {
- transactionPolicy[EJBInterfaceType.HOME.getOrdinal()] =
mapPolicies("Home", signatures, transactionPolicySource);
- transactionPolicy[EJBInterfaceType.REMOTE.getOrdinal()] =
mapPolicies("Remote", signatures, transactionPolicySource);
- transactionPolicy[EJBInterfaceType.LOCALHOME.getOrdinal()] =
mapPolicies("LocalHome", signatures, transactionPolicySource);
- transactionPolicy[EJBInterfaceType.LOCAL.getOrdinal()] =
mapPolicies("Local", signatures, transactionPolicySource);
- transactionPolicy[EJBInterfaceType.WEB_SERVICE.getOrdinal()] =
mapPolicies("ServiceEndpoint", signatures, transactionPolicySource);
- transactionPolicy[EJBInterfaceType.TIMEOUT.getOrdinal()] = new
TransactionPolicy[signatures.length];
-
Arrays.fill(transactionPolicy[EJBInterfaceType.TIMEOUT.getOrdinal()],
ContainerPolicy.Supports); //we control the transaction from the top of the
stack.
+ public TransactionPolicyManager(TransactionPolicy[][] transactionPolicy)
{
+ this.transactionPolicy = transactionPolicy;
}
public TransactionPolicy getTransactionPolicy(EJBInterfaceType
invocationType, int operationIndex) {
return
transactionPolicy[invocationType.getOrdinal()][operationIndex];
}
- private static TransactionPolicy[] mapPolicies(String intfName,
InterfaceMethodSignature[] signatures, TransactionPolicySource
transactionPolicySource) {
- TransactionPolicy[] policies = new
TransactionPolicy[signatures.length];
- for (int index = 0; index < signatures.length; index++) {
- InterfaceMethodSignature signature = signatures[index];
- policies[index] =
transactionPolicySource.getTransactionPolicy(intfName, signature);
- }
- return policies;
- }
}
1.1
openejb/modules/core/src/java/org/openejb/transaction/TransactionPolicies.java
Index: TransactionPolicies.java
===================================================================
/**
*
* Copyright 2003-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.openejb.transaction;
/**
* @version $Rev: $ $Date: 2005/03/15 05:27:09 $
*/
public class TransactionPolicies {
private static final TransactionPolicy[] policies = new
TransactionPolicy[TransactionPolicyType.size()];
static {
policies[TransactionPolicyType.Mandatory.getIndex()] =
ContainerPolicy.Mandatory;
policies[TransactionPolicyType.Never.getIndex()] =
ContainerPolicy.Never;
policies[TransactionPolicyType.NotSupported.getIndex()] =
ContainerPolicy.NotSupported;
policies[TransactionPolicyType.Required.getIndex()] =
ContainerPolicy.Required;
policies[TransactionPolicyType.RequiresNew.getIndex()] =
ContainerPolicy.RequiresNew;
policies[TransactionPolicyType.Supports.getIndex()] =
ContainerPolicy.Supports;
policies[TransactionPolicyType.Bean.getIndex()] = BeanPolicy.INSTANCE;
}
public static TransactionPolicy
getTransactionPolicy(TransactionPolicyType transactionPolicyType) {
return policies[transactionPolicyType.getIndex()];
}
}
1.1
openejb/modules/core/src/java/org/openejb/transaction/TransactionPolicyType.java
Index: TransactionPolicyType.java
===================================================================
/**
*
* Copyright 2003-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.openejb.transaction;
/**
* Enumeration of abstract transaction policies, with ordinals, for use as
index to determine concrete TransactionPolicies.
*
* @version $Rev: $ $Date: 2005/03/15 05:27:09 $
*/
public class TransactionPolicyType {
public static final TransactionPolicyType NotSupported = new
TransactionPolicyType("NotSupported");
public static final TransactionPolicyType Required = new
TransactionPolicyType("Required");
public static final TransactionPolicyType Supports = new
TransactionPolicyType("Supports");
public static final TransactionPolicyType RequiresNew = new
TransactionPolicyType("RequiresNew");
public static final TransactionPolicyType Mandatory = new
TransactionPolicyType("Mandatory");
public static final TransactionPolicyType Never = new
TransactionPolicyType("Never");
public static final TransactionPolicyType Bean = new
TransactionPolicyType("Bean");
private static final TransactionPolicyType[] values = {
NotSupported,
Required,
Supports,
RequiresNew,
Mandatory,
Never,
Bean
};
private final int index;
private final String name;
private static int last = 0;
private TransactionPolicyType(String name) {
this.name = name;
this.index = last++;
}
public int getIndex() {
return index;
}
public String getName() {
return name;
}
public static int size() {
return values.length;
}
}