djencks 2005/03/15 00:27:06
Added:
modules/core/src/java/org/openejb/corba/transaction/nodistributedtransactions
Ignore.java NoDTxClientTransactionPolicyConfig.java
NoDTxServerTransactionPolicies.java
NotRequired.java Required.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.1
openejb/modules/core/src/java/org/openejb/corba/transaction/nodistributedtransactions/Ignore.java
Index: Ignore.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.corba.transaction.nodistributedtransactions;
import java.io.Serializable;
import org.openejb.corba.transaction.OperationTxPolicy;
import org.openejb.corba.idl.CosTransactions.PropagationContext;
/**
* Use for:
* RequiresNew
* NotSupported
* Bean (? client should not send a PropagationContext)
*
* @version $Rev: $ $Date: 2005/03/15 05:27:06 $
*/
public class Ignore implements OperationTxPolicy, Serializable {
public static final OperationTxPolicy INSTANCE = new Ignore();
public void importTransaction(PropagationContext propagationContext) {
}
}
1.1
openejb/modules/core/src/java/org/openejb/corba/transaction/nodistributedtransactions/NoDTxClientTransactionPolicyConfig.java
Index: NoDTxClientTransactionPolicyConfig.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.corba.transaction.nodistributedtransactions;
import org.apache.geronimo.transaction.context.TransactionContextManager;
import org.apache.geronimo.transaction.context.TransactionContext;
import org.omg.PortableInterceptor.ClientRequestInfo;
import org.omg.IOP.Codec;
import org.omg.IOP.ServiceContext;
import org.omg.IOP.TransactionService;
import org.omg.IOP.CodecPackage.InvalidTypeForEncoding;
import org.omg.CORBA.Any;
import org.omg.CORBA.INTERNAL;
import org.openejb.corba.util.Util;
import org.openejb.corba.transaction.ClientTransactionPolicyConfig;
import org.openejb.corba.idl.CosTransactions.TransIdentity;
import org.openejb.corba.idl.CosTransactions.PropagationContext;
import org.openejb.corba.idl.CosTransactions.PropagationContextHelper;
import org.openejb.corba.idl.CosTransactions.otid_t;
/**
* @version $Rev: $ $Date: 2005/03/15 05:27:06 $
*/
public class NoDTxClientTransactionPolicyConfig implements
ClientTransactionPolicyConfig {
private static final TransIdentity[] NO_PARENTS = new TransIdentity[0];
private static final otid_t NULL_XID = new otid_t(0, 0, new byte[0]);
private final TransactionContextManager transactionContextManager;
public NoDTxClientTransactionPolicyConfig(TransactionContextManager
transactionContextManager) {
if (transactionContextManager == null) {
throw new IllegalArgumentException("transactionContextManager
must not be null");
}
this.transactionContextManager = transactionContextManager;
}
public void exportTransaction(ClientRequestInfo ri) {
TransactionContext transactionContext =
transactionContextManager.getContext();
if (transactionContext != null && transactionContext.isInheritable()
&& transactionContext.isActive()) {
//19.6.2.1 (1) propagate an "empty" transaction context.
//but, it needs an xid!
TransIdentity transIdentity = new TransIdentity(null, null,
NULL_XID);
int timeout = 0;
Any implementationSpecificData = Util.getORB().create_any();
PropagationContext propagationContext = new
PropagationContext(timeout, transIdentity, NO_PARENTS,
implementationSpecificData);
Codec codec = Util.getCodec();
Any any = Util.getORB().create_any();
PropagationContextHelper.insert(any, propagationContext);
byte[] encodedPropagationContext;
try {
encodedPropagationContext = codec.encode(any);
} catch (InvalidTypeForEncoding invalidTypeForEncoding) {
throw (INTERNAL)new INTERNAL("Could not encode
propagationContext").initCause(invalidTypeForEncoding);
}
ServiceContext otsServiceContext = new
ServiceContext(TransactionService.value, encodedPropagationContext);
ri.add_request_service_context(otsServiceContext, true);
}
}
}
1.1
openejb/modules/core/src/java/org/openejb/corba/transaction/nodistributedtransactions/NoDTxServerTransactionPolicies.java
Index: NoDTxServerTransactionPolicies.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.corba.transaction.nodistributedtransactions;
import org.openejb.corba.transaction.OperationTxPolicy;
import org.openejb.transaction.TransactionPolicyType;
/**
* @version $Rev: $ $Date: 2005/03/15 05:27:06 $
*/
public class NoDTxServerTransactionPolicies {
private static final OperationTxPolicy[] policies = new
OperationTxPolicy[TransactionPolicyType.size()];
static {
policies[TransactionPolicyType.Mandatory.getIndex()] =
Required.INSTANCE;
policies[TransactionPolicyType.Never.getIndex()] =
NotRequired.INSTANCE;
policies[TransactionPolicyType.NotSupported.getIndex()] =
Ignore.INSTANCE;
policies[TransactionPolicyType.Required.getIndex()] =
Required.INSTANCE;
policies[TransactionPolicyType.RequiresNew.getIndex()] =
Ignore.INSTANCE;
policies[TransactionPolicyType.Supports.getIndex()] =
NotRequired.INSTANCE;
policies[TransactionPolicyType.Bean.getIndex()] = Ignore.INSTANCE;
}
public static OperationTxPolicy
getTransactionPolicy(TransactionPolicyType transactionPolicyType) {
return policies[transactionPolicyType.getIndex()];
}
}
1.1
openejb/modules/core/src/java/org/openejb/corba/transaction/nodistributedtransactions/NotRequired.java
Index: NotRequired.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.corba.transaction.nodistributedtransactions;
import java.io.Serializable;
import org.openejb.corba.transaction.OperationTxPolicy;
import org.openejb.corba.idl.CosTransactions.PropagationContext;
import org.omg.CORBA.INVALID_TRANSACTION;
/**
* Use for:
* Required
* Never
* Supports
*
* @version $Rev: $ $Date: 2005/03/15 05:27:06 $
*/
public class NotRequired implements OperationTxPolicy, Serializable {
public static final OperationTxPolicy INSTANCE = new NotRequired();
public void importTransaction(PropagationContext propagationContext) {
if (propagationContext != null) {
throw new INVALID_TRANSACTION("Transactions cannot be imported,
and might also be not allowed for this method");
}
}
}
1.1
openejb/modules/core/src/java/org/openejb/corba/transaction/nodistributedtransactions/Required.java
Index: Required.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.corba.transaction.nodistributedtransactions;
import java.io.Serializable;
import org.openejb.corba.transaction.OperationTxPolicy;
import org.openejb.corba.idl.CosTransactions.PropagationContext;
import org.omg.CORBA.INVALID_TRANSACTION;
/**
* Use for:
* Mandatory
*
* @version $Rev: $ $Date: 2005/03/15 05:27:06 $
*/
public class Required implements OperationTxPolicy, Serializable {
public static final OperationTxPolicy INSTANCE = new Required();
public void importTransaction(PropagationContext propagationContext) {
throw new INVALID_TRANSACTION("Transaction cannot be imported");
}
}