- 授权协议: 未知
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-javanica
- 软件文档: https://github.com/Netflix/Hystrix/blob/master/hystrix-contrib/hystrix-javanica/README.md
- 官方下载: https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-javanica
软件介绍
javanica 是 Hystrix 开源社区贡献的一个类库。
Java 语言相比其他语言有一些比较 great 的优点,那就是反射(refleaction)和注解(annotation)。在传统的使用 Hystrix 时,你需要编写大量的代码,这显然对开发者并不友好,也会制约 Hystrix 未来的发展。这种模式下,你需要花很长时间编写一些 Hystrix commands。Javanica 项目的想法就是想通过引入 annotation 让你更容易地使用 Hystrix。
使用
要使用 hystrix-javanica,首先要在项目中加入 hystrix-javanica 的依赖。
<dependency> <groupId>com.netflix.hystrix</groupId> <artifactId>hystrix-javanica</artifactId> <version>x.y.z</version> </dependency>
为了实现 AOP 的功能,如果项目中已经使用了 AspectJ,那么还需要在 aop.xml 中添加 hystrix 的切面:
<aspects> ... <aspect name="com.netflix.hystrix.contrib.javanica.aop. aspectj.HystrixCommandAspect"/> ... </aspects>
更多 AspectJ 的配置你可以点击这里。
如果使用 Spring AOP,那么需要通过使用 Spring AOP 的 namespace 来添加指定的配置,这样让 Spring 能够去管理切面,那些你使用 AspectJ 切面,需要像下面这样声明HystrixCommandAspect 作为 Spring 的 bean:
<aop:aspectj-autoproxy/> <bean id="hystrixAspect" class="com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect"></bean>
如果使用Spring的代码配置方式的话,则像下面这样:
@Configuration
public class HystrixConfiguration {
@Bean
public HystrixCommandAspect hystrixAspect() {
return new HystrixCommandAspect();
}
}无论使用哪种方式来创建 proxy,javanica 都可以和 JDK 以及 CGLIB proxy 配合得很好。
Java Web整合开发王者归来
刘京华 / 清华大学 / 2010-1 / 99.80元
《Java Web整合开发王者归来(JSP+Servlet+Struts+Hibernate+Spring)》全面介绍了Java Web开发中的各种相关技术及知识。全书分为9篇,内容层次清晰,难度循序渐进。第1篇为入门篇,内容包括Java Web开发概述等;第2篇为基础篇,内容包括Servlet技术、JSP技术、会话跟踪、过滤器Filter、监听器Listener等;第3篇为高级篇,内容包括JST......一起来看看 《Java Web整合开发王者归来》 这本书的介绍吧!
