Java Code Examples for com.sun.corba.se.impl.util.RepositoryId#createForAnyType()

The following examples show how to use com.sun.corba.se.impl.util.RepositoryId#createForAnyType() . 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: ValueHandlerImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public String createForAnyType(Class cl)
{
   return RepositoryId.createForAnyType(cl);
}
 
Example 2
Source File: PortableRemoteObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Checks to ensure that an object of a remote or abstract interface type
 * can be cast to a desired type.
 * @param narrowFrom the object to check.
 * @param narrowTo the desired type.
 * @return an object which can be cast to the desired type.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public java.lang.Object narrow ( java.lang.Object narrowFrom,
    java.lang.Class narrowTo) throws ClassCastException
{
    java.lang.Object result = null;

    if (narrowFrom == null)
        return null;

    if (narrowTo == null)
        throw new NullPointerException("invalid argument");

    try {
        if (narrowTo.isAssignableFrom(narrowFrom.getClass()))
            return narrowFrom;

        // Is narrowTo an interface that might be
        // implemented by a servant running on iiop?
        if (narrowTo.isInterface() &&
            narrowTo != java.io.Serializable.class &&
            narrowTo != java.io.Externalizable.class) {

            org.omg.CORBA.Object narrowObj
                = (org.omg.CORBA.Object) narrowFrom;

            // Create an id from the narrowTo type...
            String id = RepositoryId.createForAnyType(narrowTo);

            if (narrowObj._is_a(id)) {
                return Utility.loadStub(narrowObj,narrowTo);
            } else {
                throw new ClassCastException( "Object is not of remote type " +
                    narrowTo.getName() ) ;
            }
        } else {
            throw new ClassCastException( "Class " + narrowTo.getName() +
                " is not a valid remote interface" ) ;
        }
    } catch(Exception error) {
        ClassCastException cce = new ClassCastException() ;
        cce.initCause( error ) ;
        throw cce ;
    }
}
 
Example 3
Source File: RepIdDelegator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public String createForAnyType(Class type) {
    return RepositoryId.createForAnyType(type);
}
 
Example 4
Source File: ValueHandlerImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public String createForAnyType(Class cl)
{
   return RepositoryId.createForAnyType(cl);
}
 
Example 5
Source File: PortableRemoteObject.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Checks to ensure that an object of a remote or abstract interface type
 * can be cast to a desired type.
 * @param narrowFrom the object to check.
 * @param narrowTo the desired type.
 * @return an object which can be cast to the desired type.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public java.lang.Object narrow ( java.lang.Object narrowFrom,
    java.lang.Class narrowTo) throws ClassCastException
{
    java.lang.Object result = null;

    if (narrowFrom == null)
        return null;

    if (narrowTo == null)
        throw new NullPointerException("invalid argument");

    try {
        if (narrowTo.isAssignableFrom(narrowFrom.getClass()))
            return narrowFrom;

        // Is narrowTo an interface that might be
        // implemented by a servant running on iiop?
        if (narrowTo.isInterface() &&
            narrowTo != java.io.Serializable.class &&
            narrowTo != java.io.Externalizable.class) {

            org.omg.CORBA.Object narrowObj
                = (org.omg.CORBA.Object) narrowFrom;

            // Create an id from the narrowTo type...
            String id = RepositoryId.createForAnyType(narrowTo);

            if (narrowObj._is_a(id)) {
                return Utility.loadStub(narrowObj,narrowTo);
            } else {
                throw new ClassCastException( "Object is not of remote type " +
                    narrowTo.getName() ) ;
            }
        } else {
            throw new ClassCastException( "Class " + narrowTo.getName() +
                " is not a valid remote interface" ) ;
        }
    } catch(Exception error) {
        ClassCastException cce = new ClassCastException() ;
        cce.initCause( error ) ;
        throw cce ;
    }
}
 
Example 6
Source File: PortableRemoteObject.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Checks to ensure that an object of a remote or abstract interface type
 * can be cast to a desired type.
 * @param narrowFrom the object to check.
 * @param narrowTo the desired type.
 * @return an object which can be cast to the desired type.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public java.lang.Object narrow ( java.lang.Object narrowFrom,
    java.lang.Class narrowTo) throws ClassCastException
{
    java.lang.Object result = null;

    if (narrowFrom == null)
        return null;

    if (narrowTo == null)
        throw new NullPointerException("invalid argument");

    try {
        if (narrowTo.isAssignableFrom(narrowFrom.getClass()))
            return narrowFrom;

        // Is narrowTo an interface that might be
        // implemented by a servant running on iiop?
        if (narrowTo.isInterface() &&
            narrowTo != java.io.Serializable.class &&
            narrowTo != java.io.Externalizable.class) {

            org.omg.CORBA.Object narrowObj
                = (org.omg.CORBA.Object) narrowFrom;

            // Create an id from the narrowTo type...
            String id = RepositoryId.createForAnyType(narrowTo);

            if (narrowObj._is_a(id)) {
                return Utility.loadStub(narrowObj,narrowTo);
            } else {
                throw new ClassCastException( "Object is not of remote type " +
                    narrowTo.getName() ) ;
            }
        } else {
            throw new ClassCastException( "Class " + narrowTo.getName() +
                " is not a valid remote interface" ) ;
        }
    } catch(Exception error) {
        ClassCastException cce = new ClassCastException() ;
        cce.initCause( error ) ;
        throw cce ;
    }
}
 
Example 7
Source File: ValueHandlerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public String createForAnyType(Class cl)
{
   return RepositoryId.createForAnyType(cl);
}
 
Example 8
Source File: PortableRemoteObject.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Checks to ensure that an object of a remote or abstract interface type
 * can be cast to a desired type.
 * @param narrowFrom the object to check.
 * @param narrowTo the desired type.
 * @return an object which can be cast to the desired type.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public java.lang.Object narrow ( java.lang.Object narrowFrom,
    java.lang.Class narrowTo) throws ClassCastException
{
    java.lang.Object result = null;

    if (narrowFrom == null)
        return null;

    if (narrowTo == null)
        throw new NullPointerException("invalid argument");

    try {
        if (narrowTo.isAssignableFrom(narrowFrom.getClass()))
            return narrowFrom;

        // Is narrowTo an interface that might be
        // implemented by a servant running on iiop?
        if (narrowTo.isInterface() &&
            narrowTo != java.io.Serializable.class &&
            narrowTo != java.io.Externalizable.class) {

            org.omg.CORBA.Object narrowObj
                = (org.omg.CORBA.Object) narrowFrom;

            // Create an id from the narrowTo type...
            String id = RepositoryId.createForAnyType(narrowTo);

            if (narrowObj._is_a(id)) {
                return Utility.loadStub(narrowObj,narrowTo);
            } else {
                throw new ClassCastException( "Object is not of remote type " +
                    narrowTo.getName() ) ;
            }
        } else {
            throw new ClassCastException( "Class " + narrowTo.getName() +
                " is not a valid remote interface" ) ;
        }
    } catch(Exception error) {
        ClassCastException cce = new ClassCastException() ;
        cce.initCause( error ) ;
        throw cce ;
    }
}
 
Example 9
Source File: ValueHandlerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public String createForAnyType(Class cl)
{
   return RepositoryId.createForAnyType(cl);
}
 
Example 10
Source File: PortableRemoteObject.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Checks to ensure that an object of a remote or abstract interface type
 * can be cast to a desired type.
 * @param narrowFrom the object to check.
 * @param narrowTo the desired type.
 * @return an object which can be cast to the desired type.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public java.lang.Object narrow ( java.lang.Object narrowFrom,
    java.lang.Class narrowTo) throws ClassCastException
{
    java.lang.Object result = null;

    if (narrowFrom == null)
        return null;

    if (narrowTo == null)
        throw new NullPointerException("invalid argument");

    try {
        if (narrowTo.isAssignableFrom(narrowFrom.getClass()))
            return narrowFrom;

        // Is narrowTo an interface that might be
        // implemented by a servant running on iiop?
        if (narrowTo.isInterface() &&
            narrowTo != java.io.Serializable.class &&
            narrowTo != java.io.Externalizable.class) {

            org.omg.CORBA.Object narrowObj
                = (org.omg.CORBA.Object) narrowFrom;

            // Create an id from the narrowTo type...
            String id = RepositoryId.createForAnyType(narrowTo);

            if (narrowObj._is_a(id)) {
                return Utility.loadStub(narrowObj,narrowTo);
            } else {
                throw new ClassCastException( "Object is not of remote type " +
                    narrowTo.getName() ) ;
            }
        } else {
            throw new ClassCastException( "Class " + narrowTo.getName() +
                " is not a valid remote interface" ) ;
        }
    } catch(Exception error) {
        ClassCastException cce = new ClassCastException() ;
        cce.initCause( error ) ;
        throw cce ;
    }
}
 
Example 11
Source File: RepIdDelegator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public String createForAnyType(Class type) {
    return RepositoryId.createForAnyType(type);
}
 
Example 12
Source File: PortableRemoteObject.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Checks to ensure that an object of a remote or abstract interface type
 * can be cast to a desired type.
 * @param narrowFrom the object to check.
 * @param narrowTo the desired type.
 * @return an object which can be cast to the desired type.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public java.lang.Object narrow ( java.lang.Object narrowFrom,
    java.lang.Class narrowTo) throws ClassCastException
{
    java.lang.Object result = null;

    if (narrowFrom == null)
        return null;

    if (narrowTo == null)
        throw new NullPointerException("invalid argument");

    try {
        if (narrowTo.isAssignableFrom(narrowFrom.getClass()))
            return narrowFrom;

        // Is narrowTo an interface that might be
        // implemented by a servant running on iiop?
        if (narrowTo.isInterface() &&
            narrowTo != java.io.Serializable.class &&
            narrowTo != java.io.Externalizable.class) {

            org.omg.CORBA.Object narrowObj
                = (org.omg.CORBA.Object) narrowFrom;

            // Create an id from the narrowTo type...
            String id = RepositoryId.createForAnyType(narrowTo);

            if (narrowObj._is_a(id)) {
                return Utility.loadStub(narrowObj,narrowTo);
            } else {
                throw new ClassCastException( "Object is not of remote type " +
                    narrowTo.getName() ) ;
            }
        } else {
            throw new ClassCastException( "Class " + narrowTo.getName() +
                " is not a valid remote interface" ) ;
        }
    } catch(Exception error) {
        ClassCastException cce = new ClassCastException() ;
        cce.initCause( error ) ;
        throw cce ;
    }
}
 
Example 13
Source File: PortableRemoteObject.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Checks to ensure that an object of a remote or abstract interface type
 * can be cast to a desired type.
 * @param narrowFrom the object to check.
 * @param narrowTo the desired type.
 * @return an object which can be cast to the desired type.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public java.lang.Object narrow ( java.lang.Object narrowFrom,
    java.lang.Class narrowTo) throws ClassCastException
{
    java.lang.Object result = null;

    if (narrowFrom == null)
        return null;

    if (narrowTo == null)
        throw new NullPointerException("invalid argument");

    try {
        if (narrowTo.isAssignableFrom(narrowFrom.getClass()))
            return narrowFrom;

        // Is narrowTo an interface that might be
        // implemented by a servant running on iiop?
        if (narrowTo.isInterface() &&
            narrowTo != java.io.Serializable.class &&
            narrowTo != java.io.Externalizable.class) {

            org.omg.CORBA.Object narrowObj
                = (org.omg.CORBA.Object) narrowFrom;

            // Create an id from the narrowTo type...
            String id = RepositoryId.createForAnyType(narrowTo);

            if (narrowObj._is_a(id)) {
                return Utility.loadStub(narrowObj,narrowTo);
            } else {
                throw new ClassCastException( "Object is not of remote type " +
                    narrowTo.getName() ) ;
            }
        } else {
            throw new ClassCastException( "Class " + narrowTo.getName() +
                " is not a valid remote interface" ) ;
        }
    } catch(Exception error) {
        ClassCastException cce = new ClassCastException() ;
        cce.initCause( error ) ;
        throw cce ;
    }
}
 
Example 14
Source File: RepIdDelegator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public String createForAnyType(Class type) {
    return RepositoryId.createForAnyType(type);
}
 
Example 15
Source File: Type.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
protected boolean setRepositoryID() {

        // First, load the class...

        if (!initClass()) {
            return false;
        }

        // Now make the repositoryID and return success...

        repositoryID = RepositoryId.createForAnyType(ourClass);
        return true;
    }
 
Example 16
Source File: Type.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
protected boolean setRepositoryID() {

        // First, load the class...

        if (!initClass()) {
            return false;
        }

        // Now make the repositoryID and return success...

        repositoryID = RepositoryId.createForAnyType(ourClass);
        return true;
    }
 
Example 17
Source File: Type.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
protected boolean setRepositoryID() {

        // First, load the class...

        if (!initClass()) {
            return false;
        }

        // Now make the repositoryID and return success...

        repositoryID = RepositoryId.createForAnyType(ourClass);
        return true;
    }
 
Example 18
Source File: Type.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
protected boolean setRepositoryID() {

        // First, load the class...

        if (!initClass()) {
            return false;
        }

        // Now make the repositoryID and return success...

        repositoryID = RepositoryId.createForAnyType(ourClass);
        return true;
    }
 
Example 19
Source File: Type.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
protected boolean setRepositoryID() {

        // First, load the class...

        if (!initClass()) {
            return false;
        }

        // Now make the repositoryID and return success...

        repositoryID = RepositoryId.createForAnyType(ourClass);
        return true;
    }
 
Example 20
Source File: Type.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
protected boolean setRepositoryID() {

        // First, load the class...

        if (!initClass()) {
            return false;
        }

        // Now make the repositoryID and return success...

        repositoryID = RepositoryId.createForAnyType(ourClass);
        return true;
    }