1 /*
   2  * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.corba.se.impl.orbutil.threadpool;
  27 
  28 import com.sun.corba.se.spi.orbutil.threadpool.NoSuchThreadPoolException;
  29 import com.sun.corba.se.spi.orbutil.threadpool.ThreadPool;
  30 import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager;
  31 import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolChooser;
  32 
  33 import com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl;
  34 import com.sun.corba.se.impl.orbutil.ORBConstants;
  35 
  36 public class ThreadPoolManagerImpl implements ThreadPoolManager
  37 {
  38     private ThreadPool threadPool ;
  39 
  40     public ThreadPoolManagerImpl( ThreadGroup tg )
  41     {
  42         // Use unbounded threadpool in J2SE ORB
  43         // ThreadPoolManager from s1as appserver code base can be set in the
  44         // ORB. ThreadPools in the appserver are bounded. In that situation
  45         // the ThreadPool in this ThreadPoolManager will have its threads
  46         // die after the idle timeout.
  47         // XXX Should there be cleanup when ORB.shutdown is called if the
  48         // ORB owns the ThreadPool?
  49         threadPool = new ThreadPoolImpl( tg,
  50             ORBConstants.THREADPOOL_DEFAULT_NAME ) ;
  51     }
  52 
  53     /**
  54     * This method will return an instance of the threadpool given a threadpoolId,
  55     * that can be used by any component in the app. server.
  56     *
  57     * @throws NoSuchThreadPoolException thrown when invalid threadpoolId is passed
  58     * as a parameter
  59     */
  60     public ThreadPool getThreadPool(String threadpoolId)
  61         throws NoSuchThreadPoolException {
  62 
  63         return threadPool;
  64     }
  65 
  66     /**
  67     * This method will return an instance of the threadpool given a numeric threadpoolId.
  68     * This method will be used by the ORB to support the functionality of
  69     * dedicated threadpool for EJB beans
  70     *
  71     * @throws NoSuchThreadPoolException thrown when invalidnumericIdForThreadpool is passed
  72     * as a parameter
  73     */
  74     public ThreadPool getThreadPool(int numericIdForThreadpool)
  75         throws NoSuchThreadPoolException {
  76 
  77         return threadPool;
  78     }
  79 
  80     /**
  81     * This method is used to return the numeric id of the threadpool, given a String
  82     * threadpoolId. This is used by the POA interceptors to add the numeric threadpool
  83     * Id, as a tagged component in the IOR. This is used to provide the functionality of
  84     * dedicated threadpool for EJB beans
  85     */
  86     public int  getThreadPoolNumericId(String threadpoolId) {
  87         return 0;
  88     }
  89 
  90     /**
  91     * Return a String Id for a numericId of a threadpool managed by the threadpool
  92     * manager
  93     */
  94     public String getThreadPoolStringId(int numericIdForThreadpool) {
  95        return "";
  96     }
  97 
  98     /**
  99     * Returns the first instance of ThreadPool in the ThreadPoolManager
 100     */
 101     public ThreadPool getDefaultThreadPool() {
 102         return threadPool;
 103     }
 104 
 105     /**
 106      * Return an instance of ThreadPoolChooser based on the componentId that was
 107      * passed as argument
 108      */
 109     public ThreadPoolChooser getThreadPoolChooser(String componentId) {
 110         //FIXME: This method is not used, but should be fixed once
 111         //nio select starts working and we start using ThreadPoolChooser
 112         return null;
 113     }
 114     /**
 115      * Return an instance of ThreadPoolChooser based on the componentIndex that was
 116      * passed as argument. This is added for improved performance so that the caller
 117      * does not have to pay the cost of computing hashcode for the componentId
 118      */
 119     public ThreadPoolChooser getThreadPoolChooser(int componentIndex) {
 120         //FIXME: This method is not used, but should be fixed once
 121         //nio select starts working and we start using ThreadPoolChooser
 122         return null;
 123     }
 124 
 125     /**
 126      * Sets a ThreadPoolChooser for a particular componentId in the ThreadPoolManager. This
 127      * would enable any component to add a ThreadPoolChooser for their specific use
 128      */
 129     public void setThreadPoolChooser(String componentId, ThreadPoolChooser aThreadPoolChooser) {
 130         //FIXME: This method is not used, but should be fixed once
 131         //nio select starts working and we start using ThreadPoolChooser
 132     }
 133 
 134     /**
 135      * Gets the numeric index associated with the componentId specified for a
 136      * ThreadPoolChooser. This method would help the component call the more
 137      * efficient implementation i.e. getThreadPoolChooser(int componentIndex)
 138      */
 139     public int getThreadPoolChooserNumericId(String componentId) {
 140         //FIXME: This method is not used, but should be fixed once
 141         //nio select starts working and we start using ThreadPoolChooser
 142         return 0;
 143     }
 144 
 145 }
 146 
 147 // End of file.