Java Code Examples for com.sun.corba.se.impl.util.Utility#autoConnect()

The following examples show how to use com.sun.corba.se.impl.util.Utility#autoConnect() . These examples are extracted from open source projects. 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
public Object copy(Object obj) {
    if (obj instanceof Remote) {
        // Yes, so make sure it is connected and converted
        // to a stub (if needed)...
        return Utility.autoConnect(obj,orb,true);
    }

    try {
        ByteArrayOutputStream os = new ByteArrayOutputStream( 10000 ) ;
        ObjectOutputStream oos = new ObjectOutputStream( os ) ;
        oos.writeObject( obj ) ;

        byte[] arr = os.toByteArray() ;
        InputStream is = new ByteArrayInputStream( arr ) ;
        ObjectInputStream ois = new ObjectInputStream( is ) ;

        return ois.readObject();
    } catch (Exception exc) {
        System.out.println( "Failed with exception:" + exc ) ;
        return null ;
    }
}
 
Example 2
public Object copy(Object obj) {
    if (obj instanceof Remote) {
        // Yes, so make sure it is connected and converted
        // to a stub (if needed)...
        return Utility.autoConnect(obj,orb,true);
    }

    try {
        ByteArrayOutputStream os = new ByteArrayOutputStream( 10000 ) ;
        ObjectOutputStream oos = new ObjectOutputStream( os ) ;
        oos.writeObject( obj ) ;

        byte[] arr = os.toByteArray() ;
        InputStream is = new ByteArrayInputStream( arr ) ;
        ObjectInputStream ois = new ObjectInputStream( is ) ;

        return ois.readObject();
    } catch (Exception exc) {
        System.out.println( "Failed with exception:" + exc ) ;
        return null ;
    }
}
 
Example 3
public Object copy(Object obj) {
    if (obj instanceof Remote) {
        // Yes, so make sure it is connected and converted
        // to a stub (if needed)...
        return Utility.autoConnect(obj,orb,true);
    }

    try {
        ByteArrayOutputStream os = new ByteArrayOutputStream( 10000 ) ;
        ObjectOutputStream oos = new ObjectOutputStream( os ) ;
        oos.writeObject( obj ) ;

        byte[] arr = os.toByteArray() ;
        InputStream is = new ByteArrayInputStream( arr ) ;
        ObjectInputStream ois = new ObjectInputStream( is ) ;

        return ois.readObject();
    } catch (Exception exc) {
        System.out.println( "Failed with exception:" + exc ) ;
        return null ;
    }
}
 
Example 4
public Object copy(Object obj) {
    if (obj instanceof Remote) {
        // Yes, so make sure it is connected and converted
        // to a stub (if needed)...
        return Utility.autoConnect(obj,orb,true);
    }

    try {
        ByteArrayOutputStream os = new ByteArrayOutputStream( 10000 ) ;
        ObjectOutputStream oos = new ObjectOutputStream( os ) ;
        oos.writeObject( obj ) ;

        byte[] arr = os.toByteArray() ;
        InputStream is = new ByteArrayInputStream( arr ) ;
        ObjectInputStream ois = new ObjectInputStream( is ) ;

        return ois.readObject();
    } catch (Exception exc) {
        System.out.println( "Failed with exception:" + exc ) ;
        return null ;
    }
}
 
Example 5
/**
 * Checks for objects that are instances of java.rmi.Remote
 * that need to be serialized as proxy (Stub) objects.
 */
protected final Object replaceObject(Object obj) throws IOException {
    try {
        if ((obj instanceof java.rmi.Remote) &&
                !(StubAdapter.isStub(obj))) {
            return Utility.autoConnect(obj, orb, true);
        }
    } catch (Exception e) {
        IOException ie = new IOException("replaceObject failed");
        ie.initCause(e);
        throw ie;
    }
    return obj;
}
 
Example 6
public Object copy(Object obj) {
    if (obj instanceof Remote) {
        // Yes, so make sure it is connected and converted
        // to a stub (if needed)...
        return Utility.autoConnect(obj,orb,true);
    }

    OutputStream out = (OutputStream)orb.create_output_stream();
    out.write_value((Serializable)obj);
    InputStream in = (InputStream)out.create_input_stream();
    return in.read_value();
}
 
Example 7
public Object copy(Object obj) {
    if (obj instanceof Remote) {
        // Yes, so make sure it is connected and converted
        // to a stub (if needed)...
        return Utility.autoConnect(obj,orb,true);
    }

    OutputStream out = (OutputStream)orb.create_output_stream();
    out.write_value((Serializable)obj);
    InputStream in = (InputStream)out.create_input_stream();
    return in.read_value();
}
 
Example 8
Source Project: TencentKona-8   File: Util.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes any java.lang.Object as a CORBA any.
 * @param out the stream in which to write the any.
 * @param obj the object to write as an any.
 */
public void writeAny( org.omg.CORBA.portable.OutputStream out,
                     java.lang.Object obj)
{
    org.omg.CORBA.ORB orb = out.orb();

    // Create Any
    Any any = orb.create_any();

    // Make sure we have a connected object...
    java.lang.Object newObj = Utility.autoConnect(obj,orb,false);

    if (newObj instanceof org.omg.CORBA.Object) {
        any.insert_Object((org.omg.CORBA.Object)newObj);
    } else {
        if (newObj == null) {
            // Handle the null case, including backwards
            // compatibility issues
            any.insert_Value(null, createTypeCodeForNull(orb));
        } else {
            if (newObj instanceof Serializable) {
                // If they're our Any and ORB implementations,
                // we may want to do type code related versioning.
                TypeCode tc = createTypeCode((Serializable)newObj, any, orb);
                if (tc == null)
                    any.insert_Value((Serializable)newObj);
                else
                    any.insert_Value((Serializable)newObj, tc);
            } else if (newObj instanceof Remote) {
                ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
            } else {
                ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
            }
        }
    }

    out.write_any(any);
}
 
Example 9
public Object copy(Object obj) {
    if (obj instanceof Remote) {
        // Yes, so make sure it is connected and converted
        // to a stub (if needed)...
        return Utility.autoConnect(obj,orb,true);
    }

    OutputStream out = (OutputStream)orb.create_output_stream();
    out.write_value((Serializable)obj);
    InputStream in = (InputStream)out.create_input_stream();
    return in.read_value();
}
 
Example 10
Source Project: jdk8u60   File: Util.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes any java.lang.Object as a CORBA any.
 * @param out the stream in which to write the any.
 * @param obj the object to write as an any.
 */
public void writeAny( org.omg.CORBA.portable.OutputStream out,
                     java.lang.Object obj)
{
    org.omg.CORBA.ORB orb = out.orb();

    // Create Any
    Any any = orb.create_any();

    // Make sure we have a connected object...
    java.lang.Object newObj = Utility.autoConnect(obj,orb,false);

    if (newObj instanceof org.omg.CORBA.Object) {
        any.insert_Object((org.omg.CORBA.Object)newObj);
    } else {
        if (newObj == null) {
            // Handle the null case, including backwards
            // compatibility issues
            any.insert_Value(null, createTypeCodeForNull(orb));
        } else {
            if (newObj instanceof Serializable) {
                // If they're our Any and ORB implementations,
                // we may want to do type code related versioning.
                TypeCode tc = createTypeCode((Serializable)newObj, any, orb);
                if (tc == null)
                    any.insert_Value((Serializable)newObj);
                else
                    any.insert_Value((Serializable)newObj, tc);
            } else if (newObj instanceof Remote) {
                ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
            } else {
                ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
            }
        }
    }

    out.write_any(any);
}
 
Example 11
Source Project: openjdk-jdk9   File: Util.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes any java.lang.Object as a CORBA any.
 * @param out the stream in which to write the any.
 * @param obj the object to write as an any.
 */
public void writeAny( org.omg.CORBA.portable.OutputStream out,
                     java.lang.Object obj)
{
    org.omg.CORBA.ORB orb = out.orb();

    // Create Any
    Any any = orb.create_any();

    // Make sure we have a connected object...
    java.lang.Object newObj = Utility.autoConnect(obj,orb,false);

    if (newObj instanceof org.omg.CORBA.Object) {
        any.insert_Object((org.omg.CORBA.Object)newObj);
    } else {
        if (newObj == null) {
            // Handle the null case, including backwards
            // compatibility issues
            any.insert_Value(null, createTypeCodeForNull(orb));
        } else {
            if (newObj instanceof Serializable) {
                // If they're our Any and ORB implementations,
                // we may want to do type code related versioning.
                TypeCode tc = createTypeCode((Serializable)newObj, any, orb);
                if (tc == null)
                    any.insert_Value((Serializable)newObj);
                else
                    any.insert_Value((Serializable)newObj, tc);
            } else if (newObj instanceof Remote) {
                ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
            } else {
                ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
            }
        }
    }

    out.write_any(any);
}
 
Example 12
public Object copy(Object obj) {
    if (obj instanceof Remote) {
        // Yes, so make sure it is connected and converted
        // to a stub (if needed)...
        return Utility.autoConnect(obj,orb,true);
    }

    OutputStream out = (OutputStream)orb.create_output_stream();
    out.write_value((Serializable)obj);
    InputStream in = (InputStream)out.create_input_stream();
    return in.read_value();
}
 
Example 13
Source Project: openjdk-jdk9   File: Util.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a java.lang.Object as either a value or a CORBA Object.
 * If {@code obj} is a value object or a stub object, it is written to
 * {@code out.write_abstract_interface(java.lang.Object)}. If {@code obj} is an exported
 * RMI-IIOP server object, the tie is found and wired to {@code obj},
 * then written to {@code out.write_abstract_interface(java.lang.Object)}.
 * @param out the stream in which to write the object.
 * @param obj the object to write.
 */
public void writeAbstractObject( OutputStream out, java.lang.Object obj )
{
    // Make sure we have a connected object, then
    // write it out...

    Object newObj = Utility.autoConnect(obj,out.orb(),false);
    ((org.omg.CORBA_2_3.portable.OutputStream)out).write_abstract_interface(newObj);
}
 
Example 14
Source Project: hottub   File: Util.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a java.lang.Object as either a value or a CORBA Object.
 * If <code>obj</code> is a value object or a stub object, it is written to
 * <code>out.write_abstract_interface(java.lang.Object)</code>. If <code>obj</code> is an exported
 * RMI-IIOP server object, the tie is found and wired to <code>obj</code>,
 * then written to <code>out.write_abstract_interface(java.lang.Object)</code>.
 * @param out the stream in which to write the object.
 * @param obj the object to write.
 */
public void writeAbstractObject( OutputStream out, java.lang.Object obj )
{
    // Make sure we have a connected object, then
    // write it out...

    Object newObj = Utility.autoConnect(obj,out.orb(),false);
    ((org.omg.CORBA_2_3.portable.OutputStream)out).write_abstract_interface(newObj);
}
 
Example 15
/**
 * Writes a java.lang.Object as either a value or a CORBA Object.
 * If <code>obj</code> is a value object or a stub object, it is written to
 * <code>out.write_abstract_interface(java.lang.Object)</code>. If <code>obj</code> is an exported
 * RMI-IIOP server object, the tie is found and wired to <code>obj</code>,
 * then written to <code>out.write_abstract_interface(java.lang.Object)</code>.
 * @param out the stream in which to write the object.
 * @param obj the object to write.
 */
public void writeAbstractObject( OutputStream out, java.lang.Object obj )
{
    // Make sure we have a connected object, then
    // write it out...

    Object newObj = Utility.autoConnect(obj,out.orb(),false);
    ((org.omg.CORBA_2_3.portable.OutputStream)out).write_abstract_interface(newObj);
}
 
Example 16
Source Project: openjdk-8   File: Util.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a java.lang.Object as either a value or a CORBA Object.
 * If <code>obj</code> is a value object or a stub object, it is written to
 * <code>out.write_abstract_interface(java.lang.Object)</code>. If <code>obj</code> is an exported
 * RMI-IIOP server object, the tie is found and wired to <code>obj</code>,
 * then written to <code>out.write_abstract_interface(java.lang.Object)</code>.
 * @param out the stream in which to write the object.
 * @param obj the object to write.
 */
public void writeAbstractObject( OutputStream out, java.lang.Object obj )
{
    // Make sure we have a connected object, then
    // write it out...

    Object newObj = Utility.autoConnect(obj,out.orb(),false);
    ((org.omg.CORBA_2_3.portable.OutputStream)out).write_abstract_interface(newObj);
}
 
Example 17
/**
 * Writes a java.lang.Object as a CORBA Object. If <code>obj</code> is
 * an exported RMI-IIOP server object, the tie is found
 * and wired to <code>obj</code>, then written to <code>out.write_Object(org.omg.CORBA.Object)</code>.
 * If <code>obj</code> is a CORBA Object, it is written to
 * <code>out.write_Object(org.omg.CORBA.Object)</code>.
 * @param out the stream in which to write the object.
 * @param obj the object to write.
 */
public void writeRemoteObject(OutputStream out, java.lang.Object obj)
{
    // Make sure we have a connected object, then
    // write it out...

    Object newObj = Utility.autoConnect(obj,out.orb(),false);
    out.write_Object((org.omg.CORBA.Object)newObj);
}
 
Example 18
Source Project: TencentKona-8   File: Util.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a java.lang.Object as either a value or a CORBA Object.
 * If <code>obj</code> is a value object or a stub object, it is written to
 * <code>out.write_abstract_interface(java.lang.Object)</code>. If <code>obj</code> is an exported
 * RMI-IIOP server object, the tie is found and wired to <code>obj</code>,
 * then written to <code>out.write_abstract_interface(java.lang.Object)</code>.
 * @param out the stream in which to write the object.
 * @param obj the object to write.
 */
public void writeAbstractObject( OutputStream out, java.lang.Object obj )
{
    // Make sure we have a connected object, then
    // write it out...

    Object newObj = Utility.autoConnect(obj,out.orb(),false);
    ((org.omg.CORBA_2_3.portable.OutputStream)out).write_abstract_interface(newObj);
}
 
Example 19
Source Project: jdk8u60   File: Util.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a java.lang.Object as either a value or a CORBA Object.
 * If <code>obj</code> is a value object or a stub object, it is written to
 * <code>out.write_abstract_interface(java.lang.Object)</code>. If <code>obj</code> is an exported
 * RMI-IIOP server object, the tie is found and wired to <code>obj</code>,
 * then written to <code>out.write_abstract_interface(java.lang.Object)</code>.
 * @param out the stream in which to write the object.
 * @param obj the object to write.
 */
public void writeAbstractObject( OutputStream out, java.lang.Object obj )
{
    // Make sure we have a connected object, then
    // write it out...

    Object newObj = Utility.autoConnect(obj,out.orb(),false);
    ((org.omg.CORBA_2_3.portable.OutputStream)out).write_abstract_interface(newObj);
}
 
Example 20
Source Project: openjdk-jdk8u   File: Util.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a java.lang.Object as either a value or a CORBA Object.
 * If <code>obj</code> is a value object or a stub object, it is written to
 * <code>out.write_abstract_interface(java.lang.Object)</code>. If <code>obj</code> is an exported
 * RMI-IIOP server object, the tie is found and wired to <code>obj</code>,
 * then written to <code>out.write_abstract_interface(java.lang.Object)</code>.
 * @param out the stream in which to write the object.
 * @param obj the object to write.
 */
public void writeAbstractObject( OutputStream out, java.lang.Object obj )
{
    // Make sure we have a connected object, then
    // write it out...

    Object newObj = Utility.autoConnect(obj,out.orb(),false);
    ((org.omg.CORBA_2_3.portable.OutputStream)out).write_abstract_interface(newObj);
}