java.rmi.RemoteException.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(12.3k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中java.rmi.RemoteException.<init>方法的一些代码示例,展示了RemoteException.<init>的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RemoteException.<init>方法的具体详情如下:
包路径:java.rmi.RemoteException
类名称:RemoteException
方法名:<init>

RemoteException.<init>介绍

[英]Constructs a RemoteException with no specified detail message.
[中]构造一个没有指定详细信息的RemoteException

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Perform the actual reading of an invocation result object from the
 * given ObjectInputStream.
 * <p>The default implementation simply calls
 * {@link java.io.ObjectInputStream#readObject()}.
 * Can be overridden for deserialization of a custom wrapper object rather
 * than the plain invocation, for example an encryption-aware holder.
 * @param ois the ObjectInputStream to read from
 * @return the RemoteInvocationResult object
 * @throws java.io.IOException in case of I/O failure
 * @throws ClassNotFoundException if case of a transferred class not
 * being found in the local ClassLoader
 */
protected RemoteInvocation doReadRemoteInvocation(ObjectInputStream ois)
    throws IOException, ClassNotFoundException {
  Object obj = ois.readObject();
  if (!(obj instanceof RemoteInvocation)) {
    throw new RemoteException("Deserialized object needs to be assignable to type [" +
        RemoteInvocation.class.getName() + "]: " + ClassUtils.getDescriptiveType(obj));
  }
  return (RemoteInvocation) obj;
}

代码示例来源:origin: igniterealtime/Openfire

private void handleError(Exception e) throws RemoteException {
  LOG.error("Error occured while consuming Crowd REST service", e);
  throw new RemoteException(e.getMessage());
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Perform the actual reading of an invocation object from the
 * given ObjectInputStream.
 * <p>The default implementation simply calls {@code readObject}.
 * Can be overridden for deserialization of a custom wrapper object rather
 * than the plain invocation, for example an encryption-aware holder.
 * @param ois the ObjectInputStream to read from
 * @return the RemoteInvocationResult object
 * @throws IOException if thrown by I/O methods
 * @throws ClassNotFoundException if the class name of a serialized object
 * couldn't get resolved
 * @see java.io.ObjectOutputStream#writeObject
 */
protected RemoteInvocationResult doReadRemoteInvocationResult(ObjectInputStream ois)
    throws IOException, ClassNotFoundException {
  Object obj = ois.readObject();
  if (!(obj instanceof RemoteInvocationResult)) {
    throw new RemoteException("Deserialized object needs to be assignable to type [" +
        RemoteInvocationResult.class.getName() + "]: " + ClassUtils.getDescriptiveType(obj));
  }
  return (RemoteInvocationResult) obj;
}

代码示例来源:origin: igniterealtime/Openfire

private void handleHTTPError(CloseableHttpResponse response) throws RemoteException {
  final StatusLine statusLine = response.getStatusLine();
  final int status = statusLine.getStatusCode();
  final String statusText = statusLine.getReasonPhrase();
  final String body = response.getEntity().toString();
  StringBuilder strBuf = new StringBuilder();
  strBuf.append("Crowd returned HTTP error code:").append(status);
  strBuf.append(" - ").append(statusText);
  if (StringUtils.isNotBlank(body)) {
    strBuf.append("\n").append(body);
  }
  
  throw new RemoteException(strBuf.toString());
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Wrap the given arbitrary exception that happened during remote access
 * in either a RemoteException or a Spring RemoteAccessException (if the
 * method signature does not support RemoteException).
 * <p>Only call this for remote access exceptions, not for exceptions
 * thrown by the target service itself!
 * @param method the invoked method
 * @param ex the exception that happened, to be used as cause for the
 * RemoteAccessException or RemoteException
 * @param message the message for the RemoteAccessException respectively
 * RemoteException
 * @return the exception to be thrown to the caller
 */
public static Exception convertRmiAccessException(Method method, Throwable ex, String message) {
  if (logger.isDebugEnabled()) {
    logger.debug(message, ex);
  }
  if (ReflectionUtils.declaresException(method, RemoteException.class)) {
    return new RemoteException(message, ex);
  }
  else {
    return new RemoteAccessException(message, ex);
  }
}

代码示例来源:origin: org.springframework/spring-context

/**
 * Perform the actual reading of an invocation result object from the
 * given ObjectInputStream.
 * <p>The default implementation simply calls
 * {@link java.io.ObjectInputStream#readObject()}.
 * Can be overridden for deserialization of a custom wrapper object rather
 * than the plain invocation, for example an encryption-aware holder.
 * @param ois the ObjectInputStream to read from
 * @return the RemoteInvocationResult object
 * @throws java.io.IOException in case of I/O failure
 * @throws ClassNotFoundException if case of a transferred class not
 * being found in the local ClassLoader
 */
protected RemoteInvocation doReadRemoteInvocation(ObjectInputStream ois)
    throws IOException, ClassNotFoundException {
  Object obj = ois.readObject();
  if (!(obj instanceof RemoteInvocation)) {
    throw new RemoteException("Deserialized object needs to be assignable to type [" +
        RemoteInvocation.class.getName() + "]: " + ClassUtils.getDescriptiveType(obj));
  }
  return (RemoteInvocation) obj;
}

代码示例来源:origin: org.springframework/spring-web

/**
 * Perform the actual reading of an invocation object from the
 * given ObjectInputStream.
 * <p>The default implementation simply calls {@code readObject}.
 * Can be overridden for deserialization of a custom wrapper object rather
 * than the plain invocation, for example an encryption-aware holder.
 * @param ois the ObjectInputStream to read from
 * @return the RemoteInvocationResult object
 * @throws IOException if thrown by I/O methods
 * @throws ClassNotFoundException if the class name of a serialized object
 * couldn't get resolved
 * @see java.io.ObjectOutputStream#writeObject
 */
protected RemoteInvocationResult doReadRemoteInvocationResult(ObjectInputStream ois)
    throws IOException, ClassNotFoundException {
  Object obj = ois.readObject();
  if (!(obj instanceof RemoteInvocationResult)) {
    throw new RemoteException("Deserialized object needs to be assignable to type [" +
        RemoteInvocationResult.class.getName() + "]: " + ClassUtils.getDescriptiveType(obj));
  }
  return (RemoteInvocationResult) obj;
}

代码示例来源:origin: spring-projects/spring-framework

@Override
  public void setName(String nam) throws RemoteException {
    if (nam != null && nam.endsWith("Exception")) {
      RemoteException rex;
      try {
        Class<?> exClass = Class.forName(nam);
        Constructor<?> ctor = exClass.getConstructor(String.class);
        rex = (RemoteException) ctor.newInstance("myMessage");
      }
      catch (Exception ex) {
        throw new RemoteException("Illegal exception class name: " + nam, ex);
      }
      throw rex;
    }
    name = nam;
  }
}

代码示例来源:origin: org.springframework/spring-context

/**
 * Wrap the given arbitrary exception that happened during remote access
 * in either a RemoteException or a Spring RemoteAccessException (if the
 * method signature does not support RemoteException).
 * <p>Only call this for remote access exceptions, not for exceptions
 * thrown by the target service itself!
 * @param method the invoked method
 * @param ex the exception that happened, to be used as cause for the
 * RemoteAccessException or RemoteException
 * @param message the message for the RemoteAccessException respectively
 * RemoteException
 * @return the exception to be thrown to the caller
 */
public static Exception convertRmiAccessException(Method method, Throwable ex, String message) {
  if (logger.isDebugEnabled()) {
    logger.debug(message, ex);
  }
  if (ReflectionUtils.declaresException(method, RemoteException.class)) {
    return new RemoteException(message, ex);
  }
  else {
    return new RemoteAccessException(message, ex);
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public final RemoteException transactionPropagationNotSupported() {
  final RemoteException result = new RemoteException(String.format(getLoggingLocale(), transactionPropagationNotSupported$str()));
  final StackTraceElement[] st = result.getStackTrace();
  result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
  return result;
}
private static final String cannotCallMethodInAfterCompletion = "WFLYEJB0388: Cannot call method %s in afterCompletion callback";

代码示例来源:origin: spring-projects/spring-framework

@Test
public void testRemoteException() throws Exception {
  doTestException(new RemoteException());
}

代码示例来源:origin: stackoverflow.com

import java.rmi.RemoteException;

class Thrower {
  public static void spit(final Throwable exception) {
    class EvilThrower<T extends Throwable> {
      @SuppressWarnings("unchecked")
      private void sneakyThrow(Throwable exception) throws T {
        throw (T) exception;
      }
    }
    new EvilThrower<RuntimeException>().sneakyThrow(exception);
  }
}

public class ThrowerSample {
  public static void main( String[] args ) {
    Thrower.spit(new RemoteException("go unchecked!"));
  }
}

代码示例来源:origin: spring-projects/spring-framework

private void doTestRuleForSelectiveRollbackOnChecked(RuleBasedTransactionAttribute rta) {
  assertTrue(rta.rollbackOn(new RuntimeException()));
  // Check default behaviour is overridden
  assertFalse(rta.rollbackOn(new Exception()));
  // Check that default behaviour is overridden
  assertTrue(rta.rollbackOn(new RemoteException()));
}

代码示例来源:origin: wildfly/wildfly

return locatorRef.get().narrowAsEntity(EJBObject.class).getPrimaryKey();
throw new RemoteException("Cannot invoke getPrimaryKey() on " + proxy);
throw new RemoteException("Cannot invoke getHomeHandle() on " + proxy);
throw new RemoteException("Error", e);

代码示例来源:origin: spring-projects/spring-framework

@Test
public void testAspectMethodThrowsExceptionIllegalOnSignature() {
  TestBean target = new TestBean();
  RemoteException expectedException = new RemoteException();
  List<Advisor> advisors = getFixture().getAdvisors(
      new SingletonMetadataAwareAspectInstanceFactory(new ExceptionAspect(expectedException), "someBean"));
  assertEquals("One advice method was found", 1, advisors.size());
  ITestBean itb = (ITestBean) createProxy(target, advisors, ITestBean.class);
  try {
    itb.getAge();
    fail();
  }
  catch (UndeclaredThrowableException ex) {
    assertSame(expectedException, ex.getCause());
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void testInvokesMethodOnEjbInstanceWithBusinessInterfaceWithRemoteException() throws Exception {
  final RemoteInterface ejb = mock(RemoteInterface.class);
  given(ejb.targetMethod()).willThrow(new RemoteException());
  final String jndiName= "foobar";
  Context mockContext = mockContext(jndiName, ejb);
  SimpleRemoteSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName);
  BusinessInterface target = (BusinessInterface) configuredProxy(si, BusinessInterface.class);
  try {
    target.targetMethod();
    fail("Should have thrown RemoteAccessException");
  }
  catch (RemoteAccessException ex) {
    // expected
  }
  verify(mockContext).close();
  verify(ejb).remove();
}

代码示例来源:origin: wildfly/wildfly

@Override
  public Object processInvocation(final InterceptorContext context) throws Exception {
    try {
      return context.proceed();
    } catch (EJBTransactionRequiredException e) {
      // this exception explicitly forbids initializing a cause
      throw copyStackTrace(new TransactionRequiredException(e.getMessage()), e);
    } catch (EJBTransactionRolledbackException e) {
      // this exception explicitly forbids initializing a cause
      throw copyStackTrace(new TransactionRolledbackException(e.getMessage()), e);
    } catch (NoSuchEJBException e) {
      // this exception explicitly forbids initializing a cause
      throw copyStackTrace(new NoSuchObjectException(e.getMessage()), e);
    } catch (NoSuchEntityException e) {
      // this exception explicitly forbids initializing a cause
      throw copyStackTrace(new NoSuchObjectException(e.getMessage()), e);
    } catch (EJBException e) {
      //as the create exception is not propagated the init method interceptor just stashes it in a ThreadLocal
      CreateException createException = popCreateException();
      if (createException != null) {
        throw createException;
      }
      throw new RemoteException("Invocation failed", e);
    }
  }
});

代码示例来源:origin: spring-projects/spring-framework

@Test
public void testInvokesMethodOnEjbInstanceWithRemoteException() throws Exception {
  final RemoteInterface ejb = mock(RemoteInterface.class);
  given(ejb.targetMethod()).willThrow(new RemoteException());
  ejb.remove();
  final String jndiName= "foobar";
  Context mockContext = mockContext(jndiName, ejb);
  SimpleRemoteSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName);
  RemoteInterface target = (RemoteInterface) configuredProxy(si, RemoteInterface.class);
  try {
    target.targetMethod();
    fail("Should have thrown RemoteException");
  }
  catch (RemoteException ex) {
    // expected
  }
  verify(mockContext).close();
  verify(ejb, times(2)).remove();
}

代码示例来源:origin: spring-projects/spring-framework

@Override
@Test
public void testRemoteException() throws Exception {
  final RemoteException rex = new RemoteException();
  final String jndiName = "foo";

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

@Override
public void init() throws RemoteException {
  _spi.init();
  try {
    _spiAgent.init(this);
  }
  catch (PortalResiliencyException pre) {
    throw new RemoteException("Unable to initialize SPI agent", pre);
  }
}

相关文章