KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > ejb > containers > util > WorkAdapter


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.ejb.containers.util;
25
26 import com.sun.corba.ee.spi.orbutil.threadpool.Work;
27 import com.sun.corba.ee.spi.orbutil.threadpool.ThreadPoolManager;
28 import com.sun.corba.ee.spi.orbutil.threadpool.ThreadPool;
29 import com.sun.enterprise.util.S1ASThreadPoolManager;
30 import com.sun.enterprise.util.ORBManager;
31 import com.sun.enterprise.util.threadpool.Servicable;
32
33 /**
34  * An adapter class that adapts Servicable interface to the new Work interface
35  */

36 public class WorkAdapter
37     implements Work
38 {
39     private long enqueTime;
40     private Servicable delegate;
41
42     //This class delibarately doesn't define a no arg constructor
43
//Once we identify all the code that use Servicable interface,
44
// we can make this class as abstract and all the container
45
// classes must extend this abstract class instead of
46
// imoplementing the Servicable interface
47

48     public WorkAdapter(Servicable delegate) {
49         this.delegate = delegate;
50     }
51
52     public void setEnqueueTime(long timeInMillis) {
53         enqueTime = timeInMillis;
54     }
55
56     public long getEnqueueTime() {
57         return enqueTime;
58     }
59     
60     public void doWork() {
61         if (delegate != null) {
62             delegate.service();
63         }
64     }
65         
66     public String JavaDoc getName() {
67         return "WorkAdapter";
68     }
69
70 }
71
Popular Tags