01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.jca.work;
18:
19: import javax.resource.spi.work.Work;
20:
21: import org.springframework.util.Assert;
22:
23: /**
24: * Simple Work adapter that delegates to a given Runnable.
25: *
26: * @author Juergen Hoeller
27: * @since 2.0.3
28: * @see javax.resource.spi.work.Work
29: * @see Runnable
30: */
31: public class DelegatingWork implements Work {
32:
33: private final Runnable delegate;
34:
35: /**
36: * Create a new DelegatingWork.
37: * @param delegate the Runnable implementation to delegate to
38: */
39: public DelegatingWork(Runnable delegate) {
40: Assert.notNull(delegate, "Delegate must not be null");
41: this .delegate = delegate;
42: }
43:
44: /**
45: * Return the wrapped Runnable implementation.
46: */
47: public final Runnable getDelegate() {
48: return this .delegate;
49: }
50:
51: /**
52: * Delegates execution to the underlying Runnable.
53: */
54: public void run() {
55: this .delegate.run();
56: }
57:
58: /**
59: * This implementation is empty, since we expect the Runnable
60: * to terminate based on some specific shutdown signal.
61: */
62: public void release() {
63: }
64:
65: }
|