本文整理汇总了Java中java.rmi.StubNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java StubNotFoundException类的具体用法?Java StubNotFoundException怎么用?Java StubNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StubNotFoundException类属于java.rmi包,在下文中一共展示了StubNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStub
import java.rmi.StubNotFoundException; //导入依赖的package包/类
/**
* 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);
}
}
示例2: loadStubClass
import java.rmi.StubNotFoundException; //导入依赖的package包/类
/**
* 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;
}
示例3: findStubBaseClass
import java.rmi.StubNotFoundException; //导入依赖的package包/类
/**
* 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.");
}
示例4: createProxy
import java.rmi.StubNotFoundException; //导入依赖的package包/类
/**
* 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);
}
}
示例5: createProxy
import java.rmi.StubNotFoundException; //导入依赖的package包/类
/**
* 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);
}
}
示例6: testStubNotFoundExceptionStringException
import java.rmi.StubNotFoundException; //导入依赖的package包/类
/**
* {@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);
}
示例7: testStubNotFoundExceptionString
import java.rmi.StubNotFoundException; //导入依赖的package包/类
/**
* {@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);
}
示例8: createProxy
import java.rmi.StubNotFoundException; //导入依赖的package包/类
/**
* 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);
}
}
示例9: createStub
import java.rmi.StubNotFoundException; //导入依赖的package包/类
/**
* 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;
}
示例10: rmiProxyFactoryBeanWithStubNotFoundException
import java.rmi.StubNotFoundException; //导入依赖的package包/类
@Test
public void rmiProxyFactoryBeanWithStubNotFoundException() throws Exception {
doTestRmiProxyFactoryBeanWithException(StubNotFoundException.class);
}
示例11: rmiProxyFactoryBeanWithStubNotFoundExceptionAndRefresh
import java.rmi.StubNotFoundException; //导入依赖的package包/类
@Test
public void rmiProxyFactoryBeanWithStubNotFoundExceptionAndRefresh() throws Exception {
doTestRmiProxyFactoryBeanWithExceptionAndRefresh(StubNotFoundException.class);
}
示例12: rmiProxyFactoryBeanWithBusinessInterfaceAndStubNotFoundException
import java.rmi.StubNotFoundException; //导入依赖的package包/类
@Test
public void rmiProxyFactoryBeanWithBusinessInterfaceAndStubNotFoundException() throws Exception {
doTestRmiProxyFactoryBeanWithBusinessInterfaceAndException(
StubNotFoundException.class, RemoteConnectFailureException.class);
}
示例13: rmiProxyFactoryBeanWithBusinessInterfaceAndStubNotFoundExceptionAndRefresh
import java.rmi.StubNotFoundException; //导入依赖的package包/类
@Test
public void rmiProxyFactoryBeanWithBusinessInterfaceAndStubNotFoundExceptionAndRefresh() throws Exception {
doTestRmiProxyFactoryBeanWithBusinessInterfaceAndExceptionAndRefresh(
StubNotFoundException.class, RemoteConnectFailureException.class);
}
示例14: testRmiProxyFactoryBeanWithStubNotFoundException
import java.rmi.StubNotFoundException; //导入依赖的package包/类
public void testRmiProxyFactoryBeanWithStubNotFoundException() throws Exception {
doTestRmiProxyFactoryBeanWithException(StubNotFoundException.class);
}
示例15: testRmiProxyFactoryBeanWithStubNotFoundExceptionAndRefresh
import java.rmi.StubNotFoundException; //导入依赖的package包/类
public void testRmiProxyFactoryBeanWithStubNotFoundExceptionAndRefresh() throws Exception {
doTestRmiProxyFactoryBeanWithExceptionAndRefresh(StubNotFoundException.class);
}