Package org.apache.log4j.plugins
Class PluginSkeleton
- java.lang.Object
-
- org.apache.log4j.spi.ComponentBase
-
- org.apache.log4j.plugins.PluginSkeleton
-
- Direct Known Subclasses:
Receiver
public abstract class PluginSkeleton extends ComponentBase implements Plugin
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.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.
Contributors: Nicko Cadell- Author:
- Mark Womack (mwomack@apache.org), Paul Smith (psmith@apache.org)
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanactiveActive state of plugin.protected StringnameName of this plugin.-
Fields inherited from class org.apache.log4j.spi.ComponentBase
repository
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPluginSkeleton()Construct new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(PropertyChangeListener listener)Add property change listener.voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener)Add property change listener for one property only.protected voidfirePropertyChange(PropertyChangeEvent evt)Fire a property change event to appropriate listeners.protected voidfirePropertyChange(String propertyName, boolean oldValue, boolean newValue)Fire property change event to appropriate listeners.protected voidfirePropertyChange(String propertyName, int oldValue, int newValue)Fire property change event to appropriate listeners.protected voidfirePropertyChange(String propertyName, Object oldValue, Object newValue)Fire property change event to appropriate listeners.org.apache.log4j.spi.LoggerRepositorygetLoggerRepository()Gets the logger repository for this plugin.StringgetName()Gets the name of the plugin.booleanisActive()Returns whether this plugin is Active or not.booleanisEquivalent(Plugin testPlugin)Returns true if the plugin has the same name and logger repository as the testPlugin passed in.voidremovePropertyChangeListener(PropertyChangeListener listener)Remove property change listener.voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener)Remove property change listener on a specific property.voidsetLoggerRepository(org.apache.log4j.spi.LoggerRepository repository)Sets the logger repository used by this plugin and notifies a relevant PropertyChangeListeners registered.voidsetName(String newName)Sets the name of the plugin and notifies PropertyChangeListeners of the change.-
Methods inherited from class org.apache.log4j.spi.ComponentBase
getLogger, getNonFloodingLogger, resetErrorCount
-
-
-
-
Field Detail
-
name
protected String name
Name of this plugin.
-
active
protected boolean active
Active state of plugin.
-
-
Method Detail
-
getName
public String getName()
Gets the name of the plugin.
-
setName
public void setName(String newName)
Sets the name of the plugin and notifies PropertyChangeListeners of the change.
-
getLoggerRepository
public org.apache.log4j.spi.LoggerRepository getLoggerRepository()
Gets the logger repository for this plugin.- Specified by:
getLoggerRepositoryin interfacePlugin- Overrides:
getLoggerRepositoryin classComponentBase- Returns:
- LoggerRepository the logger repository this plugin will affect.
-
setLoggerRepository
public void setLoggerRepository(org.apache.log4j.spi.LoggerRepository repository)
Sets the logger repository used by this plugin and notifies a relevant PropertyChangeListeners registered. This repository will be used by the plugin functionality.- Specified by:
setLoggerRepositoryin interfaceComponent- Specified by:
setLoggerRepositoryin interfacePlugin- Overrides:
setLoggerRepositoryin classComponentBase- Parameters:
repository- the logger repository that this plugin should affect.
-
isActive
public boolean isActive()
Returns whether this plugin is Active or not.
-
isEquivalent
public boolean isEquivalent(Plugin testPlugin)
Returns true if the plugin has the same name and logger repository as the testPlugin passed in.- Specified by:
isEquivalentin interfacePlugin- Parameters:
testPlugin- The plugin to test equivalency against.- Returns:
- Returns true if testPlugin is considered to be equivalent.
-
addPropertyChangeListener
public final void addPropertyChangeListener(PropertyChangeListener listener)
Add property change listener.- Specified by:
addPropertyChangeListenerin interfacePlugin- Parameters:
listener- listener.
-
addPropertyChangeListener
public final void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
Add property change listener for one property only.- Specified by:
addPropertyChangeListenerin interfacePlugin- Parameters:
propertyName- property name.listener- listener.
-
removePropertyChangeListener
public final void removePropertyChangeListener(PropertyChangeListener listener)
Remove property change listener.- Specified by:
removePropertyChangeListenerin interfacePlugin- Parameters:
listener- listener.
-
removePropertyChangeListener
public final void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
Remove property change listener on a specific property.- Specified by:
removePropertyChangeListenerin interfacePlugin- Parameters:
propertyName- property name.listener- listener.
-
firePropertyChange
protected final void firePropertyChange(PropertyChangeEvent evt)
Fire a property change event to appropriate listeners.- Parameters:
evt- change event.
-
firePropertyChange
protected final void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
Fire property change event to appropriate listeners.- Parameters:
propertyName- property name.oldValue- old value.newValue- new value.
-
firePropertyChange
protected final void firePropertyChange(String propertyName, int oldValue, int newValue)
Fire property change event to appropriate listeners.- Parameters:
propertyName- property name.oldValue- old value.newValue- new value.
-
-