Class JndiManager
java.lang.Object
org.apache.logging.log4j.core.appender.AbstractManager
org.apache.logging.log4j.core.net.JndiManager
- All Implemented Interfaces:
AutoCloseable
Manages a JNDI
DirContext
.- Since:
- 2.1
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.logging.log4j.core.appender.AbstractManager
AbstractManager.AbstractFactoryData
-
Field Summary
Fields inherited from class org.apache.logging.log4j.core.appender.AbstractManager
count, LOGGER
-
Method Summary
Modifier and TypeMethodDescriptionstatic Properties
createProperties
(String initialContextFactoryName, String providerURL, String urlPkgPrefixes, String securityPrincipal, String securityCredentials, Properties additionalProperties) Creates JNDI Properties with the provided configuration information.static JndiManager
Gets the default JndiManager using the defaultInitialContext
.static JndiManager
getDefaultManager
(String name) Gets a named JndiManager using the defaultInitialContext
.static JndiManager
getJndiManager
(String initialContextFactoryName, String providerURL, String urlPkgPrefixes, String securityPrincipal, String securityCredentials, Properties additionalProperties) Gets a JndiManager with the provided configuration information.static JndiManager
getJndiManager
(Properties properties) Gets a JndiManager with the provided configuration information.static boolean
Tests whether the JNDI system properties for ContextSelector is currently enabled.static boolean
Tests whether any JNDI system properties are currently enabled.static boolean
Tests whether the JNDI system properties for JDBC is currently enabled.static boolean
Tests whether the JNDI system properties for JMS is currently enabled.static boolean
Tests whether the JNDI system properties for Lookup is currently enabled.<T> T
Looks up a named object through this JNDI context.protected boolean
releaseSub
(long timeout, TimeUnit timeUnit) May be overridden by managers to perform processing while the manager is being released and the lock is held.toString()
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractManager
close, getContentFormat, getCount, getLoggerContext, getManager, getName, getStrSubstitutor, hasManager, log, logDebug, logError, logger, logWarn, narrow, release, stop, updateData
-
Method Details
-
isJndiEnabled
public static boolean isJndiEnabled()Tests whether any JNDI system properties are currently enabled.- Returns:
- whether any JNDI system properties are currently enabled.
-
isJndiContextSelectorEnabled
public static boolean isJndiContextSelectorEnabled()Tests whether the JNDI system properties for ContextSelector is currently enabled.- Returns:
- whether the JNDI system properties for ContextSelector is currently enabled.
-
isJndiJdbcEnabled
public static boolean isJndiJdbcEnabled()Tests whether the JNDI system properties for JDBC is currently enabled.- Returns:
- whether the JNDI system properties for JDBC is currently enabled.
-
isJndiJmsEnabled
public static boolean isJndiJmsEnabled()Tests whether the JNDI system properties for JMS is currently enabled.- Returns:
- whether the JNDI system properties for JMS is currently enabled.
-
isJndiLookupEnabled
public static boolean isJndiLookupEnabled()Tests whether the JNDI system properties for Lookup is currently enabled.- Returns:
- whether the JNDI system properties for Lookup is currently enabled.
-
getDefaultManager
Gets the default JndiManager using the defaultInitialContext
.- Returns:
- the default JndiManager
-
getDefaultManager
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(String initialContextFactoryName, String providerURL, String urlPkgPrefixes, String securityPrincipal, String securityCredentials, 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 ornull
for none.- Returns:
- the JndiManager for the provided parameters.
-
getJndiManager
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
public static Properties createProperties(String initialContextFactoryName, String providerURL, String urlPkgPrefixes, String securityPrincipal, String securityCredentials, 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 ornull
for none.- Returns:
- the Properties for the provided parameters.
- Since:
- 2.9
-
releaseSub
Description copied from class:AbstractManager
May 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:
releaseSub
in classAbstractManager
- Parameters:
timeout
- timeouttimeUnit
- timeout time unit- Returns:
- true if all resources were closed normally, false otherwise.
-
lookup
Looks 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:
NamingException
- if a naming exception is encountered
-
toString
-