use of org.apache.tapestry5.internal.jpa.JpaValueEncoder in project tapestry-5 by apache.
the class JpaModule method provideValueEncoders.
@Contribute(ValueEncoderSource.class)
public static void provideValueEncoders(final MappedConfiguration<Class, ValueEncoderFactory> configuration, @Symbol(JpaSymbols.PROVIDE_ENTITY_VALUE_ENCODERS) final boolean provideEncoders, final EntityManagerSource entityManagerSource, final EntityManagerManager entityManagerManager, final TypeCoercer typeCoercer, final PropertyAccess propertyAccess, final LoggerSource loggerSource) {
if (!provideEncoders)
return;
for (final PersistenceUnitInfo info : entityManagerSource.getPersistenceUnitInfos()) {
final EntityManagerFactory emf = entityManagerSource.getEntityManagerFactory(info.getPersistenceUnitName());
final Metamodel metamodel = emf.getMetamodel();
for (final EntityType<?> entity : metamodel.getEntities()) {
final Class<?> javaType = entity.getJavaType();
final ValueEncoderFactory factory = new ValueEncoderFactory() {
@Override
public ValueEncoder create(final Class type) {
return new JpaValueEncoder(entity, entityManagerManager, info.getPersistenceUnitName(), propertyAccess, typeCoercer, loggerSource.getLogger(javaType));
}
};
configuration.add(javaType, factory);
}
}
}
Aggregations