- 授权协议: Apache-2.0
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: https://github.com/ximplementation/ximplementation
- 软件文档: https://github.com/ximplementation/ximplementation/blob/master/README_zh-CN.md
- 官方下载: https://github.com/ximplementation/ximplementation/releases
软件介绍
Ximplementation是一个基于Java注解的调用时路由框架。
它包括两个核心注解:
@Implementor
此注解标注于类,表明类是某个或者某些类的实现类,就像implements和extends关键字。
@Implement
此注解标注于@Implementor类的方法,表明方法是实现方法,就像@Overriden注解。
示例
假设有一个接口类如下:
public interface Service{ T plus(T a, T b); T minus(T a, T b); }
那么,你可以自由地编写它的实现类:
public class ServiceImplDefaultimplements Service { public T plus(T a, T b){...} public T minus(T a, T b){...} } public class ServiceImplPlusInteger implements Service { @Override public Integer plus(Integer a, Integer b){...} @NotImplement @Override public Integer minus(Integer a, Integer b){ throw new UnsupportedOperationException(); } } @Implementor(Service.class) public class ServiceImplMinusInteger { @Implement public Integer minus(Integer a, Integer b){...} }
注:ServiceImplMinusInteger并不是必须的。而且,你可以在同一个或者多个其他@Implementor实现类内为plus和/或minus编写多个实现方法。
之后,你可以通过如下方式获得Service的实例:
Implementationimplementation = new ImplementationResolver().resolve(Service.class, ServiceImplDefault.class, ServiceImplPlusInteger.class, ServiceImplMinusInteger.class); ImplementorBeanFactory implementorBeanFactory = SimpleImplementorBeanFactory .valueOf(new ServiceImplDefault (), new ServiceImplPlusInteger(), new ServiceImplMinusInteger()); Service service = new ProxyImplementeeBeanBuilder().build(implementation, implementorBeanFactory);
对于serivce.plus方法的调用,如果参数类型是Integer,将被路由至ServiceImplPlusInteger.plus方法,否则,将被路由至ServiceImplDefault.plus方法;对于serivce.minus方法的调用,如果参数类型是Integer,将被路由至ServiceImplMinusInteger.minus方法,否则,将被路由至ServiceImplDefault.minus方法。
扩展库
Ximplementation-spring是一个将ximplementation整合至Spring的库,使Spring能够支持多实例依赖注入和更多ximplementation特性。
互联网:碎片化生存
段永朝 / 中信出版社 / 2009-11 / 42.00元
《互联网:碎片化生存》内容简介:在世界互联网人数超过17亿,中国网民接近4亿的时候,断言“这个版本的互联网没有未来”是要冒很大风险的。我们生活在比特和连线的世界,现代互联网所描绘出的“数字化”、“虚拟化”的未来是否完全值得信赖? 现代商业取得了巨大成功,但这并不是电脑和互联网精髓的自由体现,我们所使用的这个版本的电脑和互联网只不过是“被阉割”、“被劫持”的商业玩偶。 《互联网:碎片化生......一起来看看 《互联网:碎片化生存》 这本书的介绍吧!
