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