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 public final Collection getObjectKeys()
45 {
46 return Collections.list( this.getSession().getAttributeNames() );
47 }
48
49 public final Object getObject( final String key )
50 {
51 if ( key == null )
52 {
53 throw new NullPointerException( "key" );
54 }
55
56 return this.getSession().getAttribute( key );
57 }
58
59 public final Object setObject( final String key, final Object o )
60 {
61 if ( key == null )
62 {
63 throw new NullPointerException( "key" );
64 }
65
66 final Object old = this.getSession().getAttribute( key );
67 this.getSession().setAttribute( key, o );
68
69 return old;
70 }
71
72 public final Object removeObject( final String key )
73 {
74 if ( key == null )
75 {
76 throw new NullPointerException( "key" );
77 }
78
79 final Object old = this.getSession().getAttribute( key );
80 this.getSession().removeAttribute( key );
81
82 return old;
83 }
84
85 public final Object getAttribute( final String key )
86 {
87 return this.getObject( key );
88 }
89
90 public final Object setAttribute( final String key, final Serializable o )
91 {
92 return this.setObject( key, o );
93 }
94
95 public final Object removeAttribute( String key )
96 {
97 return this.removeObject( key );
98 }
99
100
101
102
103
104 public HttpSession getSession()
105 {
106 return ServletFilter.getHttpSession();
107 }
108
109
110 }