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.geronimo.clustering.wadi;
17:
18: import java.util.Map;
19:
20: import org.apache.geronimo.clustering.Session;
21:
22: /**
23: *
24: * @version $Rev$ $Date$
25: */
26: public class WADISessionAdaptor implements Session {
27: private static final String ADAPTOR_KEY = "ADAPTOR_KEY";
28: private final org.codehaus.wadi.core.session.Session session;
29:
30: public static WADISessionAdaptor retrieveAdaptor(
31: org.codehaus.wadi.core.session.Session session) {
32: WADISessionAdaptor adaptor = (WADISessionAdaptor) session
33: .getLocalStateMap().get(ADAPTOR_KEY);
34: if (null == adaptor) {
35: throw new IllegalStateException("No registered adaptor");
36: }
37: return adaptor;
38: }
39:
40: public WADISessionAdaptor(
41: org.codehaus.wadi.core.session.Session session) {
42: if (null == session) {
43: throw new IllegalArgumentException("session is required");
44: }
45: this .session = session;
46:
47: session.getLocalStateMap().put(ADAPTOR_KEY, this );
48: }
49:
50: public String getSessionId() {
51: return session.getName();
52: }
53:
54: public void release() {
55: try {
56: session.destroy();
57: } catch (Exception e) {
58: throw new IllegalStateException("Cannot release session "
59: + session, e);
60: }
61: }
62:
63: public Object addState(String key, Object value) {
64: return session.addState(key, value);
65: }
66:
67: public Object getState(String key) {
68: return session.getState(key);
69: }
70:
71: public Object removeState(String key) {
72: return session.removeState(key);
73: }
74:
75: public Map getState() {
76: return session.getState();
77: }
78:
79: public void onEndAccess() {
80: session.onEndProcessing();
81: }
82:
83: }
|