KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > orbutil > threadpool > ThreadPoolManagerImpl


1 /*
2  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4  */

5
6 package com.sun.corba.se.impl.orbutil.threadpool;
7
8 import com.sun.corba.se.spi.orbutil.threadpool.NoSuchThreadPoolException;
9 import com.sun.corba.se.spi.orbutil.threadpool.ThreadPool;
10 import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager;
11 import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolChooser;
12
13 import com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl;
14 import com.sun.corba.se.impl.orbutil.ORBConstants;
15
16 public class ThreadPoolManagerImpl implements ThreadPoolManager
17 {
18     private ThreadPool threadPool ;
19
20     public ThreadPoolManagerImpl( ThreadGroup JavaDoc tg )
21     {
22     // Use unbounded threadpool in J2SE ORB
23
// ThreadPoolManager from s1as appserver code base can be set in the
24
// ORB. ThreadPools in the appserver are bounded. In that situation
25
// the ThreadPool in this ThreadPoolManager will have its threads
26
// die after the idle timeout.
27
// XXX Should there be cleanup when ORB.shutdown is called if the
28
// ORB owns the ThreadPool?
29
threadPool = new ThreadPoolImpl( tg,
30         ORBConstants.THREADPOOL_DEFAULT_NAME ) ;
31     }
32
33     /**
34     * This method will return an instance of the threadpool given a threadpoolId,
35     * that can be used by any component in the app. server.
36     *
37     * @throws NoSuchThreadPoolException thrown when invalid threadpoolId is passed
38     * as a parameter
39     */

40     public ThreadPool getThreadPool(String JavaDoc threadpoolId)
41         throws NoSuchThreadPoolException {
42             
43         return threadPool;
44     }
45
46     /**
47     * This method will return an instance of the threadpool given a numeric threadpoolId.
48     * This method will be used by the ORB to support the functionality of
49     * dedicated threadpool for EJB beans
50     *
51     * @throws NoSuchThreadPoolException thrown when invalidnumericIdForThreadpool is passed
52     * as a parameter
53     */

54     public ThreadPool getThreadPool(int numericIdForThreadpool)
55         throws NoSuchThreadPoolException {
56
57         return threadPool;
58     }
59
60     /**
61     * This method is used to return the numeric id of the threadpool, given a String
62     * threadpoolId. This is used by the POA interceptors to add the numeric threadpool
63     * Id, as a tagged component in the IOR. This is used to provide the functionality of
64     * dedicated threadpool for EJB beans
65     */

66     public int getThreadPoolNumericId(String JavaDoc threadpoolId) {
67         return 0;
68     }
69
70     /**
71     * Return a String Id for a numericId of a threadpool managed by the threadpool
72     * manager
73     */

74     public String JavaDoc getThreadPoolStringId(int numericIdForThreadpool) {
75        return "";
76     }
77
78     /**
79     * Returns the first instance of ThreadPool in the ThreadPoolManager
80     */

81     public ThreadPool getDefaultThreadPool() {
82         return threadPool;
83     }
84
85     /**
86      * Return an instance of ThreadPoolChooser based on the componentId that was
87      * passed as argument
88      */

89     public ThreadPoolChooser getThreadPoolChooser(String JavaDoc componentId) {
90     //FIXME: This method is not used, but should be fixed once
91
//nio select starts working and we start using ThreadPoolChooser
92
return null;
93     }
94     /**
95      * Return an instance of ThreadPoolChooser based on the componentIndex that was
96      * passed as argument. This is added for improved performance so that the caller
97      * does not have to pay the cost of computing hashcode for the componentId
98      */

99     public ThreadPoolChooser getThreadPoolChooser(int componentIndex) {
100     //FIXME: This method is not used, but should be fixed once
101
//nio select starts working and we start using ThreadPoolChooser
102
return null;
103     }
104
105     /**
106      * Sets a ThreadPoolChooser for a particular componentId in the ThreadPoolManager. This
107      * would enable any component to add a ThreadPoolChooser for their specific use
108      */

109     public void setThreadPoolChooser(String JavaDoc componentId, ThreadPoolChooser aThreadPoolChooser) {
110     //FIXME: This method is not used, but should be fixed once
111
//nio select starts working and we start using ThreadPoolChooser
112
}
113
114     /**
115      * Gets the numeric index associated with the componentId specified for a
116      * ThreadPoolChooser. This method would help the component call the more
117      * efficient implementation i.e. getThreadPoolChooser(int componentIndex)
118      */

119     public int getThreadPoolChooserNumericId(String JavaDoc componentId) {
120     //FIXME: This method is not used, but should be fixed once
121
//nio select starts working and we start using ThreadPoolChooser
122
return 0;
123     }
124
125 }
126
127 // End of file.
128
Popular Tags