public class DefaultManagedAwareThreadFactory extends CustomizableThreadFactory implements org.springframework.beans.factory.InitializingBean
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
ThreadFactory that can be found in JNDI. Therefore,
the default JNDI name "java:comp/DefaultManagedThreadFactory" can be customized
through the "jndiName" bean property.
| 构造器和说明 |
|---|
DefaultManagedAwareThreadFactory() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
afterPropertiesSet() |
Thread |
newThread(Runnable runnable) |
void |
setJndiEnvironment(Properties jndiEnvironment)
Set the JNDI environment to use for JNDI lookups.
|
void |
setJndiName(String jndiName)
Specify a JNDI name of the
ThreadFactory to delegate to,
replacing the default JNDI name "java:comp/DefaultManagedThreadFactory". |
void |
setJndiTemplate(JndiTemplate jndiTemplate)
Set the JNDI template to use for JNDI lookups.
|
void |
setResourceRef(boolean resourceRef)
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.
|
protected final Log logger
public void setJndiTemplate(JndiTemplate jndiTemplate)
public void setJndiEnvironment(Properties jndiEnvironment)
public void setResourceRef(boolean resourceRef)
public void setJndiName(String jndiName)
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".
setResourceRef(boolean)public void afterPropertiesSet()
throws NamingException
afterPropertiesSet 在接口中 org.springframework.beans.factory.InitializingBeanNamingExceptionpublic Thread newThread(Runnable runnable)
newThread 在接口中 ThreadFactorynewThread 在类中 CustomizableThreadFactory