]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleParentContextAware.java
Remove old license headers
[gpl/argeo-slc.git] / org.argeo.slc.spring / src / org / argeo / slc / core / test / context / SimpleParentContextAware.java
1 package org.argeo.slc.core.test.context;
2
3 import java.util.Collection;
4 import java.util.List;
5 import java.util.Vector;
6
7 import org.argeo.slc.runtime.test.ContextUtils;
8 import org.argeo.slc.test.context.ContextAware;
9 import org.argeo.slc.test.context.ParentContextAware;
10 import org.springframework.beans.factory.InitializingBean;
11
12 public class SimpleParentContextAware extends SimpleContextAware implements
13 ParentContextAware, InitializingBean {
14 private List<ContextAware> children = new Vector<ContextAware>();
15
16 public Collection<ContextAware> getChildContexts() {
17 return children;
18 }
19
20 public void addChildContext(ContextAware contextAware) {
21 children.add(contextAware);
22 }
23
24 @Override
25 public void afterPropertiesSet() throws Exception {
26 if (getParentContext() != null) {
27 // If has a parent, sync it.
28 super.afterPropertiesSet();
29 } else {
30 if (children.size() > 0) {
31 // No need to synchronize if no children
32 ContextUtils.synchronize(this);
33 }
34 }
35 }
36 }