javax.rmi.CORBA.Tie Java Examples

The following examples show how to use javax.rmi.CORBA.Tie. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StubAdapter.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
 
Example #2
Source File: PortableRemoteObject.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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.");
        }
    }
}
 
Example #3
Source File: Util.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void unregisterTargetsForORB(org.omg.CORBA.ORB orb)
{
    for (Enumeration e = exportedServants.keys(); e.hasMoreElements(); )
    {
        java.lang.Object key = e.nextElement();
        Remote target = (Remote)(key instanceof Tie ? ((Tie)key).getTarget() : key);

        // Bug 4476347: BAD_OPERATION is thrown if the ties delegate isn't set.
        // We can ignore this because it means the tie is not connected to an ORB.
        try {
            if (orb == getTie(target).orb()) {
                try {
                    unexportObject(target);
                } catch( java.rmi.NoSuchObjectException ex ) {
                    // We neglect this exception if at all if it is
                    // raised. It is not harmful.
                }
            }
        } catch (BAD_OPERATION bad) {
            /* Ignore */
        }
    }
}
 
Example #4
Source File: PortableRemoteObject.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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.");
        }
    }
}
 
Example #5
Source File: PortableRemoteObject.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * 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.");
        }
    }
}
 
Example #6
Source File: StubAdapter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
 
Example #7
Source File: Util.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Registers a target for a tie. Adds the tie to an internal table and calls
 * {@link Tie#setTarget} on the tie object.
 * @param tie the tie to register.
 * @param target the target for the tie.
 */
public void registerTarget(javax.rmi.CORBA.Tie tie, java.rmi.Remote target)
{
    synchronized (exportedServants) {
        // Do we already have this target registered?
        if (lookupTie(target) == null) {
            // No, so register it and set the target...
            exportedServants.put(target,tie);
            tie.setTarget(target);

            // Do we need to instantiate our keep-alive thread?
            if (keepAlive == null) {
                // Yes. Instantiate our keep-alive thread and start
                // it up...
                keepAlive = (KeepAlive)AccessController.doPrivileged(new PrivilegedAction() {
                    public java.lang.Object run() {
                        return new KeepAlive();
                    }
                });
                keepAlive.start();
            }
        }
    }
}
 
Example #8
Source File: Util.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers a target for a tie. Adds the tie to an internal table and calls
 * {@link Tie#setTarget} on the tie object.
 * @param tie the tie to register.
 * @param target the target for the tie.
 */
public void registerTarget(javax.rmi.CORBA.Tie tie, java.rmi.Remote target)
{
    synchronized (exportedServants) {
        // Do we already have this target registered?
        if (lookupTie(target) == null) {
            // No, so register it and set the target...
            exportedServants.put(target,tie);
            tie.setTarget(target);

            // Do we need to instantiate our keep-alive thread?
            if (keepAlive == null) {
                // Yes. Instantiate our keep-alive thread and start
                // it up...
                keepAlive = (KeepAlive)AccessController.doPrivileged(new PrivilegedAction() {
                    public java.lang.Object run() {
                        return new KeepAlive();
                    }
                });
                keepAlive.start();
            }
        }
    }
}
 
Example #9
Source File: StubAdapter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
 
Example #10
Source File: Util.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public void unregisterTargetsForORB(org.omg.CORBA.ORB orb)
{
    for (Enumeration e = exportedServants.keys(); e.hasMoreElements(); )
    {
        java.lang.Object key = e.nextElement();
        Remote target = (Remote)(key instanceof Tie ? ((Tie)key).getTarget() : key);

        // Bug 4476347: BAD_OPERATION is thrown if the ties delegate isn't set.
        // We can ignore this because it means the tie is not connected to an ORB.
        try {
            if (orb == getTie(target).orb()) {
                try {
                    unexportObject(target);
                } catch( java.rmi.NoSuchObjectException ex ) {
                    // We neglect this exception if at all if it is
                    // raised. It is not harmful.
                }
            }
        } catch (BAD_OPERATION bad) {
            /* Ignore */
        }
    }
}
 
Example #11
Source File: Util.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers a target for a tie. Adds the tie to an internal table and calls
 * {@link Tie#setTarget} on the tie object.
 * @param tie the tie to register.
 * @param target the target for the tie.
 */
public void registerTarget(javax.rmi.CORBA.Tie tie, java.rmi.Remote target)
{
    synchronized (exportedServants) {
        // Do we already have this target registered?
        if (lookupTie(target) == null) {
            // No, so register it and set the target...
            exportedServants.put(target,tie);
            tie.setTarget(target);

            // Do we need to instantiate our keep-alive thread?
            if (keepAlive == null) {
                // Yes. Instantiate our keep-alive thread and start
                // it up...
                keepAlive = (KeepAlive)AccessController.doPrivileged(new PrivilegedAction() {
                    public java.lang.Object run() {
                        return new KeepAlive();
                    }
                });
                keepAlive.start();
            }
        }
    }
}
 
Example #12
Source File: Util.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void unregisterTargetsForORB(org.omg.CORBA.ORB orb)
{
    for (Enumeration e = exportedServants.keys(); e.hasMoreElements(); )
    {
        java.lang.Object key = e.nextElement();
        Remote target = (Remote)(key instanceof Tie ? ((Tie)key).getTarget() : key);

        // Bug 4476347: BAD_OPERATION is thrown if the ties delegate isn't set.
        // We can ignore this because it means the tie is not connected to an ORB.
        try {
            if (orb == getTie(target).orb()) {
                try {
                    unexportObject(target);
                } catch( java.rmi.NoSuchObjectException ex ) {
                    // We neglect this exception if at all if it is
                    // raised. It is not harmful.
                }
            }
        } catch (BAD_OPERATION bad) {
            /* Ignore */
        }
    }
}
 
Example #13
Source File: PortableRemoteObject.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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.");
        }
    }
}
 
Example #14
Source File: Util.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void unregisterTargetsForORB(org.omg.CORBA.ORB orb)
{
    for (Enumeration e = exportedServants.keys(); e.hasMoreElements(); )
    {
        java.lang.Object key = e.nextElement();
        Remote target = (Remote)(key instanceof Tie ? ((Tie)key).getTarget() : key);

        // Bug 4476347: BAD_OPERATION is thrown if the ties delegate isn't set.
        // We can ignore this because it means the tie is not connected to an ORB.
        try {
            if (orb == getTie(target).orb()) {
                try {
                    unexportObject(target);
                } catch( java.rmi.NoSuchObjectException ex ) {
                    // We neglect this exception if at all if it is
                    // raised. It is not harmful.
                }
            }
        } catch (BAD_OPERATION bad) {
            /* Ignore */
        }
    }
}
 
Example #15
Source File: StubAdapter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
 
Example #16
Source File: PortableRemoteObject.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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.");
        }
    }
}
 
Example #17
Source File: StubAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
 
Example #18
Source File: StubAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
 
Example #19
Source File: Utility.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void purgeStubForTie (Tie tie) {
    StubEntry entry;
    synchronized (tieToStubCache) {
        entry = (StubEntry)tieToStubCache.remove(tie);
    }
    if (entry != null) {
        synchronized (stubToTieCache) {
            stubToTieCache.remove(entry.stub);
        }
    }
}
 
Example #20
Source File: PortableRemoteObject.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #21
Source File: OAInvocationInfo.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void setServant(Object servant)
{
    servantContainer = servant ;
    if (servant instanceof Tie)
        this.servant = ((Tie)servant).getTarget() ;
    else
        this.servant = servant;
}
 
Example #22
Source File: Utility.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void purgeTieAndServant (Tie tie) {
    synchronized (tieCache) {
        Object target = tie.getTarget();
        if (target != null)
            tieCache.remove(target);
    }
}
 
Example #23
Source File: Util.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Registers a target for a tie. Adds the tie to an internal table and calls
 * {@link Tie#setTarget} on the tie object.
 * @param tie the tie to register.
 * @param target the target for the tie.
 */
public static void registerTarget(javax.rmi.CORBA.Tie tie,
                                  java.rmi.Remote target) {

    if (utilDelegate != null) {
        utilDelegate.registerTarget(tie, target);
    }

}
 
Example #24
Source File: StubAdapter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/** This also gets the delegate from a Servant by
 * using Servant._this_object()
 */
public static Delegate getDelegate( Object stub )
{
    if (stub instanceof DynamicStub)
        return ((DynamicStub)stub).getDelegate() ;
    else if (stub instanceof ObjectImpl)
        return ((ObjectImpl)stub)._get_delegate() ;
    else if (stub instanceof Tie) {
        Tie tie = (Tie)stub ;
        org.omg.CORBA.Object ref = activateTie( tie ) ;
        return getDelegate( ref ) ;
    } else
        throw wrapper.getDelegateRequiresStub() ;
}
 
Example #25
Source File: Util.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Registers a target for a tie. Adds the tie to an internal table and calls
 * {@link Tie#setTarget} on the tie object.
 * @param tie the tie to register.
 * @param target the target for the tie.
 */
public static void registerTarget(javax.rmi.CORBA.Tie tie,
                                  java.rmi.Remote target) {

    if (utilDelegate != null) {
        utilDelegate.registerTarget(tie, target);
    }

}
 
Example #26
Source File: StubAdapter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/** This also gets the delegate from a Servant by
 * using Servant._this_object()
 */
public static Delegate getDelegate( Object stub )
{
    if (stub instanceof DynamicStub)
        return ((DynamicStub)stub).getDelegate() ;
    else if (stub instanceof ObjectImpl)
        return ((ObjectImpl)stub)._get_delegate() ;
    else if (stub instanceof Tie) {
        Tie tie = (Tie)stub ;
        org.omg.CORBA.Object ref = activateTie( tie ) ;
        return getDelegate( ref ) ;
    } else
        throw wrapper.getDelegateRequiresStub() ;
}
 
Example #27
Source File: Util.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the tie (if any) for a given target object.
 * @return the tie or null if no tie is registered for the given target.
 */
public Tie getTie (Remote target)
{
    synchronized (exportedServants) {
        return lookupTie(target);
    }
}
 
Example #28
Source File: OAInvocationInfo.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void setServant(Object servant)
{
    servantContainer = servant ;
    if (servant instanceof Tie)
        this.servant = ((Tie)servant).getTarget() ;
    else
        this.servant = servant;
}
 
Example #29
Source File: Util.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the tie (if any) for a given target object.
 * @return the tie or null if no tie is registered for the given target.
 */
public static Tie getTie (Remote target) {

    if (utilDelegate != null) {
        return utilDelegate.getTie(target);
    }
    return null;
}
 
Example #30
Source File: Util.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the tie (if any) for a given target object.
 * @return the tie or null if no tie is registered for the given target.
 */
public static Tie getTie (Remote target) {

    if (utilDelegate != null) {
        return utilDelegate.getTie(target);
    }
    return null;
}