本文整理汇总了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);
}