maguro      2005/03/20 18:13:32

  Modified:    modules/core/src/java/org/openejb/corba/transaction
                        ClientTransactionInterceptor.java
                        TransactionInitializer.java
  Log:

  Better debug msgs.
  
  Revision  Changes    Path
  1.5       +26 -11    
openejb/modules/core/src/java/org/openejb/corba/transaction/ClientTransactionInterceptor.java
  
  Index: ClientTransactionInterceptor.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/transaction/ClientTransactionInterceptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ClientTransactionInterceptor.java 20 Mar 2005 04:52:33 -0000      1.4
  +++ ClientTransactionInterceptor.java 20 Mar 2005 23:13:32 -0000      1.5
  @@ -44,20 +44,23 @@
    */
   package org.openejb.corba.transaction;
   
  -import org.omg.CORBA.INTERNAL;
  -import org.omg.CORBA.LocalObject;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   import org.omg.CORBA.Any;
   import org.omg.CORBA.BAD_PARAM;
  +import org.omg.CORBA.INTERNAL;
  +import org.omg.CORBA.INV_POLICY;
  +import org.omg.CORBA.LocalObject;
  +import org.omg.IOP.CodecPackage.FormatMismatch;
  +import org.omg.IOP.CodecPackage.TypeMismatch;
  +import org.omg.IOP.TaggedComponent;
   import org.omg.PortableInterceptor.ClientRequestInfo;
   import org.omg.PortableInterceptor.ClientRequestInterceptor;
   import org.omg.PortableInterceptor.ForwardRequest;
  -import org.omg.IOP.TaggedComponent;
  -import org.omg.IOP.CodecPackage.FormatMismatch;
  -import org.omg.IOP.CodecPackage.TypeMismatch;
   
   import org.openejb.corba.idl.CosTSInteroperation.TAG_OTS_POLICY;
  -import org.openejb.corba.idl.CosTransactions.OTSPolicyValueHelper;
   import org.openejb.corba.idl.CosTransactions.ADAPTS;
  +import org.openejb.corba.idl.CosTransactions.OTSPolicyValueHelper;
   import org.openejb.corba.util.Util;
   
   
  @@ -66,7 +69,10 @@
    */
   class ClientTransactionInterceptor extends LocalObject implements 
ClientRequestInterceptor {
   
  +    private final Log log = 
LogFactory.getLog(ClientTransactionInterceptor.class);
  +
       public ClientTransactionInterceptor() {
  +        if (log.isDebugEnabled()) log.debug("Registered");
       }
   
       public void receive_exception(ClientRequestInfo ri) throws 
ForwardRequest {
  @@ -84,6 +90,8 @@
       public void send_request(ClientRequestInfo ri) throws ForwardRequest {
           TaggedComponent taggedComponent = null;
           try {
  +            if (log.isDebugEnabled()) log.debug("Checking if target " + 
ri.operation() + " has a transaction policy");
  +
               taggedComponent = 
ri.get_effective_component(TAG_OTS_POLICY.value);
           } catch (BAD_PARAM e) {
               if ((e.minor & 25) == 25) {
  @@ -92,19 +100,26 @@
               }
               throw e;
           }
  +
  +        if (log.isDebugEnabled()) log.debug("Target has a transaction 
policy");
  +
           byte[] data = taggedComponent.component_data;
           Any any = null;
           try {
               any = Util.getCodec().decode_value(data, 
OTSPolicyValueHelper.type());
           } catch (FormatMismatch formatMismatch) {
  -            throw (INTERNAL) new INTERNAL("mismatched 
format").initCause(formatMismatch);
  +            log.error("Mismatched format");
  +            throw (INTERNAL) new INTERNAL("Mismatched 
format").initCause(formatMismatch);
           } catch (TypeMismatch typeMismatch) {
  +            log.error("Type mismatch");
               throw (INTERNAL) new INTERNAL("Type 
mismatch").initCause(typeMismatch);
           }
           short value = OTSPolicyValueHelper.extract(any);
           if (value == ADAPTS.value) {
  -            ClientTransactionPolicy policy = (ClientTransactionPolicy) 
ri.get_request_policy(ClientTransactionPolicyFactory.POLICY_TYPE);
  -            if (policy == null) {
  +            ClientTransactionPolicy policy = null;
  +            try {
  +                policy = (ClientTransactionPolicy) 
ri.get_request_policy(ClientTransactionPolicyFactory.POLICY_TYPE);
  +            } catch (INV_POLICY e) {
                   throw new INTERNAL("No transaction policy configured");
               }
               ClientTransactionPolicyConfig clientTransactionPolicyConfig = 
policy.getClientTransactionPolicyConfig();
  
  
  
  1.4       +27 -11    
openejb/modules/core/src/java/org/openejb/corba/transaction/TransactionInitializer.java
  
  Index: TransactionInitializer.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/transaction/TransactionInitializer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TransactionInitializer.java       15 Mar 2005 05:27:04 -0000      1.3
  +++ TransactionInitializer.java       20 Mar 2005 23:13:32 -0000      1.4
  @@ -44,6 +44,8 @@
    */
   package org.openejb.corba.transaction;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   import org.omg.CORBA.LocalObject;
   import org.omg.PortableInterceptor.ORBInitInfo;
   import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
  @@ -55,6 +57,12 @@
    */
   public class TransactionInitializer extends LocalObject implements 
ORBInitializer {
   
  +    private final Log log = LogFactory.getLog(TransactionInitializer.class);
  +
  +    public TransactionInitializer() {
  +        if (log.isDebugEnabled()) log.debug("TransactionInitializer.<init>");
  +    }
  +
       /**
        * Called during ORB initialization.  If it is expected that initial
        * services registered by an interceptor will be used by other
  @@ -63,7 +71,7 @@
        * <code>ORBInitInfo.register_initial_reference</code>.
        *
        * @param orbInitInfo provides initialization attributes and operations 
by
  -     *             which Interceptors can be registered.
  +     *                    which Interceptors can be registered.
        */
       public void pre_init(ORBInitInfo orbInitInfo) {
   
  @@ -85,18 +93,26 @@
        * created, no IOR interceptors will be invoked.
        *
        * @param orbInitInfo provides initialization attributes and
  -     *             operations by which Interceptors can be registered.
  +     *                    operations by which Interceptors can be registered.
        */
       public void post_init(ORBInitInfo orbInitInfo) {
           try {
  -            orbInitInfo.add_client_request_interceptor(new 
ClientTransactionInterceptor());
  -            orbInitInfo.add_server_request_interceptor(new 
ServerTransactionInterceptor());
  -            orbInitInfo.add_ior_interceptor(new IORTransactionInterceptor());
  -        } catch (DuplicateName duplicateName) {
  -            duplicateName.printStackTrace();
  +            if (log.isDebugEnabled()) log.debug("Registering interceptors 
and policy factories");
  +
  +            try {
  +                orbInitInfo.add_client_request_interceptor(new 
ClientTransactionInterceptor());
  +                orbInitInfo.add_server_request_interceptor(new 
ServerTransactionInterceptor());
  +                orbInitInfo.add_ior_interceptor(new 
IORTransactionInterceptor());
  +            } catch (DuplicateName duplicateName) {
  +                log.error("Duplicate name", duplicateName);
  +            }
  +
  +            
orbInitInfo.register_policy_factory(ClientTransactionPolicyFactory.POLICY_TYPE, 
new ClientTransactionPolicyFactory());
  +            
orbInitInfo.register_policy_factory(ServerTransactionPolicyFactory.POLICY_TYPE, 
new ServerTransactionPolicyFactory());
  +        } catch (RuntimeException re) {
  +            log.error("Error registering interceptor", re);
  +            throw re;
           }
  -        
orbInitInfo.register_policy_factory(ClientTransactionPolicyFactory.POLICY_TYPE, 
new ClientTransactionPolicyFactory());
  -        
orbInitInfo.register_policy_factory(ServerTransactionPolicyFactory.POLICY_TYPE, 
new ServerTransactionPolicyFactory());
       }
   
   }
  
  
  

Reply via email to