Save This Page
Home » openejb-3.1.2-src » org.apache » openejb » core » stateless » [javadoc | source]
    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.openejb.core.stateless;
   18   
   19   import org.apache.openejb.Container;
   20   import org.apache.openejb.InterfaceType;
   21   import org.apache.openejb.DeploymentInfo;
   22   import org.apache.openejb.core.ivm.EjbObjectProxyHandler;
   23   import org.apache.openejb.util.proxy.ProxyManager;
   24   
   25   import java.lang.reflect.Method;
   26   import java.rmi.RemoteException;
   27   import java.util.List;
   28   
   29   public class StatelessEjbObjectHandler extends EjbObjectProxyHandler {
   30       public Object registryId;
   31   
   32       public StatelessEjbObjectHandler(DeploymentInfo deploymentInfo, Object pk, InterfaceType interfaceType, List<Class> interfaces) {
   33           super(deploymentInfo, pk, interfaceType, interfaces);
   34       }
   35   
   36       public static Object createRegistryId(Object primKey, Object deployId, Container contnr) {
   37           return "" + deployId + contnr.getContainerID();
   38       }
   39   
   40       public Object getRegistryId() {
   41           if (registryId == null)
   42               registryId = createRegistryId(primaryKey, deploymentID, container);
   43           return registryId;
   44       }
   45   
   46       protected Object getPrimaryKey(Method method, Object[] args, Object proxy) throws Throwable {
   47           throw new RemoteException("Session objects are private resources and do not have primary keys");
   48       }
   49   
   50       protected Object isIdentical(Method method, Object[] args, Object proxy) throws Throwable {
   51           try {
   52               EjbObjectProxyHandler handler = (EjbObjectProxyHandler) ProxyManager.getInvocationHandler(args[0]);
   53               return new Boolean(deploymentID.equals(handler.deploymentID));
   54           } catch (Throwable t) {
   55               return Boolean.FALSE;
   56   
   57           }
   58       }
   59   
   60       public void invalidateReference() {
   61           // stateless can't be removed
   62       }
   63   
   64       protected Object remove(Class interfce, Method method, Object[] args, Object proxy) throws Throwable {
   65           // stateless can't be removed
   66           return null;
   67       }
   68   }

Save This Page
Home » openejb-3.1.2-src » org.apache » openejb » core » stateless » [javadoc | source]