KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jca > work > DelegatingWork


1 /*
2  * Copyright 2002-2007 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
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 JavaDoc {
32
33     private final Runnable JavaDoc delegate;
34
35
36     /**
37      * Create a new DelegatingWork.
38      * @param delegate the Runnable implementation to delegate to
39      */

40     public DelegatingWork(Runnable JavaDoc delegate) {
41         Assert.notNull(delegate, "Delegate must not be null");
42         this.delegate = delegate;
43     }
44
45     /**
46      * Return the wrapped Runnable implementation.
47      */

48     public final Runnable JavaDoc getDelegate() {
49         return this.delegate;
50     }
51
52
53     /**
54      * Delegates execution to the underlying Runnable.
55      */

56     public void run() {
57         this.delegate.run();
58     }
59
60     /**
61      * This implementation is empty, since we expect the Runnable
62      * to terminate based on some specific shutdown signal.
63      */

64     public void release() {
65     }
66
67 }
68
Popular Tags