类 DefaultManagedAwareThreadFactory
- java.lang.Object
- org.springframework.util.CustomizableThreadCreator
- org.springframework.scheduling.concurrent.CustomizableThreadFactory
- org.springframework.scheduling.concurrent.DefaultManagedAwareThreadFactory
- 所有已实现的接口:
Serializable
,ThreadFactory
,InitializingBean
public class DefaultManagedAwareThreadFactory extends CustomizableThreadFactory implements InitializingBean
JNDI-based variant ofCustomizableThreadFactory
, performing a default lookup for JSR-236's "java:comp/DefaultManagedThreadFactory" in a Java EE 7 environment, falling back to the localCustomizableThreadFactory
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.- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller
- 另请参阅:
- 序列化表格
构造器概要
构造器 构造器 说明 DefaultManagedAwareThreadFactory()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.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 theThreadFactory
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 J2EE container, i.e. if the prefix "java:comp/env/" needs to be added if the JNDI name doesn't already contain it.从类继承的方法 org.springframework.util.CustomizableThreadCreator
createThread, getDefaultThreadNamePrefix, getThreadGroup, getThreadNamePrefix, getThreadPriority, isDaemon, nextThreadName, setDaemon, setThreadGroup, setThreadGroupName, setThreadNamePrefix, setThreadPriority
构造器详细资料
DefaultManagedAwareThreadFactory
public DefaultManagedAwareThreadFactory()
方法详细资料
setJndiTemplate
public void setJndiTemplate(JndiTemplate jndiTemplate)
Set the JNDI template to use for JNDI lookups.
setJndiEnvironment
public void setJndiEnvironment(Properties jndiEnvironment)
Set the JNDI environment to use for JNDI lookups.
setResourceRef
public void setResourceRef(boolean resourceRef)
Set whether the lookup occurs in a J2EE 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".
setJndiName
public void setJndiName(String jndiName)
Specify a JNDI name of theThreadFactory
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".
afterPropertiesSet
public void afterPropertiesSet() throws NamingException
从接口复制的说明:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- 指定者:
afterPropertiesSet
在接口中InitializingBean
- 抛出:
NamingException
newThread
public Thread newThread(Runnable runnable)
- 指定者:
newThread
在接口中ThreadFactory
- 覆盖:
newThread
在类中CustomizableThreadFactory