Polishing

This commit is contained in:
Juergen Hoeller
2012-11-25 22:29:05 +01:00
parent f4532ad704
commit 667438ddb0
7 changed files with 25 additions and 40 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2012 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.
@@ -43,10 +43,15 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T
private volatile ErrorHandler errorHandler;
/**
* Provide an {@link ErrorHandler} strategy.
*/
public void setErrorHandler(ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
}
public ScheduledFuture schedule(Runnable task, Trigger trigger) {
return new ReschedulingTimerListener(errorHandlingTask(task, true), trigger).schedule();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2012 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.
@@ -65,26 +65,6 @@ import org.springframework.util.Assert;
* {@link org.springframework.jca.work.glassfish.GlassFishWorkManagerTaskExecutor}
* classes which are the direct equivalent of this CommonJ adapter class.
*
* <p>A similar facility is available on WebSphere 5.1, under the name
* "Asynch Beans". Its central interface is called WorkManager too and is
* also obtained from JNDI, just like a standard CommonJ WorkManager.
* However, this WorkManager variant is notably different: The central
* execution method is called "startWork" instead of "schedule",
* and takes a slightly different Work interface as parameter.
*
* <p>Support for this WebSphere 5.1 variant can be built with this class
* and its helper DelegatingWork as template: Call the WorkManager's
* <code>startWork(Work)</code> instead of <code>schedule(Work)</code>
* in the <code>execute(Runnable)</code> implementation. Furthermore,
* for simplicity's sake, drop the entire "Implementation of the CommonJ
* WorkManager interface" section (and the corresponding
* <code>implements WorkManager</code> clause at the class level).
* Of course, you also need to change all <code>commonj.work</code> imports in
* your WorkManagerTaskExecutor and DelegatingWork variants to the corresponding
* WebSphere API imports (<code>com.ibm.websphere.asynchbeans.WorkManager</code>
* and <code>com.ibm.websphere.asynchbeans.Work</code>, respectively).
* This should be sufficient to get a TaskExecutor adapter for WebSphere 5.
*
* @author Juergen Hoeller
* @since 2.0
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 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.
@@ -95,8 +95,8 @@ public class SchedulerAccessorBean extends SchedulerAccessor implements BeanFact
if (this.beanFactory instanceof ListableBeanFactory) {
ListableBeanFactory lbf = (ListableBeanFactory) this.beanFactory;
String[] beanNames = lbf.getBeanNamesForType(Scheduler.class);
for (int i = 0; i < beanNames.length; i++) {
Scheduler schedulerBean = (Scheduler) lbf.getBean(beanNames[i]);
for (String beanName : beanNames) {
Scheduler schedulerBean = (Scheduler) lbf.getBean(beanName);
if (schedulerName.equals(schedulerBean.getSchedulerName())) {
return schedulerBean;
}

View File

@@ -56,7 +56,6 @@ class ConfigurationClassEnhancer {
DisposableBeanMethodInterceptor.class, NoOp.class };
private static final CallbackFilter CALLBACK_FILTER = new CallbackFilter() {
public int accept(Method candidateMethod) {
// Set up the callback filter to return the index of the BeanMethodInterceptor when
// handling a @Bean-annotated method; otherwise, return index of the NoOp callback.
@@ -72,7 +71,6 @@ class ConfigurationClassEnhancer {
private static final Callback DISPOSABLE_BEAN_METHOD_INTERCEPTOR = new DisposableBeanMethodInterceptor();
private final Callback[] callbackInstances;
@@ -162,6 +160,7 @@ class ConfigurationClassEnhancer {
private static class GetObjectMethodInterceptor implements MethodInterceptor {
private final ConfigurableBeanFactory beanFactory;
private final String beanName;
public GetObjectMethodInterceptor(ConfigurableBeanFactory beanFactory, String beanName) {
@@ -296,7 +295,8 @@ class ConfigurationClassEnhancer {
this.beanFactory.setCurrentlyInCreation(beanName, false);
}
return this.beanFactory.getBean(beanName);
} finally {
}
finally {
if (alreadyInCreation) {
this.beanFactory.setCurrentlyInCreation(beanName, true);
}
@@ -347,6 +347,6 @@ class ConfigurationClassEnhancer {
Enhancer.registerCallbacks(fbSubclass, callbackInstances);
return fbSubclass.newInstance();
}
}
}

View File

@@ -3,20 +3,20 @@
*
* <p>Base classes to make implementing EJB 2.x beans simpler and less error-prone,
* as well as guaranteeing a Spring BeanFactory is available to such EJBs.
* This promotes good practice, with EJB services used for transaction
* This promotes good EJB practice, with EJB services used for transaction
* management, thread management, and (possibly) remoting, while
* business logic is implemented in easily testable POJOs.</p>
*
*
* <p>In this model, the EJB is a facade, with as many POJO helpers
* behind the BeanFactory as required.</p>
*
* <p>Note that the default behavior is to look for an EJB enviroment variable
*
* <p>Note that the default behavior is to look for an EJB environment variable
* with name <code>ejb/BeanFactoryPath</code> that specifies the
* location <i>on the classpath</i> of an XML bean factory definition
* file (such as <code>/com/mycom/mypackage/mybeans.xml</code>).
* If this JNDI key is missing, your EJB subclass won't successfully
* initialize in the container.</p>
*
*
* <p><b>Check out the <code>org.springframework.ejb.interceptor</code>
* package for equivalent support for the EJB 3 component model</b>,
* providing annotation-based autowiring using an EJB 3 interceptor.</p>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 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.
@@ -21,14 +21,14 @@ package org.springframework.util;
* errors that occur during asynchronous execution of tasks that have been
* submitted to a TaskScheduler. In such cases, it may not be possible to
* throw the error to the original caller.
*
*
* @author Mark Fisher
* @since 3.0.
* @since 3.0
*/
public interface ErrorHandler {
/**
* Handle the given error, possibly rethrowing it as a fatal exception
* Handle the given error, possibly rethrowing it as a fatal exception.
*/
void handleError(Throwable t);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2012 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.
@@ -70,7 +70,7 @@ import org.springframework.util.Assert;
* @see javax.resource.spi.work.WorkManager#scheduleWork
*/
public class WorkManagerTaskExecutor extends JndiLocatorSupport
implements SchedulingTaskExecutor, AsyncTaskExecutor, WorkManager, BootstrapContextAware, InitializingBean {
implements SchedulingTaskExecutor, WorkManager, BootstrapContextAware, InitializingBean {
private WorkManager workManager;