POAPolicyMediatorImpl_R_AOM.java revision 608:7e06bf1dcb09
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
26package com.sun.corba.se.impl.oa.poa ;
27
28import org.omg.PortableServer.Servant ;
29import org.omg.PortableServer.ServantManager ;
30import org.omg.PortableServer.ForwardRequest ;
31import org.omg.PortableServer.POAPackage.WrongPolicy ;
32import org.omg.PortableServer.POAPackage.ObjectNotActive ;
33import org.omg.PortableServer.POAPackage.ServantNotActive ;
34import org.omg.PortableServer.POAPackage.ObjectAlreadyActive ;
35import org.omg.PortableServer.POAPackage.ServantAlreadyActive ;
36import org.omg.PortableServer.POAPackage.NoServant ;
37
38import com.sun.corba.se.impl.orbutil.concurrent.SyncUtil ;
39import com.sun.corba.se.impl.orbutil.ORBUtility ;
40import com.sun.corba.se.impl.orbutil.ORBConstants ;
41
42import com.sun.corba.se.impl.oa.NullServantImpl ;
43
44/** Implementation of POARequesHandler that provides policy specific
45 * operations on the POA in the case:
46 * <ul>
47 * <li>retain</li>
48 * <li>useActiveObjectMapOnly</li>
49 * </ul>
50 */
51public class POAPolicyMediatorImpl_R_AOM extends POAPolicyMediatorBase_R {
52    POAPolicyMediatorImpl_R_AOM( Policies policies, POAImpl poa )
53    {
54        // assert policies.retainServants()
55        super( policies, poa ) ;
56
57        // policies.useActiveObjectMapOnly()
58        if (!policies.useActiveMapOnly())
59            throw poa.invocationWrapper().policyMediatorBadPolicyInFactory() ;
60    }
61
62    protected java.lang.Object internalGetServant( byte[] id,
63        String operation ) throws ForwardRequest
64    {
65        java.lang.Object servant = internalIdToServant( id ) ;
66        if (servant == null)
67            servant = new NullServantImpl(
68                poa.invocationWrapper().nullServant() ) ;
69        return servant ;
70    }
71
72    public void etherealizeAll()
73    {
74        // NO-OP
75    }
76
77    public ServantManager getServantManager() throws WrongPolicy
78    {
79        throw new WrongPolicy();
80    }
81
82    public void setServantManager( ServantManager servantManager )
83        throws WrongPolicy
84    {
85        throw new WrongPolicy();
86    }
87
88    public Servant getDefaultServant() throws NoServant, WrongPolicy
89    {
90        throw new WrongPolicy();
91    }
92
93    public void setDefaultServant( Servant servant ) throws WrongPolicy
94    {
95        throw new WrongPolicy();
96    }
97
98    public Servant idToServant( byte[] id )
99        throws WrongPolicy, ObjectNotActive
100    {
101        Servant s = internalIdToServant( id ) ;
102
103        if (s == null)
104            throw new ObjectNotActive() ;
105        else
106            return s;
107    }
108}
109