private void setClassLoaderTransformer(DeploymentUnit deploymentUnit) {
// (AS7-2233) each persistence unit can use a persistence provider, that might need
// to use ClassTransformers. Providers that need class transformers will add them
// during the call to CreateContainerEntityManagerFactory.
DelegatingClassFileTransformer transformer = deploymentUnit.getAttachment(DelegatingClassFileTransformer.ATTACHMENT_KEY);
if ( transformer != null) {
for (ResourceRoot resourceRoot : DeploymentUtils.allResourceRoots(deploymentUnit)) {
PersistenceUnitMetadataHolder holder = resourceRoot.getAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS);
if (holder != null) {
for (PersistenceUnitMetadata pu : holder.getPersistenceUnits()) {
if (Configuration.needClassFileTransformer(pu)) {
transformer.addTransformer(new JPADelegatingClassFileTransformer(pu));
}
}
}
}
}