Search in sources :

Example 1 with ConflictException

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);
    }
}
Also used : Extension(php.runtime.ext.support.Extension) JavaExtension(php.runtime.ext.JavaExtension) CoreExtension(php.runtime.ext.CoreExtension) NetExtension(php.runtime.ext.NetExtension) CompileFunctionSpec(php.runtime.ext.support.compile.CompileFunctionSpec) ConflictException(php.runtime.exceptions.ConflictException) CriticalException(php.runtime.exceptions.CriticalException) CriticalException(php.runtime.exceptions.CriticalException) JavaException(php.runtime.ext.java.JavaException) ErrorException(php.runtime.lang.spl.ErrorException) ConflictException(php.runtime.exceptions.ConflictException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ConflictException (php.runtime.exceptions.ConflictException)1 CriticalException (php.runtime.exceptions.CriticalException)1 CoreExtension (php.runtime.ext.CoreExtension)1 JavaExtension (php.runtime.ext.JavaExtension)1 NetExtension (php.runtime.ext.NetExtension)1 JavaException (php.runtime.ext.java.JavaException)1 Extension (php.runtime.ext.support.Extension)1 CompileFunctionSpec (php.runtime.ext.support.compile.CompileFunctionSpec)1 ErrorException (php.runtime.lang.spl.ErrorException)1