当前位置: 首页>>代码示例>>Java>>正文


Java PortableRemoteObject类代码示例

本文整理汇总了Java中javax.rmi.PortableRemoteObject的典型用法代码示例。如果您正苦于以下问题:Java PortableRemoteObject类的具体用法?Java PortableRemoteObject怎么用?Java PortableRemoteObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PortableRemoteObject类属于javax.rmi包,在下文中一共展示了PortableRemoteObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toStub

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
@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());
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:IIOPProxyImpl.java

示例2: lookupBMXABean

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
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;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:Client.java

示例3: lookupCMXABean

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
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;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:Client.java

示例4: acquire

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:RmiClient.java

示例5: createEJB3

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:30,代码来源:EJBFactory.java

示例6: createEJB2

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:26,代码来源:EJBFactory.java

示例7: testNarrowedRemoteAccess

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
@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();
      }
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:24,代码来源:JBWS944TestCase.java

示例8: newEJBHome

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
/**
 * 得到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;
}
 
开发者ID:8090boy,项目名称:gomall.la,代码行数:24,代码来源:EJBMetaData.java

示例9: init

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:19,代码来源:StressTest.java

示例10: init

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:19,代码来源:StressTest.java

示例11: prepare

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:JndiRmiServiceExporter.java

示例12: destroy

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:JndiRmiServiceExporter.java

示例13: lookup

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AbstractRemoteSlsbInvokerInterceptor.java

示例14: readObjectAndNarrow

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:Utility.java

示例15: readAbstractAndNarrow

import javax.rmi.PortableRemoteObject; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:Utility.java


注:本文中的javax.rmi.PortableRemoteObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。