mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-03 21:49:03 +00:00
39 lines
762 B
Java
39 lines
762 B
Java
package com.foo;
|
|
|
|
import java.util.List;
|
|
|
|
import org.springframework.beans.factory.FactoryBean;
|
|
|
|
public class ComponentFactoryBean implements FactoryBean<Component> {
|
|
private Component parent;
|
|
private List<Component> children;
|
|
|
|
public void setParent(Component parent) {
|
|
this.parent = parent;
|
|
}
|
|
|
|
public void setChildren(List<Component> children) {
|
|
this.children = children;
|
|
}
|
|
|
|
@Override
|
|
public Component getObject() throws Exception {
|
|
if (this.children != null && this.children.size() > 0) {
|
|
for (Component child : children) {
|
|
this.parent.addComponent(child);
|
|
}
|
|
}
|
|
return this.parent;
|
|
}
|
|
|
|
@Override
|
|
public Class<Component> getObjectType() {
|
|
return Component.class;
|
|
}
|
|
|
|
@Override
|
|
public boolean isSingleton() {
|
|
return true;
|
|
}
|
|
}
|