osgi-mybatis整合,整合过程中,未采用spring-osgi机制,ds方式。
关键技术说明
OSGI Mybatis eclipse(spring-tool) felix
Bundle 功能描述
bundle名称 功能
com.gooagoo.si.mybatis.lib 常用jar集合
com.gooagoo.si.mybatis.orm orm 对象
com.gooagoo.si.mybatis.datasource 数据源,以及OSGI-Mybatis整合,命名不够规范 ^_^
com.gooagoo.si.mybatis.article.category 应用示例
公共Bundle重点说明
com.gooagoo.si.mybatis.datasource说明,获得Mybatis中的SqlSessionFactory,并注入dataSource
public SqlSessionFactory getSqlSessionFactory(Bundle bundle)
{
// TODO Auto-generated method stub
ClassLoader loader = bundle.adapt(BundleWiring.class).getClassLoader();
String mybatisConfig = bundle.getHeaders().get(MybatisConstants.MybatisConfig);
System.out.println("【mybatisConfig】" + mybatisConfig);
Reader reader = null;
try
{
Resources.setDefaultClassLoader(loader);
reader = Resources.getResourceAsReader(mybatisConfig);
XMLConfigBuilder parser = new XMLConfigBuilder(reader);
configuration = parser.parse();
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("development", transactionFactory, dataSource);
configuration.setEnvironment(environment);
sessionFactory = new DefaultSqlSessionFactory(configuration);
}
catch (IOException e)
{
e.printStackTrace();
}
return sessionFactory;
}
基于以上的OSGI-Mybatis,应用示例
在每一个service实现对象中,加载一下Mybatis mapper类
private MapperRegistry mapperRegistry = null;
public void bind(CommonService commonService)
{
sessionFactory = commonService.getSqlSessionFactory();
mapperRegistry = sessionFactory.getConfiguration().getMapperRegistry();
mapperRegistry.addMapper(CategoryMapper.class);
logger.info("v1 " + sessionFactory.getConfiguration().getMapperRegistry().hasMapper((CategoryMapper.class)));
logger.info(getAllCategoryInfo() + "");
}
使用Mapper.class对象
public List<CategoryInfo> getAllCategoryInfo()
{
// TODO Auto-generated method stub
List<CategoryInfo> retlist = new ArrayList<CategoryInfo>();
SqlSession sqlSession = null;
try
{
sqlSession = sessionFactory.openSession();
retlist = sqlSession.getMapper(CategoryMapper.class).findAll();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if (sqlSession != null)
{
sqlSession.close();
}
}
return retlist;
}
OSGI hessian整合
osgi hessian 为第三方系统
分享到:
相关推荐
赠送原API文档:osgi-resource-locator-1.0.1-javadoc.jar; 赠送源代码:osgi-resource-locator-1.0.1-sources.jar; 赠送Maven依赖信息文件:osgi-resource-locator-1.0.1.pom; 包含翻译后的API文档:osgi-...
赠送原API文档:osgi-resource-locator-1.0.1-javadoc.jar; 赠送源代码:osgi-resource-locator-1.0.1-sources.jar; 赠送Maven依赖信息文件:osgi-resource-locator-1.0.1.pom; 包含翻译后的API文档:osgi-...
spring-osgi-1.2.1-with-dependencies.zip spring-osgi-1.2.1-with-dependencies.zip spring-osgi-1.2.1-with-dependencies.zip
spring-osgi-1.2.0-rc1-with-dependencies.zip
OSGi-lib.rar OSGi-lib.rar OSGi-lib.rar OSGi-lib.rar
osgi核心规范文档,osgi服务文档,osgi-最佳原理与实践(王昊编著,共79页)
spring-osgi-1.2.0-with-dependencies.zip spring-osgi-1.2.0-with-dependencies.zip spring-osgi-1.2.0-with-dependencies.zip
spring1.2的包文件 spring-osgi-1.2.0.zip
osgi-webservice教程 教授你如果通过osgi架构开发java的webservice
标签:atlassian-plugins-osgi-2.6.0.jar.zip,atlassian,plugins,osgi,2.6.0,jar.zip包下载,依赖包
java-goinstant-auth.zip,Java应用程序的GoInstant身份验证。Java应用程序的GoInstant身份验证
spring-osgi-1.2.1-with-dependencies完整包
OSGI技术 讲述了osgi的三个模块服务层 模块层 生命周期层 主要介绍了如何进行模块化的开发等等,可以灵活的开发网络模块
OSGI企业应用开发(五)使用Blueprint整合Spring框架源码
Spring-DM指的是 Spring ...Spring-DM 的主要目的是能够方便地将 Spring 框架和OSGi框架结合在一起,使得使用Spring的应用程序可以方便简单地部署在OSGi环境中,利用OSGi框架提供的服务,将应用变得 更加模块化。
中文-英文对照文档,中英对照文档,java,jar包,Maven,第三方jar包,组件,开源组件,第三方组件,Gradle,中文API文档,手册,开发手册,使用手册,参考手册 # 使用方法: 解压 【***.jar中文文档.zip】,再解压其中的 【***-...
自制CHM版的API文档,带索引。 注:如果各位下载后打开或无法显示页面,请在CHM文件右键—属性—解除锁定即可。
jar包,亲测可用
spring osgi所需的所有lib以及示例程序。
maven-osgi-plugin-launcher-framework-equinox-1.0.15.jar