|
Spring Framework example source code file (WorkManagerTaskExecutor.java)
The Spring Framework WorkManagerTaskExecutor.java source code/* * Copyright 2002-2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.jca.work; import javax.naming.NamingException; import javax.resource.spi.BootstrapContext; import javax.resource.spi.work.ExecutionContext; import javax.resource.spi.work.Work; import javax.resource.spi.work.WorkException; import javax.resource.spi.work.WorkListener; import javax.resource.spi.work.WorkManager; import javax.resource.spi.work.WorkRejectedException; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.core.task.TaskRejectedException; import org.springframework.core.task.TaskTimeoutException; import org.springframework.jca.context.BootstrapContextAware; import org.springframework.jndi.JndiLocatorSupport; import org.springframework.scheduling.SchedulingException; import org.springframework.scheduling.SchedulingTaskExecutor; import org.springframework.util.Assert; /** * {@link org.springframework.core.task.TaskExecutor} implementation * that delegates to a JCA 1.5 WorkManager, implementing the * {@link javax.resource.spi.work.WorkManager} interface. * * <p>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). * * <p>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. * * <p>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 <code>geronimo-web.xml deployment descriptor. * * <p>On JBoss and GlassFish, obtaining the default JCA WorkManager * requires special lookup steps.</b> See the * {@link org.springframework.jca.work.jboss.JBossWorkManagerTaskExecutor} * {@link org.springframework.jca.work.glassfish.GlassFishWorkManagerTaskExecutor} * classes which are the direct equivalent of this generic JCA adapter class. * * @author Juergen Hoeller * @since 2.0.3 * @see #setWorkManager * @see javax.resource.spi.work.WorkManager#scheduleWork */ public class WorkManagerTaskExecutor extends JndiLocatorSupport implements SchedulingTaskExecutor, AsyncTaskExecutor, WorkManager, BootstrapContextAware, InitializingBean { private WorkManager workManager; private String workManagerName; private boolean blockUntilStarted = false; private boolean blockUntilCompleted = false; private WorkListener workListener; /** * Create a new WorkManagerTaskExecutor, expecting bean-style configuration. * @see #setWorkManager */ public WorkManagerTaskExecutor() { } /** * Create a new WorkManagerTaskExecutor for the given WorkManager. * @param workManager the JCA WorkManager to delegate to */ public WorkManagerTaskExecutor(WorkManager workManager) { setWorkManager(workManager); } /** * Specify the JCA WorkManager instance to delegate to. */ public void setWorkManager(WorkManager workManager) { Assert.notNull(workManager, "WorkManager must not be null"); this.workManager = workManager; } /** * Set the JNDI name of the JCA WorkManager. * <p>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". * @see #setWorkManager * @see #setResourceRef */ public void setWorkManagerName(String workManagerName) { this.workManagerName = workManagerName; } /** * Specify the JCA BootstrapContext that contains the * WorkManager to delegate to. */ public void setBootstrapContext(BootstrapContext bootstrapContext) { Assert.notNull(bootstrapContext, "BootstrapContext must not be null"); this.workManager = bootstrapContext.getWorkManager(); } /** * Set whether to let {@link #execute} block until the work * has been actually started. * <p>Uses the JCA Other Spring Framework examples (source code examples)Here is a short list of links related to this Spring Framework WorkManagerTaskExecutor.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.