]> git.argeo.org Git - gpl/argeo-slc.git/blob - SimpleParentContextAware.java
76ea43f3cbbf22fc10aeaf6ca6196472b498070d
[gpl/argeo-slc.git] / 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.springframework.beans.factory.InitializingBean;
8
9 public class SimpleParentContextAware extends SimpleContextAware implements
10 ParentContextAware, InitializingBean {
11 private List<ContextAware> children = new Vector<ContextAware>();
12
13 public Collection<ContextAware> getChildContexts() {
14 return children;
15 }
16
17 public void addChildContext(ContextAware contextAware) {
18 children.add(contextAware);
19 }
20
21 @Override
22 public void afterPropertiesSet() throws Exception {
23 if (getParentContext() != null) {
24 // If has a parent, sync it.
25 super.afterPropertiesSet();
26 } else {
27 if (children.size() > 0) {
28 // No need to synchronize if no children
29 ContextUtils.synchronize(this);
30 }
31 }
32 }
33 }