Search in sources :

Example 1 with BroadleafPersistenceUnitDeclaringClassTransformer

use of org.broadleafcommerce.common.extensibility.jpa.convert.BroadleafPersistenceUnitDeclaringClassTransformer in project BroadleafCommerce by BroadleafCommerce.

the class MergePersistenceUnitManager method addTransformersToPersistenceUnits.

/**
 * Adds all of the configured {@link #classTransformers} to all of the persistence units
 * @return whether or not there was a LoadTimeWeaver registered
 * @throws Exception if there was an undetectable problem during transformer addition
 */
protected boolean addTransformersToPersistenceUnits() throws Exception {
    boolean weaverRegistered = true;
    for (PersistenceUnitInfo pui : mergedPus.values()) {
        if (pui.getProperties().containsKey(AvailableSettings.USE_CLASS_ENHANCER) && "true".equalsIgnoreCase(pui.getProperties().getProperty(AvailableSettings.USE_CLASS_ENHANCER))) {
            pui.addTransformer(new InterceptFieldClassFileTransformer(pui.getManagedClassNames()));
        }
        for (BroadleafClassTransformer transformer : classTransformers) {
            try {
                boolean isTransformerQualified = !(transformer instanceof NullClassTransformer) && (pui.getPersistenceUnitName().equals("blPU") && !(transformer instanceof BroadleafPersistenceUnitDeclaringClassTransformer)) || ((transformer instanceof BroadleafPersistenceUnitDeclaringClassTransformer) && pui.getPersistenceUnitName().equals(((BroadleafPersistenceUnitDeclaringClassTransformer) transformer).getPersistenceUnitName()));
                if (isTransformerQualified) {
                    pui.addTransformer(transformer);
                }
            } catch (Exception e) {
                weaverRegistered = handleClassTransformerRegistrationProblem(transformer, e);
            }
        }
    }
    weaverRegistered = addNamedQueriesToPersistenceUnits(weaverRegistered);
    return weaverRegistered;
}
Also used : BroadleafClassTransformer(org.broadleafcommerce.common.extensibility.jpa.convert.BroadleafClassTransformer) NullClassTransformer(org.broadleafcommerce.common.extensibility.jpa.copy.NullClassTransformer) BroadleafPersistenceUnitDeclaringClassTransformer(org.broadleafcommerce.common.extensibility.jpa.convert.BroadleafPersistenceUnitDeclaringClassTransformer) InterceptFieldClassFileTransformer(org.hibernate.ejb.instrument.InterceptFieldClassFileTransformer) MutablePersistenceUnitInfo(org.springframework.orm.jpa.persistenceunit.MutablePersistenceUnitInfo) PersistenceUnitInfo(javax.persistence.spi.PersistenceUnitInfo)

Aggregations

PersistenceUnitInfo (javax.persistence.spi.PersistenceUnitInfo)1 BroadleafClassTransformer (org.broadleafcommerce.common.extensibility.jpa.convert.BroadleafClassTransformer)1 BroadleafPersistenceUnitDeclaringClassTransformer (org.broadleafcommerce.common.extensibility.jpa.convert.BroadleafPersistenceUnitDeclaringClassTransformer)1 NullClassTransformer (org.broadleafcommerce.common.extensibility.jpa.copy.NullClassTransformer)1 InterceptFieldClassFileTransformer (org.hibernate.ejb.instrument.InterceptFieldClassFileTransformer)1 MutablePersistenceUnitInfo (org.springframework.orm.jpa.persistenceunit.MutablePersistenceUnitInfo)1