Class DataSourceConnectionSource
- java.lang.Object
-
- org.apache.logging.log4j.core.AbstractLifeCycle
-
- org.apache.logging.log4j.core.appender.db.jdbc.AbstractConnectionSource
-
- org.apache.logging.log4j.core.appender.db.jdbc.DataSourceConnectionSource
-
- All Implemented Interfaces:
org.apache.logging.log4j.core.appender.db.jdbc.ConnectionSource,org.apache.logging.log4j.core.LifeCycle,org.apache.logging.log4j.core.LifeCycle2
@Plugin(name="DataSource", category="Core", elementType="connectionSource", printObject=true) public final class DataSourceConnectionSource extends org.apache.logging.log4j.core.appender.db.jdbc.AbstractConnectionSourceAJdbcAppenderconnection source that uses aDataSourceto connect to the database. PaxLogging changes: more dynamic approach to JNDI. The idea is to be able to configure JNDI datasource for Log4J2 JDBC appender in situations where both JNDI (aries-jndi) andDataSourceservice itself may dynamically come and go to/from OSGi registry.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DataSourceConnectionSourcecreateConnectionSource(String jndiName, String serviceFilter, boolean lazy)Factory method for creating a connection source within the plugin manager.ConnectiongetConnection()voidstop()StringtoString()-
Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, start, stop, stop
-
-
-
-
Method Detail
-
stop
public void stop()
- Specified by:
stopin interfaceorg.apache.logging.log4j.core.LifeCycle- Overrides:
stopin classorg.apache.logging.log4j.core.AbstractLifeCycle
-
getConnection
public Connection getConnection() throws SQLException
- Throws:
SQLException
-
toString
public String toString()
-
createConnectionSource
@PluginFactory public static DataSourceConnectionSource createConnectionSource(@PluginAttribute("jndiName") String jndiName, @PluginAttribute("service") String serviceFilter, @PluginAttribute("lazy") boolean lazy)
Factory method for creating a connection source within the plugin manager.- Parameters:
jndiName- The full JNDI path where the data source is bound. Must start with java:/comp/env or environment-equivalent.serviceFilter-Filterdefinition to getDataSourcedirectly from OSGi registry without JNDIlazy- whether we should create lazyConnectionSourcethat's more tolerant to missing JNDI and/or actual boundDataSource.- Returns:
- the created connection source.
-
-