From a95eb1d0444adc50478e47afddaefe00c4910faa Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 4 Nov 2013 16:22:46 +0100 Subject: [PATCH] Polishing (selectively backported from recent 4.0 commits) --- .../commonj/WorkManagerTaskExecutor.java | 33 ++++++------------- .../java/org/springframework/cache/Cache.java | 14 +++++--- .../GlassFishWorkManagerTaskExecutor.java | 8 ++--- .../jboss/JBossWorkManagerTaskExecutor.java | 6 +++- .../jca/work/jboss/JBossWorkManagerUtils.java | 4 +-- 5 files changed, 30 insertions(+), 35 deletions(-) diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java index 4d1518dfa9a..49957521095 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -17,10 +17,9 @@ package org.springframework.scheduling.commonj; import java.util.Collection; +import java.util.concurrent.Callable; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; -import java.util.concurrent.Callable; - import javax.naming.NamingException; import commonj.work.Work; @@ -54,10 +53,8 @@ import org.springframework.util.Assert; * server's JNDI environment, as defined in the server's management console. * *

Note: At the time of this writing, the CommonJ WorkManager facility - * is only supported on IBM WebSphere 6.0+ and BEA WebLogic 9.0+, + * is only supported on IBM WebSphere 6.1+ and BEA WebLogic 9.0+, * despite being such a crucial API for an application server. - * (There is a similar facility available on WebSphere 5.1 Enterprise, - * though, which we will discuss below.) * *

On JBoss and GlassFish, a similar facility is available through * the JCA WorkManager. See the @@ -80,8 +77,7 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport /** * Specify the CommonJ WorkManager to delegate to. - *

Alternatively, you can also specify the JNDI name - * of the target WorkManager. + *

Alternatively, you can also specify the JNDI name of the target WorkManager. * @see #setWorkManagerName */ public void setWorkManager(WorkManager workManager) { @@ -90,9 +86,8 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport /** * Set the JNDI name of the CommonJ WorkManager. - *

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

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 */ @@ -170,27 +165,19 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport // Implementation of the CommonJ WorkManager interface //------------------------------------------------------------------------- - public WorkItem schedule(Work work) - throws WorkException, IllegalArgumentException { - + public WorkItem schedule(Work work) throws WorkException, IllegalArgumentException { return this.workManager.schedule(work); } - public WorkItem schedule(Work work, WorkListener workListener) - throws WorkException, IllegalArgumentException { - + public WorkItem schedule(Work work, WorkListener workListener) throws WorkException { return this.workManager.schedule(work, workListener); } - public boolean waitForAll(Collection workItems, long timeout) - throws InterruptedException, IllegalArgumentException { - + public boolean waitForAll(Collection workItems, long timeout) throws InterruptedException { return this.workManager.waitForAll(workItems, timeout); } - public Collection waitForAny(Collection workItems, long timeout) - throws InterruptedException, IllegalArgumentException { - + public Collection waitForAny(Collection workItems, long timeout) throws InterruptedException { return this.workManager.waitForAny(workItems, timeout); } diff --git a/spring-context/src/main/java/org/springframework/cache/Cache.java b/spring-context/src/main/java/org/springframework/cache/Cache.java index dbfa1cba84b..8a9109afc92 100644 --- a/spring-context/src/main/java/org/springframework/cache/Cache.java +++ b/spring-context/src/main/java/org/springframework/cache/Cache.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -39,11 +39,15 @@ public interface Cache { Object getNativeCache(); /** - * Return the value to which this cache maps the specified key. Returns - * {@code null} if the cache contains no mapping for this key. - * @param key key whose associated value is to be returned. + * Return the value to which this cache maps the specified key. + *

Returns {@code null} if the cache contains no mapping for this key; + * otherwise, the cached value (which may be {@code null} itself) will + * be returned in a {@link ValueWrapper}. + * @param key the key whose associated value is to be returned * @return the value to which this cache maps the specified key, - * or {@code null} if the cache contains no mapping for this key + * contained within a {@link ValueWrapper} which may also hold + * a cached {@code null} value. A straight {@code null} being + * returned means that the cache contains no mapping for this key. */ ValueWrapper get(Object key); diff --git a/spring-tx/src/main/java/org/springframework/jca/work/glassfish/GlassFishWorkManagerTaskExecutor.java b/spring-tx/src/main/java/org/springframework/jca/work/glassfish/GlassFishWorkManagerTaskExecutor.java index 431884514db..a026b111454 100644 --- a/spring-tx/src/main/java/org/springframework/jca/work/glassfish/GlassFishWorkManagerTaskExecutor.java +++ b/spring-tx/src/main/java/org/springframework/jca/work/glassfish/GlassFishWorkManagerTaskExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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,12 +43,12 @@ public class GlassFishWorkManagerTaskExecutor extends WorkManagerTaskExecutor { public GlassFishWorkManagerTaskExecutor() { try { - Class wmf = getClass().getClassLoader().loadClass(WORK_MANAGER_FACTORY_CLASS); - this.getWorkManagerMethod = wmf.getMethod("getWorkManager", new Class[] {String.class}); + Class wmf = getClass().getClassLoader().loadClass(WORK_MANAGER_FACTORY_CLASS); + this.getWorkManagerMethod = wmf.getMethod("getWorkManager", String.class); } catch (Exception ex) { throw new IllegalStateException( - "Could not initialize GlassFishWorkManagerTaskExecutor because GlassFish API is not available: " + ex); + "Could not initialize GlassFishWorkManagerTaskExecutor because GlassFish API is not available", ex); } } diff --git a/spring-tx/src/main/java/org/springframework/jca/work/jboss/JBossWorkManagerTaskExecutor.java b/spring-tx/src/main/java/org/springframework/jca/work/jboss/JBossWorkManagerTaskExecutor.java index 5abb09231b8..cc605665018 100644 --- a/spring-tx/src/main/java/org/springframework/jca/work/jboss/JBossWorkManagerTaskExecutor.java +++ b/spring-tx/src/main/java/org/springframework/jca/work/jboss/JBossWorkManagerTaskExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2013 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. @@ -29,6 +29,10 @@ import org.springframework.jca.work.WorkManagerTaskExecutor; * {@link org.springframework.scheduling.commonj.WorkManagerTaskExecutor} * adapter for WebLogic and WebSphere. * + *

Note: This class does not work on JBoss 7 or higher. + * There is no known immediate replacement, since JBoss does not want + * its JCA WorkManager to be exposed anymore. + * * @author Juergen Hoeller * @since 2.5.2 * @see org.jboss.resource.work.JBossWorkManagerMBean diff --git a/spring-tx/src/main/java/org/springframework/jca/work/jboss/JBossWorkManagerUtils.java b/spring-tx/src/main/java/org/springframework/jca/work/jboss/JBossWorkManagerUtils.java index 7c2757b600c..c2cddcd7988 100644 --- a/spring-tx/src/main/java/org/springframework/jca/work/jboss/JBossWorkManagerUtils.java +++ b/spring-tx/src/main/java/org/springframework/jca/work/jboss/JBossWorkManagerUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2013 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. @@ -69,7 +69,7 @@ public abstract class JBossWorkManagerUtils { } catch (Exception ex) { throw new IllegalStateException( - "Could not initialize JBossWorkManagerTaskExecutor because JBoss API is not available: " + ex); + "Could not initialize JBossWorkManagerTaskExecutor because JBoss API is not available", ex); } }