1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.uruma.binding.context;
17
18 import java.util.List;
19
20 import org.seasar.framework.beans.PropertyDesc;
21 import org.seasar.uruma.context.ApplicationContext;
22 import org.seasar.uruma.core.UrumaMessageCodes;
23 import org.seasar.uruma.log.UrumaLogger;
24
25
26
27
28
29
30 public class ApplicationContextBinder {
31 private static final UrumaLogger logger = UrumaLogger
32 .getLogger(ApplicationContextBinder.class);
33
34 private ApplicationContextBinder() {
35
36 }
37
38
39
40
41
42
43
44
45
46
47
48
49
50 public static void exportObjects(final Object target,
51 final List<ApplicationContextDef> defs,
52 final ApplicationContext context) {
53 for (ApplicationContextDef def : defs) {
54 PropertyDesc pd = def.getPropertyDesc();
55 String name = def.getName();
56 Object value = pd.getValue(target);
57
58 if (logger.isDebugEnabled()) {
59 logger.log(UrumaMessageCodes.EXPORT_APPLICATION_CONTEXT,
60 UrumaLogger.getObjectDescription(target), pd
61 .getPropertyName(), name, value);
62 }
63 context.setValue(name, value);
64 }
65 }
66
67
68
69
70
71
72
73
74
75
76
77
78
79 public static void importObjects(final Object target,
80 final List<ApplicationContextDef> defs,
81 final ApplicationContext context) {
82 for (ApplicationContextDef def : defs) {
83 PropertyDesc pd = def.getPropertyDesc();
84 String name = def.getName();
85 Object value = context.getValue(name);
86
87 if (logger.isDebugEnabled()) {
88 logger.log(UrumaMessageCodes.IMPORT_APPLICATION_CONTEXT,
89 UrumaLogger.getObjectDescription(target), pd
90 .getPropertyName(), name, value);
91 }
92
93 pd.setValue(target, value);
94 }
95 }
96 }