spring-framework / org.springframework.scheduling.concurrent / DefaultManagedAwareThreadFactory

DefaultManagedAwareThreadFactory

open class DefaultManagedAwareThreadFactory : CustomizableThreadFactory, InitializingBean

JNDI-based variant of CustomizableThreadFactory, performing a default lookup for JSR-236's "java:comp/DefaultManagedThreadFactory" in a Java EE 7 environment, falling back to the local CustomizableThreadFactory setup if not found.

This is a convenient way to use managed threads when running in a Java EE 7 environment, simply using regular local threads otherwise - without conditional setup (i.e. without profiles).

Note: This class is not strictly JSR-236 based; it can work with any regular java.util.concurrent.ThreadFactory that can be found in JNDI. Therefore, the default JNDI name "java:comp/DefaultManagedThreadFactory" can be customized through the "jndiName" bean property.

Author
Juergen Hoeller

Since
4.0

Constructors

<init>

DefaultManagedAwareThreadFactory()

JNDI-based variant of CustomizableThreadFactory, performing a default lookup for JSR-236's "java:comp/DefaultManagedThreadFactory" in a Java EE 7 environment, falling back to the local CustomizableThreadFactory setup if not found.

This is a convenient way to use managed threads when running in a Java EE 7 environment, simply using regular local threads otherwise - without conditional setup (i.e. without profiles).

Note: This class is not strictly JSR-236 based; it can work with any regular java.util.concurrent.ThreadFactory that can be found in JNDI. Therefore, the default JNDI name "java:comp/DefaultManagedThreadFactory" can be customized through the "jndiName" bean property.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

newThread

open fun newThread(runnable: Runnable): Thread

setJndiEnvironment

open fun setJndiEnvironment(jndiEnvironment: Properties): Unit

Set the JNDI environment to use for JNDI lookups.

setJndiName

open fun setJndiName(jndiName: String): Unit

Specify a JNDI name of the java.util.concurrent.ThreadFactory to delegate to, replacing the default JNDI name "java:comp/DefaultManagedThreadFactory".

This can either be a fully qualified JNDI name, or the JNDI name relative to the current environment naming context if "resourceRef" is set to "true".

setJndiTemplate

open fun setJndiTemplate(jndiTemplate: JndiTemplate): Unit

Set the JNDI template to use for JNDI lookups.

setResourceRef

open fun setResourceRef(resourceRef: Boolean): Unit

Set whether the lookup occurs in a Java EE container, i.e. if the prefix "java:comp/env/" needs to be added if the JNDI name doesn't already contain it. PersistenceAnnotationBeanPostProcessor's default is "true".