001: /*
002: * JOSSO: Java Open Single Sign-On
003: *
004: * Copyright 2004-2008, Atricore, Inc.
005: *
006: * This is free software; you can redistribute it and/or modify it
007: * under the terms of the GNU Lesser General Public License as
008: * published by the Free Software Foundation; either version 2.1 of
009: * the License, or (at your option) any later version.
010: *
011: * This software is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this software; if not, write to the Free
018: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
019: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
020: */
021:
022: package org.josso.tc55.agent;
023:
024: import org.apache.catalina.Session;
025: import org.josso.agent.LocalSession;
026: import org.josso.agent.LocalSessionEvent;
027: import org.josso.agent.LocalSessionListener;
028:
029: import java.util.ArrayList;
030: import java.util.Iterator;
031:
032: /**
033: * Local Session default implementation.
034: *
035: * @author <a href="mailto:gbrigand@josso.org">Gianluca Brigandi</a>
036: * @version CVS $Id: LocalSessionImpl.java 508 2008-02-18 13:32:29Z sgonzalez $
037: */
038:
039: public class LocalSessionImpl implements LocalSession {
040:
041: /**
042: * The session event listeners for this Session.
043: */
044: private transient ArrayList _listeners = new ArrayList();
045: private long _creationTime;
046:
047: private String _id;
048: private long _lastAccessedTime;
049: private int _maxInactiveInterval;
050: private Object _wrapped;
051:
052: public LocalSessionImpl() {
053: }
054:
055: public long getCreationTime() {
056: return _creationTime;
057: }
058:
059: public String getId() {
060: return _id;
061: }
062:
063: public long getLastAccessedTime() {
064: return _lastAccessedTime;
065: }
066:
067: public void setMaxInactiveInterval(int i) {
068: _maxInactiveInterval = i;
069: }
070:
071: public int getMaxInactiveInterval() {
072: return _maxInactiveInterval;
073: }
074:
075: public void expire() {
076:
077: Iterator i = _listeners.iterator();
078: while (i.hasNext()) {
079: LocalSessionListener listener = (LocalSessionListener) i
080: .next();
081:
082: listener.localSessionEvent(new LocalSessionEvent(this ,
083: LocalSession.LOCAL_SESSION_DESTROYED_EVENT, null));
084: }
085: }
086:
087: public void addSessionListener(LocalSessionListener sessionListener) {
088: _listeners.add(sessionListener);
089: }
090:
091: public void removeSessionListener(
092: LocalSessionListener sessionListener) {
093: _listeners.remove(sessionListener);
094: }
095:
096: public void exipre() {
097: ((Session) _wrapped).expire();
098: }
099:
100: public void setWrapped(Object wrapped) {
101: _wrapped = wrapped;
102: }
103:
104: public Object getWrapped() {
105: return _wrapped;
106: }
107: }
|