Java 类java.rmi.StubNotFoundException 实例源码

项目:cn1    文件:ActivatableRef.java   
/**
 * Returns the Remote Stub for the given activatable class.
 */
public static RemoteStub getStub(ActivationDesc desc, ActivationID aid)
        throws StubNotFoundException {

    String cn = desc.getClassName();
    String stubName = ""; //$NON-NLS-1$

    try {
        Class cl = RMIClassLoader.loadClass(desc.getLocation(), cn);
        Class rcl = RMIUtil.getRemoteClass(cl);
        stubName = rcl.getName() + "_Stub"; //$NON-NLS-1$
        Class stubClass = RMIClassLoader.loadClass((String) null, stubName);
        Constructor constructor = stubClass.getConstructor(new Class[] { RemoteRef.class });
        RemoteStub stub = (RemoteStub) constructor.newInstance(new Object[] {
                new ActivatableRef(aid, null)
        });
        return stub;

    } catch (Exception ex) {
        // rmi.68=Stub {0} not found.
        throw new StubNotFoundException(Messages.getString("rmi.68", stubName), //$NON-NLS-1$ //$NON-NLS-2$
                ex);
    }
}
项目:cn1    文件:UnicastServerRef.java   
/**
 * Loads stub class for the given remote class.
 *
 * @param c Class whose stub should be loaded
 * @param throwException should we throw StubNotFoundException in case of
 *        failure or silently return null
 *
 * @return loaded stub or null if throwException is false and any failure
 *         occurred during stub loading
 *
 * @throws StubNotFoundException if throwException parameter is true and any
 *         failure occurred during stub loading
 */
protected Class loadStubClass(Class c, boolean throwException)
        throws StubNotFoundException {
    String stubName = c.getName() + "_Stub"; //$NON-NLS-1$
    ClassLoader cl = c.getClassLoader();

    try {
        if (cl != null) {
            return cl.loadClass(stubName);
        } else {
            return Class.forName(stubName);
        }
    } catch (ClassNotFoundException cnfe) {
        if (throwException) {
            // rmi.68=Stub {0} not found.
            throw new StubNotFoundException(Messages.getString("rmi.68", stubName), cnfe); //$NON-NLS-1$
        }
    }
    return null;
}
项目:freeVM    文件:RemoteReferenceManager.java   
/**
 * Finds the "root class" according to RMI Specification, wich name will be
 * used for constructing the name of the stub class that corresponds to the
 * <code>inspect</code> class.
 * 
 * @param inspect
 *            the class of the object
 * @return the root class of the object
 * @throws StubNotFoundException
 *             If the class does not implement any remote interfaces
 */
// Returns the apropriate root class for a stub of the class received as
// parameter.
private final Class findStubBaseClass(Class inspect)
        throws StubNotFoundException {
    Set<Class> remoteInterfacesList = RemoteUtils
            .getRemoteInterfaces(inspect);

    do {
        // Check if the class implements any Remote Interface directly
        Class[] directInterfacesList = inspect.getInterfaces();
        for (Class directInterface : directInterfacesList) {
            if (remoteInterfacesList.contains(directInterface)) {
                return inspect;
            }
        }
        // The interfaces implemented directly aren't remote interfaces...
        // check now the interfaces implemented directly by the superclass.
        inspect = inspect.getSuperclass();
    } while (inspect != null);

    throw new StubNotFoundException(
            "The remote object doesn't implement any Remote interfaces.");
}
项目:freeVM    文件:RemoteReferenceManager.java   
/**
 * Finds the "root class" according to RMI Specification, wich name will be
 * used for constructing the name of the stub class that corresponds to the
 * <code>inspect</code> class.
 * 
 * @param inspect
 *            the class of the object
 * @return the root class of the object
 * @throws StubNotFoundException
 *             If the class does not implement any remote interfaces
 */
// Returns the apropriate root class for a stub of the class received as
// parameter.
private final Class findStubBaseClass(Class inspect)
        throws StubNotFoundException {
    Set<Class> remoteInterfacesList = RemoteUtils
            .getRemoteInterfaces(inspect);

    do {
        // Check if the class implements any Remote Interface directly
        Class[] directInterfacesList = inspect.getInterfaces();
        for (Class directInterface : directInterfacesList) {
            if (remoteInterfacesList.contains(directInterface)) {
                return inspect;
            }
        }
        // The interfaces implemented directly aren't remote interfaces...
        // check now the interfaces implemented directly by the superclass.
        inspect = inspect.getSuperclass();
    } while (inspect != null);

    throw new StubNotFoundException(
            "The remote object doesn't implement any Remote interfaces.");
}
项目:freeVM    文件:ActivatableRef.java   
/**
 * Returns the Remote Stub for the given activatable class.
 */
public static RemoteStub getStub(ActivationDesc desc, ActivationID aid)
        throws StubNotFoundException {

    String cn = desc.getClassName();
    String stubName = ""; //$NON-NLS-1$

    try {
        Class cl = RMIClassLoader.loadClass(desc.getLocation(), cn);
        Class rcl = RMIUtil.getRemoteClass(cl);
        stubName = rcl.getName() + "_Stub"; //$NON-NLS-1$
        Class stubClass = RMIClassLoader.loadClass((String) null, stubName);
        Constructor constructor = stubClass.getConstructor(new Class[] { RemoteRef.class });
        RemoteStub stub = (RemoteStub) constructor.newInstance(new Object[] {
                new ActivatableRef(aid, null)
        });
        return stub;

    } catch (Exception ex) {
        // rmi.68=Stub {0} not found.
        throw new StubNotFoundException(Messages.getString("rmi.68", stubName), //$NON-NLS-1$ //$NON-NLS-2$
                ex);
    }
}
项目:freeVM    文件:UnicastServerRef.java   
/**
 * Loads stub class for the given remote class.
 *
 * @param c Class whose stub should be loaded
 * @param throwException should we throw StubNotFoundException in case of
 *        failure or silently return null
 *
 * @return loaded stub or null if throwException is false and any failure
 *         occurred during stub loading
 *
 * @throws StubNotFoundException if throwException parameter is true and any
 *         failure occurred during stub loading
 */
protected Class loadStubClass(Class c, boolean throwException)
        throws StubNotFoundException {
    String stubName = c.getName() + "_Stub"; //$NON-NLS-1$
    ClassLoader cl = c.getClassLoader();

    try {
        if (cl != null) {
            return cl.loadClass(stubName);
        } else {
            return Class.forName(stubName);
        }
    } catch (ClassNotFoundException cnfe) {
        if (throwException) {
            // rmi.68=Stub {0} not found.
            throw new StubNotFoundException(Messages.getString("rmi.68", stubName), cnfe); //$NON-NLS-1$
        }
    }
    return null;
}
项目:freeVM    文件:ActivatableRef.java   
/**
 * Returns the Remote Stub for the given activatable class.
 */
public static RemoteStub getStub(ActivationDesc desc, ActivationID aid)
        throws StubNotFoundException {

    String cn = desc.getClassName();
    String stubName = ""; //$NON-NLS-1$

    try {
        Class cl = RMIClassLoader.loadClass(desc.getLocation(), cn);
        Class rcl = RMIUtil.getRemoteClass(cl);
        stubName = rcl.getName() + "_Stub"; //$NON-NLS-1$
        Class stubClass = RMIClassLoader.loadClass((String) null, stubName);
        Constructor constructor = stubClass.getConstructor(new Class[] { RemoteRef.class });
        RemoteStub stub = (RemoteStub) constructor.newInstance(new Object[] {
                new ActivatableRef(aid, null)
        });
        return stub;

    } catch (Exception ex) {
        // rmi.68=Stub {0} not found.
        throw new StubNotFoundException(Messages.getString("rmi.68", stubName), //$NON-NLS-1$ //$NON-NLS-2$
                ex);
    }
}
项目:freeVM    文件:UnicastServerRef.java   
/**
 * Loads stub class for the given remote class.
 *
 * @param c Class whose stub should be loaded
 * @param throwException should we throw StubNotFoundException in case of
 *        failure or silently return null
 *
 * @return loaded stub or null if throwException is false and any failure
 *         occurred during stub loading
 *
 * @throws StubNotFoundException if throwException parameter is true and any
 *         failure occurred during stub loading
 */
protected Class loadStubClass(Class c, boolean throwException)
        throws StubNotFoundException {
    String stubName = c.getName() + "_Stub"; //$NON-NLS-1$
    ClassLoader cl = c.getClassLoader();

    try {
        if (cl != null) {
            return cl.loadClass(stubName);
        } else {
            return Class.forName(stubName);
        }
    } catch (ClassNotFoundException cnfe) {
        if (throwException) {
            // rmi.68=Stub {0} not found.
            throw new StubNotFoundException(Messages.getString("rmi.68", stubName), cnfe); //$NON-NLS-1$
        }
    }
    return null;
}
项目:OpenJSharp    文件:Util.java   
/**
 * Returns a proxy for the specified implClass.
 *
 * If both of the following criteria is satisfied, a dynamic proxy for
 * the specified implClass is returned (otherwise a RemoteStub instance
 * for the specified implClass is returned):
 *
 *    a) either the property java.rmi.server.ignoreStubClasses is true or
 *       a pregenerated stub class does not exist for the impl class, and
 *    b) forceStubUse is false.
 *
 * If the above criteria are satisfied, this method constructs a
 * dynamic proxy instance (that implements the remote interfaces of
 * implClass) constructed with a RemoteObjectInvocationHandler instance
 * constructed with the clientRef.
 *
 * Otherwise, this method loads the pregenerated stub class (which
 * extends RemoteStub and implements the remote interfaces of
 * implClass) and constructs an instance of the pregenerated stub
 * class with the clientRef.
 *
 * @param implClass the class to obtain remote interfaces from
 * @param clientRef the remote ref to use in the invocation handler
 * @param forceStubUse if true, forces creation of a RemoteStub
 * @throws IllegalArgumentException if implClass implements illegal
 * remote interfaces
 * @throws StubNotFoundException if problem locating/creating stub or
 * creating the dynamic proxy instance
 **/
public static Remote createProxy(Class<?> implClass,
                                 RemoteRef clientRef,
                                 boolean forceStubUse)
    throws StubNotFoundException
{
    Class<?> remoteClass;

    try {
        remoteClass = getRemoteClass(implClass);
    } catch (ClassNotFoundException ex ) {
        throw new StubNotFoundException(
            "object does not implement a remote interface: " +
            implClass.getName());
    }

    if (forceStubUse ||
        !(ignoreStubClasses || !stubClassExists(remoteClass)))
    {
        return createStub(remoteClass, clientRef);
    }

    final ClassLoader loader = implClass.getClassLoader();
    final Class<?>[] interfaces = getRemoteInterfaces(implClass);
    final InvocationHandler handler =
        new RemoteObjectInvocationHandler(clientRef);

    /* REMIND: private remote interfaces? */

    try {
        return AccessController.doPrivileged(new PrivilegedAction<Remote>() {
            public Remote run() {
                return (Remote) Proxy.newProxyInstance(loader,
                                                       interfaces,
                                                       handler);
            }});
    } catch (IllegalArgumentException e) {
        throw new StubNotFoundException("unable to create proxy", e);
    }
}
项目:jdk8u-jdk    文件:Util.java   
/**
 * Returns a proxy for the specified implClass.
 *
 * If both of the following criteria is satisfied, a dynamic proxy for
 * the specified implClass is returned (otherwise a RemoteStub instance
 * for the specified implClass is returned):
 *
 *    a) either the property java.rmi.server.ignoreStubClasses is true or
 *       a pregenerated stub class does not exist for the impl class, and
 *    b) forceStubUse is false.
 *
 * If the above criteria are satisfied, this method constructs a
 * dynamic proxy instance (that implements the remote interfaces of
 * implClass) constructed with a RemoteObjectInvocationHandler instance
 * constructed with the clientRef.
 *
 * Otherwise, this method loads the pregenerated stub class (which
 * extends RemoteStub and implements the remote interfaces of
 * implClass) and constructs an instance of the pregenerated stub
 * class with the clientRef.
 *
 * @param implClass the class to obtain remote interfaces from
 * @param clientRef the remote ref to use in the invocation handler
 * @param forceStubUse if true, forces creation of a RemoteStub
 * @throws IllegalArgumentException if implClass implements illegal
 * remote interfaces
 * @throws StubNotFoundException if problem locating/creating stub or
 * creating the dynamic proxy instance
 **/
public static Remote createProxy(Class<?> implClass,
                                 RemoteRef clientRef,
                                 boolean forceStubUse)
    throws StubNotFoundException
{
    Class<?> remoteClass;

    try {
        remoteClass = getRemoteClass(implClass);
    } catch (ClassNotFoundException ex ) {
        throw new StubNotFoundException(
            "object does not implement a remote interface: " +
            implClass.getName());
    }

    if (forceStubUse ||
        !(ignoreStubClasses || !stubClassExists(remoteClass)))
    {
        return createStub(remoteClass, clientRef);
    }

    final ClassLoader loader = implClass.getClassLoader();
    final Class<?>[] interfaces = getRemoteInterfaces(implClass);
    final InvocationHandler handler =
        new RemoteObjectInvocationHandler(clientRef);

    /* REMIND: private remote interfaces? */

    try {
        return AccessController.doPrivileged(new PrivilegedAction<Remote>() {
            public Remote run() {
                return (Remote) Proxy.newProxyInstance(loader,
                                                       interfaces,
                                                       handler);
            }});
    } catch (IllegalArgumentException e) {
        throw new StubNotFoundException("unable to create proxy", e);
    }
}
项目:openjdk-jdk10    文件:Util.java   
/**
 * Returns a proxy for the specified implClass.
 *
 * If both of the following criteria is satisfied, a dynamic proxy for
 * the specified implClass is returned (otherwise a RemoteStub instance
 * for the specified implClass is returned):
 *
 *    a) either the property java.rmi.server.ignoreStubClasses is true or
 *       a pregenerated stub class does not exist for the impl class, and
 *    b) forceStubUse is false.
 *
 * If the above criteria are satisfied, this method constructs a
 * dynamic proxy instance (that implements the remote interfaces of
 * implClass) constructed with a RemoteObjectInvocationHandler instance
 * constructed with the clientRef.
 *
 * Otherwise, this method loads the pregenerated stub class (which
 * extends RemoteStub and implements the remote interfaces of
 * implClass) and constructs an instance of the pregenerated stub
 * class with the clientRef.
 *
 * @param implClass the class to obtain remote interfaces from
 * @param clientRef the remote ref to use in the invocation handler
 * @param forceStubUse if true, forces creation of a RemoteStub
 * @throws IllegalArgumentException if implClass implements illegal
 * remote interfaces
 * @throws StubNotFoundException if problem locating/creating stub or
 * creating the dynamic proxy instance
 **/
public static Remote createProxy(Class<?> implClass,
                                 RemoteRef clientRef,
                                 boolean forceStubUse)
    throws StubNotFoundException
{
    Class<?> remoteClass;

    try {
        remoteClass = getRemoteClass(implClass);
    } catch (ClassNotFoundException ex ) {
        throw new StubNotFoundException(
            "object does not implement a remote interface: " +
            implClass.getName());
    }

    if (forceStubUse ||
        !(ignoreStubClasses || !stubClassExists(remoteClass)))
    {
        return createStub(remoteClass, clientRef);
    }

    final ClassLoader loader = implClass.getClassLoader();
    final Class<?>[] interfaces = getRemoteInterfaces(implClass);
    final InvocationHandler handler =
        new RemoteObjectInvocationHandler(clientRef);

    /* REMIND: private remote interfaces? */

    try {
        return AccessController.doPrivileged(new PrivilegedAction<Remote>() {
            public Remote run() {
                return (Remote) Proxy.newProxyInstance(loader,
                                                       interfaces,
                                                       handler);
            }});
    } catch (IllegalArgumentException e) {
        throw new StubNotFoundException("unable to create proxy", e);
    }
}
项目:openjdk9    文件:Util.java   
/**
 * Returns a proxy for the specified implClass.
 *
 * If both of the following criteria is satisfied, a dynamic proxy for
 * the specified implClass is returned (otherwise a RemoteStub instance
 * for the specified implClass is returned):
 *
 *    a) either the property java.rmi.server.ignoreStubClasses is true or
 *       a pregenerated stub class does not exist for the impl class, and
 *    b) forceStubUse is false.
 *
 * If the above criteria are satisfied, this method constructs a
 * dynamic proxy instance (that implements the remote interfaces of
 * implClass) constructed with a RemoteObjectInvocationHandler instance
 * constructed with the clientRef.
 *
 * Otherwise, this method loads the pregenerated stub class (which
 * extends RemoteStub and implements the remote interfaces of
 * implClass) and constructs an instance of the pregenerated stub
 * class with the clientRef.
 *
 * @param implClass the class to obtain remote interfaces from
 * @param clientRef the remote ref to use in the invocation handler
 * @param forceStubUse if true, forces creation of a RemoteStub
 * @throws IllegalArgumentException if implClass implements illegal
 * remote interfaces
 * @throws StubNotFoundException if problem locating/creating stub or
 * creating the dynamic proxy instance
 **/
public static Remote createProxy(Class<?> implClass,
                                 RemoteRef clientRef,
                                 boolean forceStubUse)
    throws StubNotFoundException
{
    Class<?> remoteClass;

    try {
        remoteClass = getRemoteClass(implClass);
    } catch (ClassNotFoundException ex ) {
        throw new StubNotFoundException(
            "object does not implement a remote interface: " +
            implClass.getName());
    }

    if (forceStubUse ||
        !(ignoreStubClasses || !stubClassExists(remoteClass)))
    {
        return createStub(remoteClass, clientRef);
    }

    final ClassLoader loader = implClass.getClassLoader();
    final Class<?>[] interfaces = getRemoteInterfaces(implClass);
    final InvocationHandler handler =
        new RemoteObjectInvocationHandler(clientRef);

    /* REMIND: private remote interfaces? */

    try {
        return AccessController.doPrivileged(new PrivilegedAction<Remote>() {
            public Remote run() {
                return (Remote) Proxy.newProxyInstance(loader,
                                                       interfaces,
                                                       handler);
            }});
    } catch (IllegalArgumentException e) {
        throw new StubNotFoundException("unable to create proxy", e);
    }
}
项目:jdk8u_jdk    文件:Util.java   
/**
 * Returns a proxy for the specified implClass.
 *
 * If both of the following criteria is satisfied, a dynamic proxy for
 * the specified implClass is returned (otherwise a RemoteStub instance
 * for the specified implClass is returned):
 *
 *    a) either the property java.rmi.server.ignoreStubClasses is true or
 *       a pregenerated stub class does not exist for the impl class, and
 *    b) forceStubUse is false.
 *
 * If the above criteria are satisfied, this method constructs a
 * dynamic proxy instance (that implements the remote interfaces of
 * implClass) constructed with a RemoteObjectInvocationHandler instance
 * constructed with the clientRef.
 *
 * Otherwise, this method loads the pregenerated stub class (which
 * extends RemoteStub and implements the remote interfaces of
 * implClass) and constructs an instance of the pregenerated stub
 * class with the clientRef.
 *
 * @param implClass the class to obtain remote interfaces from
 * @param clientRef the remote ref to use in the invocation handler
 * @param forceStubUse if true, forces creation of a RemoteStub
 * @throws IllegalArgumentException if implClass implements illegal
 * remote interfaces
 * @throws StubNotFoundException if problem locating/creating stub or
 * creating the dynamic proxy instance
 **/
public static Remote createProxy(Class<?> implClass,
                                 RemoteRef clientRef,
                                 boolean forceStubUse)
    throws StubNotFoundException
{
    Class<?> remoteClass;

    try {
        remoteClass = getRemoteClass(implClass);
    } catch (ClassNotFoundException ex ) {
        throw new StubNotFoundException(
            "object does not implement a remote interface: " +
            implClass.getName());
    }

    if (forceStubUse ||
        !(ignoreStubClasses || !stubClassExists(remoteClass)))
    {
        return createStub(remoteClass, clientRef);
    }

    final ClassLoader loader = implClass.getClassLoader();
    final Class<?>[] interfaces = getRemoteInterfaces(implClass);
    final InvocationHandler handler =
        new RemoteObjectInvocationHandler(clientRef);

    /* REMIND: private remote interfaces? */

    try {
        return AccessController.doPrivileged(new PrivilegedAction<Remote>() {
            public Remote run() {
                return (Remote) Proxy.newProxyInstance(loader,
                                                       interfaces,
                                                       handler);
            }});
    } catch (IllegalArgumentException e) {
        throw new StubNotFoundException("unable to create proxy", e);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Util.java   
/**
 * Returns a proxy for the specified implClass.
 *
 * If both of the following criteria is satisfied, a dynamic proxy for
 * the specified implClass is returned (otherwise a RemoteStub instance
 * for the specified implClass is returned):
 *
 *    a) either the property java.rmi.server.ignoreStubClasses is true or
 *       a pregenerated stub class does not exist for the impl class, and
 *    b) forceStubUse is false.
 *
 * If the above criteria are satisfied, this method constructs a
 * dynamic proxy instance (that implements the remote interfaces of
 * implClass) constructed with a RemoteObjectInvocationHandler instance
 * constructed with the clientRef.
 *
 * Otherwise, this method loads the pregenerated stub class (which
 * extends RemoteStub and implements the remote interfaces of
 * implClass) and constructs an instance of the pregenerated stub
 * class with the clientRef.
 *
 * @param implClass the class to obtain remote interfaces from
 * @param clientRef the remote ref to use in the invocation handler
 * @param forceStubUse if true, forces creation of a RemoteStub
 * @throws IllegalArgumentException if implClass implements illegal
 * remote interfaces
 * @throws StubNotFoundException if problem locating/creating stub or
 * creating the dynamic proxy instance
 **/
public static Remote createProxy(Class<?> implClass,
                                 RemoteRef clientRef,
                                 boolean forceStubUse)
    throws StubNotFoundException
{
    Class<?> remoteClass;

    try {
        remoteClass = getRemoteClass(implClass);
    } catch (ClassNotFoundException ex ) {
        throw new StubNotFoundException(
            "object does not implement a remote interface: " +
            implClass.getName());
    }

    if (forceStubUse ||
        !(ignoreStubClasses || !stubClassExists(remoteClass)))
    {
        return createStub(remoteClass, clientRef);
    }

    final ClassLoader loader = implClass.getClassLoader();
    final Class<?>[] interfaces = getRemoteInterfaces(implClass);
    final InvocationHandler handler =
        new RemoteObjectInvocationHandler(clientRef);

    /* REMIND: private remote interfaces? */

    try {
        return AccessController.doPrivileged(new PrivilegedAction<Remote>() {
            public Remote run() {
                return (Remote) Proxy.newProxyInstance(loader,
                                                       interfaces,
                                                       handler);
            }});
    } catch (IllegalArgumentException e) {
        throw new StubNotFoundException("unable to create proxy", e);
    }
}
项目:infobip-open-jdk-8    文件:Util.java   
/**
 * Returns a proxy for the specified implClass.
 *
 * If both of the following criteria is satisfied, a dynamic proxy for
 * the specified implClass is returned (otherwise a RemoteStub instance
 * for the specified implClass is returned):
 *
 *    a) either the property java.rmi.server.ignoreStubClasses is true or
 *       a pregenerated stub class does not exist for the impl class, and
 *    b) forceStubUse is false.
 *
 * If the above criteria are satisfied, this method constructs a
 * dynamic proxy instance (that implements the remote interfaces of
 * implClass) constructed with a RemoteObjectInvocationHandler instance
 * constructed with the clientRef.
 *
 * Otherwise, this method loads the pregenerated stub class (which
 * extends RemoteStub and implements the remote interfaces of
 * implClass) and constructs an instance of the pregenerated stub
 * class with the clientRef.
 *
 * @param implClass the class to obtain remote interfaces from
 * @param clientRef the remote ref to use in the invocation handler
 * @param forceStubUse if true, forces creation of a RemoteStub
 * @throws IllegalArgumentException if implClass implements illegal
 * remote interfaces
 * @throws StubNotFoundException if problem locating/creating stub or
 * creating the dynamic proxy instance
 **/
public static Remote createProxy(Class<?> implClass,
                                 RemoteRef clientRef,
                                 boolean forceStubUse)
    throws StubNotFoundException
{
    Class<?> remoteClass;

    try {
        remoteClass = getRemoteClass(implClass);
    } catch (ClassNotFoundException ex ) {
        throw new StubNotFoundException(
            "object does not implement a remote interface: " +
            implClass.getName());
    }

    if (forceStubUse ||
        !(ignoreStubClasses || !stubClassExists(remoteClass)))
    {
        return createStub(remoteClass, clientRef);
    }

    final ClassLoader loader = implClass.getClassLoader();
    final Class<?>[] interfaces = getRemoteInterfaces(implClass);
    final InvocationHandler handler =
        new RemoteObjectInvocationHandler(clientRef);

    /* REMIND: private remote interfaces? */

    try {
        return AccessController.doPrivileged(new PrivilegedAction<Remote>() {
            public Remote run() {
                return (Remote) Proxy.newProxyInstance(loader,
                                                       interfaces,
                                                       handler);
            }});
    } catch (IllegalArgumentException e) {
        throw new StubNotFoundException("unable to create proxy", e);
    }
}
项目:jdk8u-dev-jdk    文件:Util.java   
/**
 * Returns a proxy for the specified implClass.
 *
 * If both of the following criteria is satisfied, a dynamic proxy for
 * the specified implClass is returned (otherwise a RemoteStub instance
 * for the specified implClass is returned):
 *
 *    a) either the property java.rmi.server.ignoreStubClasses is true or
 *       a pregenerated stub class does not exist for the impl class, and
 *    b) forceStubUse is false.
 *
 * If the above criteria are satisfied, this method constructs a
 * dynamic proxy instance (that implements the remote interfaces of
 * implClass) constructed with a RemoteObjectInvocationHandler instance
 * constructed with the clientRef.
 *
 * Otherwise, this method loads the pregenerated stub class (which
 * extends RemoteStub and implements the remote interfaces of
 * implClass) and constructs an instance of the pregenerated stub
 * class with the clientRef.
 *
 * @param implClass the class to obtain remote interfaces from
 * @param clientRef the remote ref to use in the invocation handler
 * @param forceStubUse if true, forces creation of a RemoteStub
 * @throws IllegalArgumentException if implClass implements illegal
 * remote interfaces
 * @throws StubNotFoundException if problem locating/creating stub or
 * creating the dynamic proxy instance
 **/
public static Remote createProxy(Class<?> implClass,
                                 RemoteRef clientRef,
                                 boolean forceStubUse)
    throws StubNotFoundException
{
    Class<?> remoteClass;

    try {
        remoteClass = getRemoteClass(implClass);
    } catch (ClassNotFoundException ex ) {
        throw new StubNotFoundException(
            "object does not implement a remote interface: " +
            implClass.getName());
    }

    if (forceStubUse ||
        !(ignoreStubClasses || !stubClassExists(remoteClass)))
    {
        return createStub(remoteClass, clientRef);
    }

    final ClassLoader loader = implClass.getClassLoader();
    final Class<?>[] interfaces = getRemoteInterfaces(implClass);
    final InvocationHandler handler =
        new RemoteObjectInvocationHandler(clientRef);

    /* REMIND: private remote interfaces? */

    try {
        return AccessController.doPrivileged(new PrivilegedAction<Remote>() {
            public Remote run() {
                return (Remote) Proxy.newProxyInstance(loader,
                                                       interfaces,
                                                       handler);
            }});
    } catch (IllegalArgumentException e) {
        throw new StubNotFoundException("unable to create proxy", e);
    }
}
项目:jdk7-jdk    文件:Util.java   
/**
 * Returns a proxy for the specified implClass.
 *
 * If both of the following criteria is satisfied, a dynamic proxy for
 * the specified implClass is returned (otherwise a RemoteStub instance
 * for the specified implClass is returned):
 *
 *    a) either the property java.rmi.server.ignoreStubClasses is true or
 *       a pregenerated stub class does not exist for the impl class, and
 *    b) forceStubUse is false.
 *
 * If the above criteria are satisfied, this method constructs a
 * dynamic proxy instance (that implements the remote interfaces of
 * implClass) constructed with a RemoteObjectInvocationHandler instance
 * constructed with the clientRef.
 *
 * Otherwise, this method loads the pregenerated stub class (which
 * extends RemoteStub and implements the remote interfaces of
 * implClass) and constructs an instance of the pregenerated stub
 * class with the clientRef.
 *
 * @param implClass the class to obtain remote interfaces from
 * @param clientRef the remote ref to use in the invocation handler
 * @param forceStubUse if true, forces creation of a RemoteStub
 * @throws IllegalArgumentException if implClass implements illegal
 * remote interfaces
 * @throws StubNotFoundException if problem locating/creating stub or
 * creating the dynamic proxy instance
 **/
public static Remote createProxy(Class implClass,
                                 RemoteRef clientRef,
                                 boolean forceStubUse)
    throws StubNotFoundException
{
    Class remoteClass;

    try {
        remoteClass = getRemoteClass(implClass);
    } catch (ClassNotFoundException ex ) {
        throw new StubNotFoundException(
            "object does not implement a remote interface: " +
            implClass.getName());
    }

    if (forceStubUse ||
        !(ignoreStubClasses || !stubClassExists(remoteClass)))
    {
        return createStub(remoteClass, clientRef);
    }

    ClassLoader loader = implClass.getClassLoader();
    Class[] interfaces = getRemoteInterfaces(implClass);
    InvocationHandler handler =
        new RemoteObjectInvocationHandler(clientRef);

    /* REMIND: private remote interfaces? */

    try {
        return (Remote) Proxy.newProxyInstance(loader,
                                               interfaces,
                                               handler);
    } catch (IllegalArgumentException e) {
        throw new StubNotFoundException("unable to create proxy", e);
    }
}
项目:openjdk-source-code-learn    文件:Util.java   
/**
 * Returns a proxy for the specified implClass.
 *
 * If both of the following criteria is satisfied, a dynamic proxy for
 * the specified implClass is returned (otherwise a RemoteStub instance
 * for the specified implClass is returned):
 *
 *    a) either the property java.rmi.server.ignoreStubClasses is true or
 *       a pregenerated stub class does not exist for the impl class, and
 *    b) forceStubUse is false.
 *
 * If the above criteria are satisfied, this method constructs a
 * dynamic proxy instance (that implements the remote interfaces of
 * implClass) constructed with a RemoteObjectInvocationHandler instance
 * constructed with the clientRef.
 *
 * Otherwise, this method loads the pregenerated stub class (which
 * extends RemoteStub and implements the remote interfaces of
 * implClass) and constructs an instance of the pregenerated stub
 * class with the clientRef.
 *
 * @param implClass the class to obtain remote interfaces from
 * @param clientRef the remote ref to use in the invocation handler
 * @param forceStubUse if true, forces creation of a RemoteStub
 * @throws IllegalArgumentException if implClass implements illegal
 * remote interfaces
 * @throws StubNotFoundException if problem locating/creating stub or
 * creating the dynamic proxy instance
 **/
public static Remote createProxy(Class implClass,
                                 RemoteRef clientRef,
                                 boolean forceStubUse)
    throws StubNotFoundException
{
    Class remoteClass;

    try {
        remoteClass = getRemoteClass(implClass);
    } catch (ClassNotFoundException ex ) {
        throw new StubNotFoundException(
            "object does not implement a remote interface: " +
            implClass.getName());
    }

    if (forceStubUse ||
        !(ignoreStubClasses || !stubClassExists(remoteClass)))
    {
        return createStub(remoteClass, clientRef);
    }

    ClassLoader loader = implClass.getClassLoader();
    Class[] interfaces = getRemoteInterfaces(implClass);
    InvocationHandler handler =
        new RemoteObjectInvocationHandler(clientRef);

    /* REMIND: private remote interfaces? */

    try {
        return (Remote) Proxy.newProxyInstance(loader,
                                               interfaces,
                                               handler);
    } catch (IllegalArgumentException e) {
        throw new StubNotFoundException("unable to create proxy", e);
    }
}
项目:OLD-OpenJDK8    文件:Util.java   
/**
 * Returns a proxy for the specified implClass.
 *
 * If both of the following criteria is satisfied, a dynamic proxy for
 * the specified implClass is returned (otherwise a RemoteStub instance
 * for the specified implClass is returned):
 *
 *    a) either the property java.rmi.server.ignoreStubClasses is true or
 *       a pregenerated stub class does not exist for the impl class, and
 *    b) forceStubUse is false.
 *
 * If the above criteria are satisfied, this method constructs a
 * dynamic proxy instance (that implements the remote interfaces of
 * implClass) constructed with a RemoteObjectInvocationHandler instance
 * constructed with the clientRef.
 *
 * Otherwise, this method loads the pregenerated stub class (which
 * extends RemoteStub and implements the remote interfaces of
 * implClass) and constructs an instance of the pregenerated stub
 * class with the clientRef.
 *
 * @param implClass the class to obtain remote interfaces from
 * @param clientRef the remote ref to use in the invocation handler
 * @param forceStubUse if true, forces creation of a RemoteStub
 * @throws IllegalArgumentException if implClass implements illegal
 * remote interfaces
 * @throws StubNotFoundException if problem locating/creating stub or
 * creating the dynamic proxy instance
 **/
public static Remote createProxy(Class<?> implClass,
                                 RemoteRef clientRef,
                                 boolean forceStubUse)
    throws StubNotFoundException
{
    Class<?> remoteClass;

    try {
        remoteClass = getRemoteClass(implClass);
    } catch (ClassNotFoundException ex ) {
        throw new StubNotFoundException(
            "object does not implement a remote interface: " +
            implClass.getName());
    }

    if (forceStubUse ||
        !(ignoreStubClasses || !stubClassExists(remoteClass)))
    {
        return createStub(remoteClass, clientRef);
    }

    final ClassLoader loader = implClass.getClassLoader();
    final Class<?>[] interfaces = getRemoteInterfaces(implClass);
    final InvocationHandler handler =
        new RemoteObjectInvocationHandler(clientRef);

    /* REMIND: private remote interfaces? */

    try {
        return AccessController.doPrivileged(new PrivilegedAction<Remote>() {
            public Remote run() {
                return (Remote) Proxy.newProxyInstance(loader,
                                                       interfaces,
                                                       handler);
            }});
    } catch (IllegalArgumentException e) {
        throw new StubNotFoundException("unable to create proxy", e);
    }
}
项目:cn1    文件:StubNotFoundExceptionTest.java   
/**
 * {@link java.rmi.StubNotFoundException#StubNotFoundException(java.lang.String, java.lang.Exception)}.
 */
public void testStubNotFoundExceptionStringException() {
    NullPointerException npe = new NullPointerException();
    StubNotFoundException e = new StubNotFoundException("fixture", npe);
    assertTrue(e.getMessage().indexOf("fixture") > -1);
    assertSame(npe, e.getCause());
    assertSame(npe, e.detail);
}
项目:cn1    文件:StubNotFoundExceptionTest.java   
/**
 * {@link java.rmi.StubNotFoundException#StubNotFoundException(java.lang.String)}.
 */
public void testStubNotFoundExceptionString() {
    StubNotFoundException e = new StubNotFoundException("fixture");
    assertEquals("fixture", e.getMessage());
    assertNull(e.getCause());
    assertNull(e.detail);
}
项目:openjdk-jdk7u-jdk    文件:Util.java   
/**
 * Returns a proxy for the specified implClass.
 *
 * If both of the following criteria is satisfied, a dynamic proxy for
 * the specified implClass is returned (otherwise a RemoteStub instance
 * for the specified implClass is returned):
 *
 *    a) either the property java.rmi.server.ignoreStubClasses is true or
 *       a pregenerated stub class does not exist for the impl class, and
 *    b) forceStubUse is false.
 *
 * If the above criteria are satisfied, this method constructs a
 * dynamic proxy instance (that implements the remote interfaces of
 * implClass) constructed with a RemoteObjectInvocationHandler instance
 * constructed with the clientRef.
 *
 * Otherwise, this method loads the pregenerated stub class (which
 * extends RemoteStub and implements the remote interfaces of
 * implClass) and constructs an instance of the pregenerated stub
 * class with the clientRef.
 *
 * @param implClass the class to obtain remote interfaces from
 * @param clientRef the remote ref to use in the invocation handler
 * @param forceStubUse if true, forces creation of a RemoteStub
 * @throws IllegalArgumentException if implClass implements illegal
 * remote interfaces
 * @throws StubNotFoundException if problem locating/creating stub or
 * creating the dynamic proxy instance
 **/
public static Remote createProxy(Class<?> implClass,
                                 RemoteRef clientRef,
                                 boolean forceStubUse)
    throws StubNotFoundException
{
    Class<?> remoteClass;

    try {
        remoteClass = getRemoteClass(implClass);
    } catch (ClassNotFoundException ex ) {
        throw new StubNotFoundException(
            "object does not implement a remote interface: " +
            implClass.getName());
    }

    if (forceStubUse ||
        !(ignoreStubClasses || !stubClassExists(remoteClass)))
    {
        return createStub(remoteClass, clientRef);
    }

    ClassLoader loader = implClass.getClassLoader();
    Class[] interfaces = getRemoteInterfaces(implClass);
    InvocationHandler handler =
        new RemoteObjectInvocationHandler(clientRef);

    /* REMIND: private remote interfaces? */

    try {
        return (Remote) Proxy.newProxyInstance(loader,
                                               interfaces,
                                               handler);
    } catch (IllegalArgumentException e) {
        throw new StubNotFoundException("unable to create proxy", e);
    }
}
项目:freeVM    文件:RemoteReferenceManager.java   
/**
 * Instantiates and returns a stub either starting from a class generated by
 * <code>rmic</code>, or creating a dynamic proxy class for the remote
 * object.
 * 
 * @param ref
 *            The remote reference for the stub
 * @param obj
 *            The object, that the stub will represent
 * @return a stub for <code>obj</code>
 * @throws StubNotFoundException
 *             If a dynamic proxy can not be instantiated for that object.
 */
public final Remote createStub(RemoteRef ref, Remote obj)
        throws StubNotFoundException {
    Remote stub = null;
    boolean ignoreStubClasses = false;
    String propertyValue;

    // Verify if the old non-dynamic stubs should be ignored
    propertyValue = PropertiesReader
            .readString("java.rmi.server.ignoreStubClasses");
    if (propertyValue != null) {
        ignoreStubClasses = propertyValue.equalsIgnoreCase("true");
    }

    if (!ignoreStubClasses) {
        try {
            stub = createRegularStub(ref, obj);
            return stub;
        } catch (StubNotFoundException e) {
            // An error has been produced during regular stub instantiation.
            // ignore it and try now a dynamic proxy.
        }
    }

    Set<Class> remoteSet = (RemoteUtils.getRemoteInterfaces(obj.getClass()));
    Class[] remoteInterfaces = new Class[remoteSet.size()];
    remoteSet.toArray(remoteInterfaces);

    try {
        stub = (Remote) Proxy.newProxyInstance(obj.getClass()
                .getClassLoader(), remoteInterfaces,
                new RemoteObjectInvocationHandler(ref));
    } catch (IllegalArgumentException ex) {
        throw new StubNotFoundException(
                "Couldn't create dynamic proxy for " + obj, ex);
    }
    return stub;
}
项目:freeVM    文件:RemoteReferenceManager.java   
/**
 * Instantiates and returns a stub either starting from a class generated by
 * <code>rmic</code>, or creating a dynamic proxy class for the remote
 * object.
 * 
 * @param ref
 *            The remote reference for the stub
 * @param obj
 *            The object, that the stub will represent
 * @return a stub for <code>obj</code>
 * @throws StubNotFoundException
 *             If a dynamic proxy can not be instantiated for that object.
 */
public final Remote createStub(RemoteRef ref, Remote obj)
        throws StubNotFoundException {
    Remote stub = null;
    boolean ignoreStubClasses = false;
    String propertyValue;

    // Verify if the old non-dynamic stubs should be ignored
    propertyValue = PropertiesReader
            .readString("java.rmi.server.ignoreStubClasses");
    if (propertyValue != null) {
        ignoreStubClasses = propertyValue.equalsIgnoreCase("true");
    }

    if (!ignoreStubClasses) {
        try {
            stub = createRegularStub(ref, obj);
            return stub;
        } catch (StubNotFoundException e) {
            // An error has been produced during regular stub instantiation.
            // ignore it and try now a dynamic proxy.
        }
    }

    Set<Class> remoteSet = (RemoteUtils.getRemoteInterfaces(obj.getClass()));
    Class[] remoteInterfaces = new Class[remoteSet.size()];
    remoteSet.toArray(remoteInterfaces);

    try {
        stub = (Remote) Proxy.newProxyInstance(obj.getClass()
                .getClassLoader(), remoteInterfaces,
                new RemoteObjectInvocationHandler(ref));
    } catch (IllegalArgumentException ex) {
        throw new StubNotFoundException(
                "Couldn't create dynamic proxy for " + obj, ex);
    }
    return stub;
}
项目:freeVM    文件:StubNotFoundExceptionTest.java   
/**
 * {@link java.rmi.StubNotFoundException#StubNotFoundException(java.lang.String, java.lang.Exception)}.
 */
public void testStubNotFoundExceptionStringException() {
    NullPointerException npe = new NullPointerException();
    StubNotFoundException e = new StubNotFoundException("fixture", npe);
    assertTrue(e.getMessage().indexOf("fixture") > -1);
    assertSame(npe, e.getCause());
    assertSame(npe, e.detail);
}
项目:freeVM    文件:StubNotFoundExceptionTest.java   
/**
 * {@link java.rmi.StubNotFoundException#StubNotFoundException(java.lang.String)}.
 */
public void testStubNotFoundExceptionString() {
    StubNotFoundException e = new StubNotFoundException("fixture");
    assertEquals("fixture", e.getMessage());
    assertNull(e.getCause());
    assertNull(e.detail);
}
项目:freeVM    文件:StubNotFoundExceptionTest.java   
/**
 * {@link java.rmi.StubNotFoundException#StubNotFoundException(java.lang.String, java.lang.Exception)}.
 */
public void testStubNotFoundExceptionStringException() {
    NullPointerException npe = new NullPointerException();
    StubNotFoundException e = new StubNotFoundException("fixture", npe);
    assertTrue(e.getMessage().indexOf("fixture") > -1);
    assertSame(npe, e.getCause());
    assertSame(npe, e.detail);
}
项目:freeVM    文件:StubNotFoundExceptionTest.java   
/**
 * {@link java.rmi.StubNotFoundException#StubNotFoundException(java.lang.String)}.
 */
public void testStubNotFoundExceptionString() {
    StubNotFoundException e = new StubNotFoundException("fixture");
    assertEquals("fixture", e.getMessage());
    assertNull(e.getCause());
    assertNull(e.detail);
}
项目:openjdk-icedtea7    文件:Util.java   
/**
 * Returns a proxy for the specified implClass.
 *
 * If both of the following criteria is satisfied, a dynamic proxy for
 * the specified implClass is returned (otherwise a RemoteStub instance
 * for the specified implClass is returned):
 *
 *    a) either the property java.rmi.server.ignoreStubClasses is true or
 *       a pregenerated stub class does not exist for the impl class, and
 *    b) forceStubUse is false.
 *
 * If the above criteria are satisfied, this method constructs a
 * dynamic proxy instance (that implements the remote interfaces of
 * implClass) constructed with a RemoteObjectInvocationHandler instance
 * constructed with the clientRef.
 *
 * Otherwise, this method loads the pregenerated stub class (which
 * extends RemoteStub and implements the remote interfaces of
 * implClass) and constructs an instance of the pregenerated stub
 * class with the clientRef.
 *
 * @param implClass the class to obtain remote interfaces from
 * @param clientRef the remote ref to use in the invocation handler
 * @param forceStubUse if true, forces creation of a RemoteStub
 * @throws IllegalArgumentException if implClass implements illegal
 * remote interfaces
 * @throws StubNotFoundException if problem locating/creating stub or
 * creating the dynamic proxy instance
 **/
public static Remote createProxy(Class<?> implClass,
                                 RemoteRef clientRef,
                                 boolean forceStubUse)
    throws StubNotFoundException
{
    Class<?> remoteClass;

    try {
        remoteClass = getRemoteClass(implClass);
    } catch (ClassNotFoundException ex ) {
        throw new StubNotFoundException(
            "object does not implement a remote interface: " +
            implClass.getName());
    }

    if (forceStubUse ||
        !(ignoreStubClasses || !stubClassExists(remoteClass)))
    {
        return createStub(remoteClass, clientRef);
    }

    ClassLoader loader = implClass.getClassLoader();
    Class[] interfaces = getRemoteInterfaces(implClass);
    InvocationHandler handler =
        new RemoteObjectInvocationHandler(clientRef);

    /* REMIND: private remote interfaces? */

    try {
        return (Remote) Proxy.newProxyInstance(loader,
                                               interfaces,
                                               handler);
    } catch (IllegalArgumentException e) {
        throw new StubNotFoundException("unable to create proxy", e);
    }
}
项目:spring4-understanding    文件:RmiSupportTests.java   
@Test
public void rmiProxyFactoryBeanWithStubNotFoundException() throws Exception {
    doTestRmiProxyFactoryBeanWithException(StubNotFoundException.class);
}
项目:spring4-understanding    文件:RmiSupportTests.java   
@Test
public void rmiProxyFactoryBeanWithStubNotFoundExceptionAndRefresh() throws Exception {
    doTestRmiProxyFactoryBeanWithExceptionAndRefresh(StubNotFoundException.class);
}
项目:spring4-understanding    文件:RmiSupportTests.java   
@Test
public void rmiProxyFactoryBeanWithBusinessInterfaceAndStubNotFoundException() throws Exception {
    doTestRmiProxyFactoryBeanWithBusinessInterfaceAndException(
            StubNotFoundException.class, RemoteConnectFailureException.class);
}
项目:spring4-understanding    文件:RmiSupportTests.java   
@Test
public void rmiProxyFactoryBeanWithBusinessInterfaceAndStubNotFoundExceptionAndRefresh() throws Exception {
    doTestRmiProxyFactoryBeanWithBusinessInterfaceAndExceptionAndRefresh(
            StubNotFoundException.class, RemoteConnectFailureException.class);
}
项目:class-guard    文件:RmiSupportTests.java   
public void testRmiProxyFactoryBeanWithStubNotFoundException() throws Exception {
    doTestRmiProxyFactoryBeanWithException(StubNotFoundException.class);
}
项目:class-guard    文件:RmiSupportTests.java   
public void testRmiProxyFactoryBeanWithStubNotFoundExceptionAndRefresh() throws Exception {
    doTestRmiProxyFactoryBeanWithExceptionAndRefresh(StubNotFoundException.class);
}
项目:class-guard    文件:RmiSupportTests.java   
public void testRmiProxyFactoryBeanWithBusinessInterfaceAndStubNotFoundException() throws Exception {
    doTestRmiProxyFactoryBeanWithBusinessInterfaceAndException(
            StubNotFoundException.class, RemoteConnectFailureException.class);
}
项目:class-guard    文件:RmiSupportTests.java   
public void testRmiProxyFactoryBeanWithBusinessInterfaceAndStubNotFoundExceptionAndRefresh() throws Exception {
    doTestRmiProxyFactoryBeanWithBusinessInterfaceAndExceptionAndRefresh(
            StubNotFoundException.class, RemoteConnectFailureException.class);
}
项目:cn1    文件:RegistryContext.java   
/**
 * Prepares a new {@link NamingException} wrapping the specified
 * {@link RemoteException} source exception. Source exception becomes a
 * {@linkplain NamingException#getCause() cause} of the generated exception.
 * 
 * The particular subclass of {@link NamingException} returned depends on
 * the particular subclass of source {@link RemoteException}.
 * 
 * If source exception is not of a specific class or is not a
 * {@link RemoteException} or is <code>null</code>, then plain
 * {@link NamingException} is returned.
 * 
 * Note: {@link Throwable#fillInStackTrace()} should be called before
 * throwing the generated exception, to provide the proper (not including
 * this method) stack trace for the exception.
 * 
 * Example of use:
 * 
 * <code>try {
 *     ...
 * } catch (RemoteException e) {
 *     throw (NamingException) newNamingException(e).fillInStackTrace();
 * }</code>
 * 
 * @param e
 *            Source {@link RemoteException}.
 * 
 * @return Generated {@link NamingException} exception.
 */
@SuppressWarnings("deprecation")
protected NamingException newNamingException(Throwable e) {
    NamingException ret = (e instanceof AccessException) ? new NoPermissionException()
            : (e instanceof ConnectException) ? new ServiceUnavailableException()
                    : (e instanceof ConnectIOException)
                            || (e instanceof ExportException)
                            || (e instanceof MarshalException)
                            || (e instanceof UnmarshalException) ? new CommunicationException()
                            : (e instanceof ActivateFailedException)
                                    || (e instanceof NoSuchObjectException)
                                    || (e instanceof java.rmi.server.SkeletonMismatchException)
                                    || (e instanceof java.rmi.server.SkeletonNotFoundException)
                                    || (e instanceof StubNotFoundException)
                                    || (e instanceof UnknownHostException) ? new ConfigurationException()
                                    : (e instanceof ServerException) ? newNamingException(e
                                            .getCause())
                                            : new NamingException();

    if (ret.getCause() == null) {
        ret.initCause(e);
    }
    return ret;
}
项目:nextop-client    文件:RegistryContext.java   
/**
 * Prepares a new {@link NamingException} wrapping the specified
 * {@link RemoteException} source exception. Source exception becomes a
 * {@linkplain NamingException#getCause() cause} of the generated exception.
 * 
 * The particular subclass of {@link NamingException} returned depends on
 * the particular subclass of source {@link RemoteException}.
 * 
 * If source exception is not of a specific class or is not a
 * {@link RemoteException} or is <code>null</code>, then plain
 * {@link NamingException} is returned.
 * 
 * Note: {@link Throwable#fillInStackTrace()} should be called before
 * throwing the generated exception, to provide the proper (not including
 * this method) stack trace for the exception.
 * 
 * Example of use:
 * 
 * <code>try {
 *     ...
 * } catch (RemoteException e) {
 *     throw (NamingException) newNamingException(e).fillInStackTrace();
 * }</code>
 * 
 * @param e
 *            Source {@link RemoteException}.
 * 
 * @return Generated {@link NamingException} exception.
 */
@SuppressWarnings("deprecation")
protected NamingException newNamingException(Throwable e) {
    NamingException ret = (e instanceof AccessException) ? new NoPermissionException()
            : (e instanceof ConnectException) ? new ServiceUnavailableException()
                    : (e instanceof ConnectIOException)
                            || (e instanceof ExportException)
                            || (e instanceof MarshalException)
                            || (e instanceof UnmarshalException) ? new CommunicationException()
                            : (e instanceof ActivateFailedException)
                                    || (e instanceof NoSuchObjectException)
                                    || (e instanceof java.rmi.server.SkeletonMismatchException)
                                    || (e instanceof java.rmi.server.SkeletonNotFoundException)
                                    || (e instanceof StubNotFoundException)
                                    || (e instanceof UnknownHostException) ? new ConfigurationException()
                                    : (e instanceof ServerException) ? newNamingException(e
                                            .getCause())
                                            : new NamingException();

    if (ret.getCause() == null) {
        ret.initCause(e);
    }
    return ret;
}
项目:freeVM    文件:RegistryContext.java   
/**
 * Prepares a new {@link NamingException} wrapping the specified
 * {@link RemoteException} source exception. Source exception becomes a
 * {@linkplain NamingException#getCause() cause} of the generated exception.
 * 
 * The particular subclass of {@link NamingException} returned depends on
 * the particular subclass of source {@link RemoteException}.
 * 
 * If source exception is not of a specific class or is not a
 * {@link RemoteException} or is <code>null</code>, then plain
 * {@link NamingException} is returned.
 * 
 * Note: {@link Throwable#fillInStackTrace()} should be called before
 * throwing the generated exception, to provide the proper (not including
 * this method) stack trace for the exception.
 * 
 * Example of use:
 * 
 * <code>try {
 *     ...
 * } catch (RemoteException e) {
 *     throw (NamingException) newNamingException(e).fillInStackTrace();
 * }</code>
 * 
 * @param e
 *            Source {@link RemoteException}.
 * 
 * @return Generated {@link NamingException} exception.
 */
@SuppressWarnings("deprecation")
protected NamingException newNamingException(Throwable e) {
    NamingException ret = (e instanceof AccessException) ? new NoPermissionException()
            : (e instanceof ConnectException) ? new ServiceUnavailableException()
                    : (e instanceof ConnectIOException)
                            || (e instanceof ExportException)
                            || (e instanceof MarshalException)
                            || (e instanceof UnmarshalException) ? new CommunicationException()
                            : (e instanceof ActivateFailedException)
                                    || (e instanceof NoSuchObjectException)
                                    || (e instanceof java.rmi.server.SkeletonMismatchException)
                                    || (e instanceof java.rmi.server.SkeletonNotFoundException)
                                    || (e instanceof StubNotFoundException)
                                    || (e instanceof UnknownHostException) ? new ConfigurationException()
                                    : (e instanceof ServerException) ? newNamingException(e
                                            .getCause())
                                            : new NamingException();

    if (ret.getCause() == null) {
        ret.initCause(e);
    }
    return ret;
}