惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
博客园_首页
Google DeepMind News
Google DeepMind News
博客园 - Franky
The GitHub Blog
The GitHub Blog
GbyAI
GbyAI
有赞技术团队
有赞技术团队
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog
Recent Announcements
Recent Announcements
A
About on SuperTechFans
博客园 - 【当耐特】
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
罗磊的独立博客
IT之家
IT之家
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Jina AI
Jina AI
腾讯CDC
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

博客园 - 笨笨

UTF-8 Oracle生成MD5 How do you define Success? pbrun su -root Shell/Windows命令备忘 爸妈 What is ieHTTPHeaders? SLA(Service Level Agreement) Cluster/Fail-Over/Load Banlance Thread Dump 非常郁闷 Bea World 2005 materials available now 程序依赖库的管理 EJB琐碎的想法 J2EE的世界越来越精彩了 LDAP信息模型 人类进入文明史的标志 TimeZone Socket
Spring中的exception处理
笨笨 · 2006-01-03 · via 博客园 - 笨笨

exception.jpg

checkedexception.jpg

以上为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,分为两种,RemoteConnectFailureExceptionRemoteLookupFailureException两种,分别代表了不能连接到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     }