*/
public synchronized void resolve() throws ResolveError {
// already resolved ?
if (state==ModuleState.ERROR)
throw new ResolveError("Module " + getName() + " is in ERROR state");
if (state.compareTo(ModuleState.RESOLVED)>=0)
return;
if (state==ModuleState.PREPARING) {
Utils.identifyCyclicDependency(this, Logger.getAnonymousLogger());
throw new ResolveError("Cyclic dependency with " + getName());
}
state = ModuleState.PREPARING;
if (moduleDef.getImportPolicyClassName()!=null) {
try {
Class<ImportPolicy> importPolicyClass = (Class<ImportPolicy>) getPrivateClassLoader().loadClass(moduleDef.getImportPolicyClassName());
ImportPolicy importPolicy = importPolicyClass.newInstance();
importPolicy.prepare(this);
} catch(ClassNotFoundException e) {
state = ModuleState.ERROR;
throw new ResolveError(e);
} catch(java.lang.InstantiationException e) {
state = ModuleState.ERROR;
throw new ResolveError(e);
} catch(IllegalAccessException e) {
state = ModuleState.ERROR;
throw new ResolveError(e);
}
}
for (ModuleDependency dependency : moduleDef.getDependencies()) {
ModuleImpl depModule = (ModuleImpl)registry.makeModuleFor(dependency.getName(), dependency.getVersion());
if (depModule==null) {
state = ModuleState.ERROR;
throw new ResolveError(dependency + " referenced from "
+ moduleDef.getName() + " is not resolved");
}
//if (Utils.isLoggable(Level.INFO)) {
// Utils.getDefaultLogger().info("For module" + getName() + " adding new dependent " + module.getName());