View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.jdiagnose.library.web.spring;
17  
18  import java.util.Collection;
19  import java.util.HashSet;
20  import java.util.Iterator;
21  import java.util.Set;
22  
23  import javax.servlet.http.HttpSessionBindingEvent;
24  import javax.servlet.http.HttpSessionBindingListener;
25  
26  import org.jdiagnose.remote.provider.MutableSystemProvider;
27  
28  /***
29   * @author JMcCrindle
30   */
31  public class DefaultSessionSystems implements HttpSessionBindingListener, SessionSystems {
32      
33      private transient MutableSystemProvider provider = null;
34      private Set ids = new HashSet();
35      
36      public DefaultSessionSystems(MutableSystemProvider provider) {
37          this.provider = provider;
38      }
39  
40      /* (non-Javadoc)
41       * @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent)
42       */
43      public void valueBound(HttpSessionBindingEvent event) {
44      }
45  
46      /* (non-Javadoc)
47       * @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(javax.servlet.http.HttpSessionBindingEvent)
48       */
49      public void valueUnbound(HttpSessionBindingEvent event) {
50          if(provider != null) {
51              for (Iterator iter = ids.iterator(); iter.hasNext();) {
52                  String id = (String) iter.next();
53                  provider.removeHolder(id);
54              }
55          }
56      }
57  
58      /* (non-Javadoc)
59       * @see org.jdiagnose.library.web.spring.SessionSystems#getIds()
60       */
61      public Collection getIds() {
62          return ids;
63      }
64      
65  
66  }