use of com.revolsys.spring.TargetBeanFactoryBean in project com.revolsys.open by revolsys.
the class SpringProcessNetwork method postProcessAfterInitialization.
@Override
public Object postProcessAfterInitialization(final Object bean, final String beanName) throws BeansException {
final ProcessNetwork parent = getParent();
if (parent == null) {
if (bean instanceof TargetBeanFactoryBean) {
final TargetBeanFactoryBean targetBean = (TargetBeanFactoryBean) bean;
final Class<?> targetClass = targetBean.getObjectType();
if (Process.class.isAssignableFrom(targetClass)) {
try {
final Process process = new TargetBeanProcess(targetBean);
addProcess(process);
} catch (final Exception e) {
Logs.error(this, "Unable to create process for bean " + beanName, e);
}
}
} else if (bean instanceof Process) {
final Map<Process, Thread> processes = getProcessMap();
final Process process = (Process) bean;
// threads aren't created
if (processes != null) {
for (final Entry<Process, Thread> entry : processes.entrySet()) {
final Process otherProcess = entry.getKey();
if (otherProcess instanceof TargetBeanProcess) {
final TargetBeanProcess targetProcessBean = (TargetBeanProcess) otherProcess;
if (targetProcessBean.isInstanceCreated()) {
final Process targetProcess = targetProcessBean.getProcess();
if (targetProcess == process) {
synchronized (getSync()) {
final Thread thread = entry.getValue();
processes.put(targetProcess, thread);
processes.remove(otherProcess);
return bean;
}
}
}
}
}
}
addProcess(process);
}
} else if (parent instanceof SpringProcessNetwork) {
final SpringProcessNetwork parentProcessNetwork = (SpringProcessNetwork) parent;
parentProcessNetwork.postProcessAfterInitialization(bean, beanName);
}
return bean;
}
Aggregations