import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
private static final Log LOG = LogFactory.getLog(Container.class);
- private List<Component> _components;
- private CompositeEdgeFilter _edgeFilter;
- private boolean _sealed;
+ private List<Component> components;
+ private CompositeEdgeFilter edgeFilter;
+ private boolean sealed;
/**
* Constructs the container
public Container(String aName, Component[] aComponents,
List<ProvidedInterface> aProvided, List<RequiredInterface> aRequired) {
super(aName, aProvided, aRequired);
- _components = new ArrayList<Component>();
+ components = new ArrayList<Component>();
- _edgeFilter = new CompositeEdgeFilter();
- _sealed = false;
+ edgeFilter = new CompositeEdgeFilter();
+ sealed = false;
for (Component component : aComponents) {
addComponent(component);
}
throw new SystemAssemblyException("Duplicate component '"
+ aComponent.getName() + "'");
}
- _components.add(aComponent);
+ components.add(aComponent);
aComponent.addContext(getQualifiedName());
return this;
}
+ aProvidedInterface + "'");
}
}
- _edgeFilter.add(new ConnectRequiredProvidedEdgeFilter(aClientComponent, aRequiredInterface, aServerComponent, aProvidedInterface));
+ edgeFilter.add(new ConnectRequiredProvidedEdgeFilter(aClientComponent, aRequiredInterface, aServerComponent, aProvidedInterface));
}
/**
+ aExternalRequiredInterface + "'");
}
}
- _edgeFilter.add(new ConnectRequiredExternallyRequiredEdgeFilter(
+ edgeFilter.add(new ConnectRequiredExternallyRequiredEdgeFilter(
aComponent, aRequiredInterface, aExternalRequiredInterface));
}
+ aExternalProvided + "'");
}
}
- _edgeFilter.add(new ConnectExternalProvidedProvidedFilter(aExternalProvided, aComponent, aProvidedInterface));
+ edgeFilter.add(new ConnectExternalProvidedProvidedFilter(aExternalProvided, aComponent, aProvidedInterface));
}
@Override
public void addContext(String aContext) {
super.addContext(aContext);
- for (Component component : _components) {
+ for (Component component : components) {
component.addContext(aContext);
}
}
* be added.
*/
public void seal() {
- _sealed = true;
+ sealed = true;
}
/**
* @return True iff the container is sealed.
*/
public boolean isSealed() {
- return _sealed;
+ return sealed;
}
/**
@Override
protected Scope doStart(Scope aExternalScope) {
- checkSealed();
validate();
Scope scope = new DefaultScope(getProvidedInterfaces().toArray(new ProvidedInterface[0]), aExternalScope);
ComponentGraph graph = doStartOptionalDryRun(scope, false);
private ComponentGraph doStartOptionalDryRun(Scope aScope, boolean aDryRun) {
ComponentGraph graph = createComponentGraph();
graph.validate();
- if (!aDryRun) {
- graph.link();
- }
+ graph.link();
LOG.info("Starting '" + getQualifiedName() + "'");
List<Component> started = new ArrayList<Component>();
- for (Component component : _components) {
+ for (Component component : components) {
try {
// Start the service.
if (!aDryRun) {
for (RequiredInterface req : getRequiredInterfaces()) {
graph.addRequiredInterface(this, req);
}
- for (Component comp : _components) {
+ for (Component comp : components) {
graph.addComponent(comp);
}
for (ProvidedInterface prov: getProvidedInterfaces()) {
graph.addProvidedInterface(this, prov);
}
- graph.addEdgeFilter(_edgeFilter);
+ graph.addEdgeFilter(edgeFilter);
return graph;
}
@Override
protected void doStop(Scope aScope) {
- for (int i = _components.size() - 1; i >= 0; i--) {
- Component component = _components.get(i);
+ for (int i = components.size() - 1; i >= 0; i--) {
+ Component component = components.get(i);
Object runtime = aScope.getRuntime(component);
component.stop(runtime);
}
}
private void checkSealed() {
- if (_sealed) {
+ if (sealed) {
throw new SystemAssemblyException("Container is sealed");
}
}
* @return Component or null if not found.
*/
public Component findComponent(String aName) {
- for (Component<?> component: _components) {
+ for (Component<?> component: components) {
if ( component.getName().equals(aName)) {
return component;
}