RedHat配置YUM 从centos5源与光盘源更新软件
2012-08-10 14:27
387 查看
在struts2的struts-default.xml中定义了一个name为prepare拦截器,实现类是com.opensymphony.xwork2.interceptor.PrepareInterceptor,它的作用是为实现了com.opensymphony.xwork2.Preparable接口的action调用相关方法。该拦截器有两个参数:alwaysInvokePrepare,firstCallPrepareDo,两者的类型都是boolean,默认值分别是true,false。
该拦截器的核心代码如下:
该代码的逻辑非常简单,如果action实现了com.opensymphony.xwork2.Preparable接口,则在调用setXXX和execute()方法之前调用系列方法。如果firstCallPrepareDo为true,则调用prepareDoXXX方法,否则调用prepareXXX方法(XXX为action对应的方法)。接下来查看alwaysInvokePrepare状态,如果其值为true则调用com.opensymphony.xwork2.Preparable接口的prepare方法。最后将action转交给下一个拦截器。
版权所有,转载请标明出处:http://blogwarning.iteye.com/blog/1390172
该拦截器的核心代码如下:
public String doIntercept(ActionInvocation invocation) throws Exception { Object action = invocation.getAction(); if (action instanceof Preparable) { try { String[] prefixes; if (firstCallPrepareDo) { prefixes = new String[] {ALT_PREPARE_PREFIX, PREPARE_PREFIX}; } else { prefixes = new String[] {PREPARE_PREFIX, ALT_PREPARE_PREFIX}; } PrefixMethodInvocationUtil.invokePrefixMethod(invocation, prefixes); } catch (InvocationTargetException e) { /* * The invoked method threw an exception and reflection wrapped it * in an InvocationTargetException. * If possible re-throw the original exception so that normal * exception handling will take place. */ Throwable cause = e.getCause(); if (cause instanceof Exception) { throw (Exception) cause; } else if(cause instanceof Error) { throw (Error) cause; } else { /* * The cause is not an Exception or Error (must be Throwable) so * just re-throw the wrapped exception. */ throw e; } } if (alwaysInvokePrepare) { ((Preparable) action).prepare(); } } return invocation.invoke(); }
该代码的逻辑非常简单,如果action实现了com.opensymphony.xwork2.Preparable接口,则在调用setXXX和execute()方法之前调用系列方法。如果firstCallPrepareDo为true,则调用prepareDoXXX方法,否则调用prepareXXX方法(XXX为action对应的方法)。接下来查看alwaysInvokePrepare状态,如果其值为true则调用com.opensymphony.xwork2.Preparable接口的prepare方法。最后将action转交给下一个拦截器。
版权所有,转载请标明出处:http://blogwarning.iteye.com/blog/1390172
相关文章推荐
- RedHat 5.5配置yum 从centos5源与光盘源更新软件
- RedHat 5.5配置YUM 从centos5源与光盘源更新软件
- 小总结:RedHat 5配置YUM 从centos5源与光盘源更新软件
- RedHat配置YUM 从centos5源与光盘源更新软件
- RedHat 5.5配置YUM 从centos5源与光盘源更新软件
- RedHat 5.3配置YUM 从centos5源与光盘源更新软件
- RedHat配置YUM 从centos5源与光盘源更新软件
- RedHat 5.3配置YUM 从centos5源与光盘源更新软件
- 配置YUM 从centos5源与光盘源更新软件
- Redhat 配置YUM 从centos5源更新软件
- Redhat 配置YUM 从centos5源更新软件
- RHEL5配置YUM从本地光盘更新软件
- 在Vmware中配置YUM 从本地光盘更新软件
- 配置YUM 从centos5源更新软件
- 配置YUM 从centos5源更新软件
- 软件包管理 之 Fedora/Redhat 在线安装更新软件包,yum 篇 ── 给新手指南
- Fedora/Redhat 在线安装更新软件包,yum 篇 ── 给新手指南
- Fedora/Redhat 在线安装更新软件包,yum 篇 ── 给新手指南 (转载)
- 配置Fedora core 6中yum光盘源 --去除无网络不能打开软件包管理的问题
- 【推荐】在RedHat Server 5.4上安装YUM【利用网易免费yum源,配置和更新yum】