本文整理汇总了Java中javax.persistence.spi.PersistenceUnitTransactionType.RESOURCE_LOCAL属性的典型用法代码示例。如果您正苦于以下问题:Java PersistenceUnitTransactionType.RESOURCE_LOCAL属性的具体用法?Java PersistenceUnitTransactionType.RESOURCE_LOCAL怎么用?Java PersistenceUnitTransactionType.RESOURCE_LOCAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.persistence.spi.PersistenceUnitTransactionType
的用法示例。
在下文中一共展示了PersistenceUnitTransactionType.RESOURCE_LOCAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HSQLDBProvider
public HSQLDBProvider() {
scan.limitSearchingPathTo(full());
generator = new RuntimePersistenceGenerator("test", PersistenceUnitTransactionType.RESOURCE_LOCAL, getProvider());
setProperties(generator);
generateAnnotedClasses();
for (Class<?> annotatedClass : entities) {
generator.addAnnotatedClass(annotatedClass);
}
if (haveSchema()) {
try {
executeStatement("CREATE SCHEMA " + schema + " AUTHORIZATION DBA;");
} catch (Exception e) {
}
}
}
示例2: testResourceLocal
public void testResourceLocal() throws Exception {
transactionType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
entityManagerFactory = createEntityManagerFactory();
final Object jpaTestObject = getClass().getClassLoader().loadClass("org.apache.openejb.core.cmp.jpa.JpaTestObject").newInstance();
set(jpaTestObject, "EntityManagerFactory", EntityManagerFactory.class, entityManagerFactory);
set(jpaTestObject, "NonJtaDs", DataSource.class, nonJtaDs);
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
invoke(jpaTestObject, "setUp");
try {
invoke(jpaTestObject, "jpaLifecycle");
} finally {
invoke(jpaTestObject, "tearDown");
}
}
示例3: addingService
@SuppressWarnings("unchecked")
@Override
public Object addingService(ServiceReference reference) {
String unitName = (String)reference.getProperty(JPA_UNIT_NAME);
if (unitName == null) {
return null;
}
BundleContext puContext = reference.getBundle().getBundleContext();
TrackedEmf tracked = new TrackedEmf();
tracked.emf = (EntityManagerFactory)puContext.getService(reference);
tracked.emSupplier = new EMSupplierImpl(unitName, tracked.emf, coordinator);
tracked.emSupplierReg = puContext.registerService(EmSupplier.class, tracked.emSupplier,
getEmSupplierProps(unitName));
EntityManager emProxy = createProxy(tracked.emSupplier);
tracked.emProxyReg = puContext.registerService(EntityManager.class, emProxy,
getEmSupplierProps(unitName));
if (getTransactionType(tracked.emf) == PersistenceUnitTransactionType.RESOURCE_LOCAL) {
JpaTemplate txManager = new ResourceLocalJpaTemplate(tracked.emSupplier, coordinator);
tracked.rlTxManagerReg = puContext.registerService(JpaTemplate.class, txManager,
rlTxManProps(unitName));
} else {
tracked.tmTracker = new TMTracker(puContext, tracked.emSupplier, unitName, coordinator);
tracked.tmTracker.open();
}
return tracked;
}
示例4: getTransactionType
/**
*
* @param emf to get type from
* @return
*/
private PersistenceUnitTransactionType getTransactionType(EntityManagerFactory emf) {
try {
PersistenceUnitTransactionType transactionType = (PersistenceUnitTransactionType) emf.getProperties().get(PersistenceUnitTransactionType.class.getName());
if (transactionType == PersistenceUnitTransactionType.RESOURCE_LOCAL) {
return PersistenceUnitTransactionType.RESOURCE_LOCAL;
}
} catch (Exception e) {
LOG.warn("Error while determining the transaction type. Falling back to JTA.", e);
}
return PersistenceUnitTransactionType.JTA;
}
示例5: getTransactionType
@Override
public PersistenceUnitTransactionType getTransactionType() {
if (this.transactionType != null) {
return this.transactionType;
}
else {
return (this.jtaDataSource != null ?
PersistenceUnitTransactionType.JTA : PersistenceUnitTransactionType.RESOURCE_LOCAL);
}
}
示例6: getTransactionType
@Override
public PersistenceUnitTransactionType getTransactionType() {
if (transactionType != null) {
return transactionType;
} else {
return jtaDataSource != null ? PersistenceUnitTransactionType.JTA : PersistenceUnitTransactionType.RESOURCE_LOCAL;
}
}
示例7: getTransactionType
@Override
public PersistenceUnitTransactionType getTransactionType() {
if (transactionType != null) {
return transactionType;
} else {
return jtaDataSource != null ? PersistenceUnitTransactionType.JTA : PersistenceUnitTransactionType.RESOURCE_LOCAL;
}
}
示例8: getTransactionType
@Override
public PersistenceUnitTransactionType getTransactionType() {
if (persistenceUnitXml.getTransactionType() ==
org.wisdom.framework.jpa.model.PersistenceUnitTransactionType
.RESOURCE_LOCAL) {
return PersistenceUnitTransactionType.RESOURCE_LOCAL;
} else {
return PersistenceUnitTransactionType.JTA;
}
}
示例9: getTransactionType
public PersistenceUnitTransactionType getTransactionType() {
if (this.transactionType != null) {
return this.transactionType;
}
else {
return (this.jtaDataSource != null ?
PersistenceUnitTransactionType.JTA : PersistenceUnitTransactionType.RESOURCE_LOCAL);
}
}
示例10: locatePersistenceUnits
@SuppressWarnings({ "deprecation", "rawtypes" })
public static List<ParsedPersistenceXmlDescriptor> locatePersistenceUnits(
Map integration, MetaConfig metaConfig) {
final PersistenceXmlParserImpl parser = new PersistenceXmlParserImpl(
ClassLoaderServiceExt.fromConfigSettings(integration),
PersistenceUnitTransactionType.RESOURCE_LOCAL);
parser.metaConfig = metaConfig;
return parser.doResolve(integration);
}
示例11: parseTransactionType
private static PersistenceUnitTransactionType parseTransactionType(
String value) {
if (StringHelper.isEmpty(value)) {
return null;
} else if (value.equalsIgnoreCase("JTA")) {
return PersistenceUnitTransactionType.JTA;
} else if (value.equalsIgnoreCase("RESOURCE_LOCAL")) {
return PersistenceUnitTransactionType.RESOURCE_LOCAL;
} else {
throw new PersistenceException(
"Unknown persistence unit transaction type : " + value);
}
}
示例12: isResourceLocalInternal
/**
* @param em
* @return
*/
private boolean isResourceLocalInternal(EntityManager em) {
PersistenceUnitTransactionType transactionType = (PersistenceUnitTransactionType)em.getProperties()
.get(PersistenceUnitTransactionType.class.getName());
return transactionType == PersistenceUnitTransactionType.RESOURCE_LOCAL;
}
示例13: setNonJtaDataSource
public PersistenceUnitInfoImpl setNonJtaDataSource(DataSource nonJtaDataSource) {
this.nonJtaDataSource = nonJtaDataSource;
this.jtaDataSource = null;
transactionType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
return this;
}
示例14: getTransactionType
@Override
public PersistenceUnitTransactionType getTransactionType() {
// manage by carbon or developer
return PersistenceUnitTransactionType.RESOURCE_LOCAL;
}
示例15: start
@Override
public void start() {
if(null != entityManagerFactory) {
throw new IllegalStateException("Persistence service was already initialized.");
}
final Configuration configuration = new Configuration();
//
// We'll want to map these to settings
//
configuration.setProperty(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, "managed");
configuration.setProperty(AvailableSettings.USE_GET_GENERATED_KEYS, TRUE_STRING);
configuration.setProperty(AvailableSettings.USE_REFLECTION_OPTIMIZER, TRUE_STRING);
configuration.setProperty(AvailableSettings.ORDER_UPDATES, TRUE_STRING);
configuration.setProperty(AvailableSettings.ORDER_INSERTS, TRUE_STRING);
configuration.setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, TRUE_STRING);
configuration.setProperty("jadira.usertype.autoRegisterUserTypes", TRUE_STRING);
configuration.setProperty(AvailableSettings.DIALECT, settings.getDatabaseSettings().getDialectClass());
// turn on and off features based upon log level
if(LOG.isDebugEnabled()) {
configuration.setProperty(AvailableSettings.GENERATE_STATISTICS, TRUE_STRING);
configuration.setProperty(AvailableSettings.SHOW_SQL, TRUE_STRING);
} else {
configuration.setProperty(AvailableSettings.GENERATE_STATISTICS, FALSE_STRING);
configuration.setProperty(AvailableSettings.SHOW_SQL, FALSE_STRING);
}
// add in all the entities
for (final Class<? extends Serializable> entity : settings.getDatabaseSettings().getEntities()) {
LOG.debug("Adding entity: {}", entity.getCanonicalName());
configuration.addAnnotatedClass(entity);
}
final ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings(configuration.getProperties())
// set our connection provider
.addService(ConnectionProvider.class, connectionProvider)
.build();
// create the actual entity manager
this.entityManagerFactory = new EntityManagerFactoryImpl(PersistenceUnitTransactionType.RESOURCE_LOCAL,
false,
null,
configuration,
serviceRegistry,
persistenceUnitName);
}