use of org.apache.logging.log4j.core.config.Property in project logging-log4j2 by apache.
the class JeroMqAppender method createAppender.
// The ZMQ.Socket class has other set methods that we do not cover because
// they throw unsupported operation exceptions.
@PluginFactory
public static JeroMqAppender createAppender(// @formatter:off
@Required(message = "No name provided for JeroMqAppender") @PluginAttribute final String name, @PluginElement Layout<?> layout, @PluginElement final Filter filter, @PluginElement final Property[] properties, // Super attributes
@PluginAttribute final boolean ignoreExceptions, // ZMQ attributes; defaults picked from zmq.Options.
@PluginAttribute(defaultLong = 0) final long affinity, @PluginAttribute(defaultLong = DEFAULT_BACKLOG) final long backlog, @PluginAttribute final boolean delayAttachOnConnect, @PluginAttribute final byte[] identity, @PluginAttribute(defaultBoolean = true) final boolean ipv4Only, @PluginAttribute(defaultLong = -1) final long linger, @PluginAttribute(defaultLong = -1) final long maxMsgSize, @PluginAttribute(defaultLong = DEFAULT_RCV_HWM) final long rcvHwm, @PluginAttribute(defaultLong = 0) final long receiveBufferSize, @PluginAttribute(defaultLong = -1) final int receiveTimeOut, @PluginAttribute(defaultLong = DEFAULT_IVL) final long reconnectIVL, @PluginAttribute(defaultLong = 0) final long reconnectIVLMax, @PluginAttribute(defaultLong = 0) final long sendBufferSize, @PluginAttribute(defaultLong = -1) final int sendTimeOut, @PluginAttribute(defaultLong = DEFAULT_SND_HWM) final long sndHwm, @PluginAttribute(defaultInt = -1) final int tcpKeepAlive, @PluginAttribute(defaultLong = -1) final long tcpKeepAliveCount, @PluginAttribute(defaultLong = -1) final long tcpKeepAliveIdle, @PluginAttribute(defaultLong = -1) final long tcpKeepAliveInterval, @PluginAttribute final boolean xpubVerbose) // @formatter:on
{
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
List<String> endpoints;
if (properties == null) {
endpoints = new ArrayList<>(0);
} else {
endpoints = new ArrayList<>(properties.length);
for (final Property property : properties) {
if ("endpoint".equalsIgnoreCase(property.getName())) {
final String value = property.getValue();
if (Strings.isNotEmpty(value)) {
endpoints.add(value);
}
}
}
}
LOGGER.debug("Creating JeroMqAppender with name={}, filter={}, layout={}, ignoreExceptions={}, endpoints={}", name, filter, layout, ignoreExceptions, endpoints);
return new JeroMqAppender(name, filter, layout, ignoreExceptions, endpoints, affinity, backlog, delayAttachOnConnect, identity, ipv4Only, linger, maxMsgSize, rcvHwm, receiveBufferSize, receiveTimeOut, reconnectIVL, reconnectIVLMax, sendBufferSize, sendTimeOut, sndHwm, tcpKeepAlive, tcpKeepAliveCount, tcpKeepAliveIdle, tcpKeepAliveInterval, xpubVerbose, Property.EMPTY_ARRAY);
}
use of org.apache.logging.log4j.core.config.Property in project logging-log4j2 by apache.
the class PoolingDriverConnectionSource method setupDriver.
private void setupDriver(final String connectionString, final PoolableConnectionFactoryConfig poolableConnectionFactoryConfig) throws SQLException {
//
// First, we'll create a ConnectionFactory that the
// pool will use to create Connections.
// We'll use the DriverManagerConnectionFactory,
// using the connect string passed in the command line
// arguments.
//
final Property[] properties = getProperties();
final char[] userName = getUserName();
final char[] password = getPassword();
final ConnectionFactory connectionFactory;
if (properties != null && properties.length > 0) {
if (userName != null || password != null) {
throw new SQLException("Either set the userName and password, or set the Properties, but not both.");
}
connectionFactory = new DriverManagerConnectionFactory(connectionString, toProperties(properties));
} else {
connectionFactory = new DriverManagerConnectionFactory(connectionString, toString(userName), toString(password));
}
//
// Next, we'll create the PoolableConnectionFactory, which wraps
// the "real" Connections created by the ConnectionFactory with
// the classes that implement the pooling functionality.
//
final PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, null);
if (poolableConnectionFactoryConfig != null) {
poolableConnectionFactoryConfig.init(poolableConnectionFactory);
}
//
// Now we'll need a ObjectPool that serves as the
// actual pool of connections.
//
// We'll use a GenericObjectPool instance, although
// any ObjectPool implementation will suffice.
//
@SuppressWarnings("resource") final ObjectPool<PoolableConnection> // This GenericObjectPool will be closed on shutdown
connectionPool = new GenericObjectPool<>(poolableConnectionFactory);
// Set the factory's pool property to the owning pool
poolableConnectionFactory.setPool(connectionPool);
loadDriver(poolingDriverClassName);
final PoolingDriver driver = getPoolingDriver();
if (driver != null) {
getLogger().debug("Registering DBCP pool '{}' with pooling driver {}: {}", poolName, driver, connectionPool);
driver.registerPool(poolName, connectionPool);
}
//
// Now we can just use the connect string "jdbc:apache:commons:dbcp:example"
// to access our pool of Connections.
//
}
use of org.apache.logging.log4j.core.config.Property in project logging-log4j2 by apache.
the class ThreadContextBenchmark method createMap.
// from Log4jLogEvent::createMap
static Map<String, String> createMap(final List<Property> properties) {
final Map<String, String> contextMap = ThreadContext.getImmutableContext();
if (properties == null || properties.isEmpty()) {
// may be ThreadContext.EMPTY_MAP but not null
return contextMap;
}
final Map<String, String> map = new HashMap<>(contextMap);
for (final Property prop : properties) {
if (!map.containsKey(prop.getName())) {
map.put(prop.getName(), prop.getValue());
}
}
return Collections.unmodifiableMap(map);
}
Aggregations