Package org.jboss.errai.bus.server.io

Source Code of org.jboss.errai.bus.server.io.MethodBindingCallback

package org.jboss.errai.bus.server.io;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import org.jboss.errai.bus.client.api.base.MessageCallbackFailure;
import org.jboss.errai.bus.client.api.messaging.Message;
import org.jboss.errai.bus.client.api.messaging.MessageCallback;

abstract class MethodBindingCallback implements MessageCallback {

  protected void maybeUnwrapAndThrowError(Throwable throwable) throws RuntimeException {
    while (throwable instanceof InvocationTargetException && throwable.getCause() != null) {
      throwable = throwable.getCause();
    }

    throw (throwable instanceof RuntimeException) ? (RuntimeException) throwable
            : new MessageCallbackFailure(throwable);
  }

  protected void verifyMethodSignature(final Method method) {
    final Class<?>[] parmTypes = method.getParameterTypes();

    if (parmTypes.length > 1 || (parmTypes.length == 1 && !Message.class.isAssignableFrom(parmTypes[0]))) {
      throw new IllegalStateException("method does not implement signature: " + method.getName() + "("
              + Message.class.getName() + ")");
    }
  }

}
TOP

Related Classes of org.jboss.errai.bus.server.io.MethodBindingCallback

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.