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