this.listener.debug( "KnowledgeAgent building resource map" );
synchronized ( this.resources ) {
for ( Package pkg : rbase.getPackages() ) {
for ( Rule rule : pkg.getRules() ) {
Resource resource = rule.getResource();
if ( resource == null || !((InternalResource) resource).hasURL() ) {
continue;
}
ResourceMapping mapping = this.resources.get( resource );
if ( mapping == null ) {
this.notifier.subscribeResourceChangeListener( this,
resource );
mapping = new ResourceMapping( resource );
this.resources.put( resource,
mapping );
}
this.listener.debug( "KnowledgeAgent mapping resource=" + resource + " to rule=" + rule );
mapping.getKnowledgeDefinitions().add( rule );
}
for ( Process process : pkg.getRuleFlows().values() ) {
Resource resource = ((org.drools.process.core.Process) process).getResource();
if ( resource == null || !((InternalResource) resource).hasURL() ) {
continue;
}
ResourceMapping mapping = this.resources.get( resource );
if ( mapping == null ) {
this.notifier.subscribeResourceChangeListener( this,
resource );
mapping = new ResourceMapping( resource );
this.resources.put( resource,
mapping );
}
this.listener.debug( "KnowledgeAgent mapping resource=" + resource + " to process=" + process );
mapping.getKnowledgeDefinitions().add( process );
}
for ( TypeDeclaration typeDeclaration : pkg.getTypeDeclarations().values() ) {
Resource resource = typeDeclaration.getResource();
if ( resource == null || !((InternalResource) resource).hasURL() ) {
continue;
}
ResourceMapping mapping = this.resources.get( resource );
if ( mapping == null ) {
this.notifier.subscribeResourceChangeListener( this,
resource );
mapping = new ResourceMapping( resource );
this.resources.put( resource,
mapping );
}
this.listener.debug( "KnowledgeAgent mapping resource=" + resource + " to TypeDeclaration=" + typeDeclaration );
mapping.getKnowledgeDefinitions().add( typeDeclaration );
}
for ( Function function : pkg.getFunctions().values() ) {
Resource resource = function.getResource();
if ( resource == null || !((InternalResource) resource).hasURL() ) {
continue;
}
ResourceMapping mapping = this.resources.get( resource );
if ( mapping == null ) {