|
spring-tx | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.jndi.JndiAccessor
org.springframework.jndi.JndiLocatorSupport
org.springframework.jca.work.WorkManagerTaskExecutor
public class WorkManagerTaskExecutor
TaskExecutor
implementation
that delegates to a JCA 1.5 WorkManager, implementing the
WorkManager
interface.
This is mainly intended for use within a JCA ResourceAdapter implementation, but may also be used in a standalone environment, delegating to a locally embedded WorkManager implementation (such as Geronimo's).
Also implements the JCA 1.5 WorkManager interface itself, delegating all calls to the target WorkManager. Hence, a caller can choose whether it wants to talk to this executor through the Spring TaskExecutor interface or the JCA 1.5 WorkManager interface.
This adapter is also capable of obtaining a JCA WorkManager from JNDI.
This is for example appropriate on the Geronimo application server, where
WorkManager GBeans (e.g. Geronimo's default "DefaultWorkManager" GBean)
can be linked into the J2EE environment through "gbean-ref" entries
in the geronimo-web.xml
deployment descriptor.
On JBoss and GlassFish, obtaining the default JCA WorkManager
requires special lookup steps. See the
JBossWorkManagerTaskExecutor
GlassFishWorkManagerTaskExecutor
classes which are the direct equivalent of this generic JCA adapter class.
setWorkManager(javax.resource.spi.work.WorkManager)
,
WorkManager.scheduleWork(javax.resource.spi.work.Work)
Field Summary |
---|
Fields inherited from class org.springframework.jndi.JndiLocatorSupport |
---|
CONTAINER_PREFIX |
Fields inherited from class org.springframework.jndi.JndiAccessor |
---|
logger |
Fields inherited from interface org.springframework.core.task.AsyncTaskExecutor |
---|
TIMEOUT_IMMEDIATE, TIMEOUT_INDEFINITE |
Fields inherited from interface javax.resource.spi.work.WorkManager |
---|
IMMEDIATE, INDEFINITE, UNKNOWN |
Constructor Summary | |
---|---|
WorkManagerTaskExecutor()
Create a new WorkManagerTaskExecutor, expecting bean-style configuration. |
|
WorkManagerTaskExecutor(javax.resource.spi.work.WorkManager workManager)
Create a new WorkManagerTaskExecutor for the given WorkManager. |
Method Summary | ||
---|---|---|
void |
afterPropertiesSet()
|
|
void |
doWork(javax.resource.spi.work.Work work)
|
|
void |
doWork(javax.resource.spi.work.Work work,
long delay,
javax.resource.spi.work.ExecutionContext executionContext,
javax.resource.spi.work.WorkListener workListener)
|
|
void |
execute(java.lang.Runnable task)
|
|
void |
execute(java.lang.Runnable task,
long startTimeout)
|
|
protected javax.resource.spi.work.WorkManager |
getDefaultWorkManager()
Obtain a default WorkManager to delegate to. |
|
boolean |
prefersShortLivedTasks()
This task executor prefers short-lived work units. |
|
void |
scheduleWork(javax.resource.spi.work.Work work)
|
|
void |
scheduleWork(javax.resource.spi.work.Work work,
long delay,
javax.resource.spi.work.ExecutionContext executionContext,
javax.resource.spi.work.WorkListener workListener)
|
|
void |
setBlockUntilCompleted(boolean blockUntilCompleted)
Set whether to let execute(java.lang.Runnable) block until the work
has been completed. |
|
void |
setBlockUntilStarted(boolean blockUntilStarted)
Set whether to let execute(java.lang.Runnable) block until the work
has been actually started. |
|
void |
setBootstrapContext(javax.resource.spi.BootstrapContext bootstrapContext)
Specify the JCA BootstrapContext that contains the WorkManager to delegate to. |
|
void |
setWorkListener(javax.resource.spi.work.WorkListener workListener)
Specify a JCA 1.5 WorkListener to apply, if any. |
|
void |
setWorkManager(javax.resource.spi.work.WorkManager workManager)
Specify the JCA WorkManager instance to delegate to. |
|
void |
setWorkManagerName(java.lang.String workManagerName)
Set the JNDI name of the JCA WorkManager. |
|
long |
startWork(javax.resource.spi.work.Work work)
|
|
long |
startWork(javax.resource.spi.work.Work work,
long delay,
javax.resource.spi.work.ExecutionContext executionContext,
javax.resource.spi.work.WorkListener workListener)
|
|
|
submit(java.util.concurrent.Callable<T> task)
|
|
java.util.concurrent.Future<?> |
submit(java.lang.Runnable task)
|
Methods inherited from class org.springframework.jndi.JndiLocatorSupport |
---|
convertJndiName, isResourceRef, lookup, lookup, setResourceRef |
Methods inherited from class org.springframework.jndi.JndiAccessor |
---|
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WorkManagerTaskExecutor()
setWorkManager(javax.resource.spi.work.WorkManager)
public WorkManagerTaskExecutor(javax.resource.spi.work.WorkManager workManager)
workManager
- the JCA WorkManager to delegate toMethod Detail |
---|
public void setWorkManager(javax.resource.spi.work.WorkManager workManager)
public void setWorkManagerName(java.lang.String workManagerName)
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".
setWorkManager(javax.resource.spi.work.WorkManager)
,
JndiLocatorSupport.setResourceRef(boolean)
public void setBootstrapContext(javax.resource.spi.BootstrapContext bootstrapContext)
setBootstrapContext
in interface BootstrapContextAware
bootstrapContext
- BootstrapContext object to be used by this objectInitializingBean.afterPropertiesSet()
,
ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
public void setBlockUntilStarted(boolean blockUntilStarted)
execute(java.lang.Runnable)
block until the work
has been actually started.
Uses the JCA startWork
operation underneath,
instead of the default scheduleWork
.
WorkManager.startWork(javax.resource.spi.work.Work)
,
WorkManager.scheduleWork(javax.resource.spi.work.Work)
public void setBlockUntilCompleted(boolean blockUntilCompleted)
execute(java.lang.Runnable)
block until the work
has been completed.
Uses the JCA doWork
operation underneath,
instead of the default scheduleWork
.
WorkManager.doWork(javax.resource.spi.work.Work)
,
WorkManager.scheduleWork(javax.resource.spi.work.Work)
public void setWorkListener(javax.resource.spi.work.WorkListener workListener)
This shared WorkListener instance will be passed on to the
WorkManager by all execute(java.lang.Runnable)
calls on this TaskExecutor.
public void afterPropertiesSet() throws javax.naming.NamingException
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
javax.naming.NamingException
protected javax.resource.spi.work.WorkManager getDefaultWorkManager()
The default implementation returns a SimpleTaskWorkManager
.
Can be overridden in subclasses.
public void execute(java.lang.Runnable task)
execute
in interface java.util.concurrent.Executor
execute
in interface org.springframework.core.task.TaskExecutor
public void execute(java.lang.Runnable task, long startTimeout)
execute
in interface org.springframework.core.task.AsyncTaskExecutor
public java.util.concurrent.Future<?> submit(java.lang.Runnable task)
submit
in interface org.springframework.core.task.AsyncTaskExecutor
public <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
submit
in interface org.springframework.core.task.AsyncTaskExecutor
public boolean prefersShortLivedTasks()
prefersShortLivedTasks
in interface org.springframework.scheduling.SchedulingTaskExecutor
public void doWork(javax.resource.spi.work.Work work) throws javax.resource.spi.work.WorkException
doWork
in interface javax.resource.spi.work.WorkManager
javax.resource.spi.work.WorkException
public void doWork(javax.resource.spi.work.Work work, long delay, javax.resource.spi.work.ExecutionContext executionContext, javax.resource.spi.work.WorkListener workListener) throws javax.resource.spi.work.WorkException
doWork
in interface javax.resource.spi.work.WorkManager
javax.resource.spi.work.WorkException
public long startWork(javax.resource.spi.work.Work work) throws javax.resource.spi.work.WorkException
startWork
in interface javax.resource.spi.work.WorkManager
javax.resource.spi.work.WorkException
public long startWork(javax.resource.spi.work.Work work, long delay, javax.resource.spi.work.ExecutionContext executionContext, javax.resource.spi.work.WorkListener workListener) throws javax.resource.spi.work.WorkException
startWork
in interface javax.resource.spi.work.WorkManager
javax.resource.spi.work.WorkException
public void scheduleWork(javax.resource.spi.work.Work work) throws javax.resource.spi.work.WorkException
scheduleWork
in interface javax.resource.spi.work.WorkManager
javax.resource.spi.work.WorkException
public void scheduleWork(javax.resource.spi.work.Work work, long delay, javax.resource.spi.work.ExecutionContext executionContext, javax.resource.spi.work.WorkListener workListener) throws javax.resource.spi.work.WorkException
scheduleWork
in interface javax.resource.spi.work.WorkManager
javax.resource.spi.work.WorkException
|
spring-tx | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |