本文整理汇总了Java中org.omg.PortableServer.RequestProcessingPolicyValue类的典型用法代码示例。如果您正苦于以下问题:Java RequestProcessingPolicyValue类的具体用法?Java RequestProcessingPolicyValue怎么用?Java RequestProcessingPolicyValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RequestProcessingPolicyValue类属于org.omg.PortableServer包,在下文中一共展示了RequestProcessingPolicyValue类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validatePolicies
import org.omg.PortableServer.RequestProcessingPolicyValue; //导入依赖的package包/类
/**
* Check if the policy set is valid.
*/
protected boolean validatePolicies(Policy[] a)
throws InvalidPolicy
{
if (applies(ServantRetentionPolicyValue.NON_RETAIN))
{
if (!applies(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT) &&
!applies(RequestProcessingPolicyValue.USE_SERVANT_MANAGER)
)
{
short p = 0;
for (short i = 0; i < a.length; i++)
{
if (a [ i ].policy_type() == SERVANT_RETENTION_POLICY_ID.value)
p = i;
}
throw new InvalidPolicy("NON_RETAIN requires either " +
"USE_DEFAULT_SERVANT or USE_SERVANT_MANAGER",
p
);
}
}
return true;
}
示例2: start
import org.omg.PortableServer.RequestProcessingPolicyValue; //导入依赖的package包/类
public void start(String[] args) throws Exception {
Properties p = System.getProperties();
p.put("org.omg.CORBA.ORBClass", "com.sun.corba.se.internal.POA.POAORB");
p.put("org.omg.CORBA.ORBSingletonClass", "com.sun.corba.se.internal.corba.ORBSingleton");
ORB orb = ORB.init(args, p);
POA rootPOA = (POA) orb.resolve_initial_references("RootPOA");
Policy[] tpolicy = new Policy[3];
tpolicy[0] = rootPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
tpolicy[1] = rootPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY);
tpolicy[2] = rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
POA tPOA = rootPOA.create_POA("MyTransientPOA", null, tpolicy);
tPOA.the_POAManager().activate();
Tie tie = (Tie) Util.getTie(remoteDatabaseManager);
byte[] id = "db".getBytes();
tPOA.activate_object_with_id(id, (Servant) tie);
Context initialNamingContext = new InitialContext();
initialNamingContext.rebind("DatabaseService", tPOA.create_reference_with_id(id, ((Servant) tie)._all_interfaces(tPOA, id)[0]));
System.out.println("Database Server: Ready...");
orb.run();
}
示例3: gnuRequestProcessingPolicy
import org.omg.PortableServer.RequestProcessingPolicyValue; //导入依赖的package包/类
/**
* Create the policy.
*
* @param v a value for the policy.
*/
public gnuRequestProcessingPolicy(RequestProcessingPolicyValue v)
{
super(REQUEST_PROCESSING_POLICY_ID.value, v, v.value(),
"IDL:org.omg/PortableServer/RequestProcessingPolicy:1.0"
);
}
示例4: get_servant_manager
import org.omg.PortableServer.RequestProcessingPolicyValue; //导入依赖的package包/类
/**
* Get the servant manager, associated with this POA.
*
* @return the associated servant manager or null if it has
* been previously set.
*
* @throws WrongPolicy if the required USE_SERVANT_MANAGER policy does not
* apply to this POA.
*/
public ServantManager get_servant_manager()
throws WrongPolicy
{
required(RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
if (servant_activator != null)
return servant_activator;
else
return servant_locator;
}
示例5: servant_to_id
import org.omg.PortableServer.RequestProcessingPolicyValue; //导入依赖的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: servant_to_id
import org.omg.PortableServer.RequestProcessingPolicyValue; //导入依赖的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."
);
}
示例7: CorbaExporter
import org.omg.PortableServer.RequestProcessingPolicyValue; //导入依赖的package包/类
public CorbaExporter()
throws Exception
{
Properties p = System.getProperties();
// add runtime properties here
p.put("org.omg.CORBA.ORBClass",
"com.sun.corba.se.internal.POA.POAORB");
p.put("org.omg.CORBA.ORBSingletonClass",
"com.sun.corba.se.internal.corba.ORBSingleton");
p.put("java.naming.factory.initial",
"com.sun.jndi.cosnaming.CNCtxFactory");
p.put("java.naming.provider.url",
"iiop://localhost:1060");
_orb = ORB.init( new String[0], p );
POA rootPOA = (POA)_orb.resolve_initial_references("RootPOA");
// STEP 1: Create a POA with the appropriate policies
Policy[] tpolicy = new Policy[4];
tpolicy[0] = rootPOA.create_lifespan_policy(
LifespanPolicyValue.TRANSIENT );
tpolicy[1] = rootPOA.create_request_processing_policy(
RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY );
tpolicy[2] = rootPOA.create_servant_retention_policy(
ServantRetentionPolicyValue.RETAIN);
tpolicy[3] = rootPOA.create_implicit_activation_policy(
ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
_poa = rootPOA.create_POA("MyTransientPOA", null, tpolicy);
// STEP 2: Activate the POA Manager, otherwise all calls to the
// servant hang because, by default, POAManager will be in the
// HOLD state.
_poa.the_POAManager().activate();
}
示例8: createPolicy
import org.omg.PortableServer.RequestProcessingPolicyValue; //导入依赖的package包/类
public static RequestProcessingPolicyImpl createPolicy(Any val)
throws org.omg.CORBA.PolicyError
{
try {
RequestProcessingPolicyValue value =
RequestProcessingPolicyValueHelper.extract(val);
return new RequestProcessingPolicyImpl(value);
}
catch (BAD_PARAM bp) {
throw new PolicyError(BAD_POLICY_VALUE.value);
}
}
示例9: NameService
import org.omg.PortableServer.RequestProcessingPolicyValue; //导入依赖的package包/类
/**
* Create NameService which starts the Root Naming Context in Persistent CosNaming
* @param orb an ORB object.
* @param logDir a File
* @exception java.lang.Exception a Java exception.
*/
public NameService(ORB orb, File logDir)
throws Exception
{
theorb = orb;
// Moved this to the creation of the ORB that is passed into this
// constructor.
//
// This is required for creating Persistent Servants under this ORB
// Right now the Persistent NameService and ORBD are launched together
// Find out a better way of doing this, Since ORBD is an important
// process which should not be killed because of some external process
// orb.setPersistentServerId( (int) 1000 );
// get and activate the root naming POA
POA rootPOA = (POA)orb.resolve_initial_references(
ORBConstants.ROOT_POA_NAME ) ;
rootPOA.the_POAManager().activate();
// create a new POA for persistent Naming Contexts
// With Non-Retain policy, So that every time Servant Manager
// will be contacted when the reference is made for the context
// The id assignment is made by the NameServer, The Naming Context
// id's will be in the format NC<Index>
int i=0;
Policy[] poaPolicy = new Policy[4];
poaPolicy[i++] = rootPOA.create_lifespan_policy(
LifespanPolicyValue.PERSISTENT);
poaPolicy[i++] = rootPOA.create_request_processing_policy(
RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
poaPolicy[i++] = rootPOA.create_id_assignment_policy(
IdAssignmentPolicyValue.USER_ID);
poaPolicy[i++] = rootPOA.create_servant_retention_policy(
ServantRetentionPolicyValue.NON_RETAIN);
nsPOA = rootPOA.create_POA("NameService", null, poaPolicy);
nsPOA.the_POAManager().activate( );
// create and set the servant manager
contextMgr = new
ServantManagerImpl(orb, logDir, this );
// The RootObject key will be NC0
String rootKey = contextMgr.getRootObjectKey( );
// initialize the root Naming Context
NamingContextImpl nc =
new NamingContextImpl( orb, rootKey, this, contextMgr );
nc = contextMgr.addContext( rootKey, nc );
nc.setServantManagerImpl( contextMgr );
nc.setORB( orb );
nc.setRootNameService( this );
nsPOA.set_servant_manager(contextMgr);
rootContext = NamingContextHelper.narrow(
nsPOA.create_reference_with_id( rootKey.getBytes( ),
NamingContextHelper.id( ) ) );
}
示例10: create_request_processing_policy
import org.omg.PortableServer.RequestProcessingPolicyValue; //导入依赖的package包/类
/**
* <code>create_request_processing_policy</code>
* <b>Section 3.3.8.5</b>
*/
public RequestProcessingPolicy create_request_processing_policy(
RequestProcessingPolicyValue value)
{
return new RequestProcessingPolicyImpl(value);
}
示例11: value
import org.omg.PortableServer.RequestProcessingPolicyValue; //导入依赖的package包/类
/**
* Get the value for the policy that was passed in a constructor.
*/
public RequestProcessingPolicyValue value()
{
return (RequestProcessingPolicyValue) getValue();
}
示例12: create_request_processing_policy
import org.omg.PortableServer.RequestProcessingPolicyValue; //导入依赖的package包/类
/** {@inheritDoc} */
public RequestProcessingPolicy create_request_processing_policy(RequestProcessingPolicyValue a_value)
{
return new gnuRequestProcessingPolicy(a_value);
}