protected void addEntryPoint( final Package pkg, final String id ) throws InvalidPatternException { lock(); try { addEntryPoint( id ); } finally { unlock(); } }
public void removeFunction( final String packageName, final String functionName ) { lock(); try { final Package pkg = this.pkgs.get( packageName ); if (pkg == null) { throw new IllegalArgumentException( "Package name '" + packageName + "' does not exist for this Rule Base." ); } if (!pkg.getFunctions().containsKey( functionName )) { throw new IllegalArgumentException( "function name '" + packageName + "' does not exist in the Package '" + packageName + "'." ); } removeFunction( pkg, functionName ); pkg.removeFunction( functionName ); addReloadDialectDatas( pkg ); } finally { unlock(); } }
public void addRule( final Package pkg, final Rule rule ) throws InvalidPatternException { lock(); try { this.eventSupport.fireBeforeRuleAdded( pkg, rule ); // if ( !rule.isValid() ) { // throw new IllegalArgumentException( "The rule called " + rule.getName() + " is not valid. Check for compile errors reported." ); // } addRule( rule ); this.eventSupport.fireAfterRuleAdded( pkg, rule ); } finally { unlock(); } }
public void addWindowDeclaration( final Package pkg, final WindowDeclaration window ) throws InvalidPatternException { lock(); try { addWindowDeclaration( window ); } finally { unlock(); } }
public TypeDeclaration getTypeDeclaration( Class<?> clazz ) { TypeDeclaration typeDeclaration = this.classTypeDeclaration.get( clazz.getName() ); if (typeDeclaration == null) { // check super classes and keep a score of how up in the hierarchy is there a declaration TypeDeclarationCandidate candidate = checkSuperClasses( clazz ); // now check interfaces candidate = checkInterfaces( clazz, candidate, 1 ); if (candidate != null) { typeDeclaration = candidate.candidate; } } return typeDeclaration; }
lock(); try { getTraitRegistry().merge( newPkg.getTraitRegistry() ); ); Class<?> definedKlass = registerAndLoadTypeDefinition( className, def ); mergeTypeDeclarations( typeDeclaration, newDecl ); updateDependentTypes( newPkg, typeDeclaration ); mergePackage( pkg, newPkg ); addWindowDeclaration( newPkg, window ); addEntryPoint( id ); addRule( newPkg, rule ); addProcess( process ); unlock();
public void removeRule( final String packageName, final String ruleName ) { lock(); try { final Package pkg = this.pkgs.get( packageName ); if (pkg == null) { throw new IllegalArgumentException( "Package name '" + packageName + "' does not exist for this Rule Base." ); } final Rule rule = pkg.getRule( ruleName ); if (rule == null) { throw new IllegalArgumentException( "Rule name '" + ruleName + "' does not exist in the Package '" + packageName + "'." ); } this.removalsSinceLock++; removeRule( pkg, rule ); pkg.removeRule( rule ); addReloadDialectDatas( pkg ); } finally { unlock(); } }
private Package getPackage(String pack) { Package pkg = ruleBase.getPackage( pack ); if ( pkg == null ) { pkg = new Package( pack ); JavaDialectRuntimeData data = new JavaDialectRuntimeData(); pkg.getDialectRuntimeRegistry().setDialectData( "java", data ); data.onAdd(pkg.getDialectRuntimeRegistry(), ruleBase.getRootClassLoader()); ruleBase.addPackages( Arrays.asList(pkg) ); } return pkg; }
super.addStatefulSession( session ); for (Object listener : session.getRuleBaseUpdateListeners()) { addEventListener((RuleBaseEventListener) listener);
private TypeDeclarationCandidate checkInterfaces( Class<?> clazz, TypeDeclarationCandidate baseline, int level ) { TypeDeclarationCandidate candidate = null; if (baseline == null || level < baseline.score) { // search TypeDeclaration typeDeclaration; for (Class<?> ifc : clazz.getInterfaces()) { typeDeclaration = this.classTypeDeclaration.get( ifc.getName() ); if (typeDeclaration != null) { candidate = new TypeDeclarationCandidate(); candidate.candidate = typeDeclaration; candidate.score = level; break; } else { candidate = checkInterfaces( ifc, baseline, level + 1 ); } } } else { candidate = baseline; } return candidate; }
droolsStream.writeObject( this.agendaGroupRuleTotals ); droolsStream.writeUTF( this.factHandleFactory.getClass().getName() ); droolsStream.writeObject( buildGlobalMapForSerialization() ); droolsStream.writeObject( this.partitionIDs );
public void addPackages(Collection<Package> pkgs) { super.addPackages( pkgs ); if ( this.getConfiguration().isSequential() ) { this.reteooBuilder.setOrdered( false ); } }
StatefulSession newStatefulSession(int id, final SessionConfiguration sessionConfig, final Environment environment) { if ( this.getConfiguration().isSequential() ) { throw new RuntimeException( "Cannot have a stateful rule session, with sequential configuration set to true" ); } ExecutorService executor = ExecutorServiceFactory.createExecutorService( this.getConfiguration().getExecutorService() ); readLock(); try { ReteooStatefulSession session = new ReteooStatefulSession( id, this, executor, sessionConfig, environment ); new StatefulKnowledgeSessionImpl(session); executor.setCommandExecutor( new CommandExecutor( session ) ); if ( sessionConfig.isKeepReference() ) { super.addStatefulSession( session ); for (Object listener : session.getRuleBaseUpdateListeners()) { addEventListener((RuleBaseEventListener) listener); } } session.startPartitionManagers(); return session; } finally { readUnlock(); } }