private static final Log LOG = LogFactory.getLog(AbstractComponent.class);
- private ThreadLocal<List<ProvidedInterface>> _remaining;
+ private ThreadLocal<List<ProvidedInterface>> remaining;
- private String _context;
- private String _name;
- private List<ProvidedInterface> _provided;
- private List<RequiredInterface> _required;
+ private String context;
+ private String name;
+ private List<ProvidedInterface> provided;
+ private List<RequiredInterface> required;
/**
* Constructs the subsystem.
*/
protected AbstractComponent(String aName, List<ProvidedInterface> aProvided,
List<RequiredInterface> aRequired) {
- _remaining = new ThreadLocal<List<ProvidedInterface>>();
- _context = null;
- _name = aName;
- _provided = new ArrayList<ProvidedInterface>(aProvided);
- _required = new ArrayList<RequiredInterface>(aRequired);
+ remaining = new ThreadLocal<List<ProvidedInterface>>();
+ context = null;
+ name = aName;
+ provided = new ArrayList<ProvidedInterface>(aProvided);
+ required = new ArrayList<RequiredInterface>(aRequired);
}
/**
}
public AbstractComponent<Type> addProvidedInterface(ProvidedInterface aProvided) {
- _provided.add(aProvided);
+ provided.add(aProvided);
return this;
}
public AbstractComponent<Type> addRequiredInterface(RequiredInterface aRequired) {
- _required.add(aRequired);
+ required.add(aRequired);
return this;
}
@Override
public final String getName() {
- return _name;
+ return name;
}
@Override
public void addContext(String aContext) {
- if (_context == null) {
- _context = aContext;
+ if (context == null) {
+ context = aContext;
} else {
- _context = aContext + "." + _context;
+ context = aContext + "." + context;
}
}
@Override
public String getContext() {
- return _context;
+ return context;
}
@Override
public String getQualifiedName() {
- if (_context == null) {
+ if (context == null) {
return getName();
}
- return _context + "." + getName();
+ return context + "." + getName();
}
@Override
public final List<ProvidedInterface> getProvidedInterfaces() {
- return Collections.unmodifiableList(_provided);
+ return Collections.unmodifiableList(provided);
}
@Override
public final List<RequiredInterface> getRequiredInterfaces() {
- return Collections.unmodifiableList(_required);
+ return Collections.unmodifiableList(required);
}
@Override
public final Type start(Scope aScope) {
LOG.info("Initialization starting '" + getQualifiedName() + "'");
- List<ProvidedInterface> oldRemaining = _remaining.get();
- _remaining.set(new ArrayList<ProvidedInterface>(getProvidedInterfaces()));
+ List<ProvidedInterface> oldRemaining = remaining.get();
+ remaining.set(new ArrayList<ProvidedInterface>(getProvidedInterfaces()));
try {
Type runtime = doStart(aScope);
checkNotStartedInterfaces();
LOG.info("Initialization finished '" + getQualifiedName() + "'");
return runtime;
} finally {
- _remaining.set(oldRemaining);
+ remaining.set(oldRemaining);
}
}
private void checkNotStartedInterfaces() {
- if (_remaining.get().size() > 0) {
+ if (remaining.get().size() > 0) {
String notProvided = "";
- for (ProvidedInterface provided : _remaining.get()) {
+ for (ProvidedInterface provided : remaining.get()) {
notProvided += "\nComponent " + getQualifiedName()
+ " did not start interface " + provided;
}
Object aService, Scope aScope) {
LOG.info("Interface '" + getQualifiedName() + "."
+ aDescriptor.getName() + "' started.");
- if ( !_remaining.get().remove(aDescriptor) ) {
+ if ( !remaining.get().remove(aDescriptor) ) {
throw new SystemAssemblyException("Component '" + getQualifiedName() + "' started an unexpected interface '" +
aDescriptor + "' that was not registerd as a provided interface before");
}