1. /*
  2. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package com.sun.corba.se.impl.orbutil.threadpool;
  6. import com.sun.corba.se.spi.orbutil.threadpool.NoSuchThreadPoolException;
  7. import com.sun.corba.se.spi.orbutil.threadpool.ThreadPool;
  8. import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager;
  9. import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolChooser;
  10. import com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl;
  11. import com.sun.corba.se.impl.orbutil.ORBConstants;
  12. public class ThreadPoolManagerImpl implements ThreadPoolManager
  13. {
  14. private ThreadPool threadPool ;
  15. public ThreadPoolManagerImpl( ThreadGroup tg )
  16. {
  17. // Use unbounded threadpool in J2SE ORB
  18. // ThreadPoolManager from s1as appserver code base can be set in the
  19. // ORB. ThreadPools in the appserver are bounded. In that situation
  20. // the ThreadPool in this ThreadPoolManager will have its threads
  21. // die after the idle timeout.
  22. // XXX Should there be cleanup when ORB.shutdown is called if the
  23. // ORB owns the ThreadPool?
  24. threadPool = new ThreadPoolImpl( tg,
  25. ORBConstants.THREADPOOL_DEFAULT_NAME ) ;
  26. }
  27. /**
  28. * This method will return an instance of the threadpool given a threadpoolId,
  29. * that can be used by any component in the app. server.
  30. *
  31. * @throws NoSuchThreadPoolException thrown when invalid threadpoolId is passed
  32. * as a parameter
  33. */
  34. public ThreadPool getThreadPool(String threadpoolId)
  35. throws NoSuchThreadPoolException {
  36. return threadPool;
  37. }
  38. /**
  39. * This method will return an instance of the threadpool given a numeric threadpoolId.
  40. * This method will be used by the ORB to support the functionality of
  41. * dedicated threadpool for EJB beans
  42. *
  43. * @throws NoSuchThreadPoolException thrown when invalidnumericIdForThreadpool is passed
  44. * as a parameter
  45. */
  46. public ThreadPool getThreadPool(int numericIdForThreadpool)
  47. throws NoSuchThreadPoolException {
  48. return threadPool;
  49. }
  50. /**
  51. * This method is used to return the numeric id of the threadpool, given a String
  52. * threadpoolId. This is used by the POA interceptors to add the numeric threadpool
  53. * Id, as a tagged component in the IOR. This is used to provide the functionality of
  54. * dedicated threadpool for EJB beans
  55. */
  56. public int getThreadPoolNumericId(String threadpoolId) {
  57. return 0;
  58. }
  59. /**
  60. * Return a String Id for a numericId of a threadpool managed by the threadpool
  61. * manager
  62. */
  63. public String getThreadPoolStringId(int numericIdForThreadpool) {
  64. return "";
  65. }
  66. /**
  67. * Returns the first instance of ThreadPool in the ThreadPoolManager
  68. */
  69. public ThreadPool getDefaultThreadPool() {
  70. return threadPool;
  71. }
  72. /**
  73. * Return an instance of ThreadPoolChooser based on the componentId that was
  74. * passed as argument
  75. */
  76. public ThreadPoolChooser getThreadPoolChooser(String componentId) {
  77. //FIXME: This method is not used, but should be fixed once
  78. //nio select starts working and we start using ThreadPoolChooser
  79. return null;
  80. }
  81. /**
  82. * Return an instance of ThreadPoolChooser based on the componentIndex that was
  83. * passed as argument. This is added for improved performance so that the caller
  84. * does not have to pay the cost of computing hashcode for the componentId
  85. */
  86. public ThreadPoolChooser getThreadPoolChooser(int componentIndex) {
  87. //FIXME: This method is not used, but should be fixed once
  88. //nio select starts working and we start using ThreadPoolChooser
  89. return null;
  90. }
  91. /**
  92. * Sets a ThreadPoolChooser for a particular componentId in the ThreadPoolManager. This
  93. * would enable any component to add a ThreadPoolChooser for their specific use
  94. */
  95. public void setThreadPoolChooser(String componentId, ThreadPoolChooser aThreadPoolChooser) {
  96. //FIXME: This method is not used, but should be fixed once
  97. //nio select starts working and we start using ThreadPoolChooser
  98. }
  99. /**
  100. * Gets the numeric index associated with the componentId specified for a
  101. * ThreadPoolChooser. This method would help the component call the more
  102. * efficient implementation i.e. getThreadPoolChooser(int componentIndex)
  103. */
  104. public int getThreadPoolChooserNumericId(String componentId) {
  105. //FIXME: This method is not used, but should be fixed once
  106. //nio select starts working and we start using ThreadPoolChooser
  107. return 0;
  108. }
  109. }
  110. // End of file.