From 667438ddb05c414d4b1f1274f4112f105f0f2523 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sun, 25 Nov 2012 22:29:05 +0100 Subject: [PATCH] Polishing --- .../commonj/TimerManagerTaskScheduler.java | 7 +++++- .../commonj/WorkManagerTaskExecutor.java | 22 +------------------ .../quartz/SchedulerAccessorBean.java | 6 ++--- .../ConfigurationClassEnhancer.java | 8 +++---- .../ejb/support/package-info.java | 10 ++++----- .../springframework/util/ErrorHandler.java | 8 +++---- .../jca/work/WorkManagerTaskExecutor.java | 4 ++-- 7 files changed, 25 insertions(+), 40 deletions(-) diff --git a/org.springframework.context.support/src/main/java/org/springframework/scheduling/commonj/TimerManagerTaskScheduler.java b/org.springframework.context.support/src/main/java/org/springframework/scheduling/commonj/TimerManagerTaskScheduler.java index 8d0f0795bc..76714ce5f2 100644 --- a/org.springframework.context.support/src/main/java/org/springframework/scheduling/commonj/TimerManagerTaskScheduler.java +++ b/org.springframework.context.support/src/main/java/org/springframework/scheduling/commonj/TimerManagerTaskScheduler.java @@ -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(); } diff --git a/org.springframework.context.support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java b/org.springframework.context.support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java index e1d2cb0911..4d1518dfa9 100644 --- a/org.springframework.context.support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java +++ b/org.springframework.context.support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java @@ -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. * - *

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. - * - *

Support for this WebSphere 5.1 variant can be built with this class - * and its helper DelegatingWork as template: Call the WorkManager's - * startWork(Work) instead of schedule(Work) - * in the execute(Runnable) implementation. Furthermore, - * for simplicity's sake, drop the entire "Implementation of the CommonJ - * WorkManager interface" section (and the corresponding - * implements WorkManager clause at the class level). - * Of course, you also need to change all commonj.work imports in - * your WorkManagerTaskExecutor and DelegatingWork variants to the corresponding - * WebSphere API imports (com.ibm.websphere.asynchbeans.WorkManager - * and com.ibm.websphere.asynchbeans.Work, respectively). - * This should be sufficient to get a TaskExecutor adapter for WebSphere 5. - * * @author Juergen Hoeller * @since 2.0 */ diff --git a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessorBean.java b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessorBean.java index d02689462d..9c69a47c00 100644 --- a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessorBean.java +++ b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessorBean.java @@ -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; } diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java index af6515c774..e4d23a2274 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java @@ -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(); } - } + } diff --git a/org.springframework.context/src/main/java/org/springframework/ejb/support/package-info.java b/org.springframework.context/src/main/java/org/springframework/ejb/support/package-info.java index 9487c5ca99..185a3a5002 100644 --- a/org.springframework.context/src/main/java/org/springframework/ejb/support/package-info.java +++ b/org.springframework.context/src/main/java/org/springframework/ejb/support/package-info.java @@ -3,20 +3,20 @@ * *

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.

- * + * *

In this model, the EJB is a facade, with as many POJO helpers * behind the BeanFactory as required.

- * - *

Note that the default behavior is to look for an EJB enviroment variable + * + *

Note that the default behavior is to look for an EJB environment variable * with name ejb/BeanFactoryPath that specifies the * location on the classpath of an XML bean factory definition * file (such as /com/mycom/mypackage/mybeans.xml). * If this JNDI key is missing, your EJB subclass won't successfully * initialize in the container.

- * + * *

Check out the org.springframework.ejb.interceptor * package for equivalent support for the EJB 3 component model, * providing annotation-based autowiring using an EJB 3 interceptor.

diff --git a/org.springframework.core/src/main/java/org/springframework/util/ErrorHandler.java b/org.springframework.core/src/main/java/org/springframework/util/ErrorHandler.java index 10e9daf0d0..a43ee8b659 100644 --- a/org.springframework.core/src/main/java/org/springframework/util/ErrorHandler.java +++ b/org.springframework.core/src/main/java/org/springframework/util/ErrorHandler.java @@ -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); diff --git a/org.springframework.transaction/src/main/java/org/springframework/jca/work/WorkManagerTaskExecutor.java b/org.springframework.transaction/src/main/java/org/springframework/jca/work/WorkManagerTaskExecutor.java index 4e06eeeb29..ac03decd34 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/jca/work/WorkManagerTaskExecutor.java +++ b/org.springframework.transaction/src/main/java/org/springframework/jca/work/WorkManagerTaskExecutor.java @@ -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;