102 |
/** |
/** |
103 |
* The active object map, mapping between object keys, objects and servants. |
* The active object map, mapping between object keys, objects and servants. |
104 |
*/ |
*/ |
105 |
public final activeObjectMap aom = new activeObjectMap(); |
public final AOM aom = new AOM(); |
106 |
|
|
107 |
/** |
/** |
108 |
* The children of this POA. |
* The children of this POA. |
199 |
throws InvalidPolicy |
throws InvalidPolicy |
200 |
{ |
{ |
201 |
// Add default policies. |
// Add default policies. |
202 |
Policy[] all_policies = policySets.withDefault(a_policies); |
Policy[] all_policies = StandardPolicies.withDefault(a_policies); |
203 |
|
|
204 |
name = a_name; |
name = a_name; |
205 |
parent = a_parent; |
parent = a_parent; |
222 |
for (int i = 0; i < s_policies.length; i++) |
for (int i = 0; i < s_policies.length; i++) |
223 |
{ |
{ |
224 |
s_policies [ i ] = all_policies [ i ].copy(); |
s_policies [ i ] = all_policies [ i ].copy(); |
225 |
m_policies.add(((vPolicy) s_policies [ i ]).getValue()); |
m_policies.add(((AccessiblePolicy) s_policies [ i ]).getValue()); |
226 |
} |
} |
227 |
|
|
228 |
retain_servant = applies(ServantRetentionPolicyValue.RETAIN); |
retain_servant = applies(ServantRetentionPolicyValue.RETAIN); |
281 |
keys.addAll(aom.keySet()); |
keys.addAll(aom.keySet()); |
282 |
|
|
283 |
byte[] key; |
byte[] key; |
284 |
activeObjectMap.Obj obj; |
AOM.Obj obj; |
285 |
boolean last; |
boolean last; |
286 |
for (int i = 0; i < keys.size(); i++) |
for (int i = 0; i < keys.size(); i++) |
287 |
{ |
{ |
445 |
required(ServantRetentionPolicyValue.RETAIN); |
required(ServantRetentionPolicyValue.RETAIN); |
446 |
required(IdAssignmentPolicyValue.SYSTEM_ID); |
required(IdAssignmentPolicyValue.SYSTEM_ID); |
447 |
|
|
448 |
activeObjectMap.Obj exists = aom.findServant(a_servant); |
AOM.Obj exists = aom.findServant(a_servant); |
449 |
|
|
450 |
if (exists != null) |
if (exists != null) |
451 |
{ |
{ |
464 |
// activations. |
// activations. |
465 |
} |
} |
466 |
|
|
467 |
byte[] object_key = activeObjectMap.getFreeId(); |
byte[] object_key = AOM.getFreeId(); |
468 |
servantDelegate delegate = new servantDelegate(a_servant, this, object_key); |
ServantDelegateImpl delegate = new ServantDelegateImpl(a_servant, this, object_key); |
469 |
connectDelegate(object_key, delegate); |
connectDelegate(object_key, delegate); |
470 |
return object_key; |
return object_key; |
471 |
} |
} |
514 |
// already active. |
// already active. |
515 |
if (applies(IdUniquenessPolicyValue.UNIQUE_ID)) |
if (applies(IdUniquenessPolicyValue.UNIQUE_ID)) |
516 |
{ |
{ |
517 |
activeObjectMap.Obj sx = aom.findServant(a_servant, false); |
AOM.Obj sx = aom.findServant(a_servant, false); |
518 |
if (sx != null) |
if (sx != null) |
519 |
throw new ServantAlreadyActive(); |
throw new ServantAlreadyActive(); |
520 |
} |
} |
521 |
|
|
522 |
activeObjectMap.Obj exists = aom.get(an_Object_Id); |
AOM.Obj exists = aom.get(an_Object_Id); |
523 |
if (exists != null) |
if (exists != null) |
524 |
{ |
{ |
525 |
if (exists.servant == null) |
if (exists.servant == null) |
537 |
} |
} |
538 |
else |
else |
539 |
{ |
{ |
540 |
servantDelegate delegate = |
ServantDelegateImpl delegate = |
541 |
new servantDelegate(a_servant, this, an_Object_Id); |
new ServantDelegateImpl(a_servant, this, an_Object_Id); |
542 |
connectDelegate(an_Object_Id, delegate); |
connectDelegate(an_Object_Id, delegate); |
543 |
} |
} |
544 |
} |
} |
556 |
* (the required servant manager may be missing). |
* (the required servant manager may be missing). |
557 |
*/ |
*/ |
558 |
private void locateServant(byte[] an_Object_Id, Servant a_servant, |
private void locateServant(byte[] an_Object_Id, Servant a_servant, |
559 |
activeObjectMap.Obj exists, boolean use_forwarding |
AOM.Obj exists, boolean use_forwarding |
560 |
) |
) |
561 |
throws InternalError |
throws InternalError |
562 |
{ |
{ |
582 |
throw new OBJ_ADAPTER("no servant", 4, CompletionStatus.COMPLETED_NO); |
throw new OBJ_ADAPTER("no servant", 4, CompletionStatus.COMPLETED_NO); |
583 |
} |
} |
584 |
|
|
585 |
servantDelegate delegate = |
ServantDelegateImpl delegate = |
586 |
new servantDelegate(exists.servant, this, an_Object_Id); |
new ServantDelegateImpl(exists.servant, this, an_Object_Id); |
587 |
exists.servant._set_delegate(delegate); |
exists.servant._set_delegate(delegate); |
588 |
object.setServant(exists.servant); |
object.setServant(exists.servant); |
589 |
connect_to_orb(an_Object_Id, delegate.object); |
connect_to_orb(an_Object_Id, delegate.object); |
605 |
{ |
{ |
606 |
required(ServantRetentionPolicyValue.RETAIN); |
required(ServantRetentionPolicyValue.RETAIN); |
607 |
|
|
608 |
activeObjectMap.Obj exists = aom.get(the_Object_Id); |
AOM.Obj exists = aom.get(the_Object_Id); |
609 |
|
|
610 |
if (exists == null || exists.isDeactiveted()) |
if (exists == null || exists.isDeactiveted()) |
611 |
throw new ObjectNotActive(); |
throw new ObjectNotActive(); |
615 |
// Check if this servant is serving something else. |
// Check if this servant is serving something else. |
616 |
aom.remove(the_Object_Id); |
aom.remove(the_Object_Id); |
617 |
|
|
618 |
activeObjectMap.Obj other = aom.findServant(exists.servant, false); |
AOM.Obj other = aom.findServant(exists.servant, false); |
619 |
|
|
620 |
boolean remaining = other != null; |
boolean remaining = other != null; |
621 |
|
|
643 |
throws WrongPolicy |
throws WrongPolicy |
644 |
{ |
{ |
645 |
required(IdAssignmentPolicyValue.SYSTEM_ID); |
required(IdAssignmentPolicyValue.SYSTEM_ID); |
646 |
return create_reference_with_id(activeObjectMap.getFreeId(), a_repository_id); |
return create_reference_with_id(AOM.getFreeId(), a_repository_id); |
647 |
} |
} |
648 |
|
|
649 |
/** |
/** |
672 |
ids = new String[] { a_repository_id }; |
ids = new String[] { a_repository_id }; |
673 |
|
|
674 |
// Check maybe such object is already activated. |
// Check maybe such object is already activated. |
675 |
activeObjectMap.Obj e = aom.get(an_object_id); |
AOM.Obj e = aom.get(an_object_id); |
676 |
|
|
677 |
Servant servant; |
Servant servant; |
678 |
if (e == null) |
if (e == null) |
874 |
{ |
{ |
875 |
required(ServantRetentionPolicyValue.RETAIN); |
required(ServantRetentionPolicyValue.RETAIN); |
876 |
|
|
877 |
activeObjectMap.Obj ref = aom.get(the_Object_Id); |
AOM.Obj ref = aom.get(the_Object_Id); |
878 |
if (ref == null) |
if (ref == null) |
879 |
throw new ObjectNotActive(); |
throw new ObjectNotActive(); |
880 |
else |
else |
897 |
{ |
{ |
898 |
if (applies(ServantRetentionPolicyValue.RETAIN)) |
if (applies(ServantRetentionPolicyValue.RETAIN)) |
899 |
{ |
{ |
900 |
activeObjectMap.Obj ref = aom.get(the_Object_Id); |
AOM.Obj ref = aom.get(the_Object_Id); |
901 |
if (ref == null || ref.isDeactiveted()) |
if (ref == null || ref.isDeactiveted()) |
902 |
{ |
{ |
903 |
if (default_servant != null) |
if (default_servant != null) |
932 |
public byte[] reference_to_id(org.omg.CORBA.Object the_Object) |
public byte[] reference_to_id(org.omg.CORBA.Object the_Object) |
933 |
throws WrongAdapter, WrongPolicy |
throws WrongAdapter, WrongPolicy |
934 |
{ |
{ |
935 |
activeObjectMap.Obj ref = aom.findObject(the_Object); |
AOM.Obj ref = aom.findObject(the_Object); |
936 |
if (ref == null) |
if (ref == null) |
937 |
throw new WrongAdapter(); |
throw new WrongAdapter(); |
938 |
return ref.key; |
return ref.key; |
958 |
{ |
{ |
959 |
if (applies(ServantRetentionPolicyValue.RETAIN)) |
if (applies(ServantRetentionPolicyValue.RETAIN)) |
960 |
{ |
{ |
961 |
activeObjectMap.Obj ref = aom.findObject(the_Object); |
AOM.Obj ref = aom.findObject(the_Object); |
962 |
if (ref == null) |
if (ref == null) |
963 |
throw new WrongAdapter(); |
throw new WrongAdapter(); |
964 |
else if (ref.isDeactiveted() || ref.servant == null) |
else if (ref.isDeactiveted() || ref.servant == null) |
1017 |
) |
) |
1018 |
) |
) |
1019 |
{ |
{ |
1020 |
activeObjectMap.Obj ref = null; |
AOM.Obj ref = null; |
1021 |
if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID)) |
if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID)) |
1022 |
ref = aom.findServant(the_Servant); |
ref = aom.findServant(the_Servant); |
1023 |
if (ref == null && |
if (ref == null && |
1071 |
{ |
{ |
1072 |
required(ServantRetentionPolicyValue.RETAIN); |
required(ServantRetentionPolicyValue.RETAIN); |
1073 |
|
|
1074 |
activeObjectMap.Obj exists = null; |
AOM.Obj exists = null; |
1075 |
|
|
1076 |
if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID)) |
if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID)) |
1077 |
exists = aom.findServant(the_Servant); |
exists = aom.findServant(the_Servant); |
1098 |
{ |
{ |
1099 |
checkDiscarding(); |
checkDiscarding(); |
1100 |
|
|
1101 |
byte[] object_key = activeObjectMap.getFreeId(); |
byte[] object_key = AOM.getFreeId(); |
1102 |
|
|
1103 |
servantDelegate delegate = |
ServantDelegateImpl delegate = |
1104 |
new servantDelegate(the_Servant, this, object_key); |
new ServantDelegateImpl(the_Servant, this, object_key); |
1105 |
connectDelegate(object_key, delegate); |
connectDelegate(object_key, delegate); |
1106 |
|
|
1107 |
return delegate.object; |
return delegate.object; |
1126 |
* under the forwarding exception (for remote client). Otherwise, the |
* under the forwarding exception (for remote client). Otherwise, the |
1127 |
* request is internally redirected (for local invocation). |
* request is internally redirected (for local invocation). |
1128 |
*/ |
*/ |
1129 |
private Servant incarnate(activeObjectMap.Obj x, byte[] object_key, |
private Servant incarnate(AOM.Obj x, byte[] object_key, |
1130 |
Servant a_servant, boolean use_forwarding |
Servant a_servant, boolean use_forwarding |
1131 |
) |
) |
1132 |
{ |
{ |
1328 |
keys.addAll(aom.keySet()); |
keys.addAll(aom.keySet()); |
1329 |
|
|
1330 |
byte[] key; |
byte[] key; |
1331 |
activeObjectMap.Obj obj; |
AOM.Obj obj; |
1332 |
for (int i = 0; i < keys.size(); i++) |
for (int i = 0; i < keys.size(); i++) |
1333 |
{ |
{ |
1334 |
key = (byte[]) keys.get(i); |
key = (byte[]) keys.get(i); |
1433 |
* Connect the given delegate under the given key, also calling |
* Connect the given delegate under the given key, also calling |
1434 |
* incarnate. |
* incarnate. |
1435 |
*/ |
*/ |
1436 |
private void connectDelegate(byte[] object_key, servantDelegate delegate) |
private void connectDelegate(byte[] object_key, ServantDelegateImpl delegate) |
1437 |
{ |
{ |
1438 |
aom.add(delegate); |
aom.add(delegate); |
1439 |
connect_to_orb(object_key, delegate.object); |
connect_to_orb(object_key, delegate.object); |
1517 |
/** |
/** |
1518 |
* Recursively searches for the given object in the POA tree. |
* Recursively searches for the given object in the POA tree. |
1519 |
*/ |
*/ |
1520 |
public activeObjectMap.Obj findObject(org.omg.CORBA.Object object) |
public AOM.Obj findObject(org.omg.CORBA.Object object) |
1521 |
{ |
{ |
1522 |
activeObjectMap.Obj h = aom.findObject(object); |
AOM.Obj h = aom.findObject(object); |
1523 |
if (h != null) |
if (h != null) |
1524 |
return h; |
return h; |
1525 |
else |
else |
1540 |
* and poa ids. |
* and poa ids. |
1541 |
* @return |
* @return |
1542 |
*/ |
*/ |
1543 |
public activeObjectMap.Obj findKey(byte[] object_id, byte[] poa_id) |
public AOM.Obj findKey(byte[] object_id, byte[] poa_id) |
1544 |
{ |
{ |
1545 |
activeObjectMap.Obj h = null; |
AOM.Obj h = null; |
1546 |
if (Arrays.equals(poa_id, id())) |
if (Arrays.equals(poa_id, id())) |
1547 |
h = aom.get(object_id); |
h = aom.get(object_id); |
1548 |
if (h != null) |
if (h != null) |
1563 |
* Parses the given key, extracts poa and object id and searches |
* Parses the given key, extracts poa and object id and searches |
1564 |
* for such reference. |
* for such reference. |
1565 |
*/ |
*/ |
1566 |
public activeObjectMap.Obj findIorKey(byte[] ior_key) |
public AOM.Obj findIorKey(byte[] ior_key) |
1567 |
{ |
{ |
1568 |
BufferredCdrInput in = new BufferredCdrInput(ior_key); |
BufferredCdrInput in = new BufferredCdrInput(ior_key); |
1569 |
int signature = in.read_long(); |
int signature = in.read_long(); |
1616 |
/** |
/** |
1617 |
* Recursively searches for the given servant in the POA tree. |
* Recursively searches for the given servant in the POA tree. |
1618 |
*/ |
*/ |
1619 |
public activeObjectMap.Obj findServant(Servant servant) |
public AOM.Obj findServant(Servant servant) |
1620 |
{ |
{ |
1621 |
activeObjectMap.Obj h = aom.findServant(servant); |
AOM.Obj h = aom.findServant(servant); |
1622 |
if (h != null) |
if (h != null) |
1623 |
return h; |
return h; |
1624 |
else |
else |