javax.rmi.PortableRemoteObject Java Examples

The following examples show how to use javax.rmi.PortableRemoteObject. 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: IIOPProxyImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example #2
Source File: IIOPProxyImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example #3
Source File: IIOPProxyImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example #4
Source File: IIOPProxyImpl.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example #5
Source File: Client.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private static BMXATest lookupBMXABean(InitialContext ictx, String jndiName) {
    try {
        Object home = ictx.lookup(jndiName);
        BMXATestHome rhome = (BMXATestHome) PortableRemoteObject.narrow(
                home, BMXATestHome.class);
        BMXATest bean = (BMXATest) PortableRemoteObject.narrow(
                rhome.create(), BMXATest.class);
        return bean;
    } catch (NamingException ne) {
        log("The client was unable to lookup the EJBHome.  Please make sure ");
        log("that you have deployed the ejb with the JNDI name " + jndiName
                + " on the WebLogic server at " + url);
    } catch (CreateException ce) {
        log("Creation failed: " + ce);
    } catch (RemoteException ex) {
        log("Creation failed: " + ex);
    }
    return null;
}
 
Example #6
Source File: Client.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private static CMXATest lookupCMXABean(InitialContext ictx, String jndiName) {
    try {
        Object home = ictx.lookup(jndiName);
        CMXATestHome rhome = (CMXATestHome) PortableRemoteObject.narrow(
                home, CMXATestHome.class);
        CMXATest bean = (CMXATest) PortableRemoteObject.narrow(
                rhome.create(), CMXATest.class);
        return bean;
    } catch (NamingException ne) {
        log("The client was unable to lookup the EJBHome.  Please make sure ");
        log("that you have deployed the ejb with the JNDI name " + jndiName
                + " on the WebLogic server at " + url);
    } catch (CreateException ce) {
        log("Creation failed: " + ce);
    } catch (RemoteException ex) {
        log("Creation failed: " + ex);
    }
    return null;
}
 
Example #7
Source File: IIOPProxyImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example #8
Source File: IIOPProxyImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example #9
Source File: IIOPProxyImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example #10
Source File: Client.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private static CMXATest lookupCMXABean(InitialContext ictx, String jndiName) {
    try {
        Object home = ictx.lookup(jndiName);
        CMXATestHome rhome = (CMXATestHome) PortableRemoteObject.narrow(
                home, CMXATestHome.class);
        CMXATest bean = (CMXATest) PortableRemoteObject.narrow(
                rhome.create(), CMXATest.class);
        return bean;
    } catch (NamingException ne) {
        log("The client was unable to lookup the EJBHome.  Please make sure ");
        log("that you have deployed the ejb with the JNDI name " + jndiName
                + " on the WebLogic server at " + url);
    } catch (CreateException ce) {
        log("Creation failed: " + ce);
    } catch (RemoteException ex) {
        log("Creation failed: " + ex);
    }
    return null;
}
 
Example #11
Source File: IIOPProxyImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example #12
Source File: IIOPProxyImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example #13
Source File: IIOPProxyImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example #14
Source File: IIOPProxyImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
    if (System.getSecurityManager() == null) {
        return PortableRemoteObject.toStub(obj);
    } else {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {

                @Override
                public Remote run() throws Exception {
                    return PortableRemoteObject.toStub(obj);
                }
            }, STUB_ACC);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof NoSuchObjectException) {
                throw (NoSuchObjectException)e.getException();
            }
            throw new RuntimeException("Unexpected exception type", e.getException());
        }
    }
}
 
Example #15
Source File: Utility.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read an abstract interface type from the input stream and narrow
 * it to the desired type.
 * @param in the stream to read from.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public static Object readAbstractAndNarrow(
    org.omg.CORBA_2_3.portable.InputStream in, Class narrowTo)
    throws ClassCastException
{
    Object result = in.read_abstract_interface();
    if (result != null)
        return PortableRemoteObject.narrow(result, narrowTo);
    else
        return null;
}
 
Example #16
Source File: Utility.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read an object reference from the input stream and narrow
 * it to the desired type.
 * @param in the stream to read from.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public static Object readObjectAndNarrow(InputStream in,
                                         Class narrowTo)
    throws ClassCastException
{
    Object result = in.read_Object();
    if (result != null)
        return PortableRemoteObject.narrow(result, narrowTo);
    else
        return null;
}
 
Example #17
Source File: JndiRmiServiceExporter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize this service exporter, binding the specified service to JNDI.
 * @throws NamingException if service binding failed
 * @throws RemoteException if service export failed
 */
public void prepare() throws NamingException, RemoteException {
	if (this.jndiName == null) {
		throw new IllegalArgumentException("Property 'jndiName' is required");
	}

	// Initialize and cache exported object.
	this.exportedObject = getObjectToExport();
	PortableRemoteObject.exportObject(this.exportedObject);

	rebind();
}
 
Example #18
Source File: JndiRmiServiceExporter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Unbind the RMI service from JNDI on bean factory shutdown.
 */
@Override
public void destroy() throws NamingException, NoSuchObjectException {
	if (logger.isInfoEnabled()) {
		logger.info("Unbinding RMI service from JNDI location [" + this.jndiName + "]");
	}
	this.jndiTemplate.unbind(this.jndiName);
	PortableRemoteObject.unexportObject(this.exportedObject);
}
 
Example #19
Source File: AbstractRemoteSlsbInvokerInterceptor.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * This overridden lookup implementation performs a narrow operation
 * after the JNDI lookup, provided that a home interface is specified.
 * @see #setHomeInterface
 * @see javax.rmi.PortableRemoteObject#narrow
 */
@Override
protected Object lookup() throws NamingException {
	Object homeObject = super.lookup();
	if (this.homeInterface != null) {
		try {
			homeObject = PortableRemoteObject.narrow(homeObject, this.homeInterface);
		}
		catch (ClassCastException ex) {
			throw new RemoteLookupFailureException(
					"Could not narrow EJB home stub to home interface [" + this.homeInterface.getName() + "]", ex);
		}
	}
	return homeObject;
}
 
Example #20
Source File: Utility.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read an object reference from the input stream and narrow
 * it to the desired type.
 * @param in the stream to read from.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public static Object readObjectAndNarrow(InputStream in,
                                         Class narrowTo)
    throws ClassCastException
{
    Object result = in.read_Object();
    if (result != null)
        return PortableRemoteObject.narrow(result, narrowTo);
    else
        return null;
}
 
Example #21
Source File: Utility.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read an abstract interface type from the input stream and narrow
 * it to the desired type.
 * @param in the stream to read from.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public static Object readAbstractAndNarrow(
    org.omg.CORBA_2_3.portable.InputStream in, Class narrowTo)
    throws ClassCastException
{
    Object result = in.read_abstract_interface();
    if (result != null)
        return PortableRemoteObject.narrow(result, narrowTo);
    else
        return null;
}
 
Example #22
Source File: Utility.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read an abstract interface type from the input stream and narrow
 * it to the desired type.
 * @param in the stream to read from.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public static Object readAbstractAndNarrow(
    org.omg.CORBA_2_3.portable.InputStream in, Class narrowTo)
    throws ClassCastException
{
    Object result = in.read_abstract_interface();
    if (result != null)
        return PortableRemoteObject.narrow(result, narrowTo);
    else
        return null;
}
 
Example #23
Source File: Utility.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read an object reference from the input stream and narrow
 * it to the desired type.
 * @param in the stream to read from.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public static Object readObjectAndNarrow(InputStream in,
                                         Class narrowTo)
    throws ClassCastException
{
    Object result = in.read_Object();
    if (result != null)
        return PortableRemoteObject.narrow(result, narrowTo);
    else
        return null;
}
 
Example #24
Source File: Utility.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Read an object reference from the input stream and narrow
 * it to the desired type.
 * @param in the stream to read from.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public static Object readObjectAndNarrow(InputStream in,
                                         Class narrowTo)
    throws ClassCastException
{
    Object result = in.read_Object();
    if (result != null)
        return PortableRemoteObject.narrow(result, narrowTo);
    else
        return null;
}
 
Example #25
Source File: Utility.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read an object reference from the input stream and narrow
 * it to the desired type.
 * @param in the stream to read from.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public static Object readObjectAndNarrow(InputStream in,
                                         Class narrowTo)
    throws ClassCastException
{
    Object result = in.read_Object();
    if (result != null)
        return PortableRemoteObject.narrow(result, narrowTo);
    else
        return null;
}
 
Example #26
Source File: AbstractRemoteSlsbInvokerInterceptor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This overridden lookup implementation performs a narrow operation
 * after the JNDI lookup, provided that a home interface is specified.
 * @see #setHomeInterface
 * @see javax.rmi.PortableRemoteObject#narrow
 */
@Override
protected Object lookup() throws NamingException {
	Object homeObject = super.lookup();
	if (this.homeInterface != null) {
		try {
			homeObject = PortableRemoteObject.narrow(homeObject, this.homeInterface);
		}
		catch (ClassCastException ex) {
			throw new RemoteLookupFailureException(
					"Could not narrow EJB home stub to home interface [" + this.homeInterface.getName() + "]", ex);
		}
	}
	return homeObject;
}
 
Example #27
Source File: JndiRmiServiceExporter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unbind the RMI service from JNDI on bean factory shutdown.
 */
@Override
public void destroy() throws NamingException, NoSuchObjectException {
	if (logger.isInfoEnabled()) {
		logger.info("Unbinding RMI service from JNDI location [" + this.jndiName + "]");
	}
	this.jndiTemplate.unbind(this.jndiName);
	PortableRemoteObject.unexportObject(this.exportedObject);
}
 
Example #28
Source File: JndiRmiServiceExporter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialize this service exporter, binding the specified service to JNDI.
 * @throws NamingException if service binding failed
 * @throws RemoteException if service export failed
 */
public void prepare() throws NamingException, RemoteException {
	if (this.jndiName == null) {
		throw new IllegalArgumentException("Property 'jndiName' is required");
	}

	// Initialize and cache exported object.
	this.exportedObject = getObjectToExport();
	PortableRemoteObject.exportObject(this.exportedObject);

	rebind();
}
 
Example #29
Source File: testCallEJB2InSB_TestingSessionBean.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private TestingEntityRemoteHome lookupMyTestingEntityBean() {
    try {
        Context c = new InitialContext();
        Object remote = c.lookup("java:comp/env/ejb/MyTestingEntityBean");
        TestingEntityRemoteHome rv = (TestingEntityRemoteHome) PortableRemoteObject.narrow(remote, TestingEntityRemoteHome.class);
        return rv;
    } catch (NamingException ne) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
        throw new RuntimeException(ne);
    }
}
 
Example #30
Source File: HelloImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void start() throws Exception
{
   if (!m_isRunning)
   {
      // export the remote object
      PortableRemoteObject.exportObject(this);
      // set up the initialContext
      Context ctx = new InitialContext();
      ctx.rebind(IIOP_JNDI_NAME, this);
      System.out.println("My Service servant started successfully");
      m_isRunning = true;
   }
}