KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mortbay > j2ee > session > SynchronizingInterceptor


1 // ========================================================================
2
// $Id: SynchronizingInterceptor.java,v 1.4 2004/05/09 20:30:48 gregwilkins Exp $
3
// Copyright 2002-2004 Mort Bay Consulting Pty. Ltd.
4
// ------------------------------------------------------------------------
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
// ========================================================================
15

16 package org.mortbay.j2ee.session;
17
18 //----------------------------------------
19

20 import java.rmi.RemoteException JavaDoc;
21 import java.util.Enumeration JavaDoc;
22 import java.util.Map JavaDoc;
23
24 import org.jfox.ioc.logger.Logger;
25
26 //----------------------------------------
27

28 // OK - so I could just synchronise in the LocalState class - but I'm
29
// sure this will come in handy somewhere... - after all - if your
30
// were using a SingleThreaded model servlet....
31

32
33 // we only need to synchronize attributes that have writers as well as
34
// readers...
35

36 public class SynchronizingInterceptor
37   extends StateInterceptor
38 {
39   protected static final Logger _log=Logger.getLogger(SynchronizingInterceptor.class);
40
41   protected final Object JavaDoc _lastAccessedTimeLock=new Object JavaDoc();
42   public void setLastAccessedTime(long time) throws RemoteException JavaDoc {synchronized(_lastAccessedTimeLock){super.setLastAccessedTime(time);}}
43   public long getLastAccessedTime() throws RemoteException JavaDoc {synchronized(_lastAccessedTimeLock){return super.getLastAccessedTime();}}
44
45   protected final Object JavaDoc _maxInactiveIntervalLock=new Object JavaDoc();
46   public void setMaxInactiveInterval(int interval) throws RemoteException JavaDoc {synchronized(_maxInactiveIntervalLock){super.setMaxInactiveInterval(interval);}}
47   public int getMaxInactiveInterval() throws RemoteException JavaDoc {synchronized(_maxInactiveIntervalLock){return super.getMaxInactiveInterval();}}
48
49   protected final Object JavaDoc _attributesLock=new Object JavaDoc();
50   public Object JavaDoc getAttribute(String JavaDoc name) throws RemoteException JavaDoc {synchronized(_attributesLock){return super.getAttribute(name);}}
51   public Enumeration JavaDoc getAttributeNameEnumeration() throws RemoteException JavaDoc {synchronized(_attributesLock){return super.getAttributeNameEnumeration();}}
52   public String JavaDoc[] getAttributeNameStringArray() throws RemoteException JavaDoc {synchronized(_attributesLock){return super.getAttributeNameStringArray();}}
53   public Object JavaDoc setAttribute(String JavaDoc name, Object JavaDoc value, boolean returnValue) throws RemoteException JavaDoc {synchronized(_attributesLock){return super.setAttribute(name, value, returnValue);}}
54   public Object JavaDoc removeAttribute(String JavaDoc name, boolean returnValue) throws RemoteException JavaDoc {synchronized(_attributesLock){return super.removeAttribute(name, returnValue);}}
55   public Map JavaDoc getAttributes() throws RemoteException JavaDoc {synchronized(_attributesLock){return super.getAttributes();}}
56   public void setAttributes(Map JavaDoc attributes) throws RemoteException JavaDoc {synchronized(_attributesLock){super.setAttributes(attributes);}}
57
58   // public Object clone() { return null; } // Stateful
59
}
60
Popular Tags