void applyChangeSet(KnowledgeAgent kagent, Resource r) {
// Calls the Resource Scanner and sets up a listener and a latch so we can wait until it's finished processing, instead of using timers
final CountDownLatch latch = new CountDownLatch( 1 );
KnowledgeAgentEventListener l = new KnowledgeAgentEventListener() {
public void resourceCompilationFailed(ResourceCompilationFailedEvent event) {
KnowledgeBuilderErrors errors = event.getKnowledgeBuilder().getErrors();
if (errors != null){
Iterator<KnowledgeBuilderError> iterator = errors.iterator();