40 |
|
|
41 |
import org.omg.CORBA.BAD_INV_ORDER; |
import org.omg.CORBA.BAD_INV_ORDER; |
42 |
import org.omg.CORBA.LocalObject; |
import org.omg.CORBA.LocalObject; |
43 |
|
import org.omg.PortableInterceptor.NON_EXISTENT; |
44 |
|
import org.omg.PortableInterceptor.ObjectReferenceTemplate; |
45 |
import org.omg.PortableServer.POAManager; |
import org.omg.PortableServer.POAManager; |
46 |
import org.omg.PortableServer.POAManagerPackage.AdapterInactive; |
import org.omg.PortableServer.POAManagerPackage.AdapterInactive; |
47 |
import org.omg.PortableServer.POAManagerPackage.State; |
import org.omg.PortableServer.POAManagerPackage.State; |
61 |
extends LocalObject |
extends LocalObject |
62 |
implements POAManager |
implements POAManager |
63 |
{ |
{ |
64 |
|
/** |
65 |
|
* Use serialVersionUID for interoperability. |
66 |
|
*/ |
67 |
|
private static final long serialVersionUID = 1; |
68 |
|
|
69 |
/** |
/** |
70 |
* The POAs, controlled by this manager. The members must be instances of |
* The POAs, controlled by this manager. |
|
* the gnuAbstractPOA. |
|
71 |
*/ |
*/ |
72 |
HashSet POAs = new HashSet(); |
private HashSet POAs = new HashSet(); |
73 |
|
|
74 |
/** |
/** |
75 |
* The state of the manager. The newly created manager is always |
* The state of the manager. The newly created manager is always |
76 |
* in the holding state. |
* in the holding state. |
77 |
*/ |
*/ |
78 |
State state = State.HOLDING; |
State state = State.HOLDING; |
79 |
|
|
80 |
/** |
/** |
81 |
* Get the state of the POA manager. |
* Get the state of the POA manager. |
82 |
*/ |
*/ |
100 |
state = State.ACTIVE; |
state = State.ACTIVE; |
101 |
else |
else |
102 |
throw new AdapterInactive(); |
throw new AdapterInactive(); |
103 |
|
|
104 |
|
notifyInterceptors(state.value()); |
105 |
} |
} |
106 |
|
|
107 |
/** |
/** |
121 |
state = State.HOLDING; |
state = State.HOLDING; |
122 |
else |
else |
123 |
throw new AdapterInactive(); |
throw new AdapterInactive(); |
124 |
|
|
125 |
|
notifyInterceptors(state.value()); |
126 |
|
|
127 |
if (wait_for_completion) |
if (wait_for_completion) |
128 |
waitForIdle(); |
waitForIdle(); |
129 |
} |
} |
155 |
if (state == State.INACTIVE) |
if (state == State.INACTIVE) |
156 |
throw new AdapterInactive("Repetetive inactivation"); |
throw new AdapterInactive("Repetetive inactivation"); |
157 |
state = State.INACTIVE; |
state = State.INACTIVE; |
158 |
|
|
159 |
|
notifyInterceptors(state.value()); |
160 |
|
|
161 |
if (wait_for_completion) |
if (wait_for_completion) |
162 |
waitForIdle(); |
waitForIdle(); |
163 |
|
|
192 |
state = State.DISCARDING; |
state = State.DISCARDING; |
193 |
else |
else |
194 |
throw new AdapterInactive(); |
throw new AdapterInactive(); |
195 |
|
|
196 |
|
notifyInterceptors(state.value()); |
197 |
|
|
198 |
if (wait_for_completion) |
if (wait_for_completion) |
199 |
waitForIdle(); |
waitForIdle(); |
200 |
} |
} |
210 |
{ |
{ |
211 |
if (state == State.ACTIVE) |
if (state == State.ACTIVE) |
212 |
throw new BAD_INV_ORDER("The state is active"); |
throw new BAD_INV_ORDER("The state is active"); |
213 |
|
|
214 |
|
gnuPOA poa; |
215 |
Iterator iter = POAs.iterator(); |
Iterator iter = POAs.iterator(); |
216 |
|
|
217 |
while (iter.hasNext()) |
while (iter.hasNext()) |
218 |
{ |
{ |
219 |
gnuPOA poa = (gnuPOA) iter.next(); |
poa = (gnuPOA) iter.next(); |
220 |
poa.waitWhileRunning(); |
poa.waitWhileRunning(); |
221 |
} |
} |
222 |
} |
} |
241 |
{ |
{ |
242 |
POAs.remove(poa); |
POAs.remove(poa); |
243 |
} |
} |
244 |
|
|
245 |
|
/** |
246 |
|
* This method is called when POA is destryed. The interceptors are |
247 |
|
* notified. |
248 |
|
*/ |
249 |
|
public void poaDestroyed(gnuPOA poa) |
250 |
|
{ |
251 |
|
notifyInterceptors(NON_EXISTENT.value); |
252 |
|
} |
253 |
|
|
254 |
|
/** |
255 |
|
* Notify CORBA 3.0 interceptors about the status change. |
256 |
|
*/ |
257 |
|
public synchronized void notifyInterceptors(int new_state) |
258 |
|
{ |
259 |
|
gnuPOA poa; |
260 |
|
Iterator iter = POAs.iterator(); |
261 |
|
|
262 |
|
// The System.identityHashCode is also called in gnuIorInfo. |
263 |
|
while (iter.hasNext()) |
264 |
|
{ |
265 |
|
poa = (gnuPOA) iter.next(); |
266 |
|
if (poa.m_orb.iIor != null) |
267 |
|
{ |
268 |
|
poa.m_orb.iIor.adapter_manager_state_changed( |
269 |
|
System.identityHashCode(this), (short) new_state); |
270 |
|
} |
271 |
|
} |
272 |
|
} |
273 |
} |
} |