本文整理汇总了Java中org.osgi.service.jpa.EntityManagerFactoryBuilder类的典型用法代码示例。如果您正苦于以下问题:Java EntityManagerFactoryBuilder类的具体用法?Java EntityManagerFactoryBuilder怎么用?Java EntityManagerFactoryBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityManagerFactoryBuilder类属于org.osgi.service.jpa包,在下文中一共展示了EntityManagerFactoryBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addingService
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
@Override
public StoredPerProvider addingService(ServiceReference<PersistenceProvider> reference) {
String providerName = (String)reference.getProperty(JAVAX_PERSISTENCE_PROVIDER);
// FIXME should be set when creating the EMF was successful
if (punit.getPersistenceProviderClassName() == null) {
punit.setProviderClassName(providerName);
}
StoredPerProvider stored = new StoredPerProvider();
LOGGER.info("Found provider for " + punit.getPersistenceUnitName() + " " + punit.getPersistenceProviderClassName());
PersistenceProvider provider = context.getService(reference);
createAndCloseDummyEMF(provider);
stored.builder = new AriesEntityManagerFactoryBuilder(context, provider, reference.getBundle(), punit);
Dictionary<String, ?> props = AriesEntityManagerFactoryBuilder.createBuilderProperties(punit, punit.getBundle());
stored.reg = context.registerService(EntityManagerFactoryBuilder.class, stored.builder , props);
return stored;
}
开发者ID:apache,项目名称:aries-jpa,代码行数:20,代码来源:PersistenceProviderTracker.java
示例2: incompatibleExtender
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
private boolean incompatibleExtender(Bundle bundle) {
List<BundleWire> requiredWires = bundle.adapt(BundleWiring.class)
.getRequiredWires(OSGI_EXTENDER_NS);
for(BundleWire bw : requiredWires) {
BundleCapability capability = bw.getCapability();
if(EntityManagerFactoryBuilder.JPA_CAPABILITY_NAME.equals(
capability.getAttributes().get(OSGI_EXTENDER_NS))) {
// If the persistence bundle requires a different revision for the
// JPA extender then we are incompatible, otherwise we are
return !capability.getRevision().equals(wiring.getRevision());
}
}
// If there is no requirement then we must assume that it's safe
return false;
}
开发者ID:apache,项目名称:aries-jpa,代码行数:20,代码来源:PersistenceBundleTracker.java
示例3: testEntityManagerFactoryBuilderWithIncompletePersistenceUnitAddPlugin
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
@Test
public void testEntityManagerFactoryBuilderWithIncompletePersistenceUnitAddPlugin() throws Exception {
EntityManagerFactoryBuilder builder = getService(EntityManagerFactoryBuilder.class, "(osgi.unit.name=incompleteTestUnit2)", 1000);
DataSourceFactory dsf = getService(DataSourceFactory.class,
"(" + OSGI_JDBC_DRIVER_CLASS + "=org.apache.derby.jdbc.EmbeddedDriver)");
Properties jdbcProps = new Properties();
jdbcProps.setProperty("url", "jdbc:derby:memory:DSFTEST;create=true");
Map<String, Object> props = new HashMap<String, Object>();
props.put("javax.persistence.nonJtaDataSource", dsf.createDataSource(jdbcProps));
props.put("javax.persistence.transactionType", RESOURCE_LOCAL.name());
props.put("org.apache.aries.jpa.eclipselink.plugin.types", SessionCustomizerImpl.class);
props.put("eclipselink.session.customizer", SessionCustomizerImpl.class.getName());
EntityManagerFactory emf = builder.createEntityManagerFactory(props);
emf.createEntityManager();
assertEquals("invoked", emf
.getProperties().get(CUSTOMIZER_CALLED));
}
开发者ID:apache,项目名称:aries-jpa,代码行数:24,代码来源:EclipseAdditionalTest.java
示例4: testCarEMFBuilderExternalDS
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
@Test
public void testCarEMFBuilderExternalDS() throws Exception {
DataSourceFactory dsf = getService(DataSourceFactory.class,
"(" + OSGI_JDBC_DRIVER_CLASS + "=org.apache.derby.jdbc.EmbeddedDriver)");
EntityManagerFactoryBuilder emfBuilder = getService(EntityManagerFactoryBuilder.class,
"(osgi.unit.name=" + EXTERNAL_TEST_UNIT + ")");
assertEquals(getProviderClassName(), emfBuilder.getPersistenceProviderName());
assertEquals(getProviderBundle(), emfBuilder.getPersistenceProviderBundle());
Properties jdbcProps = new Properties();
jdbcProps.setProperty("url", "jdbc:derby:memory:DSFTEST;create=true");
Map<String, Object> props = new HashMap<String, Object>();
props.put("javax.persistence.nonJtaDataSource", dsf.createDataSource(jdbcProps));
props.put("javax.persistence.transactionType", RESOURCE_LOCAL.name());
EntityManagerFactory emf = emfBuilder.createEntityManagerFactory(props);
carLifecycleRL(emf.createEntityManager());
}
开发者ID:apache,项目名称:aries-jpa,代码行数:22,代码来源:JPAContainerTest.java
示例5: testTruckEMFBuilderExternalDS
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
@Test
public void testTruckEMFBuilderExternalDS() throws Exception {
DataSourceFactory dsf = getService(DataSourceFactory.class,
"(" + OSGI_JDBC_DRIVER_CLASS + "=org.apache.derby.jdbc.EmbeddedDriver)");
EntityManagerFactoryBuilder emfBuilder = getService(EntityManagerFactoryBuilder.class,
"(osgi.unit.name=" + EXTERNAL_TEST_UNIT + ")");
assertEquals(getProviderClassName(), emfBuilder.getPersistenceProviderName());
assertEquals(getProviderBundle(), emfBuilder.getPersistenceProviderBundle());
Properties jdbcProps = new Properties();
jdbcProps.setProperty("url", "jdbc:derby:memory:DSFTEST;create=true");
Map<String, Object> props = new HashMap<String, Object>();
props.put("javax.persistence.nonJtaDataSource", dsf.createDataSource(jdbcProps));
props.put("javax.persistence.transactionType", RESOURCE_LOCAL.name());
EntityManagerFactory emf = emfBuilder.createEntityManagerFactory(props);
truckLifecycleRL(emf.createEntityManager());
}
开发者ID:apache,项目名称:aries-jpa,代码行数:22,代码来源:JPAContainerTest.java
示例6: testCarEMFBuilderExternalDSXA
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
@Test
public void testCarEMFBuilderExternalDSXA() throws Exception {
EntityManagerFactoryBuilder emfBuilder = getService(EntityManagerFactoryBuilder.class,
"(osgi.unit.name=" + EXTERNAL_TEST_UNIT + ")");
assertEquals(getProviderClassName(), emfBuilder.getPersistenceProviderName());
assertEquals(getProviderBundle(), emfBuilder.getPersistenceProviderBundle());
Map<String, Object> props = new HashMap<String, Object>();
props.put("javax.persistence.jtaDataSource", ds);
props.put("javax.persistence.transactionType", JTA.name());
//EclipseLink also needs a non-jta-datasource
props.put("javax.persistence.nonJtaDataSource", ds);
EntityManagerFactory emf = emfBuilder.createEntityManagerFactory(props);
carLifecycleXA(ut, emf.createEntityManager());
}
开发者ID:apache,项目名称:aries-jpa,代码行数:17,代码来源:JPAContainerTest.java
示例7: testTruckEMFBuilderExternalDSXA
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
@Test
public void testTruckEMFBuilderExternalDSXA() throws Exception {
EntityManagerFactoryBuilder emfBuilder = getService(EntityManagerFactoryBuilder.class,
"(osgi.unit.name=" + EXTERNAL_TEST_UNIT + ")");
assertEquals(getProviderClassName(), emfBuilder.getPersistenceProviderName());
assertEquals(getProviderBundle(), emfBuilder.getPersistenceProviderBundle());
Map<String, Object> props = new HashMap<String, Object>();
props.put("javax.persistence.jtaDataSource", ds);
props.put("javax.persistence.transactionType", JTA.name());
//EclipseLink also needs a non-jta-datasource
props.put("javax.persistence.nonJtaDataSource", ds);
EntityManagerFactory emf = emfBuilder.createEntityManagerFactory(props);
truckLifecycleXA(ut, emf.createEntityManager());
}
开发者ID:apache,项目名称:aries-jpa,代码行数:17,代码来源:JPAContainerTest.java
示例8: testCarEMFBuilderNoNonJTADataSource
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
@Test
public void testCarEMFBuilderNoNonJTADataSource() throws Exception {
EntityManagerFactoryBuilder emfBuilder = getService(EntityManagerFactoryBuilder.class,
"(osgi.unit.name=" + EXTERNAL_TEST_UNIT + ")");
assertEquals(getProviderClassName(), emfBuilder.getPersistenceProviderName());
assertEquals(getProviderBundle(), emfBuilder.getPersistenceProviderBundle());
Map<String, Object> props = new HashMap<String, Object>();
Properties jdbcProps = new Properties();
jdbcProps.setProperty("url", "jdbc:derby:memory:TESTNOJTA;create=true");
props.put("javax.persistence.dataSource", dsf.createDataSource(jdbcProps));
props.put("javax.persistence.transactionType", RESOURCE_LOCAL.name());
EntityManagerFactory emf = emfBuilder.createEntityManagerFactory(props);
carLifecycleRL(emf.createEntityManager());
}
开发者ID:apache,项目名称:aries-jpa,代码行数:18,代码来源:JPAContainerTest.java
示例9: testTruckEMFBuilderNoNonJTADataSource
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
@Test
public void testTruckEMFBuilderNoNonJTADataSource() throws Exception {
EntityManagerFactoryBuilder emfBuilder = getService(EntityManagerFactoryBuilder.class,
"(osgi.unit.name=" + EXTERNAL_TEST_UNIT + ")");
assertEquals(getProviderClassName(), emfBuilder.getPersistenceProviderName());
assertEquals(getProviderBundle(), emfBuilder.getPersistenceProviderBundle());
Map<String, Object> props = new HashMap<String, Object>();
Properties jdbcProps = new Properties();
jdbcProps.setProperty("url", "jdbc:derby:memory:TESTNOJTA;create=true");
props.put("javax.persistence.dataSource", dsf.createDataSource(jdbcProps));
props.put("javax.persistence.transactionType", RESOURCE_LOCAL.name());
EntityManagerFactory emf = emfBuilder.createEntityManagerFactory(props);
truckLifecycleRL(emf.createEntityManager());
}
开发者ID:apache,项目名称:aries-jpa,代码行数:18,代码来源:JPAContainerTest.java
示例10: create
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
private void create(Bundle bundle, Context context) {
Map.Entry<String, PersistenceProvider> pp = provider.get(context.definition.provider);
// Do the registration of the service asynchronously. Since it may imply all kinds of
// listening actions performed as a result of it, it may block the bundle handling.
// However, indicate that we are in the process of the actions by
// setting the used provider.
context.usedProvider = pp.getKey();
new Thread(() -> {
synchronized (context) {
if (context.usedProvider != null) {
PersistenceUnitInfo info = PersistenceUnitProcessor.getPersistenceUnitInfo(bundle,
context.definition, pp.getValue());
context.factory = PersistenceUnitProcessor.createFactory(pp.getValue(), info);
Hashtable<String, Object> props = new Hashtable<>();
props.put(EntityManagerFactoryBuilder.JPA_UNIT_NAME, context.definition.name);
props.put(PersistenceUnitTransactionType.class.getName(), info.getTransactionType().name());
context.registration = bundle.getBundleContext().registerService(
EntityManagerFactory.class, context.factory, props);
}
}
}).start();
}
开发者ID:arievanwi,项目名称:osgi.ee,代码行数:23,代码来源:JpaBundleChangeListener.java
示例11: testLifecycle
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testLifecycle() {
BundleContext context = mock(BundleContext.class);
Coordinator coordinator = mock(Coordinator.class);
EMFTracker tracker = new EMFTracker(context, coordinator);
ServiceReference<EntityManagerFactory> ref = mock(ServiceReference.class);
Mockito.when(ref.getProperty(EntityManagerFactoryBuilder.JPA_UNIT_NAME)).thenReturn("testunit");
Mockito.when(ref.getProperty(PersistenceUnitTransactionType.class.getName())).thenReturn("JTA");
Bundle puBundle = mock(Bundle.class);
BundleContext puContext = mock(BundleContext.class);
when(puBundle.getBundleContext()).thenReturn(puContext);
when(ref.getBundle()).thenReturn(puBundle);
EntityManagerFactory emf = mock(EntityManagerFactory.class);
when(puContext.getService(ref)).thenReturn(emf);
ServiceRegistration<?> emSupplierReg = mock(ServiceRegistration.class, "emSupplierReg");
ServiceRegistration<?> emProxyReg = mock(ServiceRegistration.class, "emProxyReg");
when(puContext.registerService(any(Class.class), any(), any(Dictionary.class)))
.thenReturn(emSupplierReg, emProxyReg);
EMFTracker.TrackedEmf tracked = (TrackedEmf)tracker.addingService(ref);
Assert.assertEquals(emf, tracked.emf);
Assert.assertEquals(emSupplierReg, tracked.emSupplierReg);
Assert.assertEquals(emProxyReg, tracked.emProxyReg);
Assert.assertNotNull(tracked.tmTracker);
Assert.assertNull(tracked.rlTxManagerReg);
tracker.removedService(ref, tracked);
verify(emSupplierReg, times(1)).unregister();
verify(emProxyReg, times(1)).unregister();
verify(puContext, times(1)).ungetService(ref);
}
开发者ID:apache,项目名称:aries-jpa,代码行数:34,代码来源:EmfTrackerTest.java
示例12: testCarEMFBuilder
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
@Test
public void testCarEMFBuilder() throws Exception {
EntityManagerFactoryBuilder emfBuilder = getService(EntityManagerFactoryBuilder.class,
"(osgi.unit.name=" + DSF_TEST_UNIT + ")");
assertEquals(getProviderClassName(), emfBuilder.getPersistenceProviderName());
assertEquals(getProviderBundle(), emfBuilder.getPersistenceProviderBundle());
Map<String, Object> props = new HashMap<String, Object>();
EntityManagerFactory emf = emfBuilder.createEntityManagerFactory(props);
carLifecycleRL(emf.createEntityManager());
}
开发者ID:apache,项目名称:aries-jpa,代码行数:13,代码来源:JPAContainerTest.java
示例13: testTruckEMFBuilder
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
@Test
public void testTruckEMFBuilder() throws Exception {
EntityManagerFactoryBuilder emfBuilder = getService(EntityManagerFactoryBuilder.class,
"(osgi.unit.name=" + DSF_TEST_UNIT + ")");
assertEquals(getProviderClassName(), emfBuilder.getPersistenceProviderName());
assertEquals(getProviderBundle(), emfBuilder.getPersistenceProviderBundle());
Map<String, Object> props = new HashMap<String, Object>();
EntityManagerFactory emf = emfBuilder.createEntityManagerFactory(props);
truckLifecycleRL(emf.createEntityManager());
}
开发者ID:apache,项目名称:aries-jpa,代码行数:13,代码来源:JPAContainerTest.java
示例14: registerJpaCrudRepository
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
void registerJpaCrudRepository(String unitName, EntityManagerFactory emf) {
Dictionary<String, String> properties = new Hashtable<>();
properties.put(SERVICE_VENDOR, "AdeptJ");
properties.put(SERVICE_PID, EclipseLinkCrudRepository.class.getName());
properties.put(SERVICE_DESCRIPTION, "AdeptJ Modules JpaCrudRepository(EclipseLink)");
properties.put(EntityManagerFactoryBuilder.JPA_UNIT_NAME, unitName);
LOGGER.info("Registering JpaCrudRepository For PersistenceUnit: [{}]", unitName);
this.jpaCrudRepositories.put(unitName, this.context.registerService(JpaCrudRepository.class,
new EclipseLinkCrudRepository(emf), properties));
this.entityManagerFactories.put(unitName, emf);
}
开发者ID:AdeptJ,项目名称:adeptj-modules,代码行数:12,代码来源:JpaCrudRepositoryManager.java
示例15: start
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
@Override
public void start(BundleContext context) {
TransactionController.initialize(context);
OurPersistenceProvider provider = new OurPersistenceProvider();
Hashtable<String, Object> dict = new Hashtable<>();
dict.put( EntityManagerFactoryBuilder.JPA_UNIT_PROVIDER, "org.eclipse.persistence.jpa.PersistenceProvider");
context.registerService(PersistenceProvider.class, provider, dict);
}
开发者ID:arievanwi,项目名称:osgi.ee,代码行数:9,代码来源:Activator.java
示例16: getEntityManagerFactoryServiceReference
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
private ServiceReference getEntityManagerFactoryServiceReference() throws Exception {
ServiceReference[] serviceReferences = bc.getServiceReferences(EntityManagerFactory.class.getName(),
String.format("(%s=%s)", EntityManagerFactoryBuilder.JPA_UNIT_NAME, STUDENTS_UNIT));
if (serviceReferences != null && serviceReferences.length > 0) {
return serviceReferences[0];
} else {
throw new Exception("EntityManagerFactory is not available");
}
}
开发者ID:vandewilly,项目名称:osgi-jpa,代码行数:10,代码来源:CommandLineService.java
示例17: setup
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的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
示例18: xaTxManProps
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
private static Dictionary<String, String> xaTxManProps(String unitName) {
Dictionary<String, String> txmanProperties = new Hashtable<String, String>(); // NOSONAR
txmanProperties.put(EntityManagerFactoryBuilder.JPA_UNIT_NAME, unitName);
txmanProperties.put(TRANSACTION_TYPE, "JTA");
return txmanProperties;
}
开发者ID:apache,项目名称:aries-jpa,代码行数:7,代码来源:TMTracker.java
示例19: testEntityManagerFactoryBuilderWithIncompletePersistenceUnit
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
@Test
public void testEntityManagerFactoryBuilderWithIncompletePersistenceUnit() throws Exception {
getService(EntityManagerFactoryBuilder.class, "(osgi.unit.name=incompleteTestUnit)", 1000);
}
开发者ID:apache,项目名称:aries-jpa,代码行数:5,代码来源:EclipseAdditionalTest.java
示例20: getName
import org.osgi.service.jpa.EntityManagerFactoryBuilder; //导入依赖的package包/类
private static String getName(ServiceReference<?> ref) {
String providerName = (String) ref.getProperty(EntityManagerFactoryBuilder.JPA_UNIT_PROVIDER);
return providerName;
}
开发者ID:arievanwi,项目名称:osgi.ee,代码行数:5,代码来源:PersistenceProviderListener.java
注:本文中的org.osgi.service.jpa.EntityManagerFactoryBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论