use of org.apache.tapestry5.jpa.PersistenceUnitConfigurer in project tapestry-5 by apache.
the class AppModule method configurePersistenceUnitInfos.
@Contribute(EntityManagerSource.class)
public static void configurePersistenceUnitInfos(final MappedConfiguration<String, PersistenceUnitConfigurer> configuration) {
final PersistenceUnitConfigurer configurer = new PersistenceUnitConfigurer() {
@Override
public void configure(final TapestryPersistenceUnitInfo unitInfo) {
unitInfo.nonJtaDataSource("jdbc/JPATest").addMappingFileName("mappings.xml").addProperty("eclipselink.ddl-generation", "create-tables").addProperty("eclipselink.logging.level", "fine");
}
};
configuration.add("JndiDataSourcePersistenceUnit", configurer);
}
use of org.apache.tapestry5.jpa.PersistenceUnitConfigurer in project tapestry-5 by apache.
the class EntityManagerSourceImplTest method create.
private EntityManagerSourceImpl create(final String persistenceUnitFile) {
PersistenceUnitConfigurer configurer = new PersistenceUnitConfigurer() {
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void configure(TapestryPersistenceUnitInfo unitInfo) {
Map properties = new HashMap();
properties.put("MYKEY", "MYVALUE");
unitInfo.transactionType(PersistenceUnitTransactionType.RESOURCE_LOCAL).persistenceProviderClassName("org.eclipse.persistence.jpa.PersistenceProvider").excludeUnlistedClasses(true).addProperty("javax.persistence.jdbc.user", "sa").addProperty("javax.persistence.jdbc.driver", "org.h2.Driver").addProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:test").setEntityManagerProperties(properties);
}
};
Map<String, PersistenceUnitConfigurer> configurerMap = CollectionFactory.<String, PersistenceUnitConfigurer>newMap();
configurerMap.put("defaultpropertytest", configurer);
EntityManagerSourceImpl emSource = new EntityManagerSourceImpl(LoggerFactory.getLogger(EntityManagerSourceImplTest.class), new ClasspathResource(persistenceUnitFile), null, configurerMap);
return emSource;
}
use of org.apache.tapestry5.jpa.PersistenceUnitConfigurer in project tapestry-5 by apache.
the class EntityManagerSourceImpl method configure.
private Map<String, PersistenceUnitConfigurer> configure(Map<String, PersistenceUnitConfigurer> configuration, List<TapestryPersistenceUnitInfo> persistenceUnitInfos) {
final Map<String, PersistenceUnitConfigurer> remainingConfigurations = CollectionFactory.newMap(configuration);
for (final TapestryPersistenceUnitInfo info : persistenceUnitInfos) {
final String unitName = info.getPersistenceUnitName();
final PersistenceUnitConfigurer configurer = configuration.get(unitName);
if (configurer != null) {
configurer.configure(info);
remainingConfigurations.remove(unitName);
}
}
return remainingConfigurations;
}
Aggregations