You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
762 B
38 lines
762 B
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; |
|
} |
|
}
|
|
|