OfficeFloorIoC框架

联合创作 · 2023-09-30 07:13

OfficeFloor 是一个 IoC 2.0 的实现,主要是聚焦于方法的依赖注入而不是对象。OfficeFloor 还拥有一个基于Eclipse的图形化配置插件,如下图所示:

示例代码:

// OfficeFloor source to create an inline HTTP Server (useful for testing a single web page).
// Note that applications would be configured using the WoOF graphical configuration.
HttpServerAutoWireOfficeFloorSource server = new HttpServerAutoWireOfficeFloorSource();
 
// Add a dynamic web page (ExampleBean provides the page logic and is just a POJO)
server.addHttpTemplate("example.html", ExampleBean.class);
 
// Add configured DataSource for dependency injection
server.addManagedObject(DataSourceManagedObjectSource.class, null, DataSource.class).loadProperties("datasource.properties");
 
// Assign Team (specific thread pool) responsible for executing the methods with a DataSource dependency
server.assignTeam(LeaderFollowerTeamSource.class, DataSource.class).addProperty("size", "10");
 
// Start the HTTP Server
server.openOfficeFloor();
浏览 9
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报