本文整理汇总了Java中org.omg.PortableServer.POA.servant_to_reference方法的典型用法代码示例。如果您正苦于以下问题:Java POA.servant_to_reference方法的具体用法?Java POA.servant_to_reference怎么用?Java POA.servant_to_reference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.omg.PortableServer.POA
的用法示例。
在下文中一共展示了POA.servant_to_reference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activateServant
import org.omg.PortableServer.POA; //导入方法依赖的package包/类
/** Use implicit activation to get an object reference for the servant.
*/
public static org.omg.CORBA.Object activateServant( Servant servant )
{
POA poa = servant._default_POA() ;
org.omg.CORBA.Object ref = null ;
try {
ref = poa.servant_to_reference( servant ) ;
} catch (ServantNotActive sna) {
throw wrapper.getDelegateServantNotActive( sna ) ;
} catch (WrongPolicy wp) {
throw wrapper.getDelegateWrongPolicy( wp ) ;
}
// Make sure that the POAManager is activated if no other
// POAManager state management has taken place.
POAManager mgr = poa.the_POAManager() ;
if (mgr instanceof POAManagerImpl) {
POAManagerImpl mgrImpl = (POAManagerImpl)mgr ;
mgrImpl.implicitActivation() ;
}
return ref ;
}
示例2: main
import org.omg.PortableServer.POA; //导入方法依赖的package包/类
public static void main(String args[]) {
try{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// get reference to rootpoa & activate the POAManager
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
// create servant and register it with the ORB
HelloImpl helloImpl = new HelloImpl();
helloImpl.setORB(orb);
// get object reference from the servant
org.omg.CORBA.Object ref = rootpoa.servant_to_reference(helloImpl);
Hello href = HelloHelper.narrow(ref);
// get the root naming context
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
// Use NamingContextExt which is part of the Interoperable
// Naming Service (INS) specification.
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
// bind the Object Reference in Naming
String name = "Hello";
NameComponent path[] = ncRef.to_name( name );
ncRef.rebind(path, href);
System.out.println("HelloServer ready and waiting ...");
// wait for invocations from clients
while (true) {
orb.run();
}
} catch (Exception e) {
System.out.println("ERROR: " + e);
e.printStackTrace(System.out);
}
System.out.println("HelloServer Exiting ...");
}
示例3: connect
import org.omg.PortableServer.POA; //导入方法依赖的package包/类
/**
* Connect when the POA is specified.
*/
public static void connect(Stub self, ORB orb, POA poa)
throws RemoteException
{
ORB oorb = null;
try
{
Delegate d = self._get_delegate();
if (d != null)
oorb = d.orb(self);
}
catch (Exception e)
{
// Failed to get Delegate or ORB.
// (possible ony for user-written Stubs).
}
if (oorb != null)
{
if (!oorb.equals(orb))
throw new RemoteException("Stub " + self
+ " is connected to another ORB, " + orb);
else
return;
}
Tie t = null;
if (self instanceof Remote)
t = Util.getTie((Remote) self);
// Find by name pattern.
if (t == null)
t = getTieFromStub(self);
Delegate delegate;
if (t instanceof Servant)
{
try
{
if (poa == null)
{
poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
// Activate if not active.
if (poa.the_POAManager().get_state().value() == State._HOLDING)
poa.the_POAManager().activate();
}
ObjectImpl obj = (ObjectImpl) poa.servant_to_reference((Servant) t);
delegate = obj._get_delegate();
}
catch (Exception ex)
{
throw new Unexpected(ex);
}
}
else if (t instanceof ObjectImpl)
{
ObjectImpl o = (ObjectImpl) t;
orb.connect(o);
delegate = o._get_delegate();
}
else
throw new BAD_PARAM("The Tie must be either Servant or ObjectImpl");
self._set_delegate(delegate);
}