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() . 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: JavaStreamObjectCopierImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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
Source File: JavaStreamObjectCopierImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
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
Source File: JavaStreamObjectCopierImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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
Source File: JavaStreamObjectCopierImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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
Source File: ORBStreamObjectCopierImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
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 6
Source File: IDLJavaSerializationOutputStream.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 7
Source File: ORBStreamObjectCopierImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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 File: ORBStreamObjectCopierImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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 9
Source File: Util.java    From TencentKona-8 with 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 10
Source File: Util.java    From openjdk-jdk9 with 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 File: ORBStreamObjectCopierImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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 12
Source File: Util.java    From jdk8u60 with 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 13
Source File: Util.java    From TencentKona-8 with 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 14
Source File: Util.java    From openjdk-jdk8u with 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
Source File: Util.java    From jdk8u60 with 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 16
Source File: Util.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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 17
Source File: Util.java    From openjdk-8 with 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 18
Source File: Util.java    From openjdk-8-source with 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 File: Util.java    From hottub with 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 File: Util.java    From openjdk-jdk9 with 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);
}