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

de.intarsys.tools.logging.CompositeHandlerFactory Maven / Gradle / Ivy

There is a newer version: 4.11
Show newest version
package de.intarsys.tools.logging;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Handler;

/**
 * An {@link IHandlerFactory} that creates a {@link CompositeHandler} by
 * delegating to a collection of other {@link IHandlerFactory} instances.
 * 
 */
public class CompositeHandlerFactory extends CommonHandlerFactory {

	private List handlerFactories = new ArrayList();

	public void addLogHandlerFactory(IHandlerFactory factory) {
		handlerFactories.add(factory);
	}

	@Override
	protected Handler basicCreateHandler() throws IOException {
		CompositeHandler handler = new CompositeHandler();
		for (IHandlerFactory factory : handlerFactories) {
			handler.addHandler(factory.createLogHandler());
		}
		return handler;
	}

	public void removeLogHandlerFactory(IHandlerFactory factory) {
		handlerFactories.remove(factory);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy