djencks     2005/03/15 00:27:05

  Modified:    modules/core/src/java/org/openejb/corba/transaction
                        ClientTransactionInterceptor.java
                        ServerTransactionInterceptor.java
                        TransactionInitializer.java
  Added:       modules/core/src/java/org/openejb/corba/transaction
                        AbstractServerTransactionPolicyConfig.java
                        ClientTransactionPolicy.java
                        ClientTransactionPolicyConfig.java
                        ClientTransactionPolicyFactory.java
                        IORTransactionInterceptor.java
                        MappedServerTransactionPolicyConfig.java
                        OperationTxPolicy.java ServerTransactionPolicy.java
                        ServerTransactionPolicyConfig.java
                        ServerTransactionPolicyFactory.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.3       +38 -12    
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClientTransactionInterceptor.java 13 Jan 2005 17:00:23 -0000      1.2
  +++ ClientTransactionInterceptor.java 15 Mar 2005 05:27:04 -0000      1.3
  @@ -44,10 +44,19 @@
    */
   package org.openejb.corba.transaction;
   
  +import org.omg.CORBA.INTERNAL;
   import org.omg.CORBA.LocalObject;
  +import org.omg.CORBA.Any;
  +import org.omg.CORBA.BAD_PARAM;
   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.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.util.Util;
   
   
   /**
  @@ -55,34 +64,51 @@
    */
   class ClientTransactionInterceptor extends LocalObject implements 
ClientRequestInterceptor {
   
  -    private final int slotId;
  -
  -    public ClientTransactionInterceptor(int slotId) {
  -        this.slotId = slotId;
  +    public ClientTransactionInterceptor() {
       }
   
       public void receive_exception(ClientRequestInfo ri) throws 
ForwardRequest {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
       public void receive_other(ClientRequestInfo ri) throws ForwardRequest {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
       public void receive_reply(ClientRequestInfo ri) {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
       public void send_poll(ClientRequestInfo ri) {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
       public void send_request(ClientRequestInfo ri) throws ForwardRequest {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
  +        TaggedComponent taggedComponent = null;
  +        try {
  +            taggedComponent = 
ri.get_effective_component(TAG_OTS_POLICY.value);
  +        } catch (BAD_PARAM e) {
  +            if ((e.minor & 25) == 25) {
  +                //tagged component missing
  +                return;
  +            }
  +            throw e;
  +        }
  +        byte[] data = taggedComponent.component_data;
  +        Any any = null;
  +        try {
  +            any = Util.getCodec().decode(data);
  +        } catch (FormatMismatch formatMismatch) {
  +            throw (INTERNAL) new INTERNAL("mismatched 
format").initCause(formatMismatch);
  +        }
  +        short value = OTSPolicyValueHelper.extract(any);
  +        if (value == ADAPTS.value) {
  +            ClientTransactionPolicy policy = (ClientTransactionPolicy) 
ri.get_request_policy(ClientTransactionPolicyFactory.POLICY_TYPE);
  +            if (policy == null) {
  +                throw new INTERNAL("No transaction policy configured");
  +            }
  +            ClientTransactionPolicyConfig clientTransactionPolicyConfig = 
policy.getClientTransactionPolicyConfig();
  +            clientTransactionPolicyConfig.exportTransaction(ri);
  +        }
       }
   
       public void destroy() {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
       /**
  
  
  
  1.3       +11 -12    
openejb/modules/core/src/java/org/openejb/corba/transaction/ServerTransactionInterceptor.java
  
  Index: ServerTransactionInterceptor.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/transaction/ServerTransactionInterceptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServerTransactionInterceptor.java 13 Jan 2005 17:00:23 -0000      1.2
  +++ ServerTransactionInterceptor.java 15 Mar 2005 05:27:04 -0000      1.3
  @@ -44,6 +44,7 @@
    */
   package org.openejb.corba.transaction;
   
  +import org.omg.CORBA.INTERNAL;
   import org.omg.CORBA.LocalObject;
   import org.omg.PortableInterceptor.ForwardRequest;
   import org.omg.PortableInterceptor.ServerRequestInfo;
  @@ -55,34 +56,32 @@
    */
   class ServerTransactionInterceptor extends LocalObject implements 
ServerRequestInterceptor {
   
  -    private final int slotId;
   
  -    public ServerTransactionInterceptor(int slotId) {
  -        this.slotId = slotId;
  +    public ServerTransactionInterceptor() {
       }
   
  -    public void receive_request(ServerRequestInfo ri) throws ForwardRequest {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
  +    public void receive_request(ServerRequestInfo serverRequestInfo) throws 
ForwardRequest {
  +        ServerTransactionPolicy policy = (ServerTransactionPolicy) 
serverRequestInfo.get_server_policy(ServerTransactionPolicyFactory.POLICY_TYPE);
  +        if (policy == null) {
  +            throw new INTERNAL("No transaction policy configured");
  +        }
  +        ServerTransactionPolicyConfig serverTransactionPolicyConfig = 
policy.getServerTransactionPolicyConfig();
  +        serverTransactionPolicyConfig.importTransaction(serverRequestInfo);
       }
   
       public void receive_request_service_contexts(ServerRequestInfo ri) 
throws ForwardRequest {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
       public void send_exception(ServerRequestInfo ri) throws ForwardRequest {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
       public void send_other(ServerRequestInfo ri) throws ForwardRequest {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
       public void send_reply(ServerRequestInfo ri) {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
       public void destroy() {
  -        //To change body of implemented methods use File | Settings | File 
Templates.
       }
   
       /**
  
  
  
  1.3       +15 -18    
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TransactionInitializer.java       13 Jan 2005 17:00:23 -0000      1.2
  +++ TransactionInitializer.java       15 Mar 2005 05:27:04 -0000      1.3
  @@ -44,8 +44,6 @@
    */
   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;
  @@ -56,9 +54,6 @@
    * @version $Revision$ $Date$
    */
   public class TransactionInitializer extends LocalObject implements 
ORBInitializer {
  -    private final Log log = LogFactory.getLog(TransactionInitializer.class);
  -
  -    private static int slotId;
   
       /**
        * Called during ORB initialization.  If it is expected that initial
  @@ -67,18 +62,11 @@
        * this point via calls to
        * <code>ORBInitInfo.register_initial_reference</code>.
        *
  -     * @param info provides initialization attributes and operations by
  +     * @param orbInitInfo provides initialization attributes and operations 
by
        *             which Interceptors can be registered.
        */
  -    public void pre_init(ORBInitInfo info) {
  -        slotId = info.allocate_slot_id();
  +    public void pre_init(ORBInitInfo orbInitInfo) {
   
  -        try {
  -            info.add_client_request_interceptor(new 
ClientTransactionInterceptor(slotId));
  -            info.add_server_request_interceptor(new 
ServerTransactionInterceptor(slotId));
  -        } catch (DuplicateName duplicateName) {
  -            duplicateName.printStackTrace();
  -        }
       }
   
       /**
  @@ -96,10 +84,19 @@
        * Likewise, if an operation is performed which causes an IOR to be
        * created, no IOR interceptors will be invoked.
        *
  -     * @param info provides initialization attributes and
  +     * @param orbInitInfo provides initialization attributes and
        *             operations by which Interceptors can be registered.
        */
  -    public void post_init(ORBInitInfo info) {
  +    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();
  +        }
  +        
orbInitInfo.register_policy_factory(ClientTransactionPolicyFactory.POLICY_TYPE, 
new ClientTransactionPolicyFactory());
  +        
orbInitInfo.register_policy_factory(ServerTransactionPolicyFactory.POLICY_TYPE, 
new ServerTransactionPolicyFactory());
       }
   
   }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/transaction/AbstractServerTransactionPolicyConfig.java
  
  Index: AbstractServerTransactionPolicyConfig.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;
  
  import org.omg.CORBA.Any;
  import org.omg.CORBA.INTERNAL;
  import org.omg.CORBA.SystemException;
  import org.omg.IOP.Codec;
  import org.omg.IOP.CodecPackage.FormatMismatch;
  import org.omg.IOP.ServiceContext;
  import org.omg.IOP.TransactionService;
  import org.omg.PortableInterceptor.ServerRequestInfo;
  import org.openejb.corba.idl.CosTransactions.PropagationContext;
  import org.openejb.corba.idl.CosTransactions.PropagationContextHelper;
  import org.openejb.corba.util.Util;
  
  /**
   * @version $Rev:  $ $Date: 2005/03/15 05:27:04 $
   */
  public abstract class AbstractServerTransactionPolicyConfig implements 
ServerTransactionPolicyConfig {
      public void importTransaction(ServerRequestInfo serverRequestInfo) throws 
SystemException {
          ServiceContext serviceContext = 
serverRequestInfo.get_request_service_context(TransactionService.value);
          PropagationContext propagationContext;
          if (serviceContext == null) {
              propagationContext = null;
          } else {
              byte[] encoded = serviceContext.context_data;
              Codec codec = Util.getCodec();
              Any any;
              try {
                  any = codec.decode(encoded);
              } catch (FormatMismatch formatMismatch) {
                  throw (INTERNAL) new INTERNAL("Could not decode encoded 
propagation context").initCause(formatMismatch);
              }
              propagationContext = PropagationContextHelper.extract(any);
          }
          //figure out what method is being invoked
          //operation name is unique... it contains the mangled operation name 
+ arg types.
          String operation = serverRequestInfo.operation();
          importTransaction(operation, propagationContext);
      }
  
      protected abstract void importTransaction(String operation, 
PropagationContext propagationContext) throws SystemException;
  
  
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/transaction/ClientTransactionPolicy.java
  
  Index: ClientTransactionPolicy.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;
  
  import org.omg.CORBA.LocalObject;
  import org.omg.CORBA.Policy;
  
  /**
   * @version $Rev:  $ $Date: 2005/03/15 05:27:04 $
   */
  public class ClientTransactionPolicy extends LocalObject implements Policy {
  
      private final ClientTransactionPolicyConfig clientTransactionPolicyConfig;
  
      public ClientTransactionPolicy(ClientTransactionPolicyConfig 
clientTransactionPolicyConfig) {
          this.clientTransactionPolicyConfig = clientTransactionPolicyConfig;
      }
  
  
      public int policy_type() {
          return ClientTransactionPolicyFactory.POLICY_TYPE;
      }
  
      public Policy copy() {
          return new ClientTransactionPolicy(clientTransactionPolicyConfig);
      }
  
      public void destroy() {
  
      }
  
      ClientTransactionPolicyConfig getClientTransactionPolicyConfig() {
          return clientTransactionPolicyConfig;
      }
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/transaction/ClientTransactionPolicyConfig.java
  
  Index: ClientTransactionPolicyConfig.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;
  
  import java.io.Serializable;
  
  import org.omg.PortableInterceptor.ClientRequestInfo;
  
  /**
   * @version $Rev:  $ $Date: 2005/03/15 05:27:04 $
   */
  public interface ClientTransactionPolicyConfig extends Serializable {
      void exportTransaction(ClientRequestInfo ri);
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/transaction/ClientTransactionPolicyFactory.java
  
  Index: ClientTransactionPolicyFactory.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;
  
  import org.omg.CORBA.Any;
  import org.omg.CORBA.LocalObject;
  import org.omg.CORBA.Policy;
  import org.omg.CORBA.PolicyError;
  import org.omg.PortableInterceptor.PolicyFactory;
  
  /**
   * @version $Rev:  $ $Date: 2005/03/15 05:27:04 $
   */
  public class ClientTransactionPolicyFactory extends LocalObject implements 
PolicyFactory {
      public final static int POLICY_TYPE = 0x41534603;
  
      public Policy create_policy(int type, Any value) throws PolicyError {
          if (type != POLICY_TYPE){
              throw new PolicyError();
          }
          return new 
ClientTransactionPolicy(((ClientTransactionPolicyConfig)value.extract_Value()));
      }
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/transaction/IORTransactionInterceptor.java
  
  Index: IORTransactionInterceptor.java
  ===================================================================
  /**
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 2. Redistributions in binary form must reproduce the
   *    above copyright notice, this list of conditions and the
   *    following disclaimer in the documentation and/or other
   *    materials provided with the distribution.
   *
   * 3. The name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.sf.net/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
   * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * Copyright 2001 (C) The OpenEJB Group. All Rights Reserved.
   *
   * $Id: IORTransactionInterceptor.java,v 1.1 2005/03/15 05:27:04 djencks Exp $
   */
  package org.openejb.corba.transaction;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.omg.CORBA.Any;
  import org.omg.CORBA.INV_POLICY;
  import org.omg.CORBA.LocalObject;
  import org.omg.IOP.TAG_INTERNET_IOP;
  import org.omg.IOP.TAG_OTS_POLICY;
  import org.omg.IOP.TaggedComponent;
  import org.omg.PortableInterceptor.IORInfo;
  import org.omg.PortableInterceptor.IORInterceptor;
  import org.openejb.corba.idl.CosTSInteroperation.TAG_INV_POLICY;
  import org.openejb.corba.idl.CosTransactions.ADAPTS;
  import org.openejb.corba.idl.CosTransactions.InvocationPolicyValueHelper;
  import org.openejb.corba.idl.CosTransactions.OTSPolicyValueHelper;
  import org.openejb.corba.idl.CosTransactions.SHARED;
  import org.openejb.corba.util.Util;
  
  
  /**
   * @version $Revision: 1.1 $ $Date: 2005/03/15 05:27:04 $
   */
  final class IORTransactionInterceptor extends LocalObject implements 
IORInterceptor {
  
      private final Log log = 
LogFactory.getLog(IORTransactionInterceptor.class);
  
      public void establish_components(IORInfo info) {
  
          try {
              Any invAny = Util.getORB().create_any();
              InvocationPolicyValueHelper.insert(invAny, SHARED.value);
              TaggedComponent invocationPolicyComponent = new 
TaggedComponent(TAG_INV_POLICY.value, Util.getCodec().encode_value(invAny));
              info.add_ior_component_to_profile(invocationPolicyComponent, 
TAG_INTERNET_IOP.value);
  
              Any otsAny = Util.getORB().create_any();
              OTSPolicyValueHelper.insert(otsAny, ADAPTS.value);
              byte[] bytes = Util.getCodec().encode(otsAny);
              TaggedComponent otsPolicyComponent = new 
TaggedComponent(TAG_OTS_POLICY.value, bytes);
              info.add_ior_component_to_profile(otsPolicyComponent, 
TAG_INTERNET_IOP.value);
          } catch (INV_POLICY e) {
              // do nothing
          } catch (Exception e) {
              log.error("Generating IOR", e);
          }
      }
  
      public void destroy() {
      }
  
      public String name() {
          return "org.openejb.corba.transaction.IORTransactionInterceptor";
      }
  
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/transaction/MappedServerTransactionPolicyConfig.java
  
  Index: MappedServerTransactionPolicyConfig.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;
  
  import java.util.Map;
  
  import org.omg.CORBA.BAD_OPERATION;
  import org.omg.CORBA.SystemException;
  import org.openejb.corba.idl.CosTransactions.PropagationContext;
  
  /**
   * @version $Rev:  $ $Date: 2005/03/15 05:27:04 $
   */
  public class MappedServerTransactionPolicyConfig extends 
AbstractServerTransactionPolicyConfig {
      private final Map operationToPolicyMap;
      public MappedServerTransactionPolicyConfig(Map operationToPolicyMap) {
          this.operationToPolicyMap = operationToPolicyMap;
      }
  
      protected void importTransaction(String operation, PropagationContext 
propagationContext) throws SystemException {
          //TODO TOTAL HACK WARNING FIXME!!
          int pos = operation.indexOf("__");
          if (pos > -1) {
              operation = operation.substring(0, pos);
          }
  
          OperationTxPolicy operationTxPolicy = (OperationTxPolicy) 
operationToPolicyMap.get(operation);
          if (operationTxPolicy == null) {
              throw new BAD_OPERATION("Operation " + operation + " not 
recognized, no tx mapping");
          }
          operationTxPolicy.importTransaction(propagationContext);
       }
  
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/transaction/OperationTxPolicy.java
  
  Index: OperationTxPolicy.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;
  
  import org.openejb.corba.idl.CosTransactions.PropagationContext;
  
  
  /**
   * @version $Rev:  $ $Date: 2005/03/15 05:27:04 $
   */
  public interface OperationTxPolicy {
      void importTransaction(PropagationContext propagationContext);
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/transaction/ServerTransactionPolicy.java
  
  Index: ServerTransactionPolicy.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;
  
  import org.apache.geronimo.transaction.context.TransactionContextManager;
  import org.omg.CORBA.LocalObject;
  import org.omg.CORBA.Policy;
  
  /**
   * @version $Rev:  $ $Date: 2005/03/15 05:27:04 $
   */
  public class ServerTransactionPolicy extends LocalObject implements Policy {
  
      private final ServerTransactionPolicyConfig serverTransactionPolicyConfig;
  
      public ServerTransactionPolicy(ServerTransactionPolicyConfig 
serverTransactionPolicyConfig) {
          this.serverTransactionPolicyConfig = serverTransactionPolicyConfig;
      }
  
  
      public int policy_type() {
          return ServerTransactionPolicyFactory.POLICY_TYPE;
      }
  
      public Policy copy() {
          return new ServerTransactionPolicy(serverTransactionPolicyConfig);
      }
  
      public void destroy() {
  
      }
  
      ServerTransactionPolicyConfig getServerTransactionPolicyConfig() {
          return serverTransactionPolicyConfig;
      }
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/transaction/ServerTransactionPolicyConfig.java
  
  Index: ServerTransactionPolicyConfig.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;
  
  import java.io.Serializable;
  
  import org.omg.CORBA.SystemException;
  import org.omg.PortableInterceptor.ServerRequestInfo;
  
  /**
   * @version $Rev:  $ $Date: 2005/03/15 05:27:04 $
   */
  public interface ServerTransactionPolicyConfig extends Serializable {
  
      void importTransaction(ServerRequestInfo serverRequestInfo) throws 
SystemException;
  
  }
  
  
  
  1.1                  
openejb/modules/core/src/java/org/openejb/corba/transaction/ServerTransactionPolicyFactory.java
  
  Index: ServerTransactionPolicyFactory.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;
  
  import org.omg.CORBA.Any;
  import org.omg.CORBA.LocalObject;
  import org.omg.CORBA.Policy;
  import org.omg.CORBA.PolicyError;
  import org.omg.PortableInterceptor.PolicyFactory;
  
  /**
   * @version $Rev:  $ $Date: 2005/03/15 05:27:04 $
   */
  public class ServerTransactionPolicyFactory extends LocalObject implements 
PolicyFactory {
      public final static int POLICY_TYPE = 0x41534602;
  
      public Policy create_policy(int type, Any value) throws PolicyError {
          if (type != POLICY_TYPE){
              throw new PolicyError();
          }
          return new ServerTransactionPolicy((ServerTransactionPolicyConfig) 
value.extract_Value());
      }
  }
  
  
  

Reply via email to