1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.mina.integration.ognl;
18
19 import java.util.Map;
20 import java.util.TreeMap;
21
22 import ognl.OgnlContext;
23 import ognl.OgnlException;
24 import ognl.OgnlRuntime;
25 import ognl.PropertyAccessor;
26
27 import org.apache.mina.core.session.IoSession;
28
29
30
31
32
33
34 public class IoSessionPropertyAccessor extends AbstractPropertyAccessor {
35
36 @Override
37 protected Object getProperty0(OgnlContext context, Object target, String name) throws OgnlException {
38 if (target instanceof IoSession && "attributes".equals(name)) {
39 Map<String, Object> attributes = new TreeMap<>();
40 IoSession="../../../../../org/apache/mina/core/session/IoSession.html#IoSession">IoSession s = (IoSession) target;
41 for (Object key : s.getAttributeKeys()) {
42 Object value = s.getAttribute(key);
43 if (value == null) {
44 continue;
45 }
46 attributes.put(String.valueOf(key), value);
47 }
48 return attributes;
49 }
50
51 return OgnlRuntime.NotFound;
52 }
53
54 @Override
55 protected boolean hasGetProperty0(OgnlContext context, Object target, String name) throws OgnlException {
56 return target instanceof IoSession && "attributes".equals(name);
57 }
58
59 @Override
60 protected boolean hasSetProperty0(OgnlContext context, Object target, String name) throws OgnlException {
61 return false;
62 }
63
64 @Override
65 protected Object setProperty0(OgnlContext context, Object target, String name, Object value) throws OgnlException {
66 return OgnlRuntime.NotFound;
67 }
68 }