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

推荐订阅源

Y
Y Combinator Blog
腾讯CDC
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
H
Help Net Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
博客园_首页
D
DataBreaches.Net
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
月光博客
月光博客
Jina AI
Jina AI
Stack Overflow Blog
Stack Overflow Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
Vercel News
Vercel News
WordPress大学
WordPress大学
J
Java Code Geeks
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
U
Unit 42

博客园 - 笨笨

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     }