All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.drools.logger.KnowledgeRuntimeLoggerFactory Maven / Gradle / Ivy

There is a newer version: 5.1.1
Show newest version
package org.drools.logger;

import org.drools.ProviderInitializationException;
import org.drools.event.KnowledgeRuntimeEventManager;

public class KnowledgeRuntimeLoggerFactory {

	private static KnowledgeRuntimeLoggerProvider knowledgeRuntimeLoggerProvider;

	public static KnowledgeRuntimeLogger newFileLogger(KnowledgeRuntimeEventManager session, String fileName) {
		return getKnowledgeRuntimeLoggerProvider().newFileLogger(session, fileName);
	}

	public static KnowledgeRuntimeLogger newThreadedFileLogger(
			KnowledgeRuntimeEventManager session, String fileName, int interval) {
		return getKnowledgeRuntimeLoggerProvider().newThreadedFileLogger(session, fileName, interval);
	}

	public static KnowledgeRuntimeLogger newConsoleLogger(KnowledgeRuntimeEventManager session) {
		return getKnowledgeRuntimeLoggerProvider().newConsoleLogger(session);
	}

	private static synchronized void setKnowledgeRuntimeLoggerProvider(
			KnowledgeRuntimeLoggerProvider provider) {
		KnowledgeRuntimeLoggerFactory.knowledgeRuntimeLoggerProvider = provider;
	}

	private static synchronized KnowledgeRuntimeLoggerProvider getKnowledgeRuntimeLoggerProvider() {
		if (knowledgeRuntimeLoggerProvider == null) {
			loadProvider();
		}
		return knowledgeRuntimeLoggerProvider;
	}

	@SuppressWarnings("unchecked")
	private static void loadProvider() {
		try {
			Class cls = (Class)
				Class.forName("org.drools.audit.KnowledgeRuntimeLoggerProviderImpl");
			setKnowledgeRuntimeLoggerProvider(cls.newInstance());
		} catch (Exception e) {
			throw new ProviderInitializationException(
				"Provider org.drools.audit.KnowledgeRuntimeLoggerProviderImpl could not be set.", e);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy