dain        2006/02/01 06:50:08

  Added:       modules/core/src/java/org/openejb/naming
                        ComponentContextInterceptor.java
  Log:

  Major refactor
  Split container into an object to represent a deployed ejb and a set of 
shared containers which process invocations
  Introduced interface between CMP container and CMP engine
  
  Revision  Changes    Path
  1.1                  
openejb/modules/core/src/java/org/openejb/naming/ComponentContextInterceptor.java
  
  Index: ComponentContextInterceptor.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.naming;
  
  import javax.naming.Context;
  
  import org.apache.geronimo.core.service.Interceptor;
  import org.apache.geronimo.core.service.Invocation;
  import org.apache.geronimo.core.service.InvocationResult;
  import org.apache.geronimo.naming.java.RootContext;
  import org.openejb.EjbInvocation;
  import org.openejb.ExtendedEjbDeployment;
  
  /**
   * An interceptor that pushes the current component's java:comp context into
   * the java: JNDI namespace
   *
   * @version $Rev: 6509 $ $Date: 2006/02/01 11:50:08 $
   */
  public class ComponentContextInterceptor implements Interceptor {
      private final Interceptor next;
  
      public ComponentContextInterceptor(Interceptor next) {
          assert next != null;
          this.next = next;
      }
  
      public InvocationResult invoke(Invocation invocation) throws Throwable {
          EjbInvocation ejbInvocation = (EjbInvocation) invocation;
          ExtendedEjbDeployment deployment = (ExtendedEjbDeployment) 
ejbInvocation.getEjbDeployment();
          Context componentContext = deployment.getComponentContext();
  
          Context oldContext = RootContext.getComponentContext();
          try {
              RootContext.setComponentContext(componentContext);
              return next.invoke(invocation);
          } finally {
              RootContext.setComponentContext(oldContext);
          }
      }
  }
  
  
  

Reply via email to