Maybe I can clarify a bit.  The reason the remoting client declares that it 
throws Throwable is that remoting will pass along the Throwable object thrown 
from the server side hanlder.  Since we don't know what type of exceptions the 
server side handler might throw, we have to declare the most generic base class 
there is, which is Throwable.  

So for example, suppose the user has an implementation of 
ServerInvocationHandler that looks like:


  |    public class MyInvocationHandler implements ServerInvocationHandler
  |    {
  |       ...
  | 
  |       public Object invoke(InvocationRequest invocation) throws Throwable
  |       {
  |           Object param = invocation.getParameter();
  |           if("foo".equals(param)
  |           {
  |               throw new AssertionError();
  |           }
  |           else if("bar".equals(param)
  |           {
  |               throw new IllegalArgumentException();
  |           }
  |           else
  |           {
  |              return "Thank you";
  |           }
  |       }
  | 
  |       ...
  |    }
  | 
  | 
  |   | 
  |   | So if the remoting client passes the String "foo" to the invoke() 
method, an AssertionError will be thrown from the invoke() method call.  If the 
remoting client passes the String "bar" to the invoke() method, an 
IllegalArgumentException will be thrown from the invoke() method call.  Both 
will appear just as it was thrown from the handler on the server side to the 
client.  Since there is no way for remoting to know what might possibly thrown 
by the server handler, we have to just declare we throw Throwable.  
  |   | 
  |   | Now it is possible that an exception may occur that has nothing to do 
with the server handler (i.e. a network error).  So if the remoting client can 
not connect to the server for some reason, remoting will throw a 
org.jboss.remoting.CannotConnectException.  If there was some other network 
exception such as a socket timeout, would get that exception thrown as well 
(i.e. java.net.SocketException).
  |   | 
  |   | Hope that helps.
  |   | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4017469#4017469

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4017469
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to