org.objectweb.fractal.bf.adl.binder.BinderLoader Maven / Gradle / Ivy
package org.objectweb.fractal.bf.adl.binder;
import java.util.logging.Logger;
import org.objectweb.fractal.adl.ADLException;
import org.objectweb.fractal.bf.adl.common.BindingFactoryLoader;
import org.objectweb.fractal.bf.adl.common.ParameterContainer;
import org.objectweb.fractal.bf.adl.common.ParameterVerifier;
/**
* A loader for nodes.
*/
public class BinderLoader extends BindingFactoryLoader {
Logger log = Logger.getLogger(BinderLoader.class.getCanonicalName());
/**
* @throws ADLException
* @see org.objectweb.fractal.bf.adl.common.BindingFactoryLoader#performSpecificChecksOn(java.lang.Object)
*/
@Override
protected void performSpecificChecksOn(Object node) throws ADLException {
if (node instanceof BinderContainer) {
BinderContainer bindingContaier = (BinderContainer) node;
final Binder[] binders = bindingContaier.getBinders();
if (binders.length > 0) {
for (Binder binder : binders) {
if (binder.getType() == null
|| binder.getType().equalsIgnoreCase("")) {
throw new ADLException(
"The type of the binder to use can't be empty");
}
if (binder.getInterface() == null
| binder.getInterface().equalsIgnoreCase("")) {
throw new ADLException(
"Interface to be used by the binder missing");
} else {
String itf = binder.getInterface();
int dot = itf.lastIndexOf(".");
String componentName = itf.substring(0, dot);
String itfName = itf.substring(dot + 1);
log.info("Binder will bind interface '" + itfName
+ "' of component '" + componentName + "'");
}
if (binder instanceof ParameterContainer) {
ParameterContainer pc = (ParameterContainer) binder;
ParameterVerifier.verify(pc);
}
}
}
}
}
}