"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsAppender.java" between
apache-log4j-2.11.1-src.tar.gz and apache-log4j-2.11.2-src.tar.gz

About: Apache Log4j 2 is a logging library for Java. Source distribution (Java).

JmsAppender.java  (apache-log4j-2.11.1-src):JmsAppender.java  (apache-log4j-2.11.2-src)
skipping to change at line 34 skipping to change at line 34
import javax.jms.JMSException; import javax.jms.JMSException;
import org.apache.logging.log4j.core.Appender; import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Filter; import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.Layout; import org.apache.logging.log4j.core.Layout;
import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.appender.AbstractAppender; import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.logging.log4j.core.appender.AbstractManager; import org.apache.logging.log4j.core.appender.AbstractManager;
import org.apache.logging.log4j.core.appender.mom.JmsManager.JmsManagerConfigura tion; import org.apache.logging.log4j.core.appender.mom.JmsManager.JmsManagerConfigura tion;
import org.apache.logging.log4j.core.config.Node; import org.apache.logging.log4j.core.config.Node;
import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.config.plugins.Plugin; import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginAliases; import org.apache.logging.log4j.core.config.plugins.PluginAliases;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute; import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory; import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.Requi red; import org.apache.logging.log4j.core.config.plugins.validation.constraints.Requi red;
import org.apache.logging.log4j.core.net.JndiManager; import org.apache.logging.log4j.core.net.JndiManager;
/** /**
* Generic JMS Appender plugin for both queues and topics. This Appender replace s the previous split ones. However, * Generic JMS Appender plugin for both queues and topics. This Appender replace s the previous split ones. However,
* configurations set up for the 2.0 version of the JMS appenders will still wor k. * configurations set up for the 2.0 version of the JMS appenders will still wor k.
*/ */
@Plugin(name = "JMS", category = Node.CATEGORY, elementType = Appender.ELEMENT_T YPE, printObject = true) @Plugin(name = "JMS", category = Node.CATEGORY, elementType = Appender.ELEMENT_T YPE, printObject = true)
@PluginAliases({ "JMSQueue", "JMSTopic" }) @PluginAliases({ "JMSQueue", "JMSTopic" })
public class JmsAppender extends AbstractAppender { public class JmsAppender extends AbstractAppender {
public static class Builder implements org.apache.logging.log4j.core.util.Bu public static class Builder<B extends Builder<B>> extends AbstractAppender.B
ilder<JmsAppender> { uilder<B>
implements org.apache.logging.log4j.core.util.Builder<JmsAppender> {
public static final int DEFAULT_RECONNECT_INTERVAL_MILLIS = 5000; public static final int DEFAULT_RECONNECT_INTERVAL_MILLIS = 5000;
@PluginBuilderAttribute @PluginBuilderAttribute
@Required(message = "A name for the JmsAppender must be specified")
private String name;
@PluginBuilderAttribute
private String factoryName; private String factoryName;
@PluginBuilderAttribute @PluginBuilderAttribute
private String providerUrl; private String providerUrl;
@PluginBuilderAttribute @PluginBuilderAttribute
private String urlPkgPrefixes; private String urlPkgPrefixes;
@PluginBuilderAttribute @PluginBuilderAttribute
private String securityPrincipalName; private String securityPrincipalName;
skipping to change at line 88 skipping to change at line 85
@PluginAliases({ "queueBindingName", "topicBindingName" }) @PluginAliases({ "queueBindingName", "topicBindingName" })
@Required(message = "A javax.jms.Destination JNDI name must be specified ") @Required(message = "A javax.jms.Destination JNDI name must be specified ")
private String destinationBindingName; private String destinationBindingName;
@PluginBuilderAttribute @PluginBuilderAttribute
private String userName; private String userName;
@PluginBuilderAttribute(sensitive = true) @PluginBuilderAttribute(sensitive = true)
private char[] password; private char[] password;
@PluginElement("Layout")
private Layout<? extends Serializable> layout;
@PluginElement("Filter")
private Filter filter;
private long reconnectIntervalMillis = DEFAULT_RECONNECT_INTERVAL_MILLIS
;
@PluginBuilderAttribute @PluginBuilderAttribute
private boolean ignoreExceptions = true; private long reconnectIntervalMillis = DEFAULT_RECONNECT_INTERVAL_MILLIS ;
@PluginBuilderAttribute @PluginBuilderAttribute
private boolean immediateFail; private boolean immediateFail;
// Programmatic access only for now. // Programmatic access only for now.
private JmsManager jmsManager; private JmsManager jmsManager;
private Builder() { private Builder() {
} }
@SuppressWarnings("resource") // actualJmsManager and jndiManager are ma naged by the JmsAppender @SuppressWarnings("resource") // actualJmsManager and jndiManager are ma naged by the JmsAppender
@Override @Override
public JmsAppender build() { public JmsAppender build() {
JmsManager actualJmsManager = jmsManager; JmsManager actualJmsManager = jmsManager;
JmsManagerConfiguration configuration = null; JmsManagerConfiguration configuration = null;
if (actualJmsManager == null) { if (actualJmsManager == null) {
final Properties jndiProperties = JndiManager.createProperties(f actoryName, providerUrl, urlPkgPrefixes, final Properties jndiProperties = JndiManager.createProperties(f actoryName, providerUrl, urlPkgPrefixes,
securityPrincipalName, securityCredentials, null); securityPrincipalName, securityCredentials, null);
configuration = new JmsManagerConfiguration(jndiProperties, fact oryBindingName, destinationBindingName, configuration = new JmsManagerConfiguration(jndiProperties, fact oryBindingName, destinationBindingName,
userName, password, false, reconnectIntervalMillis); userName, password, false, reconnectIntervalMillis);
actualJmsManager = AbstractManager.getManager(name, JmsManager.F ACTORY, configuration); actualJmsManager = AbstractManager.getManager(getName(), JmsMana ger.FACTORY, configuration);
} }
if (actualJmsManager == null) { if (actualJmsManager == null) {
// JmsManagerFactory has already logged an ERROR. // JmsManagerFactory has already logged an ERROR.
return null; return null;
} }
final Layout<? extends Serializable> layout = getLayout();
if (layout == null) { if (layout == null) {
LOGGER.error("No layout provided for JmsAppender"); LOGGER.error("No layout provided for JmsAppender");
return null; return null;
} }
try { try {
return new JmsAppender(name, filter, layout, ignoreExceptions, a return new JmsAppender(getName(), getFilter(), layout, isIgnoreE
ctualJmsManager); xceptions(), getPropertyArray(),
actualJmsManager);
} catch (final JMSException e) { } catch (final JMSException e) {
// Never happens since the ctor no longer actually throws a JMS Exception. // Never happens since the ctor no longer actually throws a JMSE xception.
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
} }
public Builder setDestinationBindingName(final String destinationBinding Name) { public Builder setDestinationBindingName(final String destinationBinding Name) {
this.destinationBindingName = destinationBindingName; this.destinationBindingName = destinationBindingName;
return this; return this;
} }
public Builder setFactoryBindingName(final String factoryBindingName) { public Builder setFactoryBindingName(final String factoryBindingName) {
this.factoryBindingName = factoryBindingName; this.factoryBindingName = factoryBindingName;
return this; return this;
} }
public Builder setFactoryName(final String factoryName) { public Builder setFactoryName(final String factoryName) {
this.factoryName = factoryName; this.factoryName = factoryName;
return this; return this;
} }
public Builder setFilter(final Filter filter) {
this.filter = filter;
return this;
}
public Builder setIgnoreExceptions(final boolean ignoreExceptions) {
this.ignoreExceptions = ignoreExceptions;
return this;
}
public Builder setImmediateFail(final boolean immediateFail) { public Builder setImmediateFail(final boolean immediateFail) {
this.immediateFail = immediateFail; this.immediateFail = immediateFail;
return this; return this;
} }
public Builder setJmsManager(final JmsManager jmsManager) { public Builder setJmsManager(final JmsManager jmsManager) {
this.jmsManager = jmsManager; this.jmsManager = jmsManager;
return this; return this;
} }
public Builder setLayout(final Layout<? extends Serializable> layout) {
this.layout = layout;
return this;
}
public Builder setName(final String name) {
this.name = name;
return this;
}
public Builder setPassword(final char[] password) { public Builder setPassword(final char[] password) {
this.password = password; this.password = password;
return this; return this;
} }
/** /**
* @deprecated Use setPassword(char[]) * @deprecated Use setPassword(char[])
*/ */
@Deprecated @Deprecated
public Builder setPassword(final String password) { public Builder setPassword(final String password) {
skipping to change at line 239 skipping to change at line 210
public Builder setUserName(final String userName) { public Builder setUserName(final String userName) {
this.userName = userName; this.userName = userName;
return this; return this;
} }
/** /**
* Does not include the password. * Does not include the password.
*/ */
@Override @Override
public String toString() { public String toString() {
return "Builder [name=" + name + ", factoryName=" + factoryName + ", providerUrl=" + providerUrl return "Builder [name=" + getName() + ", factoryName=" + factoryName + ", providerUrl=" + providerUrl
+ ", urlPkgPrefixes=" + urlPkgPrefixes + ", securityPrincipa lName=" + securityPrincipalName + ", urlPkgPrefixes=" + urlPkgPrefixes + ", securityPrincipa lName=" + securityPrincipalName
+ ", securityCredentials=" + securityCredentials + ", factor yBindingName=" + factoryBindingName + ", securityCredentials=" + securityCredentials + ", factor yBindingName=" + factoryBindingName
+ ", destinationBindingName=" + destinationBindingName + ", username=" + userName + ", layout=" + ", destinationBindingName=" + destinationBindingName + ", username=" + userName + ", layout="
+ layout + ", filter=" + filter + ", ignoreExceptions=" + ig + getLayout() + ", filter=" + getFilter() + ", ignoreExcepti
noreExceptions + ", jmsManager=" ons=" + isIgnoreExceptions()
+ jmsManager + "]"; + ", jmsManager=" + jmsManager + "]";
} }
} }
@PluginBuilderFactory @PluginBuilderFactory
public static Builder newBuilder() { public static Builder newBuilder() {
return new Builder(); return new Builder();
} }
private volatile JmsManager manager; private volatile JmsManager manager;
/** /**
* *
* @throws JMSException * @throws JMSException not thrown as of 2.9 but retained in the signature f
* not thrown as of 2.9 but retained in the signature for compat or compatibility, will be removed in 3.0
ibility, will be removed in 3.0 */
protected JmsAppender(final String name, final Filter filter, final Layout<?
extends Serializable> layout,
final boolean ignoreExceptions, final Property[] properties, final J
msManager manager) throws JMSException {
super(name, filter, layout, ignoreExceptions, properties);
this.manager = manager;
}
/**
*
* @throws JMSException not thrown as of 2.9 but retained in the signature f
or compatibility, will be removed in 3.0
* @deprecated
*/ */
@Deprecated
protected JmsAppender(final String name, final Filter filter, final Layout<? extends Serializable> layout, protected JmsAppender(final String name, final Filter filter, final Layout<? extends Serializable> layout,
final boolean ignoreExceptions, final JmsManager manager) throws JMS Exception { final boolean ignoreExceptions, final JmsManager manager) throws JMS Exception {
super(name, filter, layout, ignoreExceptions); super(name, filter, layout, ignoreExceptions, Property.EMPTY_ARRAY);
this.manager = manager; this.manager = manager;
} }
@Override @Override
public void append(final LogEvent event) { public void append(final LogEvent event) {
this.manager.send(event, toSerializable(event)); this.manager.send(event, toSerializable(event));
} }
public JmsManager getManager() { public JmsManager getManager() {
return manager; return manager;
 End of changes. 17 change blocks. 
49 lines changed or deleted 33 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)