moved components to extras
git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/companions/component/trunk@1342917 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/log4j/LoggerRepositoryExImpl.java b/src/main/java/org/apache/log4j/LoggerRepositoryExImpl.java
deleted file mode 100644
index c2f5aaf..0000000
--- a/src/main/java/org/apache/log4j/LoggerRepositoryExImpl.java
+++ /dev/null
@@ -1,697 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j;
-
-import org.apache.log4j.helpers.LogLog;
-import org.apache.log4j.or.ObjectRenderer;
-import org.apache.log4j.or.RendererMap;
-import org.apache.log4j.plugins.Plugin;
-import org.apache.log4j.plugins.PluginRegistry;
-import org.apache.log4j.scheduler.Scheduler;
-import org.apache.log4j.spi.ErrorItem;
-import org.apache.log4j.spi.HierarchyEventListener;
-import org.apache.log4j.spi.LoggerEventListener;
-import org.apache.log4j.spi.LoggerFactory;
-import org.apache.log4j.spi.LoggerRepository;
-import org.apache.log4j.spi.LoggerRepositoryEventListener;
-import org.apache.log4j.spi.LoggerRepositoryEx;
-import org.apache.log4j.spi.RendererSupport;
-import org.apache.log4j.xml.UnrecognizedElementHandler;
-import org.apache.log4j.xml.DOMConfigurator;
-import org.w3c.dom.Element;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Vector;
-
-
-/**
- * This class implements LoggerRepositoryEx by
- * wrapping an existing LoggerRepository implementation
- * and implementing the newly added capabilities.
-*/
-public final class LoggerRepositoryExImpl
- implements LoggerRepositoryEx,
- RendererSupport,
- UnrecognizedElementHandler {
-
- /**
- * Wrapped logger repository.
- */
- private final LoggerRepository repo;
-
- /**
- * Logger factory. Does not affect class of logger
- * created by underlying repository.
- */
- private LoggerFactory loggerFactory;
-
- /**
- * Renderer support.
- */
- private final RendererSupport rendererSupport;
-
- /**
- * List of repository event listeners.
- */
- private final ArrayList repositoryEventListeners = new ArrayList();
- /**
- * Map of HierarchyEventListener keyed by LoggingEventListener.
- */
- private final Map loggerEventListeners = new HashMap();
- /**
- * Name of hierarchy.
- */
- private String name;
- /**
- * Plug in registry.
- */
- private PluginRegistry pluginRegistry;
- /**
- * Properties.
- */
- private final Map properties = new Hashtable();
- /**
- * Scheduler.
- */
- private Scheduler scheduler;
-
- /** The repository can also be used as an object store
- * for various objects used by log4j components.
- */
- private Map objectMap = new HashMap();
-
-
- /**
- * Error list.
- */
- private List errorList = new Vector();
-
- /**
- * True if hierarchy has not been modified.
- */
- private boolean pristine = true;
-
- /**
- Constructs a new logger hierarchy.
-
- @param repository Base implementation of repository.
-
- */
- public LoggerRepositoryExImpl(final LoggerRepository repository) {
- super();
- if (repository == null) {
- throw new NullPointerException("repository");
- }
- repo = repository;
- if (repository instanceof RendererSupport) {
- rendererSupport = (RendererSupport) repository;
- } else {
- rendererSupport = new RendererSupportImpl();
- }
- }
-
-
- /**
- Add a {@link LoggerRepositoryEventListener} to the repository. The
- listener will be called when repository events occur.
- @param listener listener
- */
- public void addLoggerRepositoryEventListener(
- final LoggerRepositoryEventListener listener) {
- synchronized (repositoryEventListeners) {
- if (repositoryEventListeners.contains(listener)) {
- LogLog.warn(
- "Ignoring attempt to add a previously "
- + "registered LoggerRepositoryEventListener.");
- } else {
- repositoryEventListeners.add(listener);
- }
- }
- }
-
-
- /**
- Remove a {@link LoggerRepositoryEventListener} from the repository.
- @param listener listener
- */
- public void removeLoggerRepositoryEventListener(
- final LoggerRepositoryEventListener listener) {
- synchronized (repositoryEventListeners) {
- if (!repositoryEventListeners.contains(listener)) {
- LogLog.warn(
- "Ignoring attempt to remove a "
- + "non-registered LoggerRepositoryEventListener.");
- } else {
- repositoryEventListeners.remove(listener);
- }
- }
- }
-
- /**
- Add a {@link LoggerEventListener} to the repository. The listener
- will be called when repository events occur.
- @param listener listener
- */
- public void addLoggerEventListener(final LoggerEventListener listener) {
- synchronized (loggerEventListeners) {
- if (loggerEventListeners.get(listener) != null) {
- LogLog.warn(
- "Ignoring attempt to add a previously registerd LoggerEventListener.");
- } else {
- HierarchyEventListenerProxy proxy =
- new HierarchyEventListenerProxy(listener);
- loggerEventListeners.put(listener, proxy);
- repo.addHierarchyEventListener(proxy);
- }
- }
- }
-
- /**
- Add a {@link org.apache.log4j.spi.HierarchyEventListener}
- event to the repository.
- @param listener listener
- @deprecated Superceded by addLoggerEventListener
- */
- public
- void addHierarchyEventListener(final HierarchyEventListener listener) {
- repo.addHierarchyEventListener(listener);
- }
-
-
- /**
- Remove a {@link LoggerEventListener} from the repository.
- @param listener listener to be removed
- */
- public void removeLoggerEventListener(final LoggerEventListener listener) {
- synchronized (loggerEventListeners) {
- HierarchyEventListenerProxy proxy =
- (HierarchyEventListenerProxy) loggerEventListeners.get(listener);
- if (proxy == null) {
- LogLog.warn(
- "Ignoring attempt to remove a non-registered LoggerEventListener.");
- } else {
- loggerEventListeners.remove(listener);
- proxy.disable();
- }
- }
- }
-
- /**
- * Issue warning that there are no appenders in hierarchy.
- * @param cat logger, not currently used.
- */
- public void emitNoAppenderWarning(final Category cat) {
- repo.emitNoAppenderWarning(cat);
- }
-
- /**
- Check if the named logger exists in the hierarchy. If so return
- its reference, otherwise returns <code>null</code>.
-
- @param loggerName The name of the logger to search for.
- @return true if logger exists.
- */
- public Logger exists(final String loggerName) {
- return repo.exists(loggerName);
- }
-
- /**
- * Return the name of this hierarchy.
- * @return name of hierarchy
- */
- public String getName() {
- return name;
- }
-
- /**
- * Set the name of this repository.
- *
- * Note that once named, a repository cannot be rerenamed.
- * @param repoName name of hierarchy
- */
- public void setName(final String repoName) {
- if (name == null) {
- name = repoName;
- } else if (!name.equals(repoName)) {
- throw new IllegalStateException(
- "Repository [" + name + "] cannot be renamed as [" + repoName + "].");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Map getProperties() {
- return properties;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getProperty(final String key) {
- return (String) properties.get(key);
- }
-
- /**
- * Set a property by key and value. The property will be shared by all
- * events in this repository.
- * @param key property name
- * @param value property value
- */
- public void setProperty(final String key,
- final String value) {
- properties.put(key, value);
- }
-
- /**
- The string form of {@link #setThreshold(Level)}.
- @param levelStr symbolic name for level
- */
- public void setThreshold(final String levelStr) {
- repo.setThreshold(levelStr);
- }
-
- /**
- Enable logging for logging requests with level <code>l</code> or
- higher. By default all levels are enabled.
-
- @param l The minimum level for which logging requests are sent to
- their appenders. */
- public void setThreshold(final Level l) {
- repo.setThreshold(l);
- }
-
- /**
- * {@inheritDoc}
- */
- public PluginRegistry getPluginRegistry() {
- if (pluginRegistry == null) {
- pluginRegistry = new PluginRegistry(this);
- }
- return pluginRegistry;
- }
-
-
- /**
- Requests that a appender added event be sent to any registered
- {@link LoggerEventListener}.
- @param logger The logger to which the appender was added.
- @param appender The appender added to the logger.
- */
- public void fireAddAppenderEvent(final Category logger,
- final Appender appender) {
- repo.fireAddAppenderEvent(logger, appender);
- }
-
-
- /**
- Requests that a appender removed event be sent to any registered
- {@link LoggerEventListener}.
- @param logger The logger from which the appender was removed.
- @param appender The appender removed from the logger.
- */
- public void fireRemoveAppenderEvent(final Category logger,
- final Appender appender) {
- if (repo instanceof Hierarchy) {
- ((Hierarchy) repo).fireRemoveAppenderEvent(logger, appender);
- }
- }
-
-
- /**
- Requests that a level changed event be sent to any registered
- {@link LoggerEventListener}.
- @param logger The logger which changed levels.
- */
- public void fireLevelChangedEvent(final Logger logger) {
- }
-
- /**
- *
- * Requests that a configuration changed event be sent to any registered
- * {@link LoggerRepositoryEventListener}.
- *
- */
- public void fireConfigurationChangedEvent() {
- }
-
-
- /**
- Returns the current threshold.
- @return current threshold level
-
- @since 1.2 */
- public Level getThreshold() {
- return repo.getThreshold();
- }
-
-
- /**
- Return a new logger instance named as the first parameter using
- the default factory.
-
- <p>If a logger of that name already exists, then it will be
- returned. Otherwise, a new logger will be instantiated and
- then linked with its existing ancestors as well as children.
-
- @param loggerName The name of the logger to retrieve.
- @return logger
-
- */
- public Logger getLogger(final String loggerName) {
- return repo.getLogger(loggerName);
- }
-
- /**
- Return a new logger instance named as the first parameter using
- <code>factory</code>.
-
- <p>If a logger of that name already exists, then it will be
- returned. Otherwise, a new logger will be instantiated by the
- <code>factory</code> parameter and linked with its existing
- ancestors as well as children.
-
- @param loggerName The name of the logger to retrieve.
- @param factory The factory that will make the new logger instance.
- @return logger
-
- */
- public Logger getLogger(final String loggerName,
- final LoggerFactory factory) {
- return repo.getLogger(loggerName, factory);
- }
-
- /**
- Returns all the currently defined categories in this hierarchy as
- an {@link java.util.Enumeration Enumeration}.
-
- <p>The root logger is <em>not</em> included in the returned
- {@link Enumeration}.
- @return enumerator of current loggers
- */
- public Enumeration getCurrentLoggers() {
- return repo.getCurrentLoggers();
- }
-
- /**
- * Return the the list of previously encoutered {@link ErrorItem error items}.
- * @return list of errors
- */
- public List getErrorList() {
- return errorList;
- }
-
- /**
- * Add an error item to the list of previously encountered errors.
- * @param errorItem error to add to list of errors.
- */
- public void addErrorItem(final ErrorItem errorItem) {
- getErrorList().add(errorItem);
- }
-
- /**
- * Get enumerator over current loggers.
- * @return enumerator over current loggers
- @deprecated Please use {@link #getCurrentLoggers} instead.
- */
- public Enumeration getCurrentCategories() {
- return repo.getCurrentCategories();
- }
-
- /**
- Get the renderer map for this hierarchy.
- @return renderer map
- */
- public RendererMap getRendererMap() {
- return rendererSupport.getRendererMap();
- }
-
- /**
- Get the root of this hierarchy.
-
- @since 0.9.0
- @return root of hierarchy
- */
- public Logger getRootLogger() {
- return repo.getRootLogger();
- }
-
- /**
- This method will return <code>true</code> if this repository is
- disabled for <code>level</code> value passed as parameter and
- <code>false</code> otherwise. See also the {@link
- #setThreshold(Level) threshold} method.
- @param level numeric value for level.
- @return true if disabled for specified level
- */
- public boolean isDisabled(final int level) {
- return repo.isDisabled(level);
- }
-
- /**
- Reset all values contained in this hierarchy instance to their
- default. This removes all appenders from all categories, sets
- the level of all non-root categories to <code>null</code>,
- sets their additivity flag to <code>true</code> and sets the level
- of the root logger to DEBUG. Moreover,
- message disabling is set its default "off" value.
-
- <p>Existing categories are not removed. They are just reset.
-
- <p>This method should be used sparingly and with care as it will
- block all logging until it is completed.</p>
-
- @since 0.8.5 */
- public void resetConfiguration() {
- repo.resetConfiguration();
- }
-
- /**
- Used by subclasses to add a renderer to the hierarchy passed as parameter.
- @param renderedClass class
- @param renderer object used to render class.
- */
- public void setRenderer(final Class renderedClass,
- final ObjectRenderer renderer) {
- rendererSupport.setRenderer(renderedClass, renderer);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isPristine() {
- return pristine;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setPristine(final boolean state) {
- pristine = state;
- }
-
- /**
- Shutting down a hierarchy will <em>safely</em> close and remove
- all appenders in all categories including the root logger.
-
- <p>Some appenders such as org.apache.log4j.net.SocketAppender
- and AsyncAppender need to be closed before the
- application exists. Otherwise, pending logging events might be
- lost.
-
- <p>The <code>shutdown</code> method is careful to close nested
- appenders before closing regular appenders. This is allows
- configurations where a regular appender is attached to a logger
- and again to a nested appender.
-
- @since 1.0 */
- public void shutdown() {
- repo.shutdown();
- }
-
-
- /**
- * Return this repository's own scheduler.
- * The scheduler is lazily instantiated.
- * @return this repository's own scheduler.
- */
- public Scheduler getScheduler() {
- if (scheduler == null) {
- scheduler = new Scheduler();
- scheduler.setDaemon(true);
- scheduler.start();
- }
- return scheduler;
- }
-
- /**
- * Puts object by key.
- * @param key key, may not be null.
- * @param value object to associate with key.
- */
- public void putObject(final String key,
- final Object value) {
- objectMap.put(key, value);
- }
-
- /**
- * Get object by key.
- * @param key key, may not be null.
- * @return object associated with key or null.
- */
- public Object getObject(final String key) {
- return objectMap.get(key);
- }
-
- /**
- * Set logger factory.
- * @param factory logger factory.
- */
- public void setLoggerFactory(final LoggerFactory factory) {
- if (factory == null) {
- throw new NullPointerException();
- }
- this.loggerFactory = factory;
- }
-
- /**
- * Get logger factory.
- * @return logger factory.
- */
- public LoggerFactory getLoggerFactory() {
- return loggerFactory;
- }
-
- /** {@inheritDoc} */
- public boolean parseUnrecognizedElement(
- final Element element,
- final Properties props) throws Exception {
- if ("plugin".equals(element.getNodeName())) {
- Object instance =
- DOMConfigurator.parseElement(element, props, Plugin.class);
- if (instance instanceof Plugin) {
- Plugin plugin = (Plugin) instance;
- String pluginName = DOMConfigurator.subst(element.getAttribute("name"), props);
- if (pluginName.length() > 0) {
- plugin.setName(pluginName);
- }
- getPluginRegistry().addPlugin(plugin);
- plugin.setLoggerRepository(this);
-
- LogLog.debug("Pushing plugin on to the object stack.");
- plugin.activateOptions();
- return true;
- }
- }
- return false;
- }
-
-
-
- /**
- * Implementation of RendererSupportImpl if not
- * provided by LoggerRepository.
- */
- private static final class RendererSupportImpl implements RendererSupport {
- /**
- * Renderer map.
- */
- private final RendererMap renderers = new RendererMap();
-
- /**
- * Create new instance.
- */
- public RendererSupportImpl() {
- super();
- }
-
- /** {@inheritDoc} */
- public RendererMap getRendererMap() {
- return renderers;
- }
-
- /** {@inheritDoc} */
- public void setRenderer(final Class renderedClass,
- final ObjectRenderer renderer) {
- renderers.put(renderedClass, renderer);
- }
- }
-
- /**
- * Proxy that implements HierarchyEventListener
- * and delegates to LoggerEventListener.
- */
- private static final class HierarchyEventListenerProxy
- implements HierarchyEventListener {
- /**
- * Wrapper listener.
- */
- private LoggerEventListener listener;
-
- /**
- * Creates new instance.
- * @param l listener
- */
- public HierarchyEventListenerProxy(final LoggerEventListener l) {
- super();
- if (l == null) {
- throw new NullPointerException("l");
- }
- listener = l;
- }
-
- /** {@inheritDoc} */
- public void addAppenderEvent(final Category cat,
- final Appender appender) {
- if (isEnabled() && cat instanceof Logger) {
- listener.appenderAddedEvent((Logger) cat, appender);
- }
- }
-
- /** {@inheritDoc} */
- public void removeAppenderEvent(final Category cat,
- final Appender appender) {
- if (isEnabled() && cat instanceof Logger) {
- listener.appenderRemovedEvent((Logger) cat, appender);
- }
- }
-
- /**
- * Disable forwarding of notifications to
- * simulate removal of listener.
- */
- public synchronized void disable() {
- listener = null;
- }
-
- /**
- * Gets whether proxy is enabled.
- * @return true if proxy is enabled.
- */
- private synchronized boolean isEnabled() {
- return listener != null;
- }
- }
-
-}
diff --git a/src/main/java/org/apache/log4j/ULogger.java b/src/main/java/org/apache/log4j/ULogger.java
deleted file mode 100644
index 83a6bb8..0000000
--- a/src/main/java/org/apache/log4j/ULogger.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j;
-
-
-/**
- * A proxy for org.slf4j.ULogger. In slf4j implementing builds, this
- * interface will extend org.slf4j.ULogger and add no additional methods.
- *
- * @author Ceki Gülcü
- * @author Curt Arnold
- */
- public interface ULogger {
-
-
- /**
- * Is the logger instance enabled for the DEBUG level?
- * @return true if debug is enabled.
- */
- boolean isDebugEnabled();
-
- /**
- * Log a message object with the DEBUG level.
- * @param msg - the message object to be logged
- */
- void debug(Object msg);
-
-
- /**
- * Log a parameterized message object at the DEBUG level.
- *
- * <p>This form is useful in avoiding the superflous object creation
- * problem when invoking this method while it is disabled.
- * </p>
- * @param parameterizedMsg - the parameterized message object
- * @param param1 - the parameter
- */
- void debug(Object parameterizedMsg, Object param1);
-
- /**
- * Log a parameterized message object at the DEBUG level.
- *
- * <p>This form is useful in avoiding the superflous object creation
- * problem when invoking this method while it is disabled.
- * </p>
- * @param parameterizedMsg - the parameterized message object
- * @param param1 - the first parameter
- * @param param2 - the second parameter
- */
- void debug(String parameterizedMsg, Object param1, Object param2);
- /**
- * Log a message object with the <code>DEBUG</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- *
- * @param msg the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void debug(Object msg, Throwable t);
-
-
- /**
- * Is the logger instance enabled for the INFO level?
- * @return true if debug is enabled.
- */
- boolean isInfoEnabled();
- /**
- * Log a message object with the INFO level.
- * @param msg - the message object to be logged
- */
- void info(Object msg);
- /**
- * Log a parameterized message object at the INFO level.
- *
- * <p>This form is useful in avoiding the superflous object creation
- * problem when invoking this method while it is disabled.
- * </p>
- * @param parameterizedMsg - the parameterized message object
- * @param param1 - the parameter
- */
- void info(Object parameterizedMsg, Object param1);
- /**
- * Log a parameterized message object at the INFO level.
- *
- * <p>This form is useful in avoiding the superflous object creation
- * problem when invoking this method while it is disabled.
- * </p>
- * @param parameterizedMsg - the parameterized message object
- * @param param1 - the first parameter
- * @param param2 - the second parameter
- */
- void info(String parameterizedMsg, Object param1, Object param2);
- /**
- * Log a message object with the <code>INFO</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- *
- * @param msg the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void info(Object msg, Throwable t);
-
-
- /**
- * Is the logger instance enabled for the WARN level?
- * @return true if debug is enabled.
- */
- boolean isWarnEnabled();
- /**
- * Log a message object with the WARN level.
- * @param msg - the message object to be logged
- */
- void warn(Object msg);
- /**
- * Log a parameterized message object at the WARN level.
- *
- * <p>This form is useful in avoiding the superflous object creation
- * problem when invoking this method while it is disabled.
- * </p>
- * @param parameterizedMsg - the parameterized message object
- * @param param1 - the parameter
- */
- void warn(Object parameterizedMsg, Object param1);
- /**
- * Log a parameterized message object at the WARN level.
- *
- * <p>This form is useful in avoiding the superflous object creation
- * problem when invoking this method while it is disabled.
- * </p>
- * @param parameterizedMsg - the parameterized message object
- * @param param1 - the first parameter
- * @param param2 - the second parameter
- */
- void warn(String parameterizedMsg, Object param1, Object param2);
- /**
- * Log a message object with the <code>WARN</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- *
- * @param msg the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void warn(Object msg, Throwable t);
-
-
- /**
- * Is the logger instance enabled for the ERROR level?
- * @return true if debug is enabled.
- */
- boolean isErrorEnabled();
- /**
- * Log a message object with the ERROR level.
- * @param msg - the message object to be logged
- */
- void error(Object msg);
- /**
- * Log a parameterized message object at the ERROR level.
- *
- * <p>This form is useful in avoiding the superflous object creation
- * problem when invoking this method while it is disabled.
- * </p>
- * @param parameterizedMsg - the parameterized message object
- * @param param1 - the parameter
- */
- void error(Object parameterizedMsg, Object param1);
- /**
- * Log a parameterized message object at the ERROR level.
- *
- * <p>This form is useful in avoiding the superflous object creation
- * problem when invoking this method while it is disabled.
- * </p>
- * @param parameterizedMsg - the parameterized message object
- * @param param1 - the first parameter
- * @param param2 - the second parameter
- */
- void error(String parameterizedMsg, Object param1, Object param2);
-
- /**
- * Log a message object with the <code>ERROR</code> level including the
- * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
- *
- *
- * @param msg the message object to log.
- * @param t the exception to log, including its stack trace.
- */
- void error(Object msg, Throwable t);
-
-}
diff --git a/src/main/java/org/apache/log4j/helpers/Constants.java b/src/main/java/org/apache/log4j/helpers/Constants.java
deleted file mode 100644
index dbbbe59..0000000
--- a/src/main/java/org/apache/log4j/helpers/Constants.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.helpers;
-
-
-/**
- * Constants used internally throughout log4j.
- *
- */
-public interface Constants {
-
- /**
- * log4j package name string literal.
- */
- String LOG4J_PACKAGE_NAME = "org.apache.log4j";
-
- /**
- * The name of the default repository is "default" (without the quotes).
- */
- String DEFAULT_REPOSITORY_NAME = "default";
-
- /**
- * application string literal.
- */
- String APPLICATION_KEY = "application";
- /**
- * hostname string literal.
- */
- String HOSTNAME_KEY = "hostname";
- /**
- * receiver string literal.
- */
- String RECEIVER_NAME_KEY = "receiver";
- /**
- * log4jid string literal.
- */
- String LOG4J_ID_KEY = "log4jid";
- /**
- * time stamp pattern string literal.
- */
- String TIMESTAMP_RULE_FORMAT = "yyyy/MM/dd HH:mm:ss";
-
- /**
- * The default property file name for automatic configuration.
- */
- String DEFAULT_CONFIGURATION_FILE = "log4j.properties";
- /**
- * The default XML configuration file name for automatic configuration.
- */
- String DEFAULT_XML_CONFIGURATION_FILE = "log4j.xml";
- /**
- * log4j.configuration string literal.
- */
- String DEFAULT_CONFIGURATION_KEY = "log4j.configuration";
- /**
- * log4j.configuratorClass string literal.
- */
- String CONFIGURATOR_CLASS_KEY = "log4j.configuratorClass";
-
- /**
- * JNDI context name string literal.
- */
- String JNDI_CONTEXT_NAME = "java:comp/env/log4j/context-name";
-
- /**
- * TEMP_LIST_APPENDER string literal.
- */
- String TEMP_LIST_APPENDER_NAME = "TEMP_LIST_APPENDER";
- /**
- * TEMP_CONSOLE_APPENDER string literal.
- */
- String TEMP_CONSOLE_APPENDER_NAME = "TEMP_CONSOLE_APPENDER";
- /**
- * Codes URL string literal.
- */
- String CODES_HREF =
- "http://logging.apache.org/log4j/docs/codes.html";
-
-
- /**
- * ABSOLUTE string literal.
- */
- String ABSOLUTE_FORMAT = "ABSOLUTE";
- /**
- * SimpleTimePattern for ABSOLUTE.
- */
- String ABSOLUTE_TIME_PATTERN = "HH:mm:ss,SSS";
-
- /**
- * SimpleTimePattern for ABSOLUTE.
- */
- String SIMPLE_TIME_PATTERN = "HH:mm:ss";
-
- /**
- * DATE string literal.
- */
- String DATE_AND_TIME_FORMAT = "DATE";
- /**
- * SimpleTimePattern for DATE.
- */
- String DATE_AND_TIME_PATTERN = "dd MMM yyyy HH:mm:ss,SSS";
-
- /**
- * ISO8601 string literal.
- */
- String ISO8601_FORMAT = "ISO8601";
- /**
- * SimpleTimePattern for ISO8601.
- */
- String ISO8601_PATTERN = "yyyy-MM-dd HH:mm:ss,SSS";
-}
diff --git a/src/main/java/org/apache/log4j/helpers/MessageFormatter.java b/src/main/java/org/apache/log4j/helpers/MessageFormatter.java
deleted file mode 100644
index 8c77da1..0000000
--- a/src/main/java/org/apache/log4j/helpers/MessageFormatter.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.helpers;
-
-
-/**
- * Formats messages according to very simple rules.
- * See {@link #format(String,Object)} and
- * {@link #format(String,Object,Object)} for more details.
- *
- * @author Ceki Gülcü
- */
-public final class MessageFormatter {
- /**
- * Private formatter since all methods and members are static.
- */
- private MessageFormatter() {
- super();
- }
-
- /**
- * Start of replacement block.
- */
- private static final char DELIM_START = '{';
- /**
- * End of replacement block.
- */
- private static final char DELIM_STOP = '}';
-
- /**
- * Performs single argument substitution for the 'messagePattern' passed as
- * parameter.
- * <p/>
- * For example, <code>MessageFormatter.format("Hi {}.", "there");</code>
- * will return the string "Hi there.".
- * <p/>
- * The {} pair is called the formatting element. It serves to designate the
- * location where the argument needs to be inserted within the pattern.
- *
- * @param messagePattern
- * The message pattern which will be parsed and formatted
- * @param argument
- * The argument to be inserted instead of the formatting element
- * @return The formatted message
- */
- public static String format(final String messagePattern,
- final Object argument) {
- int j = messagePattern.indexOf(DELIM_START);
- int len = messagePattern.length();
- char escape = 'x';
-
- // if there are no { characters or { is the last character
- // then we just return messagePattern
- if (j == -1 || (j + 1 == len)) {
- return messagePattern;
- } else {
- char delimStop = messagePattern.charAt(j + 1);
- if (j > 0) {
- escape = messagePattern.charAt(j - 1);
- }
- if ((delimStop != DELIM_STOP) || (escape == '\\')) {
- // invalid DELIM_START/DELIM_STOP pair or espace character is
- // present
- return messagePattern;
- } else {
- StringBuffer sbuf = new StringBuffer(len + 20);
- sbuf.append(messagePattern.substring(0, j));
- sbuf.append(argument);
- sbuf.append(messagePattern.substring(j + 2));
- return sbuf.toString();
- }
- }
- }
-
- /**
- * /**
- * Performs a two argument substitution for the 'messagePattern' passed as
- * parameter.
- * <p/>
- * For example, <code>MessageFormatter.format("Hi {}. My name is {}.",
- * "there", "David");</code> will return the string
- * "Hi there. My name is David.".
- * <p/>
- * The '{}' pair is called a formatting element. It serves to designate the
- * location where the arguments need to be inserted within
- * the message pattern.
- *
- * @param messagePattern
- * The message pattern which will be parsed and formatted
- * @param arg1
- * The first argument to replace the first formatting element
- * @param arg2
- * The second argument to replace the second formatting element
- * @return The formatted message
- */
- public static String format(final String messagePattern,
- final Object arg1,
- final Object arg2) {
- int i = 0;
- int len = messagePattern.length();
-
- StringBuffer sbuf = new StringBuffer(messagePattern.length() + 50);
-
- for (int l = 0; l < 2; l++) {
- int j = messagePattern.indexOf(DELIM_START, i);
-
- if (j == -1 || (j + 1 == len)) {
- // no more variables
- if (i == 0) { // this is a simple string
- return messagePattern;
- } else {
- // add the tail string which contains no variables
- // and return the result.
- sbuf.append(messagePattern.substring(i,
- messagePattern.length()));
- return sbuf.toString();
- }
- } else {
- char delimStop = messagePattern.charAt(j + 1);
- if ((delimStop != DELIM_STOP)) {
- // invalid DELIM_START/DELIM_STOP pair
- sbuf.append(messagePattern.substring(i,
- messagePattern.length()));
- return sbuf.toString();
- }
- sbuf.append(messagePattern.substring(i, j));
- if (l == 0) {
- sbuf.append(arg1);
- } else {
- sbuf.append(arg2);
- }
- i = j + 2;
- }
- }
- // append the characters following the second {} pair.
- sbuf.append(messagePattern.substring(i, messagePattern.length()));
- return sbuf.toString();
- }
-}
diff --git a/src/main/java/org/apache/log4j/plugins/Pauseable.java b/src/main/java/org/apache/log4j/plugins/Pauseable.java
deleted file mode 100644
index 6268ba3..0000000
--- a/src/main/java/org/apache/log4j/plugins/Pauseable.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.plugins;
-
-
-/**
- * Instances of this interface can be paused, and resumed.
- *
- * @author Paul Smith (psmith@apache.org)
- *
- */
-public interface Pauseable {
- /**
- * Set paused state.
- * @param paused new value
- */
- void setPaused(boolean paused);
-
- /**
- * Get paused state.
- * @return paused state.
- */
- boolean isPaused();
-}
diff --git a/src/main/java/org/apache/log4j/plugins/Plugin.java b/src/main/java/org/apache/log4j/plugins/Plugin.java
deleted file mode 100644
index e1b6a6f..0000000
--- a/src/main/java/org/apache/log4j/plugins/Plugin.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.plugins;
-
-import org.apache.log4j.spi.LoggerRepository;
-import org.apache.log4j.spi.OptionHandler;
-
-import java.beans.PropertyChangeListener;
-
-
-/**
- * Defines the required interface for all Plugin objects.
- * <p/>
- * <p>A plugin implements some specific functionality to extend
- * the log4j framework. Each plugin is associated with a specific
- * LoggerRepository, which it then uses/acts upon. The functionality
- * of the plugin is up to the developer.
- * <p/>
- * <p>Examples of plugins are Receiver and Watchdog. Receiver plugins
- * allow for remote logging events to be received and processed by
- * a repository as if the event was sent locally. Watchdog plugins
- * allow for a repository to be reconfigured when some "watched"
- * configuration data changes.
- *
- * @author Mark Womack (mwomack@apache.org)
- * @author Nicko Cadell
- * @author Paul Smith (psmith@apache.org)
- */
-public interface Plugin extends OptionHandler {
- /**
- * Gets the name of the plugin.
- *
- * @return String the name of the plugin.
- */
- String getName();
-
- /**
- * Sets the name of the plugin.
- *
- * @param name the name of the plugin.
- */
- void setName(String name);
-
- /**
- * Gets the logger repository for this plugin.
- *
- * @return the logger repository to which this plugin is attached.
- */
- LoggerRepository getLoggerRepository();
-
- /**
- * Sets the logger repository used by this plugin. This
- * repository will be used by the plugin functionality.
- *
- * @param repository the logger repository to attach this plugin to.
- */
- void setLoggerRepository(LoggerRepository repository);
-
- /**
- * Adds a PropertyChangeListener to this instance which is
- * notified only by changes of the property with name propertyName.
- *
- * @param propertyName
- * the name of the property in standard JavaBean syntax
- * (e.g. for setName(), property="name")
- * @param l listener
- */
- void addPropertyChangeListener(
- String propertyName, PropertyChangeListener l);
-
- /**
- * Adds a PropertyChangeListener that will be notified of all property
- * changes.
- *
- * @param l The listener to add.
- */
- void addPropertyChangeListener(PropertyChangeListener l);
-
- /**
- * Removes a specific PropertyChangeListener from this instances
- * registry that has been mapped to be notified of all property
- * changes.
- *
- * @param l The listener to remove.
- */
- void removePropertyChangeListener(PropertyChangeListener l);
-
- /**
- * Removes a specific PropertyChangeListener from this instance's
- * registry which has been previously registered to be notified
- * of only a specific property change.
- *
- * @param propertyName property name, may not be null.
- * @param l listener to be removed.
- */
- void removePropertyChangeListener(
- String propertyName, PropertyChangeListener l);
-
- /**
- * True if the plugin is active and running.
- *
- * @return boolean true if the plugin is currently active.
- */
- boolean isActive();
-
- /**
- * Returns true if the testPlugin is considered to be "equivalent" to the
- * this plugin. The equivalency test is at the discretion of the plugin
- * implementation. The PluginRegistry will use this method when starting
- * new plugins to see if a given plugin is considered equivalent to an
- * already running plugin with the same name. If they are considered to
- * be equivalent, the currently running plugin will be left in place, and
- * the new plugin will not be started.
- * <p/>
- * It is possible to override the equals() method, however this has
- * more meaning than is required for this simple test and would also
- * require the overriding of the hashCode() method as well. All of this
- * is more work than is needed, so this simple method is used instead.
- *
- * @param testPlugin The plugin to test equivalency against.
- * @return Returns true if testPlugin is considered to be equivelent.
- */
- boolean isEquivalent(Plugin testPlugin);
-
- /**
- * Call when the plugin should be stopped.
- */
- void shutdown();
-}
diff --git a/src/main/java/org/apache/log4j/plugins/PluginEvent.java b/src/main/java/org/apache/log4j/plugins/PluginEvent.java
deleted file mode 100644
index 1843034..0000000
--- a/src/main/java/org/apache/log4j/plugins/PluginEvent.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.plugins;
-
-import java.util.EventObject;
-
-
-/**
- * All Plugin events are encapsulated in this class, which
- * simply contains the source Plugin, but may in future include more
- * information.
- *
- * @author Paul Smith
- */
-public class PluginEvent extends EventObject {
- /**
- * @param source The source plugin of the event
- */
- PluginEvent(final Plugin source) {
- super(source);
- }
-
- /**
- * Returns the source Plugin of this event, which is simple
- * the getSource() method casted to Plugin for convenience.
- *
- * @return Plugin source of this event
- */
- public Plugin getPlugin() {
- return (Plugin) getSource();
- }
-}
diff --git a/src/main/java/org/apache/log4j/plugins/PluginListener.java b/src/main/java/org/apache/log4j/plugins/PluginListener.java
deleted file mode 100644
index 11f628e..0000000
--- a/src/main/java/org/apache/log4j/plugins/PluginListener.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- */
-package org.apache.log4j.plugins;
-
-import java.util.EventListener;
-
-
-/**
- * PluginListeners are notified when plugins are started or stopped
- * by the PluginRegistry.
- *
- * @author Paul Smith (psmith@apache.org)
- */
-public interface PluginListener extends EventListener {
- /**
- * Notification that plugin has started.
- * @param e event
- */
- void pluginStarted(PluginEvent e);
-
- /**
- * Notification that plugin has stopped.
- * @param e event
- */
- void pluginStopped(PluginEvent e);
-}
diff --git a/src/main/java/org/apache/log4j/plugins/PluginRegistry.java b/src/main/java/org/apache/log4j/plugins/PluginRegistry.java
deleted file mode 100644
index d34f885..0000000
--- a/src/main/java/org/apache/log4j/plugins/PluginRegistry.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.plugins;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.spi.LoggerRepository;
-import org.apache.log4j.spi.LoggerRepositoryEx;
-import org.apache.log4j.spi.LoggerRepositoryEventListener;
-
-
-/**
- * This is a registry for Plugin instances. It provides methods to
- * start and stop plugin objects individually and to stop all
- * plugins for a repository.
- *
- * @author Mark Womack
- * @author Paul Smith
- */
-public final class PluginRegistry {
- /**
- * The pluginMap is keyed by plugin name and contains plugins as values.
- * key=plugin.getName, value=plugin
- */
- private final Map pluginMap;
- /**
- * Logger repository.
- */
- private final LoggerRepositoryEx loggerRepository;
-
- /**
- * the listener used to listen for repository events.
- */
- private final RepositoryListener listener = new RepositoryListener();
- /**
- * List of listeners.
- */
- private final List listenerList =
- Collections.synchronizedList(new ArrayList());
-
- /**
- * Creates a new instance.
- * @param repository logger repository.
- */
- public PluginRegistry(final LoggerRepositoryEx repository) {
- super();
- pluginMap = new HashMap();
- this.loggerRepository = repository;
- this.loggerRepository.addLoggerRepositoryEventListener(listener);
- }
-
- /**
- * Get logger repository.
- * @return logger repository.
- */
- public LoggerRepositoryEx getLoggerRepository() {
- return loggerRepository;
- }
-
-
- /**
- * Returns true if the specified name is already taken by
- * an existing Plugin registered within the scope of the specified
- * LoggerRepository.
- *
- * @param name The name to check the repository for
- * @return true if the name is already in use, otherwise false
- */
- public boolean pluginNameExists(final String name) {
- synchronized (pluginMap) {
- return pluginMap.containsKey(name);
- }
- }
-
-
- /**
- * Adds a plugin to the plugin registry.
- * If a plugin with the same name exists
- * already, it is shutdown and removed.
- *
- * @param plugin the plugin to add.
- */
- public void addPlugin(final Plugin plugin) {
- // put plugin into the repository's reciever map
- synchronized (pluginMap) {
- String name = plugin.getName();
-
- // make sure the plugin has reference to repository
- plugin.setLoggerRepository(getLoggerRepository());
-
- Plugin existingPlugin = (Plugin) pluginMap.get(name);
- if (existingPlugin != null) {
- existingPlugin.shutdown();
- }
-
- // put the new plugin into the map
- pluginMap.put(name, plugin);
- firePluginStarted(plugin);
- }
- }
-
-
- /**
- * Calls the pluginStarted method on every registered PluginListener.
- *
- * @param plugin The plugin that has been started.
- */
- private void firePluginStarted(final Plugin plugin) {
- PluginEvent e = null;
- synchronized (listenerList) {
- for (Iterator iter = listenerList.iterator(); iter.hasNext();) {
- PluginListener l = (PluginListener) iter.next();
- if (e == null) {
- e = new PluginEvent(plugin);
- }
- l.pluginStarted(e);
- }
- }
- }
-
-
- /**
- * Calls the pluginStopped method for every registered PluginListner.
- *
- * @param plugin The plugin that has been stopped.
- */
- private void firePluginStopped(final Plugin plugin) {
- PluginEvent e = null;
- synchronized (listenerList) {
- for (Iterator iter = listenerList.iterator(); iter.hasNext();) {
- PluginListener l = (PluginListener) iter.next();
- if (e == null) {
- e = new PluginEvent(plugin);
- }
- l.pluginStopped(e);
- }
- }
- }
-
-
- /**
- * Returns all the plugins for a given repository.
- *
- * @return List list of plugins from the repository.
- */
- public List getPlugins() {
- synchronized (pluginMap) {
- List pluginList = new ArrayList(pluginMap.size());
- Iterator iter = pluginMap.values().iterator();
-
- while (iter.hasNext()) {
- pluginList.add(iter.next());
- }
- return pluginList;
- }
- }
-
-
- /**
- * Returns all the plugins for a given repository that are instances
- * of a certain class.
- *
- * @param pluginClass the class the plugin must implement to be selected.
- * @return List list of plugins from the repository.
- */
- public List getPlugins(final Class pluginClass) {
- synchronized (pluginMap) {
- List pluginList = new ArrayList(pluginMap.size());
- Iterator iter = pluginMap.values().iterator();
-
- while (iter.hasNext()) {
- Object plugin = iter.next();
-
- if (pluginClass.isInstance(plugin)) {
- pluginList.add(plugin);
- }
- }
- return pluginList;
- }
- }
-
-
- /**
- * Stops a plugin by plugin name and repository.
- *
- * @param pluginName the name of the plugin to stop.
- * @return Plugin the plugin, if stopped, or null if the
- * the plugin was not found in the registry.
- */
- public Plugin stopPlugin(final String pluginName) {
- synchronized (pluginMap) {
- Plugin plugin = (Plugin) pluginMap.get(pluginName);
-
- if (plugin == null) {
- return null;
- }
-
- // shutdown the plugin
- plugin.shutdown();
-
- // remove it from the plugin map
- pluginMap.remove(pluginName);
- firePluginStopped(plugin);
-
- // return it for future use
- return plugin;
- }
- }
-
- /**
- * Stops all plugins in the given logger repository.
- */
- public void stopAllPlugins() {
- synchronized (pluginMap) {
- // remove the listener for this repository
- loggerRepository.removeLoggerRepositoryEventListener(listener);
-
- Iterator iter = pluginMap.values().iterator();
-
- while (iter.hasNext()) {
- Plugin plugin = (Plugin) iter.next();
- plugin.shutdown();
- firePluginStopped(plugin);
- }
- }
- }
-
-
- /**
- * Adds a PluginListener to this registry to be notified
- * of PluginEvents.
- *
- * @param l PluginListener to add to this registry
- */
- public void addPluginListener(final PluginListener l) {
- listenerList.add(l);
- }
-
-
- /**
- * Removes a particular PluginListener from this registry
- * such that it will no longer be notified of PluginEvents.
- *
- * @param l PluginListener to remove
- */
- public void removePluginListener(final PluginListener l) {
- listenerList.remove(l);
- }
-
- /**
- * Internal class used to handle listener events from repositories.
- */
- private class RepositoryListener implements LoggerRepositoryEventListener {
- /**
- * Stops all plugins associated with the repository being reset.
- *
- * @param repository the repository that was reset.
- */
- public void configurationResetEvent(final LoggerRepository repository) {
- PluginRegistry.this.stopAllPlugins();
- }
-
-
- /**
- * Called when the repository configuration is changed.
- *
- * @param repository the repository that was changed.
- */
- public void configurationChangedEvent(
- final LoggerRepository repository) {
- // do nothing with this event
- }
-
-
- /**
- * Stops all plugins associated with the repository being shutdown.
- *
- * @param repository the repository being shutdown.
- */
- public void shutdownEvent(final LoggerRepository repository) {
- PluginRegistry.this.stopAllPlugins();
- }
- }
-}
diff --git a/src/main/java/org/apache/log4j/plugins/PluginSkeleton.java b/src/main/java/org/apache/log4j/plugins/PluginSkeleton.java
deleted file mode 100644
index 2660473..0000000
--- a/src/main/java/org/apache/log4j/plugins/PluginSkeleton.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.plugins;
-
-import org.apache.log4j.spi.ComponentBase;
-import org.apache.log4j.spi.LoggerRepository;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-
-
-/**
- * A convienent abstract class for plugin subclasses that implements
- * the basic methods of the Plugin interface. Subclasses are required
- * to implement the isActive(), activateOptions(), and shutdown()
- * methods.
- * <p/>
- * <p>Developers are not required to subclass PluginSkeleton to
- * develop their own plugins (they are only required to implement the
- * Plugin interface), but it provides a convenient base class to start
- * from.
- * <p/>
- * Contributors: Nicko Cadell
- *
- * @author Mark Womack (mwomack@apache.org)
- * @author Paul Smith (psmith@apache.org)
- */
-public abstract class PluginSkeleton extends ComponentBase implements Plugin {
- /**
- * Name of this plugin.
- */
- protected String name = "plugin";
-
- /**
- * Active state of plugin.
- */
- protected boolean active;
-
- /**
- * This is a delegate that does all the PropertyChangeListener
- * support.
- */
- private PropertyChangeSupport propertySupport =
- new PropertyChangeSupport(this);
-
- /**
- * Construct new instance.
- */
- protected PluginSkeleton() {
- super();
- }
-
- /**
- * Gets the name of the plugin.
- *
- * @return String the name of the plugin.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the name of the plugin and notifies
- * PropertyChangeListeners of the change.
- *
- * @param newName the name of the plugin to set.
- */
- public void setName(final String newName) {
- String oldName = this.name;
- this.name = newName;
- propertySupport.firePropertyChange("name", oldName, this.name);
- }
-
- /**
- * Gets the logger repository for this plugin.
- *
- * @return LoggerRepository the logger repository this plugin will affect.
- */
- public LoggerRepository getLoggerRepository() {
- return repository;
- }
-
- /**
- * Sets the logger repository used by this plugin and notifies a
- * relevant PropertyChangeListeners registered. This
- * repository will be used by the plugin functionality.
- *
- * @param repository the logger repository that this plugin should affect.
- */
- public void setLoggerRepository(final LoggerRepository repository) {
- Object oldValue = this.repository;
- this.repository = repository;
- firePropertyChange("loggerRepository", oldValue, this.repository);
- }
-
- /**
- * Returns whether this plugin is Active or not.
- *
- * @return true/false
- */
- public synchronized boolean isActive() {
- return active;
- }
-
- /**
- * Returns true if the plugin has the same name and logger repository as the
- * testPlugin passed in.
- *
- * @param testPlugin The plugin to test equivalency against.
- * @return Returns true if testPlugin is considered to be equivalent.
- */
- public boolean isEquivalent(final Plugin testPlugin) {
- return (repository == testPlugin.getLoggerRepository())
- && ((this.name == null && testPlugin.getName() == null)
- || (this.name != null
- && name.equals(testPlugin.getName())))
- && this.getClass().equals(testPlugin.getClass());
- }
-
- /**
- * Add property change listener.
- * @param listener listener.
- */
- public final void addPropertyChangeListener(
- final PropertyChangeListener listener) {
- propertySupport.addPropertyChangeListener(listener);
- }
-
- /**
- * Add property change listener for one property only.
- * @param propertyName property name.
- * @param listener listener.
- */
- public final void addPropertyChangeListener(
- final String propertyName,
- final PropertyChangeListener listener) {
- propertySupport.addPropertyChangeListener(propertyName, listener);
- }
-
- /**
- * Remove property change listener.
- * @param listener listener.
- */
- public final void removePropertyChangeListener(
- final PropertyChangeListener listener) {
- propertySupport.removePropertyChangeListener(listener);
- }
-
- /**
- * Remove property change listener on a specific property.
- * @param propertyName property name.
- * @param listener listener.
- */
- public final void removePropertyChangeListener(
- final String propertyName,
- final PropertyChangeListener listener) {
- propertySupport.removePropertyChangeListener(propertyName, listener);
- }
-
- /**
- * Fire a property change event to appropriate listeners.
- * @param evt change event.
- */
- protected final void firePropertyChange(
- final PropertyChangeEvent evt) {
- propertySupport.firePropertyChange(evt);
- }
-
- /**
- * Fire property change event to appropriate listeners.
- * @param propertyName property name.
- * @param oldValue old value.
- * @param newValue new value.
- */
- protected final void firePropertyChange(
- final String propertyName,
- final boolean oldValue,
- final boolean newValue) {
- propertySupport.firePropertyChange(propertyName, oldValue, newValue);
- }
-
- /**
- * Fire property change event to appropriate listeners.
- * @param propertyName property name.
- * @param oldValue old value.
- * @param newValue new value.
- */
- protected final void firePropertyChange(
- final String propertyName,
- final int oldValue, final int newValue) {
- propertySupport.firePropertyChange(propertyName, oldValue, newValue);
- }
-
- /**
- * Fire property change event to appropriate listeners.
- * @param propertyName property name.
- * @param oldValue old value.
- * @param newValue new value.
- */
- protected final void firePropertyChange(
- final String propertyName,
- final Object oldValue,
- final Object newValue) {
- propertySupport.firePropertyChange(propertyName, oldValue, newValue);
- }
-}
diff --git a/src/main/java/org/apache/log4j/plugins/Receiver.java b/src/main/java/org/apache/log4j/plugins/Receiver.java
deleted file mode 100644
index d78ae59..0000000
--- a/src/main/java/org/apache/log4j/plugins/Receiver.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.plugins;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.spi.Thresholdable;
-
-
-/**
- * Defines the base class for Receiver plugins.
- * <p/>
- * <p>Just as Appenders send logging events outside of the log4j
- * environment (to files, to smtp, to sockets, etc), Receivers bring
- * logging events inside the log4j environment.
- * <p/>
- * <p>Receivers are meant to support the receiving of
- * remote logging events from another process. For example,
- * SocketAppender "appends" a logging event to a socket, configured
- * for a specific host and port number. On the receiving side of
- * the socket can be a SocketReceiver object. The SocketReceiver
- * object receives the logging event, and then "posts" it to the
- * log4j environment (LoggerRepository) on the receiving machine, to
- * be handled by the configured appenders, etc. The various
- * settings in this environment (Logger levels, Appender filters &
- * thresholds) are applied to the received logging event.
- * <p/>
- * <p>Receivers can also be used to "import" log messages from other
- * logging packages into the log4j environment.
- * <p/>
- * <p>Receivers can be configured to post events to a given
- * LoggerRepository.
- * <p/>
- * <p>Subclasses of Receiver must implement the isActive(),
- * activateOptions(), and shutdown() methods. The doPost() method
- * is provided to standardize the "import" of remote events into
- * the repository.
- *
- * @author Mark Womack
- * @author Ceki Gülcü
- * @author Paul Smith (psmith@apache.org)
- */
-public abstract class Receiver extends PluginSkeleton implements Thresholdable {
- /**
- * Threshold level.
- */
- protected Level thresholdLevel;
-
- /**
- * Create new instance.
- */
- protected Receiver() {
- super();
- }
-
- /**
- * Sets the receiver theshold to the given level.
- *
- * @param level The threshold level events must equal or be greater
- * than before further processing can be done.
- */
- public void setThreshold(final Level level) {
- Level oldValue = this.thresholdLevel;
- thresholdLevel = level;
- firePropertyChange("threshold", oldValue, this.thresholdLevel);
- }
-
- /**
- * Gets the current threshold setting of the receiver.
- *
- * @return Level The current threshold level of the receiver.
- */
- public Level getThreshold() {
- return thresholdLevel;
- }
-
- /**
- * Returns true if the given level is equals or greater than the current
- * threshold value of the receiver.
- *
- * @param level The level to test against the receiver threshold.
- * @return boolean True if level is equal or greater than the
- * receiver threshold.
- */
- public boolean isAsSevereAsThreshold(final Level level) {
- return ((thresholdLevel == null)
- || level.isGreaterOrEqual(thresholdLevel));
- }
-
- /**
- * Posts the logging event to a logger in the configured logger
- * repository.
- *
- * @param event the log event to post to the local log4j environment.
- */
- public void doPost(final LoggingEvent event) {
- // if event does not meet threshold, exit now
- if (!isAsSevereAsThreshold(event.getLevel())) {
- return;
- }
-
- // get the "local" logger for this event from the
- // configured repository.
- Logger localLogger =
- getLoggerRepository().getLogger(event.getLoggerName());
-
- // if the logger level is greater or equal to the level
- // of the event, use the logger to append the event.
- if (event.getLevel()
- .isGreaterOrEqual(localLogger.getEffectiveLevel())) {
- // call the loggers appenders to process the event
- localLogger.callAppenders(event);
- }
- }
-}
diff --git a/src/main/java/org/apache/log4j/scheduler/Job.java b/src/main/java/org/apache/log4j/scheduler/Job.java
deleted file mode 100644
index a0e9be4..0000000
--- a/src/main/java/org/apache/log4j/scheduler/Job.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.scheduler;
-
-
-/**
- * Job is a very simple interface. It only has a single method {@link #execute}
- * which is called by the {@link Scheduler} when a task is ready for execution.
- * <p/>
- * It is assumed that the execution context
- * are contained within the implementing
- * {@link Job} itself.
- *
- * @author Ceki Gülcü
- */
-public interface Job {
- /**
- * Execute job.
- */
- void execute();
-}
diff --git a/src/main/java/org/apache/log4j/scheduler/Scheduler.java b/src/main/java/org/apache/log4j/scheduler/Scheduler.java
deleted file mode 100644
index 72809f7..0000000
--- a/src/main/java/org/apache/log4j/scheduler/Scheduler.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.scheduler;
-
-import java.util.List;
-import java.util.Vector;
-
-/**
- * A simple but still useful implementation of a Scheduler (in memory only).
- * <p/>
- * This implementation will work very well when the number of scheduled job is
- * small, say less than 100 jobs. If a larger number of events need to be
- * scheduled, than a better adapted data structure for the jobList can give
- * improved performance.
- *
- * @author Ceki
- */
-public class Scheduler extends Thread {
-
- /**
- * Job list.
- */
- List jobList;
- /**
- * If set true, scheduler has or should shut down.
- */
- boolean shutdown = false;
-
- /**
- * Create new instance.
- */
- public Scheduler() {
- super();
- jobList = new Vector();
- }
-
- /**
- * Find the index of a given job.
- * @param job job
- * @return -1 if the job could not be found.
- */
- int findIndex(final Job job) {
- int size = jobList.size();
- boolean found = false;
-
- int i = 0;
- for (; i < size; i++) {
- ScheduledJobEntry se = (ScheduledJobEntry) jobList.get(i);
- if (se.job == job) {
- found = true;
- break;
- }
- }
- if (found) {
- return i;
- } else {
- return -1;
- }
- }
-
- /**
- * Delete the given job.
- * @param job job.
- * @return true if the job could be deleted, and
- * false if the job could not be found or if the Scheduler is about to
- * shutdown in which case deletions are not permitted.
- */
- public synchronized boolean delete(final Job job) {
- // if already shutdown in the process of shutdown, there is no
- // need to remove Jobs as they will never be executed.
- if (shutdown) {
- return false;
- }
- int i = findIndex(job);
- if (i != -1) {
- ScheduledJobEntry se = (ScheduledJobEntry) jobList.remove(i);
- if (se.job != job) { // this should never happen
- new IllegalStateException("Internal programming error");
- }
- // if the job is the first on the list,
- // then notify the scheduler thread to schedule a new job
- if (i == 0) {
- this.notifyAll();
- }
- return true;
- } else {
- return false;
- }
- }
-
-
- /**
- * Schedule a {@link Job} for execution at system time given by
- * the <code>desiredTime</code> parameter.
- * @param job job to schedule.
- * @param desiredTime desired time of execution.
- */
- public synchronized void schedule(final Job job,
- final long desiredTime) {
- schedule(new ScheduledJobEntry(job, desiredTime));
- }
-
- /**
- * Schedule a {@link Job} for execution at system time given by
- * the <code>desiredTime</code> parameter.
- * <p/>
- * The job will be rescheduled. It will execute with a frequency determined
- * by the period parameter.
- * @param job job to schedule.
- * @param desiredTime desired time of execution.
- * @param period repeat period.
- */
- public synchronized void schedule(final Job job,
- final long desiredTime,
- final long period) {
- schedule(new ScheduledJobEntry(job, desiredTime, period));
- }
-
- /**
- * Change the period of a job. The original job must exist for its period
- * to be changed.
- * <p/>
- * The method returns true if the period could be changed, and false
- * otherwise.
- * @param job job.
- * @param newPeriod new repeat period.
- * @return true if period could be changed.
- */
- public synchronized boolean changePeriod(final Job job,
- final long newPeriod) {
- if (newPeriod <= 0) {
- throw new IllegalArgumentException(
- "Period must be an integer langer than zero");
- }
-
- int i = findIndex(job);
- if (i == -1) {
- return false;
- } else {
- ScheduledJobEntry se = (ScheduledJobEntry) jobList.get(i);
- se.period = newPeriod;
- return true;
- }
- }
-
- /**
- * Schedule a job.
- * @param newSJE new job entry.
- */
- private synchronized void schedule(final ScheduledJobEntry newSJE) {
- // disallow new jobs after shutdown
- if (shutdown) {
- return;
- }
- int max = jobList.size();
- long desiredExecutionTime = newSJE.desiredExecutionTime;
-
- // find the index i such that timeInMillis < jobList[i]
- int i = 0;
- for (; i < max; i++) {
-
- ScheduledJobEntry sje = (ScheduledJobEntry) jobList.get(i);
-
- if (desiredExecutionTime < sje.desiredExecutionTime) {
- break;
- }
- }
- jobList.add(i, newSJE);
- // if the jobList was empty, then notify the scheduler thread
- if (i == 0) {
- this.notifyAll();
- }
- }
-
- /**
- * Shut down scheduler.
- */
- public synchronized void shutdown() {
- shutdown = true;
- }
-
- /**
- * Run scheduler.
- */
- public synchronized void run() {
- while (!shutdown) {
- if (jobList.isEmpty()) {
- linger();
- } else {
- ScheduledJobEntry sje = (ScheduledJobEntry) jobList.get(0);
- long now = System.currentTimeMillis();
- if (now >= sje.desiredExecutionTime) {
- executeInABox(sje.job);
- jobList.remove(0);
- if (sje.period > 0) {
- sje.desiredExecutionTime = now + sje.period;
- schedule(sje);
- }
- } else {
- linger(sje.desiredExecutionTime - now);
- }
- }
- }
- // clear out the job list to facilitate garbage collection
- jobList.clear();
- jobList = null;
- System.out.println("Leaving scheduler run method");
- }
-
- /**
- * We do not want a single failure to affect the whole scheduler.
- * @param job job to execute.
- */
- void executeInABox(final Job job) {
- try {
- job.execute();
- } catch (Exception e) {
- System.err.println("The execution of the job threw an exception");
- e.printStackTrace(System.err);
- }
- }
-
- /**
- * Wait for notification.
- */
- void linger() {
- try {
- while (jobList.isEmpty() && !shutdown) {
- this.wait();
- }
- } catch (InterruptedException ie) {
- shutdown = true;
- }
- }
-
- /**
- * Wait for notification or time to elapse.
- * @param timeToLinger time to linger.
- */
- void linger(final long timeToLinger) {
- try {
- this.wait(timeToLinger);
- } catch (InterruptedException ie) {
- shutdown = true;
- }
- }
-
- /**
- * Represents an entry in job scheduler.
- */
- static final class ScheduledJobEntry {
- /**
- * Desired execution time.
- */
- long desiredExecutionTime;
- /**
- * Job to run.
- */
- Job job;
- /**
- * Repeat period.
- */
- long period = 0;
-
- /**
- * Create new instance.
- * @param job job
- * @param desiredTime desired time.
- */
- ScheduledJobEntry(final Job job, final long desiredTime) {
- this(job, desiredTime, 0);
- }
-
- /**
- * Create new instance.
- * @param job job
- * @param desiredTime desired time
- * @param period repeat period
- */
- ScheduledJobEntry(final Job job,
- final long desiredTime,
- final long period) {
- super();
- this.desiredExecutionTime = desiredTime;
- this.job = job;
- this.period = period;
- }
- }
-
-}
-
-
diff --git a/src/main/java/org/apache/log4j/spi/Component.java b/src/main/java/org/apache/log4j/spi/Component.java
deleted file mode 100644
index 42ef29a..0000000
--- a/src/main/java/org/apache/log4j/spi/Component.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-
-/**
- * A common interface shared by log4j components.
- *
- * @author Ceki Gulcu
- */
-public interface Component {
-
-
- /**
- * Set owning logger repository for this component. This operation can
- * only be performed once.
- * Once set, a subsequent attempt will throw an IllegalStateException.
- *
- * @param repository The repository where this appender is attached.
- */
- void setLoggerRepository(LoggerRepository repository);
-
-}
diff --git a/src/main/java/org/apache/log4j/spi/ComponentBase.java b/src/main/java/org/apache/log4j/spi/ComponentBase.java
deleted file mode 100644
index 78932f7..0000000
--- a/src/main/java/org/apache/log4j/spi/ComponentBase.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import org.apache.log4j.ULogger;
-import org.apache.log4j.Logger;
-
-
-/**
- * Most log4j components derive from this class.
- *
- * @author Ceki Gulcu
- */
-public class ComponentBase implements Component {
-
- /**
- * Error count limit.
- */
- private static final int ERROR_COUNT_LIMIT = 3;
-
- /**
- * Logger repository.
- */
- protected LoggerRepository repository;
- /**
- * Logger.
- */
- private ULogger logger;
- /**
- * Error count.
- */
- private int errorCount = 0;
-
- /**
- * Construct a new instance.
- */
- protected ComponentBase() {
- super();
- }
-
-
- /**
- * Called by derived classes when they deem that the component has recovered
- * from an erroneous state.
- */
- protected void resetErrorCount() {
- errorCount = 0;
- }
-
- /**
- * Set the owning repository. The owning repository cannot be set more than
- * once.
- *
- * @param repository repository
- */
- public void setLoggerRepository(final LoggerRepository repository) {
- if (this.repository == null) {
- this.repository = repository;
- } else if (this.repository != repository) {
- throw new IllegalStateException("Repository has been already set");
- }
- }
-
- /**
- * Return the LoggerRepository to which this component is attached.
- *
- * @return Owning LoggerRepository
- */
- protected LoggerRepository getLoggerRepository() {
- return repository;
- }
-
- /**
- * Return an instance specific logger to be used by the component itself.
- * This logger is not intended to be accessed by the end-user, hence the
- * protected keyword.
- * <p/>
- * <p>In case the repository for this component is not set,
- * this implementations returns a {@link SimpleULogger} instance.
- *
- * @return A ULogger instance.
- */
- protected ULogger getLogger() {
- if (logger == null) {
- if (repository != null) {
- Logger l = repository.getLogger(this.getClass().getName());
- if (l instanceof ULogger) {
- logger = (ULogger) l;
- } else {
- logger = new Log4JULogger(l);
- }
- } else {
- logger = SimpleULogger.getLogger(this.getClass().getName());
- }
- }
- return logger;
- }
-
- /**
- * Frequently called methods in log4j components can invoke this method in
- * order to avoid flooding the output when logging lasting error conditions.
- *
- * @return a regular logger, or a NOPLogger if called too frequently.
- */
- protected ULogger getNonFloodingLogger() {
- if (errorCount++ >= ERROR_COUNT_LIMIT) {
- return NOPULogger.NOP_LOGGER;
- } else {
- return getLogger();
- }
- }
-}
diff --git a/src/main/java/org/apache/log4j/spi/ErrorItem.java b/src/main/java/org/apache/log4j/spi/ErrorItem.java
deleted file mode 100644
index f6f3686..0000000
--- a/src/main/java/org/apache/log4j/spi/ErrorItem.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.spi;
-
-import java.io.PrintStream;
-
-/**
- * Used to store special log4j errors which cannot be logged using internal
- * logging. Such errors include those occurring during the initial phases
- * of log4j configuration or errors emanating from core components such as
- * Logger or Hierarchy.
- *
- * @author Ceki Gulcu
- */
-public class ErrorItem {
- /**
- * Message.
- */
- String message;
- /**
- * Column.
- */
- int colNumber = -1;
- /**
- * Line number.
- */
- int lineNumber = -1;
- /**
- * Exception.
- */
- Throwable exception;
-
- /**
- * Create new instance.
- * @param message message
- * @param e exception
- */
- public ErrorItem(final String message, final Exception e) {
- super();
- this.message = message;
- exception = e;
- }
-
- /**
- * Creaet new instance.
- * @param message message.
- */
- public ErrorItem(final String message) {
- this(message, null);
- }
-
- /**
- * Get column number.
- * @return column number.
- */
- public int getColNumber() {
- return colNumber;
- }
-
- /**
- * Set column number.
- * @param colNumber new column number.
- */
- public void setColNumber(int colNumber) {
- this.colNumber = colNumber;
- }
-
- /**
- * Get exception.
- * @return exception.
- */
- public Throwable getException() {
- return exception;
- }
-
- /**
- * Set exception.
- * @param exception exception
- */
- public void setException(final Throwable exception) {
- this.exception = exception;
- }
-
- /**
- * Get line number.
- * @return line number.
- */
- public int getLineNumber() {
- return lineNumber;
- }
-
- /**
- * Set line number.
- * @param lineNumber line number.
- */
- public void setLineNumber(final int lineNumber) {
- this.lineNumber = lineNumber;
- }
-
- /**
- * Get message.
- * @return message.
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Set message.
- * @param message message.
- */
- public void setMessage(final String message) {
- this.message = message;
- }
-
- /**
- * String representation of ErrorItem.
- * @return string.
- */
- public String toString() {
- String str =
- "Reported error: \"" + message + "\"";
-
- if (lineNumber != -1) {
- str += " at line " + lineNumber + " column " + colNumber;
- }
- if (exception != null) {
- str += (" with exception " + exception);
- }
- return str;
- }
-
- /**
- * Dump the details of this ErrorItem to System.out.
- */
- public void dump() {
- dump(System.out);
- }
-
- /**
- * Dump the details of this ErrorItem on the specified {@link PrintStream}.
- * @param ps print stream.
- */
- public void dump(final PrintStream ps) {
- String str =
- "Reported error: \"" + message + "\"";
-
- if (lineNumber != -1) {
- str += " at line " + lineNumber + " column " + colNumber;
- }
- ps.println(str);
-
- if (exception != null) {
- exception.printStackTrace(ps);
- }
- }
-}
diff --git a/src/main/java/org/apache/log4j/spi/Log4JULogger.java b/src/main/java/org/apache/log4j/spi/Log4JULogger.java
deleted file mode 100644
index 2476810..0000000
--- a/src/main/java/org/apache/log4j/spi/Log4JULogger.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.ULogger;
-import org.apache.log4j.helpers.MessageFormatter;
-import org.apache.log4j.Level;
-
-
-/**
- * An implementation of ULogger on org.apache.log4j.Logger.
- */
-public final class Log4JULogger implements ULogger {
-
- /**
- * Wrapped log4j logger.
- */
- private final Logger logger;
-
- /**
- * Create a new instance.
- *
- * @param l logger, may not be null.
- */
- public Log4JULogger(final Logger l) {
- super();
- if (l == null) {
- throw new NullPointerException("l");
- }
- logger = l;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isDebugEnabled() {
- return logger.isDebugEnabled();
- }
-
- /**
- * {@inheritDoc}
- */
- public void debug(final Object msg) {
- logger.debug(msg);
- }
-
- /**
- * {@inheritDoc}
- */
- public void debug(final Object parameterizedMsg,
- final Object param1) {
- if (logger.isDebugEnabled()) {
- logger.debug(MessageFormatter.format(
- parameterizedMsg.toString(), param1));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void debug(final String parameterizedMsg,
- final Object param1,
- final Object param2) {
- if (logger.isDebugEnabled()) {
- logger.debug(MessageFormatter.format(
- parameterizedMsg.toString(), param1, param2));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void debug(final Object msg,
- final Throwable t) {
- logger.debug(msg, t);
- }
-
-
- /**
- * {@inheritDoc}
- */
- public boolean isInfoEnabled() {
- return logger.isInfoEnabled();
- }
-
- /**
- * {@inheritDoc}
- */
- public void info(final Object msg) {
- logger.info(msg);
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void info(final Object parameterizedMsg,
- final Object param1) {
- if (logger.isInfoEnabled()) {
- logger.info(MessageFormatter.format(
- parameterizedMsg.toString(), param1));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void info(final String parameterizedMsg,
- final Object param1,
- final Object param2) {
- if (logger.isInfoEnabled()) {
- logger.info(MessageFormatter.format(
- parameterizedMsg.toString(),
- param1,
- param2));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void info(final Object msg, final Throwable t) {
- logger.info(msg, t);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isWarnEnabled() {
- return logger.isEnabledFor(Level.WARN);
- }
-
- /**
- * {@inheritDoc}
- */
- public void warn(final Object msg) {
- logger.warn(msg);
- }
-
- /**
- * {@inheritDoc}
- */
- public void warn(final Object parameterizedMsg,
- final Object param1) {
- if (logger.isEnabledFor(Level.WARN)) {
- logger.warn(MessageFormatter.format(
- parameterizedMsg.toString(), param1));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void warn(final String parameterizedMsg,
- final Object param1,
- final Object param2) {
- if (logger.isEnabledFor(Level.WARN)) {
- logger.warn(MessageFormatter.format(
- parameterizedMsg.toString(), param1, param2));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void warn(final Object msg, final Throwable t) {
- logger.warn(msg, t);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isErrorEnabled() {
- return logger.isEnabledFor(Level.ERROR);
- }
-
- /**
- * {@inheritDoc}
- */
- public void error(final Object msg) {
- logger.error(msg);
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void error(final Object parameterizedMsg, final Object param1) {
- if (logger.isEnabledFor(Level.ERROR)) {
- logger.error(MessageFormatter.format(
- parameterizedMsg.toString(), param1));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void error(final String parameterizedMsg,
- final Object param1,
- final Object param2) {
- if (logger.isEnabledFor(Level.ERROR)) {
- logger.error(MessageFormatter.format(
- parameterizedMsg.toString(), param1, param2));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void error(final Object msg, final Throwable t) {
- logger.error(msg, t);
- }
-
-}
diff --git a/src/main/java/org/apache/log4j/spi/LoggerEventListener.java b/src/main/java/org/apache/log4j/spi/LoggerEventListener.java
deleted file mode 100644
index b39f728..0000000
--- a/src/main/java/org/apache/log4j/spi/LoggerEventListener.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.spi;
-
-import org.apache.log4j.Appender;
-import org.apache.log4j.Logger;
-
-
-/**
- Interface used to listen for Logger related events such as
- add/remove appender or changing levels. Clients register an instance of
- the interface and the instance is called back when the various events occur.
-
- LoggerRepository provides methods for adding and removing
- LoggerEventListener instances.
-
- When implementing the methods of this interface, it is useful to remember
- that the Logger can access the repository using its getRepository()
- method.
-
- @author Ceki Gülcü
- @author Mark Womack
-*/
-public interface LoggerEventListener {
- /**
- Called when an appender is added to the logger.
-
- @param logger The logger to which the appender was added.
- @param appender The appender added to the logger. */
- void appenderAddedEvent(Logger logger, Appender appender);
-
- /**
- Called when an appender is removed from the logger.
-
- @param logger The logger from which the appender was removed.
- @param appender The appender removed from the logger. */
- void appenderRemovedEvent(Logger logger, Appender appender);
-
- /**
- Called when level changed on the logger.
-
- @param logger The logger that changed levels. */
- void levelChangedEvent(Logger logger);
-}
diff --git a/src/main/java/org/apache/log4j/spi/LoggerRepositoryEventListener.java b/src/main/java/org/apache/log4j/spi/LoggerRepositoryEventListener.java
deleted file mode 100644
index 773a497..0000000
--- a/src/main/java/org/apache/log4j/spi/LoggerRepositoryEventListener.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.spi;
-
-
-/**
- Interface used to listen for LoggerRepository related
- events such as startup, reset, and shutdown. Clients register
- an instance of the interface and the instance is called back
- when the various events occur.
-
- LoggerRepository provides methods for adding and removing
- LoggerRepositoryEventListener instances.
-
- @author Ceki Gülcü
- @author Mark Womack
-*/
-public interface LoggerRepositoryEventListener {
- /**
- Called when the repository configuration is reset.
- @param repository repository
- */
- void configurationResetEvent(LoggerRepository repository);
-
- /**
- Called when the repository configuration is changed.
- @param repository repository
- */
- void configurationChangedEvent(LoggerRepository repository);
-
- /**
- Called when the repository is shutdown. When this method is
- invoked, the repository is still valid (ie it has not been
- shutdown, but will be after this method returns).
- @param repository repository.
- */
- void shutdownEvent(LoggerRepository repository);
-}
diff --git a/src/main/java/org/apache/log4j/spi/LoggerRepositoryEx.java b/src/main/java/org/apache/log4j/spi/LoggerRepositoryEx.java
deleted file mode 100644
index c079a2c..0000000
--- a/src/main/java/org/apache/log4j/spi/LoggerRepositoryEx.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.spi;
-
-import org.apache.log4j.Appender;
-import org.apache.log4j.Category;
-import org.apache.log4j.Logger;
-import org.apache.log4j.plugins.PluginRegistry;
-import org.apache.log4j.scheduler.Scheduler;
-
-import java.util.List;
-import java.util.Map;
-
-
-/**
- A <code>LoggerRepository</code> is used to create and retrieve
- <code>Loggers</code>. The relation between loggers in a repository
- depends on the repository but typically loggers are arranged in a
- named hierarchy.
-
- <p>In addition to the creational methods, a
- <code>LoggerRepository</code> can be queried for existing loggers,
- can act as a point of registry for events related to loggers.
-
- @author Ceki Gülcü
- @author Mark Womack
- @author Curt Arnold
- */
-public interface LoggerRepositoryEx extends LoggerRepository {
- /**
- Add a {@link LoggerRepositoryEventListener} to the repository. The
- listener will be called when repository events occur.
- @param listener event listener, may not be null.
- */
- void addLoggerRepositoryEventListener(
- LoggerRepositoryEventListener listener);
-
- /**
- Remove a {@link LoggerRepositoryEventListener} from the repository.
- @param listener listener.
- */
- void removeLoggerRepositoryEventListener(
- LoggerRepositoryEventListener listener);
-
- /**
- Add a {@link LoggerEventListener} to the repository. The listener
- will be called when repository events occur.
- @param listener listener, may not be null.
- */
- void addLoggerEventListener(LoggerEventListener listener);
-
- /**
- Remove a {@link LoggerEventListener} from the repository.
- @param listener listener, may not be null.
- */
- void removeLoggerEventListener(LoggerEventListener listener);
-
- /**
- * Get the name of this logger repository.
- * @return name, may not be null.
- */
- String getName();
-
- /**
- * A logger repository is a named entity.
- * @param repoName new name, may not be null.
- */
- void setName(String repoName);
-
- /**
- * Is the current configuration of the repository in its original (pristine)
- * state?
- * @return true if repository is in original state.
- *
- */
- boolean isPristine();
-
- /**
- * Set the pristine flag.
- * @param state state
- * @see #isPristine
- */
- void setPristine(boolean state);
-
- /**
- Requests that a appender removed event be sent to any registered
- {@link LoggerEventListener}.
- @param logger The logger from which the appender was removed.
- @param appender The appender removed from the logger.
- */
- void fireRemoveAppenderEvent(Category logger, Appender appender);
-
- /**
- Requests that a level changed event be sent to any registered
- {@link LoggerEventListener}.
- @param logger The logger which changed levels.
- */
- void fireLevelChangedEvent(Logger logger);
-
- /**
- Requests that a configuration changed event be sent to any registered
- {@link LoggerRepositoryEventListener}.
- */
- void fireConfigurationChangedEvent();
-
- /**
- * Return the PluginRegisty for this LoggerRepository.
- * @return plug in registry.
- */
- PluginRegistry getPluginRegistry();
-
- /**
- * Return the {@link Scheduler} for this LoggerRepository.
- * @return scheduler.
- */
- Scheduler getScheduler();
-
- /**
- * Get the properties specific for this repository.
- * @return property map.
- */
- Map getProperties();
-
- /**
- * Get the property of this repository.
- * @param key property key.
- * @return key value or null if not set.
- */
- String getProperty(String key);
-
- /**
- * Set a property of this repository.
- * @param key key, may not be null.
- * @param value new value, if null, property will be removed.
- */
- void setProperty(String key, String value);
-
- /**
- * Errors which cannot be logged, go to the error list.
- *
- * @return List
- */
- List getErrorList();
-
- /**
- * Errors which cannot be logged, go to the error list.
- *
- * @param errorItem an ErrorItem to add to the error list
- */
- void addErrorItem(ErrorItem errorItem);
-
- /**
- * A LoggerRepository can also act as a store for various objects used
- * by log4j components.
- *
- * @param key key, may not be null.
- * @return The object stored under 'key'.
- */
- Object getObject(String key);
-
- /**
- * Store an object under 'key'. If no object can be found, null is returned.
- *
- * @param key key, may not be null.
- * @param value value, may be null.
- */
- void putObject(String key, Object value);
-
- /**
- * Sets the logger factory used by LoggerRepository.getLogger(String).
- * @param loggerFactory factory to use, may not be null
- */
- void setLoggerFactory(LoggerFactory loggerFactory);
-
- /**
- * Returns the logger factory used by
- * LoggerRepository.getLogger(String).
- *
- * @return non-null factory
- */
- LoggerFactory getLoggerFactory();
-
-}
diff --git a/src/main/java/org/apache/log4j/spi/NOPULogger.java b/src/main/java/org/apache/log4j/spi/NOPULogger.java
deleted file mode 100644
index 98fe537..0000000
--- a/src/main/java/org/apache/log4j/spi/NOPULogger.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import org.apache.log4j.ULogger;
-
-
-/**
- * A no operation (NOP) implementation of {@link ULogger}.
- *
- * @author Ceki Gülcü
- */
-public final class NOPULogger implements ULogger {
-
- /**
- * The unique instance of NOPLogger.
- */
- public static final NOPULogger NOP_LOGGER = new NOPULogger();
-
- /**
- * There is no point in people creating multiple instances of NullLogger.
- * Hence, the private access modifier.
- */
- private NOPULogger() {
- super();
- }
-
- /**
- * Get instance.
- * @param name logger name.
- * @return logger.
- */
- public static NOPULogger getLogger(final String name) {
- return NOP_LOGGER;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isDebugEnabled() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void debug(final Object msg) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void debug(final Object parameterizedMsg, final Object param1) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void debug(final String parameterizedMsg,
- final Object param1,
- final Object param2) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void debug(final Object msg, final Throwable t) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isInfoEnabled() {
- // NOP
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void info(final Object msg) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void info(final Object parameterizedMsg, final Object param1) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void info(final String parameterizedMsg,
- final Object param1, final Object param2) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void info(final Object msg, final Throwable t) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isWarnEnabled() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void warn(final Object msg) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void warn(final Object parameterizedMsg,
- final Object param1) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void warn(final String parameterizedMsg,
- final Object param1,
- final Object param2) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void warn(final Object msg, final Throwable t) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isErrorEnabled() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void error(final Object msg) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void error(final Object parameterizedMsg, final Object param1) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void error(final String parameterizedMsg,
- final Object param1,
- final Object param2) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void error(final Object msg, final Throwable t) {
- // NOP
- }
-
-}
diff --git a/src/main/java/org/apache/log4j/spi/SimpleULogger.java b/src/main/java/org/apache/log4j/spi/SimpleULogger.java
deleted file mode 100644
index 714a57a..0000000
--- a/src/main/java/org/apache/log4j/spi/SimpleULogger.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import org.apache.log4j.ULogger;
-import org.apache.log4j.helpers.MessageFormatter;
-
-
-/**
- * A simple implementation that logs messages of level INFO or higher on
- * the console (<code>System.out</code>).
- * <p>
- * The output includes the relative time in milliseconds, thread name, level,
- * logger name, and the message followed by the line separator for the host.
- * In log4j terms it amounts to the "%r [%t] %level %logger - %m%n" pattern.
- * <pre>
-176 [main] INFO examples.Sort - Populating an array of 2 elements in reverse.
-225 [main] INFO examples.SortAlgo - Entered the sort method.
-304 [main] INFO SortAlgo.DUMP - Dump of interger array:
-317 [main] INFO SortAlgo.DUMP - Element [0] = 0
-331 [main] INFO SortAlgo.DUMP - Element [1] = 1
-343 [main] INFO examples.Sort - The next log statement should be an error msg.
-346 [main] ERROR SortAlgo.DUMP - Tried to dump an uninitialized array.
- at org.log4j.examples.SortAlgo.dump(SortAlgo.java:58)
- at org.log4j.examples.Sort.main(Sort.java:64)
-467 [main] INFO examples.Sort - Exiting main method.
-</pre>
- *
- * @author Ceki Gülcü
- */
-public final class SimpleULogger implements ULogger {
-
- /**
- * Logger name.
- */
- private final String loggerName;
-
-
- /**
- * Mark the time when this class gets loaded into memory.
- */
- private static long startTime = System.currentTimeMillis();
-
- /**
- * Line separator.
- */
- public static final String LINE_SEPARATOR
- = System.getProperty("line.separator");
-
- /**
- * INFO string literal.
- */
- private static final String INFO_STR = "INFO";
- /**
- * WARN string literal.
- */
- private static final String WARN_STR = "WARN";
- /**
- * ERROR string literal.
- */
- private static final String ERROR_STR = "ERROR";
-
- /**
- * Constructor is private to force construction through getLogger.
- * @param name logger name
- */
- private SimpleULogger(final String name) {
- super();
- this.loggerName = name;
- }
-
- /**
- * Creates a new instance.
- *
- * @param name logger name
- * @return logger.
- */
- public static SimpleULogger getLogger(final String name) {
- return new SimpleULogger(name);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isDebugEnabled() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void debug(final Object msg) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void debug(final Object parameterizedMsg, final Object param1) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void debug(final String parameterizedMsg,
- final Object param1,
- final Object param2) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- public void debug(final Object msg, final Throwable t) {
- // NOP
- }
-
- /**
- * This is our internal implementation for logging regular (non-parameterized)
- * log messages.
- *
- * @param level level
- * @param message message
- * @param t throwable
- */
- private void log(final String level,
- final String message,
- final Throwable t) {
- StringBuffer buf = new StringBuffer();
-
- long millis = System.currentTimeMillis();
- buf.append(millis - startTime);
-
- buf.append(" [");
- buf.append(Thread.currentThread().getName());
- buf.append("] ");
-
- buf.append(level);
- buf.append(" ");
-
- buf.append(loggerName);
- buf.append(" - ");
-
- buf.append(message);
-
- buf.append(LINE_SEPARATOR);
-
- System.out.print(buf.toString());
- if (t != null) {
- t.printStackTrace(System.out);
- }
- System.out.flush();
- }
- /**
- * For parameterized messages, first substitute parameters and then log.
- *
- * @param level level
- * @param parameterizedMsg message pattern
- * @param param1 param1
- * @param param2 param2
- */
- private void parameterizedLog(final String level,
- final Object parameterizedMsg,
- final Object param1,
- final Object param2) {
- if (parameterizedMsg instanceof String) {
- String msgStr = (String) parameterizedMsg;
- msgStr = MessageFormatter.format(msgStr, param1, param2);
- log(level, msgStr, null);
- } else {
- // To be failsafe, we handle the case where 'messagePattern' is not
- // a String. Unless the user makes a mistake, this should not happen.
- log(level, parameterizedMsg.toString(), null);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isInfoEnabled() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public void info(final Object msg) {
- log(INFO_STR, msg.toString(), null);
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void info(final Object parameterizedMsg, final Object param1) {
- parameterizedLog(INFO_STR, parameterizedMsg, param1, null);
- }
-
- /**
- * {@inheritDoc}
- */
- public void info(final String parameterizedMsg,
- final Object param1,
- final Object param2) {
- parameterizedLog(INFO_STR, parameterizedMsg, param1, param2);
- }
-
- /**
- * {@inheritDoc}
- */
- public void info(final Object msg, final Throwable t) {
- log(INFO_STR, msg.toString(), t);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isWarnEnabled() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public void warn(final Object msg) {
- log(WARN_STR, msg.toString(), null);
- }
-
- /**
- * {@inheritDoc}
- */
- public void warn(final Object parameterizedMsg, final Object param1) {
- parameterizedLog(WARN_STR, parameterizedMsg, param1, null);
- }
-
- /**
- * {@inheritDoc}
- */
- public void warn(final String parameterizedMsg,
- final Object param1,
- final Object param2) {
- parameterizedLog(WARN_STR, parameterizedMsg, param1, param2);
- }
-
- /**
- * {@inheritDoc}
- */
- public void warn(final Object msg, final Throwable t) {
- log(WARN_STR, msg.toString(), t);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isErrorEnabled() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public void error(final Object msg) {
- log(ERROR_STR, msg.toString(), null);
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void error(final Object parameterizedMsg, final Object param1) {
- parameterizedLog(ERROR_STR, parameterizedMsg, param1, null);
- }
-
- /**
- * {@inheritDoc}
- */
- public void error(final String parameterizedMsg,
- final Object param1,
- final Object param2) {
- parameterizedLog(ERROR_STR, parameterizedMsg, param1, param2);
- }
-
- /**
- * {@inheritDoc}
- */
- public void error(final Object msg, final Throwable t) {
- log(ERROR_STR, msg.toString(), t);
- }
-
-}
diff --git a/src/main/java/org/apache/log4j/spi/Thresholdable.java b/src/main/java/org/apache/log4j/spi/Thresholdable.java
deleted file mode 100644
index 222345f..0000000
--- a/src/main/java/org/apache/log4j/spi/Thresholdable.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.spi;
-
-import org.apache.log4j.Level;
-
-/**
- * An interface that defines the required methods for supporting the
- * setting and getting of a level threshold. Components should implement
- * this interface if logging events they process should meet a certain
- * threshold before being processed further. Examples of this are
- * Appenders and Receivers which will not process logging events unless
- * the event level is at or greater than a set threshold level.
- *
- * @author Paul Smith (psmith@apache.org)
- * @author Mark Womack
- */
-public interface Thresholdable {
- /**
- * Sets the component theshold to the given level.
- *
- * @param level The threshold level events must equal or be greater
- * than before further processing can be done.
- */
- void setThreshold(Level level);
-
- /**
- * Gets the current threshold setting of the component.
- *
- * @return Level The current threshold level of the component.
- */
- Level getThreshold();
-
- /**
- * Returns true if the given level is equals or greater than the current
- * threshold value of the component.
- *
- * @param level The level to test against the component threshold.
- * @return boolean True if level is equal or greater than the
- * component threshold.
- */
- boolean isAsSevereAsThreshold(Level level);
-}
diff --git a/src/test/java/org/apache/log4j/plugins/MockReceiver.java b/src/test/java/org/apache/log4j/plugins/MockReceiver.java
deleted file mode 100644
index 3eb07fe..0000000
--- a/src/test/java/org/apache/log4j/plugins/MockReceiver.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.plugins;
-
-import org.apache.log4j.plugins.PluginSkeleton;
-
-/**
- * Mock receiver used by PluginConfiguratorTest.
- */
-public final class MockReceiver extends PluginSkeleton {
- /**
- * Is active.
- */
- private boolean active = false;
- /**
- * Host name.
- */
- private String host;
- /**
- * Port.
- */
- private int port = 0;
-
- /**
- * Create new instance.
- */
- public MockReceiver() {
- super();
- }
-
- /**
- * Shutdown.
- */
- public void shutdown() {
- active = false;
- }
-
- /**
- * Is plugin active.
- * @return true if active.
- */
- public boolean isActive() {
- return active;
- }
-
- /**
- * Activate options.
- */
- public void activateOptions() {
- active = true;
- }
-
- /**
- Get the remote host to connect to for logging events.
- @return host
- */
- public String getHost() {
- return host;
- }
-
- /**
- * Configures the Host property, this will require activateOptions
- * to be called for this to take effect.
- * @param remoteHost address of remote host.
- */
- public void setHost(final String remoteHost) {
- this.host = remoteHost;
- }
- /**
- Set the remote host to connect to for logging events.
- Equivalent to setHost.
- @param remoteHost address of remote host.
- */
- public void setPort(final String remoteHost) {
- host = remoteHost;
- }
-
- /**
- Get the remote port to connect to for logging events.
- @return port
- */
- public int getPort() {
- return port;
- }
-
- /**
- Set the remote port to connect to for logging events.
- @param p port
- */
- public void setPort(final int p) {
- this.port = p;
- }
-
-}
diff --git a/src/test/java/org/apache/log4j/plugins/PluginTestCase.java b/src/test/java/org/apache/log4j/plugins/PluginTestCase.java
deleted file mode 100644
index b137106..0000000
--- a/src/test/java/org/apache/log4j/plugins/PluginTestCase.java
+++ /dev/null
@@ -1,623 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.plugins;
-
-import junit.framework.TestCase;
-import org.apache.log4j.FileAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.LoggerRepositoryExImpl;
-import org.apache.log4j.SimpleLayout;
-import org.apache.log4j.util.Compare;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-
-
-public class PluginTestCase extends TestCase {
-
- static String FILE = "plugins.PluginTestCase";
- static String WITNESS = "witness/plugins.PluginTestCase";
- private static boolean verbosePluginOutput = true;
- private static HashMap repositoryMap = new HashMap();
-
- PluginRegistry pluginRegistry;
- public PluginTestCase(String name) {
- super(name);
- }
-
- public void setUp() {
- pluginRegistry = new LoggerRepositoryExImpl(
- LogManager.getLoggerRepository()).getPluginRegistry();
-
- // delete the output file if they happen to exist
- new File(getOutputFile("test1")).delete();
- }
-
- private String getOutputFile(String caseName) {
-
- return FILE + "." + caseName + ".txt";
- }
-
- private String getWitnessFile(String caseName) {
-
- return WITNESS + "." + caseName + ".txt";
- }
-
- private void setupAppender(String caseName) throws IOException {
-
- Logger root = Logger.getRootLogger();
- root.removeAllAppenders();
-
- // set up appender
- FileAppender appender = new FileAppender(new SimpleLayout(),
- getOutputFile(caseName), false);
-
- //FileAppender appender = new FileAppender(new PatternLayout("%c{1}: %m%n"),
- // getOutputFile(caseName), false);
- root.addAppender(appender);
- root.setLevel(Level.DEBUG);
- }
-
- // basic test of plugin in standalone mode
- public void test1() throws Exception {
-
- String testName = "test1";
- Logger logger = Logger.getLogger(testName);
-
- setupAppender(testName);
-
- PluginTester plugin1 = new PluginTester1("plugin1", 1);
- PluginTester plugin2 = new PluginTester1("plugin1", 2);
- PluginTester plugin3 = new PluginTester2("plugin1", 3);
- PluginTester plugin4 = new PluginTester2("plugin2", 4);
- PluginTester retPlugin;
-
- repositoryMap.clear();
- repositoryMap.put(LogManager.getLoggerRepository(),
- "default repository");
-
- // test basic starting/stopping
- logger.info("test 1.1 - basic starting/stopping");
- logger.info("starting " + plugin1.getIdentifier());
- pluginRegistry.addPlugin(plugin1);
- logger.info("stopping " + plugin1.getIdentifier() +
- " using plugin object");
- pluginRegistry.stopPlugin(plugin1.getName());
-
- // test restarting and starting when already started
- logger.info("test 1.2 - restarting and starting when already started");
- logger.info("restarting " + plugin1.getIdentifier());
- pluginRegistry.addPlugin(plugin1);
- logger.info("restarting " + plugin1.getIdentifier() + " again");
- pluginRegistry.addPlugin(plugin1);
-
- // test stopping and stopping when already stopped
- logger.info("test 1.3- stopping and stopping when already stopped");
- logger.info("stopping " + plugin1.getIdentifier());
- pluginRegistry.stopPlugin(plugin1.getName());
- logger.info("stopping " + plugin1.getIdentifier() + " again");
- pluginRegistry.stopPlugin(plugin1.getName());
-
- logger.info("test 1.4 - restarting then stopping by plugin name");
- logger.info("starting " + plugin1.getIdentifier());
- pluginRegistry.addPlugin(plugin1);
- logger.info("stopping " + plugin1.getIdentifier() +
- " using plugin name");
- pluginRegistry.stopPlugin(plugin1.getName());
-
-// // test starting of an "equal" plugin
-// logger.info("test 1.5 - starting of an \"equal\" plugin");
-// logger.info("starting " + plugin1.getIdentifier());
-// retPlugin = (PluginTester) pluginRegistry.startPlugin(plugin1);
-// logger.info("returned plugin is " + retPlugin.getIdentifier());
-// logger.info("starting " + plugin2.getIdentifier());
-// retPlugin = (PluginTester) pluginRegistry.startPlugin(plugin2);
-// logger.info("returned plugin is " + retPlugin.getIdentifier());
-// logger.info("stopping " + retPlugin.getIdentifier());
-// pluginRegistry.stopPlugin(retPlugin.getName());
-//
-// // test starting an "equal" plugin after original stopped
-// logger.info(
-// "test 1.6 - starting an \"equal\" plugin after original stopped");
-// logger.info("starting " + plugin2.getIdentifier());
-// retPlugin = (PluginTester) pluginRegistry.startPlugin(plugin2);
-// logger.info("returned plugin is " + retPlugin.getIdentifier());
-// logger.info("stopping " + retPlugin.getIdentifier());
-// pluginRegistry.stopPlugin(retPlugin.getName());
-//
-// // test starting of an "unequal" plugin with same name
-// logger.info(
-// "test 1.7 - starting of an \"unequal\" plugin with same name");
-// logger.info("starting " + plugin1.getIdentifier());
-// retPlugin = (PluginTester) pluginRegistry.startPlugin(plugin1);
-// logger.info("returned plugin is " + retPlugin.getIdentifier());
-// logger.info("starting " + plugin3.getIdentifier());
-// retPlugin = (PluginTester) pluginRegistry.startPlugin(plugin3);
-// logger.info("returned plugin is " + retPlugin.getIdentifier());
-// logger.info("stopping " + retPlugin.getIdentifier());
-// pluginRegistry.stopPlugin(retPlugin.getName());
-//
-// // test starting of multiple plugins and stopAll
-// logger.info("test 1.8 - starting of multiple plugins and stopAll");
-// logger.info("starting " + plugin1.getIdentifier());
-// retPlugin = (PluginTester) pluginRegistry.startPlugin(plugin1);
-// logger.info("returned plugin is " + retPlugin.getIdentifier());
-// logger.info("starting " + plugin4.getIdentifier());
-// retPlugin = (PluginTester) pluginRegistry.startPlugin(plugin4);
-// logger.info("returned plugin is " + retPlugin.getIdentifier());
-// verbosePluginOutput = false;
-// logger.info("stopping all plugins");
-// pluginRegistry.stopAllPlugins();
-// verbosePluginOutput = true;
-// logger.info(plugin1.getIdentifier() + " is " +
-// (plugin1.isActive() ? "active" : "inactive"));
-// logger.info(plugin4.getIdentifier() + " is " +
-// (plugin4.isActive() ? "active" : "inactive"));
-// logger.info("stopping all plugins again");
-// pluginRegistry.stopAllPlugins();
-//
-// // test starting of multiple plugins and stopAll
-// logger.info(
-// "test 1.9 - starting of multiple plugins, stopping, and stopAll");
-// logger.info("starting " + plugin1.getIdentifier());
-// retPlugin = (PluginTester) pluginRegistry.startPlugin(plugin1);
-// logger.info("returned plugin is " + retPlugin.getIdentifier());
-// logger.info("starting " + plugin4.getIdentifier());
-// retPlugin = (PluginTester) pluginRegistry.startPlugin(plugin4);
-// logger.info("returned plugin is " + retPlugin.getIdentifier());
- logger.info("stopping " + plugin1.getIdentifier() +
- " using plugin object");
- pluginRegistry.stopPlugin(plugin1.getName());
- verbosePluginOutput = false;
- logger.info("stopping all plugins");
- pluginRegistry.stopAllPlugins();
- verbosePluginOutput = true;
- logger.info(plugin1.getIdentifier() + " is " +
- (plugin1.isActive() ? "active" : "inactive"));
- logger.info(plugin4.getIdentifier() + " is " +
- (plugin4.isActive() ? "active" : "inactive"));
- logger.info("stopping all plugins again");
- //
- // Warning about removing non-registered LoggerRepositoryEventListener
- // goes to console on log4j 1.2 instead of log file with log4j 1.3.
- //
- pluginRegistry.stopAllPlugins();
-
- assertTrue(Compare.compare(PluginTestCase.class,
- getOutputFile(testName),
- getWitnessFile(testName)));
- }
-
- // basic test of plugin with repositories
- public void test2() throws Exception {
-//
-// String testName = "test2";
-// Logger logger = Logger.getLogger(testName);
-//
-// setupAppender(testName);
-//
-// PluginTester plugin1 = new PluginTester1("plugin1", 1);
-// PluginTester plugin2 = new PluginTester1("plugin2", 2);
-// PluginTester retPlugin;
-// LoggerRepository repo1 = new Hierarchy(new RootLogger(Level.DEBUG));
-// LoggerRepository repo2 = new Hierarchy(new RootLogger(Level.DEBUG));
-//
-// PluginRegistry pr1 = repo1.getPluginRegistry();
-// PluginRegistry pr2 = repo2.getPluginRegistry();
-//
-// repositoryMap.clear();
-// repositoryMap.put(repo1, "repository1");
-// repositoryMap.put(repo2, "repository2");
-//
-// logger.info("test 2.1 - starting plugins in multiple repositories");
-// logger.info("starting " + plugin1.getIdentifier() + " in " +
-// repositoryMap.get(repo1));
-// retPlugin = (PluginTester) pr1.startPlugin(plugin1);
-// logger.info(
-// "returned plugin is " + retPlugin.getIdentifier() + " in " +
-// repositoryMap.get(retPlugin.getLoggerRepository()));
-// logger.info("starting " + plugin2.getIdentifier() + " in " +
-// repositoryMap.get(repo2));
-// retPlugin = (PluginTester) pr2.startPlugin(plugin2);
-// logger.info(
-// "returned plugin is " + retPlugin.getIdentifier() + " in " +
-// repositoryMap.get(retPlugin.getLoggerRepository()));
-//
-// logger.info("test 2.2 - stopping plugins in multiple repositories");
-// logger.info("stopping " + plugin1.getIdentifier() + " in " +
-// repositoryMap.get(plugin1.getLoggerRepository()));
-// retPlugin = (PluginTester) pr1.stopPlugin(plugin1.getName());
-// logger.info(
-// "returned plugin is " + retPlugin.getIdentifier() + " in " +
-// repositoryMap.get(retPlugin.getLoggerRepository()));
-// logger.info("stopping " + plugin2.getIdentifier() + " in " +
-// repositoryMap.get(plugin2.getLoggerRepository()));
-// retPlugin = (PluginTester) pr2.stopPlugin(plugin2.getName());
-// logger.info(
-// "returned plugin is " + retPlugin.getIdentifier() + " in " +
-// repositoryMap.get(retPlugin.getLoggerRepository()));
-//
-// logger.info("test 2.3 - restarting plugins in different repositories");
-// logger.info("starting " + plugin1.getIdentifier() + " in " +
-// repositoryMap.get(repo2));
-// retPlugin = (PluginTester) pr2.startPlugin(plugin1);
-// logger.info(
-// "returned plugin is " + retPlugin.getIdentifier() + " in " +
-// repositoryMap.get(retPlugin.getLoggerRepository()));
-// logger.info("starting " + plugin2.getIdentifier() + " in " +
-// repositoryMap.get(repo1));
-// retPlugin = (PluginTester) pr1.startPlugin(plugin2);
-// logger.info(
-// "returned plugin is " + retPlugin.getIdentifier() + " in " +
-// repositoryMap.get(retPlugin.getLoggerRepository()));
-//
-// logger.info("test 2.4 - stopping plugins using stopAll");
-// logger.info("stopping all plugins in " + repositoryMap.get(repo1));
-// pr1.stopAllPlugins();
-// logger.info("stopping all plugins in " + repositoryMap.get(repo2));
-// pr2.stopAllPlugins();
-//
-// logger.info(
-// "test 2.5 - starting a plugin already active in another repository");
-// logger.info("starting " + plugin1.getIdentifier() + " in " +
-// repositoryMap.get(repo1));
-// retPlugin = (PluginTester) pr1.startPlugin(plugin1);
-// logger.info(
-// "returned plugin is " + retPlugin.getIdentifier() + " in " +
-// repositoryMap.get(retPlugin.getLoggerRepository()));
-// logger.info("starting " + plugin2.getIdentifier() + " in " +
-// repositoryMap.get(repo2));
-// retPlugin = (PluginTester) pr2.startPlugin(plugin2);
-// logger.info(
-// "returned plugin is " + retPlugin.getIdentifier() + " in " +
-// repositoryMap.get(retPlugin.getLoggerRepository()));
-// logger.info("restarting " + plugin1.getIdentifier() + " in " +
-// repositoryMap.get(repo2));
-// retPlugin = (PluginTester) pr2.startPlugin(plugin1);
-// logger.info(
-// "returned plugin is " + retPlugin.getIdentifier() + " in " +
-// repositoryMap.get(retPlugin.getLoggerRepository()));
-// logger.info("restarting " + plugin2.getIdentifier() + " in " +
-// repositoryMap.get(repo1));
-// retPlugin = (PluginTester) pr1.startPlugin(plugin2);
-// logger.info(
-// "returned plugin is " + retPlugin.getIdentifier() + " in " +
-// repositoryMap.get(retPlugin.getLoggerRepository()));
-//
-// logger.info("test 2.6 - handle repository reset");
-// logger.info("resetting " + repositoryMap.get(repo1));
-// repo1.resetConfiguration();
-// logger.info("resetting " + repositoryMap.get(repo2));
-// repo2.resetConfiguration();
-//
-// logger.info("test 2.7 - handle repository shutdown");
-// logger.info("starting " + plugin1.getIdentifier() + " in " +
-// repositoryMap.get(repo1));
-// retPlugin = (PluginTester) pr1.startPlugin(plugin1);
-// logger.info(
-// "returned plugin is " + retPlugin.getIdentifier() + " in " +
-// repositoryMap.get(retPlugin.getLoggerRepository()));
-// logger.info("starting " + plugin2.getIdentifier() + " in " +
-// repositoryMap.get(repo2));
-// retPlugin = (PluginTester) pr2.startPlugin(plugin2);
-// logger.info(
-// "returned plugin is " + retPlugin.getIdentifier() + " in " +
-// repositoryMap.get(retPlugin.getLoggerRepository()));
-// logger.info("shutting down " + repositoryMap.get(repo1));
-// repo1.shutdown();
-// logger.info("shutting down " + repositoryMap.get(repo2));
-// repo2.shutdown();
-//
-// assertTrue(Compare.compare(getOutputFile(testName),
-// getWitnessFile(testName)));
- }
-
- public void testPluginListeners() {
-
- Plugin p = new PluginTester1("MyNewPlugin", 1);
- PluginListenerLatch l = new PluginListenerLatch();
- pluginRegistry.stopAllPlugins();
- pluginRegistry.addPluginListener(l);
- pluginRegistry.addPlugin(p);
-
- PluginEvent e = l.LastEvent;
-
- assertTrue("PluginListener should have been notified of start",
- l.StartLatch);
- assertTrue("PluginListener stop latch should not be activated",
- !l.StopLatch);
- assertTrue("PluginListener should be given reference to Plugin",
- e.getPlugin() == p);
-
- l.reset();
- pluginRegistry.stopAllPlugins();
- assertTrue("PluginListener should have been notified of stop",
- l.StopLatch);
- assertTrue("PluginListener should not have been notified of start",
- !l.StartLatch);
- assertTrue("PluginListener should be given reference to Plugin",
- l.LastEvent.getPlugin() == p);
- assertTrue(
- "PluginListener should have received a distinct event object",
- l.LastEvent != e);
- }
-
- public void testPropertyChangeListeners() {
-
- Plugin plugin = new PluginTester1("PluginTest1", 1);
-
- final PropertyChangeListenerLatch l = new PropertyChangeListenerLatch();
- plugin.addPropertyChangeListener(l);
-
- /**
- * Test the basic properties and ensure they get latched by notification
- */
- plugin.setName("NewName");
- assertTrue("PropertyChange latch should have been detected",
- l.isLatched());
- assertTrue("Old value unexpected: '" + l.getLastEvent().getOldValue() +
- "'", l.getLastEvent().getOldValue().equals("PluginTest1"));
- assertTrue("New value unexpected: '" + l.getLastEvent().getNewValue() +
- "'", l.getLastEvent().getNewValue().equals("NewName"));
-
- l.reset();
-
- plugin.removePropertyChangeListener(l);
- plugin.setName("SecondNewName");
-
- assertTrue("Should not have been notified/latched", !l.isLatched());
-
- l.reset();
-
- /**
- * Test when only listening for specific property
- */
- plugin.addPropertyChangeListener("name", l);
-
- plugin.setName("NewName2");
- assertTrue("PropertyChange latch should have been detected",
- l.isLatched());
- assertTrue("Old value unexpected: '" + l.getLastEvent().getOldValue() +
- "'", l.getLastEvent().getOldValue().equals("SecondNewName"));
- assertTrue("New value unexpected: '" + l.getLastEvent().getNewValue() +
- "'", l.getLastEvent().getNewValue().equals("NewName2"));
-
- plugin.removePropertyChangeListener("name", l);
-
- l.reset();
-
- /**
- * setup some assertions before continuing testing to make sure the test code isn't broken
- */
- assertTrue("Plugin should not be active just yet", !plugin.isActive());
- assertTrue("Latch should not be latched", !l.isLatched());
-
- plugin.addPropertyChangeListener("active", l);
-
- pluginRegistry.addPlugin(plugin);
-/*
- assertTrue(
- "Should have been notified of activation when pluginRegistry.start(plugin)",
- l.isLatched());
- assertTrue("Active old value should have been false",
- l.getLastEvent().getOldValue().equals(Boolean.FALSE));
- assertTrue("Active New value should have been true",
- l.getLastEvent().getNewValue().equals(Boolean.TRUE));
-
- pluginRegistry.stopAllPlugins();
- l.reset();
- assertTrue("Latch should have been reset", !l.isLatched());
-*/
-
- /**
- * start afresh
- */
-/*
- plugin = new PluginTester1("LoggerRepositoryProperty", 2);
-
- LoggerRepository oldValue = plugin.getLoggerRepository();
- plugin.addPropertyChangeListener("loggerRepository", l);
-
- LoggerRepository rep = new Hierarchy(new RootLogger(Level.DEBUG));
- plugin.setLoggerRepository(rep);
-
- assertTrue("Should be notified of LoggerRepository property change",
- l.isLatched());
- assertTrue("LoggerRepository Old value mismatch",
- l.getLastEvent().getOldValue() == oldValue);
- assertTrue("LoggerRepository New vale mismatch",
- l.getLastEvent().getNewValue() == rep);
-*/
- }
-
- private static class PluginListenerLatch implements PluginListener {
-
- private boolean StartLatch;
- private boolean StopLatch;
- private PluginEvent LastEvent;
-
- /* (non-Javadoc)
- * @see org.apache.log4j.plugins.PluginListener#pluginStarted(org.apache.log4j.plugins.PluginEvent)
- */
- public void pluginStarted(PluginEvent e) {
- StartLatch = true;
- LastEvent = e;
- }
-
- /* (non-Javadoc)
- * @see org.apache.log4j.plugins.PluginListener#pluginStopped(org.apache.log4j.plugins.PluginEvent)
- */
- public void pluginStopped(PluginEvent e) {
- StopLatch = true;
- LastEvent = e;
- }
-
- void reset() {
- StartLatch = false;
- StopLatch = false;
- LastEvent = null;
- }
- }
-
- private static class PropertyChangeListenerLatch
- implements PropertyChangeListener {
-
- boolean latch = false;
- PropertyChangeEvent lastEvent = null;
-
- /* (non-Javadoc)
- * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent evt) {
- latch = true;
- lastEvent = evt;
- }
-
- boolean isLatched() {
-
- return latch;
- }
-
- void reset() {
- latch = false;
- lastEvent = null;
- }
-
- PropertyChangeEvent getLastEvent() {
-
- return lastEvent;
- }
- }
-
- /**
- Class to test the Plugin and PluginRegistry functionality. */
- private static class PluginTester extends PluginSkeleton {
-
- protected Logger logger;
- private boolean active = false;
- public int id;
-
- public synchronized boolean isActive() {
- logger.debug(this.getIdentifier() + " is " +
- (active ? "active" : "inactive"));
-
- return active;
- }
-
- private synchronized boolean setActive(boolean _active) {
-
- boolean oldValue = active;
-
- if (active != _active) {
- active = _active;
- firePropertyChange("active", oldValue, active);
-
- return true;
- } else {
-
- return false;
- }
- }
-
- public String getIdentifier() {
-
- if (verbosePluginOutput) {
-
- return this.getName() + "-id" + id;
- } else {
-
- return "plugin in " +
- repositoryMap.get(this.getLoggerRepository());
- }
- }
-
- public void activateOptions() {
-
- if (setActive(true)) {
- logger.debug(this.getIdentifier() + " activated");
- } else {
- logger.debug(this.getIdentifier() + " already activated");
- }
- }
-
- public void shutdown() {
-
- if (setActive(false)) {
- logger.debug(this.getIdentifier() + " shutdown");
- } else {
- logger.debug(this.getIdentifier() + " already shutdown");
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.log4j.plugins.Plugin#isEquivalent(org.apache.log4j.plugins.Plugin)
- */
- public boolean isEquivalent(Plugin testPlugin) {
-
- boolean equiv = super.isEquivalent(testPlugin);
-
- if (equiv) {
- logger.debug("plugin equal");
- } else if (!(testPlugin.getClass() == this.getClass())) {
- logger.debug(
- "plugin not equal, different class: " +
- this.getClass().getName() + " != " +
- testPlugin.getClass().getName());
-
- } else if (!this.getName().equals(testPlugin.getName())) {
- logger.debug(
- "plugin not equal, different name: " + this.getName() +
- " != " + testPlugin.getName());
-
- } else if (!this.getLoggerRepository().equals(
- testPlugin.getLoggerRepository())) {
- logger.debug(
- "plugin not equal, different repository: " +
- repositoryMap.get(this.getLoggerRepository()) + " != " +
- repositoryMap.get(testPlugin.getLoggerRepository()));
- }
-
- return equiv;
- }
- }
-
- /**
- Class to test the Plugin and PluginRegistry functionality. */
- private static class PluginTester1 extends PluginTester {
- public PluginTester1(String _name, int _id) {
- logger = Logger.getLogger(this.getClass());
- setName(_name);
- id = _id;
- }
- }
-
- /**
- Class to test the Plugin and PluginRegistry functionality. */
- private static class PluginTester2 extends PluginTester {
- public PluginTester2(String _name, int _id) {
- logger = Logger.getLogger(this.getClass());
- setName(_name);
- id = _id;
- }
- }
-}
diff --git a/src/test/java/org/apache/log4j/util/Compare.java b/src/test/java/org/apache/log4j/util/Compare.java
deleted file mode 100644
index a23c8d0..0000000
--- a/src/test/java/org/apache/log4j/util/Compare.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.log4j.util;
-
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.*;
-
-
-public class Compare {
- static final int B1_NULL = -1;
- static final int B2_NULL = -2;
-
- private static final InputStream open(
- final Class testClass,
- final String fileName) throws IOException {
- String resourceName = fileName;
- if (fileName.startsWith("witness/")) {
- resourceName = fileName.substring(fileName.lastIndexOf('/') + 1);
- }
- InputStream is = testClass.getResourceAsStream(resourceName);
- if (is == null) {
- File file = new File(fileName);
- if (file.exists()) {
- is = new FileInputStream(file);
- } else {
- throw new FileNotFoundException("Resource "
- + resourceName + " not found");
- }
- }
- return is;
- }
-
- public static boolean compare(Class testClass,
- final String file1,
- final String file2)
- throws IOException {
- BufferedReader in1 = new BufferedReader(new FileReader(file1));
- BufferedReader in2 = new BufferedReader(new InputStreamReader(
- open(testClass, file2)));
- try {
- return compare(testClass, file1, file2, in1, in2);
- } finally {
- in1.close();
- in2.close();
- }
- }
-
- public static boolean compare(
- Class testClass, String file1, String file2, BufferedReader in1, BufferedReader in2) throws IOException {
-
- String s1;
- int lineCounter = 0;
-
- while ((s1 = in1.readLine()) != null) {
- lineCounter++;
-
- String s2 = in2.readLine();
-
- if (!s1.equals(s2)) {
- System.out.println(
- "Files [" + file1 + "] and [" + file2 + "] differ on line "
- + lineCounter);
- System.out.println("One reads: [" + s1 + "].");
- System.out.println("Other reads:[" + s2 + "].");
- outputFile(testClass, file1);
- outputFile(testClass, file2);
-
- return false;
- }
- }
-
- // the second file is longer
- if (in2.read() != -1) {
- System.out.println(
- "File [" + file2 + "] longer than file [" + file1 + "].");
- outputFile(testClass, file1);
- outputFile(testClass, file2);
-
- return false;
- }
-
- return true;
- }
-
- /**
- *
- * Prints file on the console.
- *
- */
- private static void outputFile(Class testClass, String file)
- throws IOException {
- InputStream is = open(testClass, file);
- BufferedReader in1 = new BufferedReader(new InputStreamReader(is));
-
- String s1;
- int lineCounter = 0;
- System.out.println("--------------------------------");
- System.out.println("Contents of " + file + ":");
-
- while ((s1 = in1.readLine()) != null) {
- lineCounter++;
- System.out.print(lineCounter);
-
- if (lineCounter < 10) {
- System.out.print(" : ");
- } else if (lineCounter < 100) {
- System.out.print(" : ");
- } else if (lineCounter < 1000) {
- System.out.print(" : ");
- } else {
- System.out.print(": ");
- }
-
- System.out.println(s1);
- }
- in1.close();
- }
-}
diff --git a/src/test/resources/org/apache/log4j/plugins/plugins.PluginTestCase.test1.txt b/src/test/resources/org/apache/log4j/plugins/plugins.PluginTestCase.test1.txt
deleted file mode 100644
index 8b13af0..0000000
--- a/src/test/resources/org/apache/log4j/plugins/plugins.PluginTestCase.test1.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-INFO - test 1.1 - basic starting/stopping
-INFO - starting plugin1-id1
-INFO - stopping plugin1-id1 using plugin object
-DEBUG - plugin1-id1 already shutdown
-INFO - test 1.2 - restarting and starting when already started
-INFO - restarting plugin1-id1
-INFO - restarting plugin1-id1 again
-DEBUG - plugin1-id1 already shutdown
-INFO - test 1.3- stopping and stopping when already stopped
-INFO - stopping plugin1-id1
-DEBUG - plugin1-id1 already shutdown
-INFO - stopping plugin1-id1 again
-INFO - test 1.4 - restarting then stopping by plugin name
-INFO - starting plugin1-id1
-INFO - stopping plugin1-id1 using plugin name
-DEBUG - plugin1-id1 already shutdown
-INFO - stopping plugin1-id1 using plugin object
-INFO - stopping all plugins
-DEBUG - plugin1-id1 is inactive
-INFO - plugin1-id1 is inactive
-DEBUG - plugin2-id4 is inactive
-INFO - plugin2-id4 is inactive
-INFO - stopping all plugins again