Class 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.AbstractConnectionSource
    A JdbcAppender connection source that uses a DataSource to 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) and DataSource service itself may dynamically come and go to/from OSGi registry.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle

        org.apache.logging.log4j.core.LifeCycle.State
    • Field Summary

      • Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle

        DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT
    • Method Detail

      • stop

        public void stop()
        Specified by:
        stop in interface org.apache.logging.log4j.core.LifeCycle
        Overrides:
        stop in class org.apache.logging.log4j.core.AbstractLifeCycle
      • toString

        public String toString()
        Specified by:
        toString in interface org.apache.logging.log4j.core.appender.db.jdbc.ConnectionSource
        Overrides:
        toString in class Object
      • 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 - Filter definition to get DataSource directly from OSGi registry without JNDI
        lazy - whether we should create lazy ConnectionSource that's more tolerant to missing JNDI and/or actual bound DataSource.
        Returns:
        the created connection source.