當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。