以上为Spring1.2的checked和非checked的exception的信息,
1. 观察Spring的RemoteAccessException,这个类的设计可以解释为什么Spring可以把普通的Interface export as EJB acccess的方式(由于远程异常和本地异常处理的不一致,我不赞成EJB Object和LocalObject继承同一个classic interface,用Spring的这种处理方式倒是可以比较好的解决这个问题,唯一的不便的地方是变成Unchecked的exception了);
2. 观察Spring的RemoteAccessException的subclass,分为两种,RemoteConnectFailureException和RemoteLookupFailureException两种,分别代表了不能连接到EJB服务器和连接成功但是lookup失败的情况,这个也是比较常用的一种区分方式,查看了一下它的判断标准:
1 RmiClientInterceptorUtils:
2
3 /**
4 * Determine whether the given RMI exception indicates a connect failure.
5 * Treats ConnectException, ConnectIOException, UnknownHostException,
6 * NoSuchObjectException, StubNotFoundException, MarshalException and
7 * UnmarshalException as connect failure.
8 * @param ex the RMI exception to check
9 * @return whether the exception should be treated as connect failure
10 * @see java.rmi.ConnectException
11 * @see java.rmi.ConnectIOException
12 * @see java.rmi.UnknownHostException
13 * @see java.rmi.NoSuchObjectException
14 * @see java.rmi.StubNotFoundException
15 * @see java.rmi.MarshalException
16 * @see java.rmi.UnmarshalException
17 */
18 public static boolean isConnectFailure(RemoteException ex) {
19 return (ex instanceof ConnectException || ex instanceof ConnectIOException ||
20 ex instanceof UnknownHostException ||
21 ex instanceof NoSuchObjectException || ex instanceof StubNotFoundException ||
22 ex instanceof MarshalException || ex instanceof UnmarshalException);
23 }
2
3 /**
4 * Determine whether the given RMI exception indicates a connect failure.
5 * Treats ConnectException, ConnectIOException, UnknownHostException,
6 * NoSuchObjectException, StubNotFoundException, MarshalException and
7 * UnmarshalException as connect failure.
8 * @param ex the RMI exception to check
9 * @return whether the exception should be treated as connect failure
10 * @see java.rmi.ConnectException
11 * @see java.rmi.ConnectIOException
12 * @see java.rmi.UnknownHostException
13 * @see java.rmi.NoSuchObjectException
14 * @see java.rmi.StubNotFoundException
15 * @see java.rmi.MarshalException
16 * @see java.rmi.UnmarshalException
17 */
18 public static boolean isConnectFailure(RemoteException ex) {
19 return (ex instanceof ConnectException || ex instanceof ConnectIOException ||
20 ex instanceof UnknownHostException ||
21 ex instanceof NoSuchObjectException || ex instanceof StubNotFoundException ||
22 ex instanceof MarshalException || ex instanceof UnmarshalException);
23 }