1 /*
   2  * Copyright (c) 2002, 2003, 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.oa.poa ;
  27 
  28 import java.util.Enumeration ;
  29 
  30 import org.omg.PortableServer.Servant ;
  31 import org.omg.PortableServer.ServantManager ;
  32 import org.omg.PortableServer.ForwardRequest ;
  33 import org.omg.PortableServer.POAPackage.WrongPolicy ;
  34 import org.omg.PortableServer.POAPackage.ObjectNotActive ;
  35 import org.omg.PortableServer.POAPackage.ServantNotActive ;
  36 import org.omg.PortableServer.POAPackage.ObjectAlreadyActive ;
  37 import org.omg.PortableServer.POAPackage.ServantAlreadyActive ;
  38 import org.omg.PortableServer.POAPackage.NoServant ;
  39 
  40 import com.sun.corba.se.impl.orbutil.concurrent.SyncUtil ;
  41 import com.sun.corba.se.impl.orbutil.ORBUtility ;
  42 import com.sun.corba.se.impl.orbutil.ORBConstants ;
  43 
  44 /** Implementation of POAPolicyMediator that provides policy specific
  45  * operations on the POA.
  46  */
  47 public class POAPolicyMediatorImpl_NR_UDS extends POAPolicyMediatorBase {
  48     private Servant defaultServant ;
  49 
  50     POAPolicyMediatorImpl_NR_UDS( Policies policies, POAImpl poa )
  51     {
  52         super( policies, poa ) ;
  53 
  54         // assert !policies.retainServants() && policies.useDefaultServant()
  55         if (policies.retainServants())
  56             throw poa.invocationWrapper().policyMediatorBadPolicyInFactory() ;
  57 
  58         if (!policies.useDefaultServant())
  59             throw poa.invocationWrapper().policyMediatorBadPolicyInFactory() ;
  60 
  61         defaultServant = null ;
  62     }
  63 
  64     protected java.lang.Object internalGetServant( byte[] id,
  65         String operation ) throws ForwardRequest
  66     {
  67         if (defaultServant == null)
  68             throw poa.invocationWrapper().poaNoDefaultServant() ;
  69 
  70         return defaultServant;
  71     }
  72 
  73     public void returnServant()
  74     {
  75         // NO-OP
  76     }
  77 
  78     public void etherealizeAll()
  79     {
  80         // NO-OP
  81     }
  82 
  83     public void clearAOM()
  84     {
  85         // NO-OP
  86     }
  87 
  88     public ServantManager getServantManager() throws WrongPolicy
  89     {
  90         throw new WrongPolicy();
  91     }
  92 
  93     public void setServantManager( ServantManager servantManager ) throws WrongPolicy
  94     {
  95         throw new WrongPolicy();
  96     }
  97 
  98     public Servant getDefaultServant() throws NoServant, WrongPolicy
  99     {
 100         if (defaultServant == null)
 101             throw new NoServant();
 102         return defaultServant;
 103     }
 104 
 105     public void setDefaultServant( Servant servant ) throws WrongPolicy
 106     {
 107         this.defaultServant = servant;
 108         setDelegate(defaultServant, "DefaultServant".getBytes());
 109     }
 110 
 111     public final void activateObject(byte[] id, Servant servant)
 112         throws WrongPolicy, ServantAlreadyActive, ObjectAlreadyActive
 113     {
 114         throw new WrongPolicy();
 115     }
 116 
 117     public Servant deactivateObject( byte[] id ) throws ObjectNotActive, WrongPolicy
 118     {
 119         throw new WrongPolicy();
 120     }
 121 
 122     public byte[] servantToId( Servant servant ) throws ServantNotActive, WrongPolicy
 123     {
 124         throw new WrongPolicy();
 125     }
 126 
 127     public Servant idToServant( byte[] id )
 128         throws WrongPolicy, ObjectNotActive
 129     {
 130         if (defaultServant != null)
 131             return defaultServant;
 132 
 133         throw new ObjectNotActive() ;
 134     }
 135 }