use of php.runtime.exceptions.ConflictException in project jphp by jphp-compiler.
the class CompileScope method registerExtension.
public void registerExtension(Extension extension) {
long t = System.currentTimeMillis();
if (extensions.containsKey(extension.getName()))
return;
// required
for (String dep : extension.getRequiredExtensions()) {
try {
Extension el = (Extension) Class.forName(dep).newInstance();
registerExtension(el);
} catch (Exception e) {
throw new CriticalException(e);
}
}
// optional
for (String dep : extension.getOptionalExtensions()) {
try {
Extension el = (Extension) Class.forName(dep).newInstance();
registerExtension(el);
} catch (ClassNotFoundException e) {
// do nothing ...
} catch (Exception e) {
throw new CriticalException(e);
}
}
// conflicts
for (String dep : extension.getConflictExtensions()) {
if (extensions.containsKey(dep))
throw new ConflictException("'" + dep + "' extension conflicts with '" + extension.getClass().getName() + "'");
}
extension.onRegister(this);
compileConstantMap.putAll(extension.getConstants());
compileFunctionSpecMap.putAll(extension.getFunctions());
for (Class<?> clazz : extension.getClasses().values()) {
registerLazyClass(extension, clazz);
}
for (CompileFunctionSpec function : extension.getFunctions().values()) {
functionMap.put(function.getLowerName(), new CompileFunctionEntity(extension, function));
}
extensions.put(extension.getName().toLowerCase(), extension);
if (Startup.isTracing()) {
Startup.traceWithTime("Register extension '" + extension.getName() + "'", t);
}
}
Aggregations