当前位置: 首页>>代码示例>>Java>>正文


Java JPAEntityManagerProviderFactory类代码示例

本文整理汇总了Java中org.osgi.service.transaction.control.jpa.JPAEntityManagerProviderFactory的典型用法代码示例。如果您正苦于以下问题:Java JPAEntityManagerProviderFactory类的具体用法?Java JPAEntityManagerProviderFactory怎么用?Java JPAEntityManagerProviderFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JPAEntityManagerProviderFactory类属于org.osgi.service.transaction.control.jpa包,在下文中一共展示了JPAEntityManagerProviderFactory类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import org.osgi.service.transaction.control.jpa.JPAEntityManagerProviderFactory; //导入依赖的package包/类
@Before
public void setup() {
    ServiceReference<DataSourceFactory> dsRef = this.context.getServiceReference(DataSourceFactory.class);
    this.jdbcFactory = this.context.getService(dsRef);

    ServiceReference<EntityManagerFactoryBuilder> emRef = this.context
            .getServiceReference(EntityManagerFactoryBuilder.class);
    this.builder = this.context.getService(emRef);

    ServiceReference<TransactionControl> txcRef = this.context.getServiceReference(TransactionControl.class);
    this.txControl = this.context.getService(txcRef);

    ServiceReference<JPAEntityManagerProviderFactory> jpaRef = this.context
            .getServiceReference(JPAEntityManagerProviderFactory.class);
    this.resourceFactory = this.context.getService(jpaRef);

    assertNotNull(this.jdbcFactory);
    assertNotNull(this.builder);
    assertNotNull(this.txControl);
    assertNotNull(this.resourceFactory);

    Properties props = new Properties();

    props.setProperty(JDBC_URL, TEST_DB_URL);
    props.setProperty(JDBC_USER, "admin");
    props.setProperty(JDBC_PASSWORD, "admin123");

    DataSource ds = null;
    try {
        ds = this.jdbcFactory.createDataSource(props);
    } catch (SQLException e) {
        Assert.fail(e.getClass() + " : " + e.getMessage());
    }

    this.em = this.resourceFactory
            .getProviderFor(this.builder, singletonMap("javax.persistence.nonJtaDataSource", (Object) ds), null)
            .getResource(this.txControl);

    assertNotNull(this.em);

}
 
开发者ID:opensecuritycontroller,项目名称:sdn-controller-nsc-plugin,代码行数:42,代码来源:OSGiIntegrationTest.java


注:本文中的org.osgi.service.transaction.control.jpa.JPAEntityManagerProviderFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。