本文整理汇总了Java中javax.rmi.CORBA.Util.getTie方法的典型用法代码示例。如果您正苦于以下问题:Java Util.getTie方法的具体用法?Java Util.getTie怎么用?Java Util.getTie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.rmi.CORBA.Util
的用法示例。
在下文中一共展示了Util.getTie方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unexportObject
import javax.rmi.CORBA.Util; //导入方法依赖的package包/类
/**
* Deregisters a server object from the runtime, allowing the object to become
* available for garbage collection.
* @param obj the object to unexport.
* @exception NoSuchObjectException if the remote object is not
* currently exported.
*/
public void unexportObject(Remote obj)
throws NoSuchObjectException {
if (obj == null) {
throw new NullPointerException("invalid argument");
}
if (StubAdapter.isStub(obj) ||
obj instanceof java.rmi.server.RemoteStub) {
throw new NoSuchObjectException(
"Can only unexport a server object.");
}
Tie theTie = Util.getTie(obj);
if (theTie != null) {
Util.unexportObject(obj);
} else {
if (Utility.loadTie(obj) == null) {
UnicastRemoteObject.unexportObject(obj,true);
} else {
throw new NoSuchObjectException("Object not exported.");
}
}
}
示例2: start
import javax.rmi.CORBA.Util; //导入方法依赖的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: toStub
import javax.rmi.CORBA.Util; //导入方法依赖的package包/类
/**
* Returns a stub for the given server object.
* @param obj the server object for which a stub is required. Must either be a subclass
* of PortableRemoteObject or have been previously the target of a call to
* {@link #exportObject}.
* @return the most derived stub for the object.
* @exception NoSuchObjectException if a stub cannot be located for the given server object.
*/
public Remote toStub (Remote obj)
throws NoSuchObjectException
{
Remote result = null;
if (obj == null) {
throw new NullPointerException("invalid argument");
}
// If the class is already an IIOP stub then return it.
if (StubAdapter.isStub( obj )) {
return obj;
}
// If the class is already a JRMP stub then return it.
if (obj instanceof java.rmi.server.RemoteStub) {
return obj;
}
// Has it been exported to IIOP?
Tie theTie = Util.getTie(obj);
if (theTie != null) {
result = Utility.loadStub(theTie,null,null,true);
} else {
if (Utility.loadTie(obj) == null) {
result = java.rmi.server.RemoteObject.toStub(obj);
}
}
if (result == null) {
throw new NoSuchObjectException("object not exported");
}
return result;
}
示例4: export
import javax.rmi.CORBA.Util; //导入方法依赖的package包/类
public Object export(Remote server, Class<?> remoteClass)
throws RemoteException
{
try {
PortableRemoteObject.exportObject(server);
POA poa = getPOA();
Object servant = Util.getTie(server);
Object ref = poa.servant_to_reference((Servant)servant);
return PortableRemoteObject.narrow(ref, remoteClass);
} catch(UserException e) {
throw new ExportException("could not export corba stream servant", e);
}
}
示例5: connect
import javax.rmi.CORBA.Util; //导入方法依赖的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);
}
示例6: exportObject
import javax.rmi.CORBA.Util; //导入方法依赖的package包/类
/**
* Makes a server object ready to receive remote calls. Note
* that subclasses of PortableRemoteObject do not need to call this
* method, as it is called by the constructor.
* @param obj the server object to export.
* @exception RemoteException if export fails.
*/
public void exportObject(Remote obj)
throws RemoteException {
if (obj == null) {
throw new NullPointerException("invalid argument");
}
// Has this object already been exported to IIOP?
if (Util.getTie(obj) != null) {
// Yes, so this is an error...
throw new ExportException (obj.getClass().getName() + " already exported");
}
// Can we load a Tie?
Tie theTie = Utility.loadTie(obj);
if (theTie != null) {
// Yes, so export it to IIOP...
Util.registerTarget(theTie,obj);
} else {
// No, so export to JRMP. If this is called twice for the
// same object, it will throw an ExportException...
UnicastRemoteObject.exportObject(obj);
}
}