4
|
1 |
/*
|
5555
|
2 |
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
4
|
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
|
5555
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
4
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5555
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
4
|
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 |
*
|
5555
|
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.
|
4
|
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 POARequesHandler that provides policy specific
|
|
45 |
* operations on the POA.
|
|
46 |
*/
|
|
47 |
public class POAPolicyMediatorImpl_R_UDS extends POAPolicyMediatorBase_R {
|
|
48 |
private Servant defaultServant ;
|
|
49 |
|
|
50 |
POAPolicyMediatorImpl_R_UDS( Policies policies, POAImpl poa )
|
|
51 |
{
|
|
52 |
// assert policies.retainServants()
|
|
53 |
super( policies, poa ) ;
|
|
54 |
defaultServant = null ;
|
|
55 |
|
|
56 |
// policies.useDefaultServant()
|
|
57 |
if (!policies.useDefaultServant())
|
|
58 |
throw poa.invocationWrapper().policyMediatorBadPolicyInFactory() ;
|
|
59 |
}
|
|
60 |
|
|
61 |
protected java.lang.Object internalGetServant( byte[] id,
|
|
62 |
String operation ) throws ForwardRequest
|
|
63 |
{
|
|
64 |
Servant servant = internalIdToServant( id ) ;
|
|
65 |
if (servant == null)
|
|
66 |
servant = defaultServant ;
|
|
67 |
|
|
68 |
if (servant == null)
|
|
69 |
throw poa.invocationWrapper().poaNoDefaultServant() ;
|
|
70 |
|
|
71 |
return servant ;
|
|
72 |
}
|
|
73 |
|
|
74 |
public void etherealizeAll()
|
|
75 |
{
|
|
76 |
// NO-OP
|
|
77 |
}
|
|
78 |
|
|
79 |
public ServantManager getServantManager() throws WrongPolicy
|
|
80 |
{
|
|
81 |
throw new WrongPolicy();
|
|
82 |
}
|
|
83 |
|
|
84 |
public void setServantManager( ServantManager servantManager ) throws WrongPolicy
|
|
85 |
{
|
|
86 |
throw new WrongPolicy();
|
|
87 |
}
|
|
88 |
|
|
89 |
public Servant getDefaultServant() throws NoServant, WrongPolicy
|
|
90 |
{
|
|
91 |
if (defaultServant == null)
|
|
92 |
throw new NoServant();
|
|
93 |
else
|
|
94 |
return defaultServant;
|
|
95 |
}
|
|
96 |
|
|
97 |
public void setDefaultServant( Servant servant ) throws WrongPolicy
|
|
98 |
{
|
|
99 |
defaultServant = servant;
|
|
100 |
setDelegate(defaultServant, "DefaultServant".getBytes());
|
|
101 |
}
|
|
102 |
|
|
103 |
public Servant idToServant( byte[] id )
|
|
104 |
throws WrongPolicy, ObjectNotActive
|
|
105 |
{
|
|
106 |
ActiveObjectMap.Key key = new ActiveObjectMap.Key( id ) ;
|
|
107 |
Servant s = internalKeyToServant(key);
|
|
108 |
|
|
109 |
if (s == null)
|
|
110 |
if (defaultServant != null)
|
|
111 |
s = defaultServant;
|
|
112 |
|
|
113 |
if (s == null)
|
|
114 |
throw new ObjectNotActive() ;
|
|
115 |
|
|
116 |
return s;
|
|
117 |
}
|
|
118 |
}
|