本文整理汇总了Java中org.omg.PortableServer.POAPackage.ServantAlreadyActive类的典型用法代码示例。如果您正苦于以下问题:Java ServantAlreadyActive类的具体用法?Java ServantAlreadyActive怎么用?Java ServantAlreadyActive使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServantAlreadyActive类属于org.omg.PortableServer.POAPackage包,在下文中一共展示了ServantAlreadyActive类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate_object
import org.omg.PortableServer.POAPackage.ServantAlreadyActive; //导入依赖的package包/类
/**
* <code>activate_object</code>
* <b>Section 3.3.8.14</b>
*/
public byte[] activate_object(Servant servant)
throws ServantAlreadyActive, WrongPolicy
{
try {
lock() ;
if (debug) {
ORBUtility.dprint( this,
"Calling activate_object on poa " + this +
" (servant=" + servant + ")" ) ;
}
// Allocate a new system-generated object-id.
// This will throw WrongPolicy if not SYSTEM_ID
// policy.
byte[] id = mediator.newSystemId();
try {
mediator.activateObject( id, servant ) ;
} catch (ObjectAlreadyActive oaa) {
// This exception can not occur in this case,
// since id is always brand new.
//
}
return id ;
} finally {
if (debug) {
ORBUtility.dprint( this,
"Exiting activate_object on poa " + this ) ;
}
unlock() ;
}
}
示例2: activate_object_with_id
import org.omg.PortableServer.POAPackage.ServantAlreadyActive; //导入依赖的package包/类
/**
* <code>activate_object_with_id</code>
* <b>Section 3.3.8.15</b>
*/
public void activate_object_with_id(byte[] id,
Servant servant)
throws ObjectAlreadyActive, ServantAlreadyActive, WrongPolicy
{
try {
lock() ;
if (debug) {
ORBUtility.dprint( this,
"Calling activate_object_with_id on poa " + this +
" (servant=" + servant + " id=" + id + ")" ) ;
}
// Clone the id to avoid possible errors due to aliasing
// (e.g. the client passes the id in and then changes it later).
byte[] idClone = (byte[])(id.clone()) ;
mediator.activateObject( idClone, servant ) ;
} finally {
if (debug) {
ORBUtility.dprint( this,
"Exiting activate_object_with_id on poa " + this ) ;
}
unlock() ;
}
}
示例3: activateObject
import org.omg.PortableServer.POAPackage.ServantAlreadyActive; //导入依赖的package包/类
public final void activateObject(byte[] id, Servant servant)
throws WrongPolicy, ServantAlreadyActive, ObjectAlreadyActive
{
if (isUnique && activeObjectMap.contains(servant))
throw new ServantAlreadyActive();
ActiveObjectMap.Key key = new ActiveObjectMap.Key( id ) ;
AOMEntry entry = activeObjectMap.get( key ) ;
// Check for an ObjectAlreadyActive error
entry.activateObject() ;
activateServant( key, entry, servant ) ;
}
示例4: activate_object
import org.omg.PortableServer.POAPackage.ServantAlreadyActive; //导入依赖的package包/类
/**
* Generate the Object Id for the given servant and add the servant to the
* Active Object Map using this Id a a key. If the servant activator is set,
* its incarnate method will be called.
*
* @param a_servant a servant that would serve the object with the returned
* Object Id. If null is passed, under apporoprate policies the servant
* activator is invoked.
*
* @return the generated objert Id for the given servant.
*
* @throws ServantAlreadyActive if this servant is already in the Active
* Object Map and the UNIQUE_ID policy applies.
*
* @throws WrongPolicy if the required policies SYSTEM_ID and RETAIN do not
* apply to this POA.
*/
public byte[] activate_object(Servant a_servant)
throws ServantAlreadyActive, WrongPolicy
{
checkDiscarding();
required(ServantRetentionPolicyValue.RETAIN);
required(IdAssignmentPolicyValue.SYSTEM_ID);
AOM.Obj exists = aom.findServant(a_servant);
if (exists != null)
{
if (exists.isDeactiveted())
{
// If exists but deactivated, activate and return
// the existing key.
exists.setDeactivated(false);
incarnate(exists, exists.key, a_servant, false);
return exists.key;
}
else if (applies(IdUniquenessPolicyValue.UNIQUE_ID))
throw new ServantAlreadyActive();
// It multiple ids are allowed, exit block allowing repetetive
// activations.
}
byte[] object_key = AOM.getFreeId();
ServantDelegateImpl delegate = new ServantDelegateImpl(a_servant, this,
object_key);
create_and_connect(object_key,
a_servant._all_interfaces(this, object_key)[0], delegate);
return object_key;
}
示例5: servant_to_id
import org.omg.PortableServer.POAPackage.ServantAlreadyActive; //导入依赖的package包/类
/**
* Returns the id of the object, served by the given servant (assuming that
* the servant serves only one object). The id is found in one of the
* following ways.
* <ul>
* <li>If the POA has both the RETAIN and the UNIQUE_ID policy and the
* specified servant is active, the method return the Object Id associated
* with that servant. </li>
* <li> If the POA has both the RETAIN and the IMPLICIT_ACTIVATION policy and
* either the POA has the MULTIPLE_ID policy or the specified servant is
* inactive, the method activates the servant using a POA-generated Object Id
* and the Interface Id associated with the servant, and returns that Object
* Id. </li>
* <li>If the POA has the USE_DEFAULT_SERVANT policy, the servant specified
* is the default servant, and the method is being invoked in the context of
* executing a request on the default servant, the method returns the ObjectId
* associated with the current invocation. </li>
* </ul>
*
* @throws ServantNotActive in all cases, not listed in the list above.
* @throws WrongPolicy The method requres USE_DEFAULT_SERVANT policy or a
* combination of the RETAIN policy and either the UNIQUE_ID or
* IMPLICIT_ACTIVATION policies and throws the WrongPolicy if these conditions
* are not satisfied.
*/
public byte[] servant_to_id(Servant the_Servant)
throws ServantNotActive, WrongPolicy
{
if (applies(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT) ||
applies(ServantRetentionPolicyValue.RETAIN) &&
(
applies(IdUniquenessPolicyValue.UNIQUE_ID) ||
applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION)
)
)
{
AOM.Obj ref = null;
if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))
ref = aom.findServant(the_Servant);
if (ref == null &&
applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION)
)
{
// Try to activate.
try
{
return activate_object(the_Servant);
}
catch (ServantAlreadyActive ex)
{
// Either it shuld not be or the policy allows multiple ids.
throw new InternalError();
}
}
if (ref == null)
throw new ServantNotActive();
else
return ref.key;
}
else
throw new WrongPolicy("(RETAIN and UNIQUE ID) " +
"or USE_DEFAULT_SERVANT required."
);
}
示例6: activate_object
import org.omg.PortableServer.POAPackage.ServantAlreadyActive; //导入依赖的package包/类
/**
* Generate the Object Id for the given servant and add the servant to the
* Active Object Map using this Id a a key. If the servant activator is set,
* its incarnate method will be called.
*
* @param a_servant a servant that would serve the object with the returned
* Object Id. If null is passed, under apporoprate policies the servant
* activator is invoked.
*
* @return the generated objert Id for the given servant.
*
* @throws ServantAlreadyActive if this servant is already in the Active
* Object Map and the UNIQUE_ID policy applies.
*
* @throws WrongPolicy if the required policies SYSTEM_ID and RETAIN do not
* apply to this POA.
*/
public byte[] activate_object(Servant a_servant)
throws ServantAlreadyActive, WrongPolicy
{
checkDiscarding();
required(ServantRetentionPolicyValue.RETAIN);
required(IdAssignmentPolicyValue.SYSTEM_ID);
AOM.Obj exists = aom.findServant(a_servant);
if (exists != null)
{
if (exists.isDeactiveted())
{
// If exists but deactivated, activate and return
// the existing key.
exists.setDeactivated(false);
incarnate(exists, exists.key, a_servant, false);
return exists.key;
}
else if (applies(IdUniquenessPolicyValue.UNIQUE_ID))
throw new ServantAlreadyActive();
// It multiple ids are allowed, exit block allowing repetetive
// activations.
}
byte[] object_key = AOM.getFreeId();
ServantDelegateImpl delegate = new ServantDelegateImpl(a_servant, this,
object_key);
create_and_connect(object_key,
a_servant._all_interfaces(this, object_key)[0], delegate);
return object_key;
}
示例7: servant_to_id
import org.omg.PortableServer.POAPackage.ServantAlreadyActive; //导入依赖的package包/类
/**
* Returns the id of the object, served by the given servant (assuming that
* the servant serves only one object). The id is found in one of the
* following ways.
* <ul>
* <li>If the POA has both the RETAIN and the UNIQUE_ID policy and the
* specified servant is active, the method return the Object Id associated
* with that servant. </li>
* <li> If the POA has both the RETAIN and the IMPLICIT_ACTIVATION policy and
* either the POA has the MULTIPLE_ID policy or the specified servant is
* inactive, the method activates the servant using a POA-generated Object Id
* and the Interface Id associated with the servant, and returns that Object
* Id. </li>
* <li>If the POA has the USE_DEFAULT_SERVANT policy, the servant specified
* is the default servant, and the method is being invoked in the context of
* executing a request on the default servant, the method returns the ObjectId
* associated with the current invocation. </li>
* </ul>
*
* @throws ServantNotActive in all cases, not listed in the list above.
* @throws WrongPolicy The method requres USE_DEFAULT_SERVANT policy or a
* combination of the RETAIN policy and either the UNIQUE_ID or
* IMPLICIT_ACTIVATION policies and throws the WrongPolicy if these conditions
* are not satisfied.
*/
public byte[] servant_to_id(Servant the_Servant)
throws ServantNotActive, WrongPolicy
{
if (applies(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT) ||
applies(ServantRetentionPolicyValue.RETAIN) &&
(
applies(IdUniquenessPolicyValue.UNIQUE_ID) ||
applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION)
)
)
{
AOM.Obj ref = null;
if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))
ref = aom.findServant(the_Servant);
if (ref == null &&
applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION)
)
{
// Try to activate.
try
{
return activate_object(the_Servant);
}
catch (ServantAlreadyActive ex)
{
// Either it shuld not be or the policy allows multiple ids.
throw new InternalError();
}
}
if (ref == null)
throw new ServantNotActive();
else
return ref.key;
}
else
throw new WrongPolicy("(RETAIN and UNIQUE ID) " +
"or USE_DEFAULT_SERVANT required."
);
}
示例8: main
import org.omg.PortableServer.POAPackage.ServantAlreadyActive; //导入依赖的package包/类
public static void main(String[] args) throws InvalidName, ServantAlreadyActive, WrongPolicy, ObjectNotActive, FileNotFoundException, AdapterInactive {
ORB orb = ORB.init(args, null);
POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
ServerStationImpl spvmServerStation = new ServerStationImpl("SPVM", 15140);
byte[] id1 = rootPOA.activate_object(spvmServerStation);
org.omg.CORBA.Object ref1 = rootPOA.id_to_reference(id1);
String ior1 = orb.object_to_string(ref1);
System.out.println(ior1);
PrintWriter file1 = new PrintWriter("spvm_ior.txt");
file1.println(ior1);
file1.close();
ServerStationImpl splServerStation = new ServerStationImpl("SPL", 14500);
byte[] id2 = rootPOA.activate_object(splServerStation);
org.omg.CORBA.Object ref2 = rootPOA.id_to_reference(id2);
String ior2 = orb.object_to_string(ref2);
System.out.println(ior2);
PrintWriter file2 = new PrintWriter("spl_ior.txt");
file2.println(ior2);
file2.close();
ServerStationImpl spbServerStation = new ServerStationImpl("SPB", 15790);
byte[] id3 = rootPOA.activate_object(spbServerStation);
org.omg.CORBA.Object ref3 = rootPOA.id_to_reference(id3);
String ior3 = orb.object_to_string(ref3);
System.out.println(ior3);
PrintWriter file3 = new PrintWriter("spb_ior.txt");
file3.println(ior3);
file3.close();
rootPOA.the_POAManager().activate();
orb.run();
}
示例9: activateObject
import org.omg.PortableServer.POAPackage.ServantAlreadyActive; //导入依赖的package包/类
public final void activateObject(byte[] id, Servant servant)
throws WrongPolicy, ServantAlreadyActive, ObjectAlreadyActive
{
throw new WrongPolicy();
}