public void setRuleBase(InternalRuleBase ruleBase) { this.ruleBase = ruleBase; this.classLoader = this.ruleBase.getRootClassLoader(); }
@Override protected Class< ? > resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { String name = desc.getName(); try { if(this.classLoader == null){ if(this.ruleBase != null){ this.classLoader = this.ruleBase.getRootClassLoader(); } } return Class.forName( name, false, this.classLoader ); } catch ( ClassNotFoundException ex ) { return super.resolveClass( desc ); } } }
public JAXBContext newJAXBContext(String[] classNames, Map<String, ? > properties, KnowledgeBase kbase) throws JAXBException { ClassLoader classLoader = ((InternalRuleBase) ((KnowledgeBaseImpl) kbase) .getRuleBase()).getRootClassLoader(); int i = 0; try { Class<?>[] classes = new Class[classNames.length + JAXB_ANNOTATED_CMD.length]; for (i = 0; i < classNames.length; i++) { classes[i] = classLoader.loadClass(classNames[i]); } int j = 0; for (i = classNames.length; i < classes.length; i++, j++) { classes[i] = classLoader.loadClass(JAXB_ANNOTATED_CMD[j]); } return JAXBContext.newInstance(classes, properties); } catch (ClassNotFoundException e) { throw new JAXBException("Unable to resolve class '" + classNames[i] + "'", e); } }
public PackageBuilder( RuleBase ruleBase, PackageBuilderConfiguration configuration ) { if (configuration == null) { this.configuration = new PackageBuilderConfiguration(); } else { this.configuration = configuration; } if (ruleBase != null) { this.rootClassLoader = ( (InternalRuleBase) ruleBase ).getRootClassLoader(); } else { this.rootClassLoader = this.configuration.getClassLoader(); } this.rootClassLoader.addClassLoader(getClass().getClassLoader()); this.dateFormats = null;//(DateFormats) this.environment.get( EnvironmentName.DATE_FORMATS ); if (this.dateFormats == null) { this.dateFormats = new DateFormatsImpl(); //this.environment.set( EnvironmentName.DATE_FORMATS , this.dateFormats ); } // FIXME, we need to get drools to support "default" namespace. //this.defaultNamespace = pkg.getName(); this.defaultDialect = this.configuration.getDefaultDialect(); this.pkgRegistryMap = new LinkedHashMap<String, PackageRegistry>(); this.results = new ArrayList<KnowledgeBuilderResult>(); this.ruleBase = (ReteooRuleBase) ruleBase; globals = new HashMap<String, Class<?>>(); processBuilder = createProcessBuilder(); builtinTypes = new HashMap<String, TypeDeclaration>(); initBuiltinTypeDeclarations(); }
private void executeJitting(Object object, InternalWorkingMemory workingMemory, LeftTuple leftTuple) { InternalRuleBase ruleBase = ((InternalRuleBase) workingMemory.getRuleBase()); if ( MemoryUtil.permGenStats.isUsageThresholdExceeded(ruleBase.getConfiguration().getPermGenThreshold()) ) { return; } try { CompositeClassLoader classLoader = ruleBase.getRootClassLoader(); if (analyzedCondition == null) { analyzedCondition = ((MvelConditionEvaluator) conditionEvaluator).getAnalyzedCondition(object, workingMemory, leftTuple); } conditionEvaluator = ASMConditionEvaluatorJitter.jitEvaluator(expression, analyzedCondition, declarations, classLoader, leftTuple); } catch (Throwable t) { if (TEST_JITTING) { if (analyzedCondition == null) { logger.error("Unable to analize condition for expression: " + expression, t); } else { throw new RuntimeException("Exception jitting: " + expression, t); } } else { logger.warn("Exception jitting: " + expression, t.getMessage()); } } }
private static void loadStrategiesIndex(MarshallerReaderContext context, ProtobufMessages.Header _header) throws IOException, ClassNotFoundException { for ( ProtobufMessages.Header.StrategyIndex _entry : _header.getStrategyList() ) { ObjectMarshallingStrategy strategyObject = context.resolverStrategyFactory.getStrategyObject( _entry.getName() ); if ( strategyObject == null ) { throw new IllegalStateException( "No strategy of type " + _entry.getName() + " available." ); } context.usedStrategies.put( _entry.getId(), strategyObject ); Context ctx = strategyObject.createContext(); context.strategyContexts.put( strategyObject, ctx ); if( _entry.hasData() && ctx != null ) { ClassLoader classLoader = null; if (context.classLoader != null ){ classLoader = context.classLoader; } else if(context.ruleBase != null){ classLoader = context.ruleBase.getRootClassLoader(); } ctx.read( new DroolsObjectInputStream( _entry.getData().newInput(), classLoader) ); } } }
@SuppressWarnings("unchecked") public Collection<Object> instantiateResultObject(InternalWorkingMemory wm) throws RuntimeDroolsException { try { // Collect can only be used with a Collection implementation, so // FactTemplateObject type is not allowed if ( this.cls == null ) { ClassObjectType objType = ((ClassObjectType) this.resultPattern.getObjectType()); String className = determineResultClassName( objType ); this.cls = (Class<Collection<Object>>) Class.forName( className, true, ((InternalRuleBase) wm.getRuleBase()).getRootClassLoader() ); } return this.cls.newInstance(); } catch ( final ClassCastException cce ) { throw new RuntimeDroolsException( "Collect CE requires a Collection implementation as return type", cce ); } catch ( final InstantiationException e ) { throw new RuntimeDroolsException( "Collect CE requires a non-argument constructor for the return type", e ); } catch ( final IllegalAccessException e ) { throw new RuntimeDroolsException( "Collect CE requires an accessible constructor for the return type", e ); } catch ( final ClassNotFoundException e ) { throw new RuntimeDroolsException( "Collect CE could not resolve return result class '" + ((ClassObjectType) this.resultPattern.getObjectType()).getClassName() + "'", e ); } }
ClassLoader classLoader = null; if ( this.isUseKBaseClassLoaderForCompiling() ) { classLoader = ((InternalRuleBase)((KnowledgeBaseImpl)this.kbase).ruleBase).getRootClassLoader(); } else if ( this.builderConfiguration != null ) { this.listener.warning("Even if a custom KnowledgeBuilderConfiguration was provided, "
context, _handle.getObject().toByteArray(), (context.ruleBase == null)?null:context.ruleBase.getRootClassLoader() );
((ClassPathResource) resource).setClassLoader( ((InternalRuleBase) ((InternalKnowledgeBase) kbase).getRuleBase()).getRootClassLoader() );
ClassLoader cl = ((InternalRuleBase) workingMemory.getRuleBase()).getRootClassLoader();
ClassLoader classLoader = ((InternalRuleBase) workingMemory.getRuleBase()).getRootClassLoader();