Java Code Examples for javax.rmi.PortableRemoteObject

The following are top voted examples for showing how to use javax.rmi.PortableRemoteObject. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: IIOPProxyImpl.java   View source code 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
Project: jdk8u-jdk   File: IIOPProxyImpl.java   View source code 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
Project: gemfirexd-oss   File: Client.java   View source code 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 4
Project: gemfirexd-oss   File: Client.java   View source code 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 5
Project: jdk8u_jdk   File: IIOPProxyImpl.java   View source code 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 6
Project: lookaside_java-1.8.0-openjdk   File: IIOPProxyImpl.java   View source code 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 7
Project: gemfirexd-oss   File: Client.java   View source code 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 8
Project: gemfirexd-oss   File: Client.java   View source code 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 9
Project: che   File: RmiClient.java   View source code 6 votes vote down vote up
private Remote acquire(RunningInfo info) throws Exception {
  Remote result;
  Registry registry = LocateRegistry.getRegistry("localhost", info.port);
  java.rmi.Remote lookup = registry.lookup(info.name);
  if (java.rmi.Remote.class.isAssignableFrom(remoteClass)) {
    Remote entry =
        remoteClass.isInstance(lookup)
            ? (Remote) lookup
            : (Remote) PortableRemoteObject.narrow(lookup, remoteClass);
    if (entry == null) {
      result = null;
    } else {
      // TODO add proxy for remote object
      result = (Remote) lookup;
    }
  } else {
    result = (Remote) lookup;
  }

  info.remoteRef = result;
  return result;
}
 
Example 10
Project: r01fb   File: EJBFactory.java   View source code 6 votes vote down vote up
/**
 * Obtiene un EJB a partir de su nombre JNDI
 * @param jndiContextProps propiedades para obtener una referencia al contexto jndi del LDAP
 * @param jndiName nombre JNDI
 * @param local true si se trata de una referencia al EJB local
 * @param type tipo del objeto
 * @return la referencia al EJB
 */
@SuppressWarnings("unchecked")
public static <T> T createEJB3(Properties jndiContextProps,
							   String jndiName,boolean local,Class<T> type) {
	T outEJB = null;			
	try {
		Context initialContext = JNDIContextLocator.getInstance().getInitialContext(jndiContextProps);
		String theJNDIName = jndiName + (local ? "Local" : "");	// Por "convenio" el nombre JNDI del EJB local tiene el sufijo "Local"
		Object obj = initialContext.lookup(theJNDIName);
		if (local) { 
			outEJB = (T)obj;
		} else {
			outEJB = (T)PortableRemoteObject.narrow(obj,type);
		}
	} catch(NamingException namEx) {
		// TODO log
		String err = Strings.of("NO se ha podido obtener un contexto jndi contra el LDAP")
							.asString();
		System.out.println(err);
	}
	return outEJB;
}
 
Example 11
Project: r01fb   File: EJBFactory.java   View source code 6 votes vote down vote up
/**
 * Obtiene un EJB a partir de su nombre JNDI
 * @param jndiContextProps propiedades para obtener una referencia al contexto jndi del LDAP
 * @param jndiName nombre JNDI
 * @param local true si se trata de una referencia al EJB local
 * @param homeType tipo del interfaz home
 * @return la referencia al EJB
 */
public static <T> T createEJB2(Properties jndiContextProps,
							   String jndiName,boolean local,Class<?> homeType) {
	T outEJB = null;			
	try {
		Context initialContext = JNDIContextLocator.getInstance().getInitialContext(jndiContextProps);
		String theJNDIName = jndiName + (local ? "Local" : "");	// Por "convenio" el nombre JNDI del EJB local tiene el sufijo "Local"
		Object home = initialContext.lookup(theJNDIName);
		Object homeNarrowed = PortableRemoteObject.narrow(home,homeType);
		outEJB = Reflection.of(homeNarrowed).method("create").<T>invoke();	// llamar al m�todo create en el objeto home
	} catch(NamingException namEx) {
		// TODO log
		String err = Strings.of("NO se ha podido obtener un contexto jndi contra el LDAP")
							.asString();
		System.out.println(err);
	}
	return outEJB;
}
 
Example 12
Project: jbossws-cxf   File: JBWS944TestCase.java   View source code 6 votes vote down vote up
@Test
@RunAsClient
public void testNarrowedRemoteAccess() throws Exception
{
   InitialContext iniCtx = null;
   try {
      iniCtx = getServerInitialContext();
      Object obj = iniCtx.lookup("jaxws-jbws944//FooBean01!" + EJB3RemoteHome.class.getName());
      EJB3RemoteHome ejb3Home = (EJB3RemoteHome)PortableRemoteObject.narrow(obj, EJB3RemoteHome.class);
      EJB3RemoteInterface ejb3Remote = ejb3Home.create();

      String helloWorld = "Hello world!";
      Object retObj = ejb3Remote.echo(helloWorld);
      assertEquals(helloWorld, retObj);
   } 
   finally
   {
      if (iniCtx != null)
      {
         iniCtx.close();
      }
   }
}
 
Example 13
Project: infobip-open-jdk-8   File: IIOPProxyImpl.java   View source code 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
Project: jdk8u-dev-jdk   File: IIOPProxyImpl.java   View source code 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
Project: gomall.la   File: EJBMetaData.java   View source code 6 votes vote down vote up
/**
 * 得到urlName下的EJB.
 * 
 * @param urlName
 *            String
 * @return Object
 */
private Object newEJBHome(String urlName) {
	try {
		Context ctx = ServiceLocator.getInstance().getContext(urlName);
		if (ctx == null) {
			log.info("can't find the context by specified url " + urlName);
			return null;
		}
		Object jndiRef = ctx.lookup(name);
		Class cl = Class.forName(homeClassName);
		Object homeObj = PortableRemoteObject.narrow(jndiRef, cl);
		return homeObj;
	} catch (Exception e) {
		log.debug("create home obj fail", e);
	}
	return null;
}
 
Example 16
Project: OLD-OpenJDK8   File: IIOPProxyImpl.java   View source code 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 17
Project: ojb   File: StressTest.java   View source code 6 votes vote down vote up
/**
 * Setting up the test fixture.
 */
private void init() throws Exception
{
    Context ctx = ContextHelper.getContext();
    times = new long[4];
    try
    {
        Object object = PortableRemoteObject.narrow(ctx.lookup(PBSessionHome.JNDI_NAME), EJBHome.class);
        bean = ((PBSessionHome) object).create();
    }
    catch(Exception e)
    {
        e.printStackTrace(System.err);
        throw e;
    }
}
 
Example 18
Project: ojb   File: StressTest.java   View source code 6 votes vote down vote up
/**
 * Setting up the test fixture.
 */
private void init() throws Exception
{
    Context ctx = ContextHelper.getContext();
    times = new long[4];
    try
    {
        Object object = PortableRemoteObject.narrow(ctx.lookup(ODMGSessionHome.JNDI_NAME), EJBHome.class);
        bean = ((ODMGSessionHome) object).create();
    }
    catch(Exception e)
    {
        e.printStackTrace(System.err);
        throw e;
    }
}
 
Example 19
Project: openjdk-jdk7u-jdk   File: IIOPProxyImpl.java   View source code 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 20
Project: openjdk-icedtea7   File: IIOPProxyImpl.java   View source code 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 21
Project: lams   File: JndiRmiServiceExporter.java   View source code 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 22
Project: lams   File: JndiRmiServiceExporter.java   View source code 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 23
Project: lams   File: AbstractRemoteSlsbInvokerInterceptor.java   View source code 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 24
Project: OpenJSharp   File: Utility.java   View source code 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
Project: OpenJSharp   File: Utility.java   View source code 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 26
Project: openjdk-jdk10   File: Utility.java   View source code 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 27
Project: openjdk-jdk10   File: Utility.java   View source code 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 28
Project: openjdk-jdk10   File: ObjectStreamTest.java   View source code 5 votes vote down vote up
/**
 * Initialize the ORB and the singleton Echo server stub.
 * @return the stub for the Echo server.
 * @throws RemoteException if an error occurs
 */
synchronized Echo getEchoStub() throws RemoteException {
    if (echoStub == null) {
        ORB orb = (ORB) ORB.init(new String[0], null);
        Echo server = new Server();
        echoStub = (javax.rmi.CORBA.Stub) PortableRemoteObject.toStub(server);
        echoStub.connect(orb);
    }
    return (Echo)echoStub;
}
 
Example 29
Project: openjdk9   File: Utility.java   View source code 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 30
Project: openjdk9   File: Utility.java   View source code 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 31
Project: spring4-understanding   File: JndiRmiServiceExporter.java   View source code 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 32
Project: spring4-understanding   File: JndiRmiServiceExporter.java   View source code 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 33
Project: spring4-understanding   File: AbstractRemoteSlsbInvokerInterceptor.java   View source code 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 34
Project: my-spring-cache-redis   File: JndiRmiServiceExporter.java   View source code 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 35
Project: my-spring-cache-redis   File: JndiRmiServiceExporter.java   View source code 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 36
Project: my-spring-cache-redis   File: AbstractRemoteSlsbInvokerInterceptor.java   View source code 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 37
Project: lookaside_java-1.8.0-openjdk   File: Utility.java   View source code 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 38
Project: lookaside_java-1.8.0-openjdk   File: Utility.java   View source code 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 39
Project: BJAF3.x   File: HomeFactoryHelper.java   View source code 5 votes vote down vote up
private static synchronized EJBHome getRemoteHome(
		String ejbContainerTagName, String jndiName, Class<?> className,
		String key) throws java.rmi.RemoteException, ClassNotFoundException {
	Context ctx;
	if (logger.isDebugEnabled()) {
		logger.debug("--getRemoteHome--");
		logger.debug("ejbContainerTagName:" + ejbContainerTagName);
		logger.debug("jndiName:" + jndiName);
		logger.debug("className:" + className);
		logger.debug("key:" + key);
	}
	try {
		if (ejbContainerTagName == null || ejbContainerTagName.equals("")) {
			ctx = ContainerUtil.getRemoteEJBContainerContext();
			if (logger.isDebugEnabled()) {
				logger.debug("call:getRemoteEJBContainerContext()");
			}
		} else {
			ctx = ContainerUtil
					.getRemoteEJBContainerContext(ejbContainerTagName);
			if (logger.isDebugEnabled()) {
				logger.debug("call:getRemoteEJBContainerContext("
						+ ejbContainerTagName + ")");
			}
		}
		Object ref = ctx.lookup(jndiName.trim());
		EJBHome ejbHome = (EJBHome) PortableRemoteObject.narrow(ref,
				className);
		HOME_INTERFACES_REMOTE.put(key, ejbHome);
		return ejbHome;
	} catch (NamingException e) {
		throw new RemoteException("getRemoteHome err", e);
	}
}
 
Example 40
Project: spring   File: JndiRmiServiceExporter.java   View source code 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();
}