Skip to content

Commit a95eb1d

Browse files
committed
Polishing (selectively backported from recent 4.0 commits)
1 parent b00c31a commit a95eb1d

File tree

5 files changed

+30
-35
lines changed

5 files changed

+30
-35
lines changed

spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java

+10-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,10 +17,9 @@
1717
package org.springframework.scheduling.commonj;
1818

1919
import java.util.Collection;
20+
import java.util.concurrent.Callable;
2021
import java.util.concurrent.Future;
2122
import java.util.concurrent.FutureTask;
22-
import java.util.concurrent.Callable;
23-
2423
import javax.naming.NamingException;
2524

2625
import commonj.work.Work;
@@ -54,10 +53,8 @@
5453
* server's JNDI environment, as defined in the server's management console.
5554
*
5655
* <p><b>Note: At the time of this writing, the CommonJ WorkManager facility
57-
* is only supported on IBM WebSphere 6.0+ and BEA WebLogic 9.0+,
56+
* is only supported on IBM WebSphere 6.1+ and BEA WebLogic 9.0+,
5857
* despite being such a crucial API for an application server.</b>
59-
* (There is a similar facility available on WebSphere 5.1 Enterprise,
60-
* though, which we will discuss below.)
6158
*
6259
* <p><b>On JBoss and GlassFish, a similar facility is available through
6360
* the JCA WorkManager.</b> See the
@@ -80,8 +77,7 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport
8077

8178
/**
8279
* Specify the CommonJ WorkManager to delegate to.
83-
* <p>Alternatively, you can also specify the JNDI name
84-
* of the target WorkManager.
80+
* <p>Alternatively, you can also specify the JNDI name of the target WorkManager.
8581
* @see #setWorkManagerName
8682
*/
8783
public void setWorkManager(WorkManager workManager) {
@@ -90,9 +86,8 @@ public void setWorkManager(WorkManager workManager) {
9086

9187
/**
9288
* Set the JNDI name of the CommonJ WorkManager.
93-
* <p>This can either be a fully qualified JNDI name,
94-
* or the JNDI name relative to the current environment
95-
* naming context if "resourceRef" is set to "true".
89+
* <p>This can either be a fully qualified JNDI name, or the JNDI name relative
90+
* to the current environment naming context if "resourceRef" is set to "true".
9691
* @see #setWorkManager
9792
* @see #setResourceRef
9893
*/
@@ -170,27 +165,19 @@ public boolean prefersShortLivedTasks() {
170165
// Implementation of the CommonJ WorkManager interface
171166
//-------------------------------------------------------------------------
172167

173-
public WorkItem schedule(Work work)
174-
throws WorkException, IllegalArgumentException {
175-
168+
public WorkItem schedule(Work work) throws WorkException, IllegalArgumentException {
176169
return this.workManager.schedule(work);
177170
}
178171

179-
public WorkItem schedule(Work work, WorkListener workListener)
180-
throws WorkException, IllegalArgumentException {
181-
172+
public WorkItem schedule(Work work, WorkListener workListener) throws WorkException {
182173
return this.workManager.schedule(work, workListener);
183174
}
184175

185-
public boolean waitForAll(Collection workItems, long timeout)
186-
throws InterruptedException, IllegalArgumentException {
187-
176+
public boolean waitForAll(Collection workItems, long timeout) throws InterruptedException {
188177
return this.workManager.waitForAll(workItems, timeout);
189178
}
190179

191-
public Collection waitForAny(Collection workItems, long timeout)
192-
throws InterruptedException, IllegalArgumentException {
193-
180+
public Collection waitForAny(Collection workItems, long timeout) throws InterruptedException {
194181
return this.workManager.waitForAny(workItems, timeout);
195182
}
196183

spring-context/src/main/java/org/springframework/cache/Cache.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,11 +39,15 @@ public interface Cache {
3939
Object getNativeCache();
4040

4141
/**
42-
* Return the value to which this cache maps the specified key. Returns
43-
* {@code null} if the cache contains no mapping for this key.
44-
* @param key key whose associated value is to be returned.
42+
* Return the value to which this cache maps the specified key.
43+
* <p>Returns {@code null} if the cache contains no mapping for this key;
44+
* otherwise, the cached value (which may be {@code null} itself) will
45+
* be returned in a {@link ValueWrapper}.
46+
* @param key the key whose associated value is to be returned
4547
* @return the value to which this cache maps the specified key,
46-
* or {@code null} if the cache contains no mapping for this key
48+
* contained within a {@link ValueWrapper} which may also hold
49+
* a cached {@code null} value. A straight {@code null} being
50+
* returned means that the cache contains no mapping for this key.
4751
*/
4852
ValueWrapper get(Object key);
4953

spring-tx/src/main/java/org/springframework/jca/work/glassfish/GlassFishWorkManagerTaskExecutor.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,12 +43,12 @@ public class GlassFishWorkManagerTaskExecutor extends WorkManagerTaskExecutor {
4343

4444
public GlassFishWorkManagerTaskExecutor() {
4545
try {
46-
Class wmf = getClass().getClassLoader().loadClass(WORK_MANAGER_FACTORY_CLASS);
47-
this.getWorkManagerMethod = wmf.getMethod("getWorkManager", new Class[] {String.class});
46+
Class<?> wmf = getClass().getClassLoader().loadClass(WORK_MANAGER_FACTORY_CLASS);
47+
this.getWorkManagerMethod = wmf.getMethod("getWorkManager", String.class);
4848
}
4949
catch (Exception ex) {
5050
throw new IllegalStateException(
51-
"Could not initialize GlassFishWorkManagerTaskExecutor because GlassFish API is not available: " + ex);
51+
"Could not initialize GlassFishWorkManagerTaskExecutor because GlassFish API is not available", ex);
5252
}
5353
}
5454

spring-tx/src/main/java/org/springframework/jca/work/jboss/JBossWorkManagerTaskExecutor.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,10 @@
2929
* {@link org.springframework.scheduling.commonj.WorkManagerTaskExecutor}
3030
* adapter for WebLogic and WebSphere.
3131
*
32+
* <p><b>Note: This class does not work on JBoss 7 or higher.</b>
33+
* There is no known immediate replacement, since JBoss does not want
34+
* its JCA WorkManager to be exposed anymore.
35+
*
3236
* @author Juergen Hoeller
3337
* @since 2.5.2
3438
* @see org.jboss.resource.work.JBossWorkManagerMBean

spring-tx/src/main/java/org/springframework/jca/work/jboss/JBossWorkManagerUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,7 +69,7 @@ public static WorkManager getWorkManager(String mbeanName) {
6969
}
7070
catch (Exception ex) {
7171
throw new IllegalStateException(
72-
"Could not initialize JBossWorkManagerTaskExecutor because JBoss API is not available: " + ex);
72+
"Could not initialize JBossWorkManagerTaskExecutor because JBoss API is not available", ex);
7373
}
7474
}
7575

0 commit comments

Comments
 (0)