當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。