public void reset() { if (compiledDependency != null) { OpenClassUtil.release(compiledDependency.getCompiledOpenClass()); } compiledDependency = null; }
/** * Handles loading dependent modules. This method should not cache * dependencies (method {@link #loadDependency(IDependency)} already uses * caching) Default implementation uses dependency loaders to load the * dependency. Can be overriden to redefine behavior. * * @param dependency dependency to load * @return loaded and compiled dependency * @throws OpenLCompilationException if exception during compilation is * occured */ protected CompiledDependency handleLoadDependency(IDependency dependency) throws OpenLCompilationException { List<IDependencyLoader> dependencyLoaders = getDependencyLoaders(); return loadDependency(dependency.getNode().getIdentifier(), dependencyLoaders); }
@Override public void setExternalParameters(Map<String, Object> parameters) { super.setExternalParameters(parameters); IDependencyManager dm = getDependencyManager(); if (dm instanceof DependencyManager) { ((DependencyManager) dm).setExternalParameters(parameters); } else { log.warn("Can't set external parameters to dependency manager {}", dm); } }
@Override protected ClassLoader initClassLoader() throws RulesInstantiationException { SimpleBundleClassLoader classLoader = new SimpleBundleClassLoader(Thread.currentThread() .getContextClassLoader()); for (Module module : modules) { try { CompiledDependency compiledDependency = getDependencyManager().loadDependency( new Dependency(DependencyType.MODULE, new IdentifierNode(null, null, module.getName(), null))); CompiledOpenClass compiledOpenClass = compiledDependency.getCompiledOpenClass(); classLoader.addClassLoader(compiledOpenClass.getClassLoader()); } catch (OpenLCompilationException e) { throw new RulesInstantiationException(e.getMessage(), e); } } return classLoader; }
protected Map<String, Object> configureParameters(IDependencyManager dependencyManager) { Map<String, Object> params = dependencyManager.getExternalParameters(); if (!singleModuleMode) { params = ProjectExternalDependenciesHelper.getExternalParamsWithProjectDependencies(params, getModules()); return params; } return params; }
public CompiledDependency loadDependency(IDependency dependency) throws OpenLCompilationException { String dependencyName = dependency.getNode().getIdentifier(); if (compiledDependencies.containsKey(dependencyName)) { return compiledDependencies.get(dependencyName); } CompiledDependency compiledDependency = handleLoadDependency(dependency); if (compiledDependency == null) { throw new OpenLCompilationException(String.format("Dependency with name '%s' hasn't been found", dependencyName), null, dependency.getNode().getSourceLocation()); } compiledDependencies.put(dependencyName, compiledDependency); return compiledDependency; }
@Override protected ClassLoader initClassLoader() throws RulesInstantiationException { SimpleBundleClassLoader classLoader = new SimpleBundleClassLoader(Thread.currentThread() .getContextClassLoader()); for (Module module : modules) { try { CompiledDependency compiledDependency = getDependencyManager().loadDependency( new Dependency(DependencyType.MODULE, new IdentifierNode(null, null, module.getName(), null))); CompiledOpenClass compiledOpenClass = compiledDependency.getCompiledOpenClass(); classLoader.addClassLoader(compiledOpenClass.getClassLoader()); } catch (OpenLCompilationException e) { throw new RulesInstantiationException(e.getMessage(), e); } } return classLoader; }
public void reset() { if (compiledDependency != null) { OpenClassUtil.release(compiledDependency.getCompiledOpenClass()); } compiledDependency = null; }
protected Map<String, Object> configureParameters(IDependencyManager dependencyManager) { Map<String, Object> params = dependencyManager.getExternalParameters(); if (!singleModuleMode) { params = ProjectExternalDependenciesHelper.getExternalParamsWithProjectDependencies(params, getModules()); return params; } return params; }
/** * Handles loading dependent modules. This method should not cache * dependencies (method {@link #loadDependency(IDependency)} already uses * caching) Default implementation uses dependency loaders to load the * dependency. Can be overriden to redefine behavior. * * @param dependency dependency to load * @return loaded and compiled dependency * @throws OpenLCompilationException if exception during compilation is * occured */ protected CompiledDependency handleLoadDependency(IDependency dependency) throws OpenLCompilationException { List<IDependencyLoader> dependencyLoaders = getDependencyLoaders(); return loadDependency(dependency.getNode().getIdentifier(), dependencyLoaders); }
@Override public void setExternalParameters(Map<String, Object> parameters) { super.setExternalParameters(parameters); IDependencyManager dm = getDependencyManager(); if (dm instanceof DependencyManager) { ((DependencyManager) dm).setExternalParameters(parameters); } else { log.warn("Can't set external parameters to dependency manager {}", dm); } }
public CompiledDependency loadDependency(IDependency dependency) throws OpenLCompilationException { String dependencyName = dependency.getNode().getIdentifier(); if (compiledDependencies.containsKey(dependencyName)) { return compiledDependencies.get(dependencyName); } CompiledDependency compiledDependency = handleLoadDependency(dependency); if (compiledDependency == null) { throw new OpenLCompilationException(String.format("Dependency with name '%s' hasn't been found", dependencyName), null, dependency.getNode().getSourceLocation()); } compiledDependencies.put(dependencyName, compiledDependency); return compiledDependency; }
private XlsModuleSyntaxNode findXlsModuleSyntaxNode(IDependencyManager dependencyManager) { if (isSingleModuleMode()) { XlsMetaInfo xmi = (XlsMetaInfo) compiledOpenClass.getOpenClassWithErrors().getMetaInfo(); return xmi.getXlsModuleNode(); } else { try { Dependency dependency = new Dependency(DependencyType.MODULE, new IdentifierNode(null, null, moduleInfo.getName(), null)); XlsMetaInfo xmi = (XlsMetaInfo) dependencyManager.loadDependency(dependency) .getCompiledOpenClass().getOpenClassWithErrors().getMetaInfo(); return xmi == null ? null : xmi.getXlsModuleNode(); } catch (OpenLCompilationException e) { throw new OpenlNotCheckedException(e); } } }
public ClassLoader getClassLoader() { return getCompiledOpenClass().getClassLoader(); }
private XlsModuleSyntaxNode findXlsModuleSyntaxNode(IDependencyManager dependencyManager) { if (isSingleModuleMode()) { XlsMetaInfo xmi = (XlsMetaInfo) compiledOpenClass.getOpenClassWithErrors().getMetaInfo(); return xmi.getXlsModuleNode(); } else { try { Dependency dependency = new Dependency(DependencyType.MODULE, new IdentifierNode(null, null, moduleInfo.getName(), null)); XlsMetaInfo xmi = (XlsMetaInfo) dependencyManager.loadDependency(dependency) .getCompiledOpenClass().getOpenClassWithErrors().getMetaInfo(); return xmi == null ? null : xmi.getXlsModuleNode(); } catch (OpenLCompilationException e) { throw new OpenlNotCheckedException(e); } } }
public ClassLoader getClassLoader() { return getCompiledOpenClass().getClassLoader(); }
protected void addDependencyTypes(CompiledDependency dependency) { CompiledOpenClass compiledOpenClass = dependency.getCompiledOpenClass(); for (IOpenClass type : compiledOpenClass.getTypes()) { try { addType(type); } catch (OpenLCompilationException e) { addError(e); } } }
protected void addDependencyTypes(CompiledDependency dependency) { CompiledOpenClass compiledOpenClass = dependency.getCompiledOpenClass(); for (IOpenClass type : compiledOpenClass.getTypes()) { try { addType(type); } catch (OpenLCompilationException e) { addError(e); } } }
/** * Overriden to add the possibility for overriding fields from dependent modules.<br> * At first tries to get the field from current module, if can`t search in dependencies. */ @Override public IOpenField getField(String fname, boolean strictMatch) { // try to get field from own field map // IOpenField field = super.getField(fname, strictMatch); if (field != null) { return field; } else { // if can`t find, search in dependencies. // for (CompiledDependency dependency : usingModules) { CompiledOpenClass compiledOpenClass = dependency.getCompiledOpenClass(); field = compiledOpenClass.getOpenClassWithErrors().getField(fname, strictMatch); if (field != null) { return field; } } } return null; }
/** * Populate current module fields with data from dependent modules. */ protected void initDependencies() {// Reduce iterators over dependencies for // compilation issue with lazy loading for (CompiledDependency dependency : this.getDependencies()) { // commented as there is no need to add each datatype to upper // module. // as now it`s will be impossible to validate from which module the // datatype is. // // addTypes(dependency); addDependencyTypes(dependency); addMethods(dependency); // Populate current module fields with data from dependent modules. // Requered // for data tables inheriting from dependend modules. addDataTables(dependency.getCompiledOpenClass()); // Required for // data tables. addFields(dependency); } }