1. /*
  2. * @(#)POAPolicyMediatorImpl_NR_UDS.java 1.19 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.impl.oa.poa ;
  8. import java.util.Enumeration ;
  9. import org.omg.PortableServer.Servant ;
  10. import org.omg.PortableServer.ServantManager ;
  11. import org.omg.PortableServer.ForwardRequest ;
  12. import org.omg.PortableServer.POAPackage.WrongPolicy ;
  13. import org.omg.PortableServer.POAPackage.ObjectNotActive ;
  14. import org.omg.PortableServer.POAPackage.ServantNotActive ;
  15. import org.omg.PortableServer.POAPackage.ObjectAlreadyActive ;
  16. import org.omg.PortableServer.POAPackage.ServantAlreadyActive ;
  17. import org.omg.PortableServer.POAPackage.NoServant ;
  18. import com.sun.corba.se.impl.orbutil.concurrent.SyncUtil ;
  19. import com.sun.corba.se.impl.orbutil.ORBUtility ;
  20. import com.sun.corba.se.impl.orbutil.ORBConstants ;
  21. /** Implementation of POAPolicyMediator that provides policy specific
  22. * operations on the POA.
  23. */
  24. public class POAPolicyMediatorImpl_NR_UDS extends POAPolicyMediatorBase {
  25. private Servant defaultServant ;
  26. POAPolicyMediatorImpl_NR_UDS( Policies policies, POAImpl poa )
  27. {
  28. super( policies, poa ) ;
  29. // assert !policies.retainServants() && policies.useDefaultServant()
  30. if (policies.retainServants())
  31. throw poa.invocationWrapper().policyMediatorBadPolicyInFactory() ;
  32. if (!policies.useDefaultServant())
  33. throw poa.invocationWrapper().policyMediatorBadPolicyInFactory() ;
  34. defaultServant = null ;
  35. }
  36. protected java.lang.Object internalGetServant( byte[] id,
  37. String operation ) throws ForwardRequest
  38. {
  39. if (defaultServant == null)
  40. throw poa.invocationWrapper().poaNoDefaultServant() ;
  41. return defaultServant;
  42. }
  43. public void returnServant()
  44. {
  45. // NO-OP
  46. }
  47. public void etherealizeAll()
  48. {
  49. // NO-OP
  50. }
  51. public void clearAOM()
  52. {
  53. // NO-OP
  54. }
  55. public ServantManager getServantManager() throws WrongPolicy
  56. {
  57. throw new WrongPolicy();
  58. }
  59. public void setServantManager( ServantManager servantManager ) throws WrongPolicy
  60. {
  61. throw new WrongPolicy();
  62. }
  63. public Servant getDefaultServant() throws NoServant, WrongPolicy
  64. {
  65. if (defaultServant == null)
  66. throw new NoServant();
  67. return defaultServant;
  68. }
  69. public void setDefaultServant( Servant servant ) throws WrongPolicy
  70. {
  71. this.defaultServant = servant;
  72. setDelegate(defaultServant, "DefaultServant".getBytes());
  73. }
  74. public final void activateObject(byte[] id, Servant servant)
  75. throws WrongPolicy, ServantAlreadyActive, ObjectAlreadyActive
  76. {
  77. throw new WrongPolicy();
  78. }
  79. public Servant deactivateObject( byte[] id ) throws ObjectNotActive, WrongPolicy
  80. {
  81. throw new WrongPolicy();
  82. }
  83. public byte[] servantToId( Servant servant ) throws ServantNotActive, WrongPolicy
  84. {
  85. throw new WrongPolicy();
  86. }
  87. public Servant idToServant( byte[] id )
  88. throws WrongPolicy, ObjectNotActive
  89. {
  90. if (defaultServant != null)
  91. return defaultServant;
  92. throw new ObjectNotActive() ;
  93. }
  94. }