Search in sources :

Example 1 with AuditStrategy

use of org.hibernate.envers.strategy.AuditStrategy in project hibernate-orm by hibernate.

the class EnversServiceImpl method initializeAuditStrategy.

private static AuditStrategy initializeAuditStrategy(String auditStrategyName, Class<?> revisionInfoClass, PropertyData revisionInfoTimestampData, ServiceRegistry serviceRegistry) {
    AuditStrategy strategy;
    try {
        final Class<?> auditStrategyClass = loadClass(auditStrategyName, serviceRegistry);
        strategy = (AuditStrategy) ReflectHelper.getDefaultConstructor(auditStrategyClass).newInstance();
    } catch (Exception e) {
        throw new MappingException(String.format("Unable to create AuditStrategy [%s] instance.", auditStrategyName), e);
    }
    if (strategy instanceof ValidityAuditStrategy) {
        // further initialization required
        final Getter revisionTimestampGetter = ReflectionTools.getGetter(revisionInfoClass, revisionInfoTimestampData, serviceRegistry);
        ((ValidityAuditStrategy) strategy).setRevisionTimestampGetter(revisionTimestampGetter);
    }
    return strategy;
}
Also used : Getter(org.hibernate.property.access.spi.Getter) AuditStrategy(org.hibernate.envers.strategy.AuditStrategy) ValidityAuditStrategy(org.hibernate.envers.strategy.ValidityAuditStrategy) ValidityAuditStrategy(org.hibernate.envers.strategy.ValidityAuditStrategy) MappingException(org.hibernate.MappingException) MappingException(org.hibernate.MappingException)

Aggregations

MappingException (org.hibernate.MappingException)1 AuditStrategy (org.hibernate.envers.strategy.AuditStrategy)1 ValidityAuditStrategy (org.hibernate.envers.strategy.ValidityAuditStrategy)1 Getter (org.hibernate.property.access.spi.Getter)1