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