1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.jdtaus.core.container.ri.servlet;
22
23 import java.io.Serializable;
24 import java.util.Collection;
25 import java.util.Collections;
26 import javax.servlet.http.HttpSession;
27 import org.jdtaus.core.container.Context;
28
29
30
31
32
33
34
35
36
37
38
39
40 public class HttpSessionContext implements Context
41 {
42
43
44
45 public HttpSessionContext()
46 {
47 super();
48 }
49
50 public final Collection getObjectKeys()
51 {
52 return Collections.list( this.getSession().getAttributeNames() );
53 }
54
55 public final Object getObject( final String key )
56 {
57 if ( key == null )
58 {
59 throw new NullPointerException( "key" );
60 }
61
62 return this.getSession().getAttribute( key );
63 }
64
65 public final Object setObject( final String key, final Object o )
66 {
67 if ( key == null )
68 {
69 throw new NullPointerException( "key" );
70 }
71
72 final Object old = this.getSession().getAttribute( key );
73 this.getSession().setAttribute( key, o );
74
75 return old;
76 }
77
78 public final Object removeObject( final String key )
79 {
80 if ( key == null )
81 {
82 throw new NullPointerException( "key" );
83 }
84
85 final Object old = this.getSession().getAttribute( key );
86 this.getSession().removeAttribute( key );
87
88 return old;
89 }
90
91 public final Object getAttribute( final String key )
92 {
93 return this.getObject( key );
94 }
95
96 public final Object setAttribute( final String key, final Serializable o )
97 {
98 return this.setObject( key, o );
99 }
100
101 public final Object removeAttribute( final String key )
102 {
103 return this.removeObject( key );
104 }
105
106
107
108
109
110 public HttpSession getSession()
111 {
112 return ServletFilter.getHttpSession();
113 }
114
115
116 }