01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.geronimo.openejb.cluster.stateful.container;
21:
22: import org.apache.geronimo.clustering.Session;
23: import org.apache.openejb.core.stateful.BeanEntry;
24:
25: /**
26: *
27: * @version $Rev:$ $Date:$
28: */
29: public class ClusteredBeanEntry extends BeanEntry {
30: protected static final String SESSION_KEY_ENTRY = "entry";
31:
32: private transient final Session session;
33: private final Object deploymentId;
34:
35: protected static ClusteredBeanEntry getEntry(Session session) {
36: if (null == session) {
37: throw new IllegalArgumentException("session is required");
38: }
39: return (ClusteredBeanEntry) session.getState(SESSION_KEY_ENTRY);
40: }
41:
42: protected ClusteredBeanEntry(Session session, Object deploymentId,
43: Object beanInstance, Object primaryKey, long timeOut) {
44: super (beanInstance, primaryKey, timeOut);
45: if (null == session) {
46: throw new IllegalArgumentException("session is required");
47: } else if (null == deploymentId) {
48: throw new IllegalArgumentException(
49: "deploymentId is required");
50: }
51: this .session = session;
52: this .deploymentId = deploymentId;
53:
54: session.addState(SESSION_KEY_ENTRY, this );
55: }
56:
57: protected ClusteredBeanEntry(Session session) {
58: super (getEntry(session));
59: this .session = session;
60: this .deploymentId = getEntry(session).deploymentId;
61: }
62:
63: public void release() {
64: session.release();
65: }
66:
67: public void endAccess() {
68: session.addState(SESSION_KEY_ENTRY, this );
69: session.onEndAccess();
70: }
71:
72: public Object getDeploymentId() {
73: return deploymentId;
74: }
75:
76: }
|