Package org.apache.log4j.net
Class JMSReceiver
- java.lang.Object
-
- org.apache.log4j.spi.ComponentBase
-
- org.apache.log4j.plugins.PluginSkeleton
-
- org.apache.log4j.plugins.Receiver
-
- org.apache.log4j.net.JMSReceiver
-
- All Implemented Interfaces:
javax.jms.MessageListener
,Plugin
,Component
,org.apache.log4j.spi.OptionHandler
,Thresholdable
public class JMSReceiver extends Receiver implements javax.jms.MessageListener
JMSReceiver receives a remote logging event on a configured JSM topic and "posts" it to a LoggerRepository as if the event was generated locally. This class is designed to receive events from the JMSAppender class (or classes that send compatible events).Once the event has been "posted", it will be handled by the appenders currently configured in the LoggerRespository.
This implementation borrows heavily from the JMSSink implementation.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
active
protected java.lang.String
jndiPath
protected java.lang.String
password
private java.lang.String
providerUrl
private java.lang.String
remoteInfo
protected javax.jms.TopicConnection
topicConnection
protected java.lang.String
topicFactoryName
protected java.lang.String
topicName
protected java.lang.String
userId
-
Fields inherited from class org.apache.log4j.plugins.Receiver
thresholdLevel
-
Fields inherited from class org.apache.log4j.plugins.PluginSkeleton
name
-
Fields inherited from class org.apache.log4j.spi.ComponentBase
repository
-
-
Constructor Summary
Constructors Constructor Description JMSReceiver()
JMSReceiver(java.lang.String _topicFactoryName, java.lang.String _topicName, java.lang.String _userId, java.lang.String _password, java.lang.String _jndiPath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateOptions()
Starts the JMSReceiver with the current options.java.lang.String
getJndiPath()
Gets the path to a properties file containing the initial context and jndi provider urljava.lang.String
getPassword()
Gets the curernt password property.java.lang.String
getTopicFactoryName()
Gets the curernt JMS topic factory name property.java.lang.String
getTopicName()
Gets the curernt JMS topic name property.java.lang.String
getUserId()
Gets the current user id property.boolean
isActive()
Returns true if this receiver is active.boolean
isEquivalent(Plugin testPlugin)
Returns true if the receiver is the same class and they are configured for the same properties, and super class also considers them to be equivalent.protected java.lang.Object
lookup(javax.naming.Context ctx, java.lang.String name)
void
onMessage(javax.jms.Message message)
protected void
setActive(boolean _active)
Sets the flag to indicate if receiver is active or not.void
setJndiPath(java.lang.String _jndiPath)
Sets the path to a properties file containing the initial context and jndi provider urlvoid
setPassword(java.lang.String _password)
Sets the password to use when creating the JMS connection.void
setTopicFactoryName(java.lang.String _topicFactoryName)
Sets the JMS topic factory name to use when creating the JMS connection.void
setTopicName(java.lang.String _topicName)
Sets the JMS topic name to use when creating the JMS connection.void
setUserId(java.lang.String _userId)
Sets the user id to use when creating the JMS connection.void
shutdown()
Called when the receiver should be stopped.-
Methods inherited from class org.apache.log4j.plugins.Receiver
doPost, getThreshold, isAsSevereAsThreshold, setThreshold
-
Methods inherited from class org.apache.log4j.plugins.PluginSkeleton
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getLoggerRepository, getName, removePropertyChangeListener, removePropertyChangeListener, setLoggerRepository, setName
-
Methods inherited from class org.apache.log4j.spi.ComponentBase
getLogger, getNonFloodingLogger, resetErrorCount
-
-
-
-
Field Detail
-
active
private boolean active
-
topicFactoryName
protected java.lang.String topicFactoryName
-
topicName
protected java.lang.String topicName
-
userId
protected java.lang.String userId
-
password
protected java.lang.String password
-
topicConnection
protected javax.jms.TopicConnection topicConnection
-
jndiPath
protected java.lang.String jndiPath
-
remoteInfo
private java.lang.String remoteInfo
-
providerUrl
private java.lang.String providerUrl
-
-
Method Detail
-
setJndiPath
public void setJndiPath(java.lang.String _jndiPath)
Sets the path to a properties file containing the initial context and jndi provider url
-
getJndiPath
public java.lang.String getJndiPath()
Gets the path to a properties file containing the initial context and jndi provider url
-
setTopicFactoryName
public void setTopicFactoryName(java.lang.String _topicFactoryName)
Sets the JMS topic factory name to use when creating the JMS connection.
-
getTopicFactoryName
public java.lang.String getTopicFactoryName()
Gets the curernt JMS topic factory name property.
-
setTopicName
public void setTopicName(java.lang.String _topicName)
Sets the JMS topic name to use when creating the JMS connection.
-
getTopicName
public java.lang.String getTopicName()
Gets the curernt JMS topic name property.
-
setUserId
public void setUserId(java.lang.String _userId)
Sets the user id to use when creating the JMS connection.
-
getUserId
public java.lang.String getUserId()
Gets the current user id property.
-
setPassword
public void setPassword(java.lang.String _password)
Sets the password to use when creating the JMS connection.
-
getPassword
public java.lang.String getPassword()
Gets the curernt password property.
-
isEquivalent
public boolean isEquivalent(Plugin testPlugin)
Returns true if the receiver is the same class and they are configured for the same properties, and super class also considers them to be equivalent. This is used by PluginRegistry when determining if the a similarly configured receiver is being started.- Specified by:
isEquivalent
in interfacePlugin
- Overrides:
isEquivalent
in classPluginSkeleton
- Parameters:
testPlugin
- The plugin to test equivalency against.- Returns:
- boolean True if the testPlugin is equivalent to this plugin.
-
isActive
public boolean isActive()
Returns true if this receiver is active.- Specified by:
isActive
in interfacePlugin
- Overrides:
isActive
in classPluginSkeleton
- Returns:
- true/false
-
setActive
protected void setActive(boolean _active)
Sets the flag to indicate if receiver is active or not.
-
activateOptions
public void activateOptions()
Starts the JMSReceiver with the current options.- Specified by:
activateOptions
in interfaceorg.apache.log4j.spi.OptionHandler
-
shutdown
public void shutdown()
Called when the receiver should be stopped.
-
onMessage
public void onMessage(javax.jms.Message message)
- Specified by:
onMessage
in interfacejavax.jms.MessageListener
-
lookup
protected java.lang.Object lookup(javax.naming.Context ctx, java.lang.String name) throws javax.naming.NamingException
- Throws:
javax.naming.NamingException
-
-