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