]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleContextAware.java
Rename SLC Core into SLC Spring.
[gpl/argeo-slc.git] / org.argeo.slc.spring / src / org / argeo / slc / core / test / context / SimpleContextAware.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
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.argeo.slc.core.test.context;
17
18 import java.util.Map;
19 import java.util.TreeMap;
20
21 import org.argeo.slc.SlcException;
22 import org.argeo.slc.test.context.ContextAware;
23 import org.argeo.slc.test.context.ParentContextAware;
24 import org.springframework.beans.factory.InitializingBean;
25
26 public class SimpleContextAware implements ContextAware, InitializingBean {
27 private ParentContextAware parentContext;
28
29 private Map<String, Object> values = new TreeMap<String, Object>();
30 private Map<String, Object> expectedValues = new TreeMap<String, Object>();
31
32 private String contextSkipFlag = DEFAULT_SKIP_FLAG;
33 private String contextAnyFlag = DEFAULT_ANY_FLAG;
34
35 public Map<String, Object> getValues() {
36 return values;
37 }
38
39 public void setValues(Map<String, Object> values) {
40 this.values = values;
41 }
42
43 public Map<String, Object> getExpectedValues() {
44 return expectedValues;
45 }
46
47 public void setExpectedValues(Map<String, Object> expectedValues) {
48 this.expectedValues = expectedValues;
49 }
50
51 /** Used to add this context as a child by setting a property. */
52 public void setParentContext(ParentContextAware parentContextAware) {
53 if (parentContext != null)
54 throw new SlcException("Parent context already set");
55 this.parentContext = parentContextAware;
56 this.parentContext.addChildContext(this);
57 }
58
59 protected ParentContextAware getParentContext() {
60 return parentContext;
61 }
62
63 public void afterPropertiesSet() throws Exception {
64 if (parentContext != null) {
65 ContextUtils.synchronize(parentContext);
66 }
67 }
68
69 public String getContextSkipFlag() {
70 return contextSkipFlag;
71 }
72
73 public void setContextSkipFlag(String contextSkipFlag) {
74 this.contextSkipFlag = contextSkipFlag;
75 }
76
77 public String getContextAnyFlag() {
78 return contextAnyFlag;
79 }
80
81 public void setContextAnyFlag(String contextAnyFlag) {
82 this.contextAnyFlag = contextAnyFlag;
83 }
84
85 }