Class JndiManager
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.AbstractManager
-
- org.apache.logging.log4j.core.net.JndiManager
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class JndiManager extends AbstractManager
Manages a JNDIDirContext.- Since:
- 2.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classJndiManager.JndiManagerFactory
-
Field Summary
Fields Modifier and Type Field Description private javax.naming.InitialContextcontextprivate static JndiManager.JndiManagerFactoryFACTORYprivate static java.lang.StringJAVA_SCHEMEprivate static booleanJNDI_CONTEXT_SELECTOR_ENABLEDprivate static booleanJNDI_JDBC_ENABLEDprivate static booleanJNDI_JMS_ENABLEDprivate static booleanJNDI_LOOKUP_ENABLEDprivate static java.lang.StringPREFIX-
Fields inherited from class org.apache.logging.log4j.core.appender.AbstractManager
count, LOGGER
-
-
Constructor Summary
Constructors Modifier Constructor Description privateJndiManager(java.lang.String name, javax.naming.InitialContext context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.StringcreateManagerName()static java.util.PropertiescreateProperties(java.lang.String initialContextFactoryName, java.lang.String providerURL, java.lang.String urlPkgPrefixes, java.lang.String securityPrincipal, java.lang.String securityCredentials, java.util.Properties additionalProperties)Creates JNDI Properties with the provided configuration information.static JndiManagergetDefaultManager()Gets the default JndiManager using the defaultInitialContext.static JndiManagergetDefaultManager(java.lang.String name)Gets a named JndiManager using the defaultInitialContext.static JndiManagergetJndiManager(java.lang.String initialContextFactoryName, java.lang.String providerURL, java.lang.String urlPkgPrefixes, java.lang.String securityPrincipal, java.lang.String securityCredentials, java.util.Properties additionalProperties)Gets a JndiManager with the provided configuration information.static JndiManagergetJndiManager(java.util.Properties properties)Gets a JndiManager with the provided configuration information.static booleanisJndiContextSelectorEnabled()static booleanisJndiEnabled()private static booleanisJndiEnabled(java.lang.String subKey)static booleanisJndiJdbcEnabled()static booleanisJndiJmsEnabled()static booleanisJndiLookupEnabled()<T> Tlookup(java.lang.String name)Looks up a named object through this JNDI context.protected booleanreleaseSub(long timeout, java.util.concurrent.TimeUnit timeUnit)May be overridden by managers to perform processing while the manager is being released and the lock is held.java.lang.StringtoString()-
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractManager
close, getContentFormat, getCount, getLoggerContext, getManager, getName, hasManager, log, logDebug, logError, logger, logWarn, narrow, release, stop, updateData
-
-
-
-
Field Detail
-
FACTORY
private static final JndiManager.JndiManagerFactory FACTORY
-
PREFIX
private static final java.lang.String PREFIX
- See Also:
- Constant Field Values
-
JAVA_SCHEME
private static final java.lang.String JAVA_SCHEME
- See Also:
- Constant Field Values
-
JNDI_CONTEXT_SELECTOR_ENABLED
private static final boolean JNDI_CONTEXT_SELECTOR_ENABLED
-
JNDI_JDBC_ENABLED
private static final boolean JNDI_JDBC_ENABLED
-
JNDI_JMS_ENABLED
private static final boolean JNDI_JMS_ENABLED
-
JNDI_LOOKUP_ENABLED
private static final boolean JNDI_LOOKUP_ENABLED
-
context
private final javax.naming.InitialContext context
-
-
Method Detail
-
isJndiEnabled
private static boolean isJndiEnabled(java.lang.String subKey)
-
isJndiEnabled
public static boolean isJndiEnabled()
-
isJndiContextSelectorEnabled
public static boolean isJndiContextSelectorEnabled()
-
isJndiJdbcEnabled
public static boolean isJndiJdbcEnabled()
-
isJndiJmsEnabled
public static boolean isJndiJmsEnabled()
-
isJndiLookupEnabled
public static boolean isJndiLookupEnabled()
-
getDefaultManager
public static JndiManager getDefaultManager()
Gets the default JndiManager using the defaultInitialContext.- Returns:
- the default JndiManager
-
getDefaultManager
public static JndiManager getDefaultManager(java.lang.String name)
Gets a named JndiManager using the defaultInitialContext.- Parameters:
name- the name of the JndiManager instance to create or use if available- Returns:
- a default JndiManager
-
getJndiManager
public static JndiManager getJndiManager(java.lang.String initialContextFactoryName, java.lang.String providerURL, java.lang.String urlPkgPrefixes, java.lang.String securityPrincipal, java.lang.String securityCredentials, java.util.Properties additionalProperties)
Gets a JndiManager with the provided configuration information.- Parameters:
initialContextFactoryName- Fully qualified class name of an implementation ofInitialContextFactory.providerURL- The provider URL to use for the JNDI connection (specific to the above factory).urlPkgPrefixes- A colon-separated list of package prefixes for the class name of the factory class that will create a URL context factorysecurityPrincipal- The name of the identity of the Principal.securityCredentials- The security credentials of the Principal.additionalProperties- Any additional JNDI environment properties to set ornullfor none.- Returns:
- the JndiManager for the provided parameters.
-
getJndiManager
public static JndiManager getJndiManager(java.util.Properties properties)
Gets a JndiManager with the provided configuration information.- Parameters:
properties- JNDI properties, usually created by callingcreateProperties(String, String, String, String, String, Properties).- Returns:
- the JndiManager for the provided parameters.
- Since:
- 2.9
- See Also:
createProperties(String, String, String, String, String, Properties)
-
createManagerName
private static java.lang.String createManagerName()
-
createProperties
public static java.util.Properties createProperties(java.lang.String initialContextFactoryName, java.lang.String providerURL, java.lang.String urlPkgPrefixes, java.lang.String securityPrincipal, java.lang.String securityCredentials, java.util.Properties additionalProperties)Creates JNDI Properties with the provided configuration information.- Parameters:
initialContextFactoryName- Fully qualified class name of an implementation ofInitialContextFactory.providerURL- The provider URL to use for the JNDI connection (specific to the above factory).urlPkgPrefixes- A colon-separated list of package prefixes for the class name of the factory class that will create a URL context factorysecurityPrincipal- The name of the identity of the Principal.securityCredentials- The security credentials of the Principal.additionalProperties- Any additional JNDI environment properties to set ornullfor none.- Returns:
- the Properties for the provided parameters.
- Since:
- 2.9
-
releaseSub
protected boolean releaseSub(long timeout, java.util.concurrent.TimeUnit timeUnit)Description copied from class:AbstractManagerMay be overridden by managers to perform processing while the manager is being released and the lock is held. A timeout is passed for implementors to use as they see fit.- Overrides:
releaseSubin classAbstractManager- Parameters:
timeout- timeouttimeUnit- timeout time unit- Returns:
- true if all resources were closed normally, false otherwise.
-
lookup
public <T> T lookup(java.lang.String name) throws javax.naming.NamingExceptionLooks up a named object through this JNDI context.- Type Parameters:
T- the type of the object.- Parameters:
name- name of the object to look up.- Returns:
- the named object if it could be located.
- Throws:
javax.naming.NamingException- if a naming exception is encountered
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-