01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.openejb.core.stateless;
17:
18: import org.apache.openejb.Container;
19: import org.apache.openejb.InterfaceType;
20: import org.apache.openejb.DeploymentInfo;
21: import org.apache.openejb.core.ivm.EjbObjectProxyHandler;
22: import org.apache.openejb.util.proxy.ProxyManager;
23:
24: import java.lang.reflect.Method;
25: import java.rmi.RemoteException;
26: import java.util.List;
27:
28: public class StatelessEjbObjectHandler extends EjbObjectProxyHandler {
29: public Object registryId;
30:
31: public StatelessEjbObjectHandler(DeploymentInfo deploymentInfo,
32: Object pk, InterfaceType interfaceType,
33: List<Class> interfaces) {
34: super (deploymentInfo, pk, interfaceType, interfaces);
35: }
36:
37: public static Object createRegistryId(Object primKey,
38: Object deployId, Container contnr) {
39: return "" + deployId + contnr.getContainerID();
40: }
41:
42: public Object getRegistryId() {
43: if (registryId == null)
44: registryId = createRegistryId(primaryKey, deploymentID,
45: container);
46: return registryId;
47: }
48:
49: protected Object getPrimaryKey(Method method, Object[] args,
50: Object proxy) throws Throwable {
51: throw new RemoteException(
52: "Session objects are private resources and do not have primary keys");
53: }
54:
55: protected Object isIdentical(Method method, Object[] args,
56: Object proxy) throws Throwable {
57: try {
58: EjbObjectProxyHandler handler = (EjbObjectProxyHandler) ProxyManager
59: .getInvocationHandler(args[0]);
60: return new Boolean(deploymentID
61: .equals(handler.deploymentID));
62: } catch (Throwable t) {
63: return Boolean.FALSE;
64:
65: }
66: }
67:
68: public void invalidateReference() {
69: // stateless can't be removed
70: }
71:
72: protected Object remove(Class interfce, Method method,
73: Object[] args, Object proxy) throws Throwable {
74: // stateless can't be removed
75: return null;
76: }
77: }
|