use of org.eclipse.persistence.internal.jpa.weaving.PersistenceWeaver in project eclipselink by eclipse-ee4j.
the class EntityManagerSetupImpl method predeployCompositeMembers.
protected void predeployCompositeMembers(Map predeployProperties, ClassLoader tempClassLoader) {
// get all puInfos found in jar-files specified in composite's persistence.xml
// all these puInfos are not composite because composites are recursively "taken apart", too.
Set<SEPersistenceUnitInfo> compositeMemberPuInfos = getCompositeMemberPuInfoSet(persistenceUnitInfo, predeployProperties);
// makes sure each member has a non-null property, overrides where required properties with composite's predeploy properties.
updateCompositeMembersProperties(compositeMemberPuInfos, predeployProperties);
// Don't log these properties - may contain passwords. The properties will be logged by contained persistence units.
Map compositeMemberMapOfProperties = (Map) getConfigProperty(PersistenceUnitProperties.COMPOSITE_UNIT_PROPERTIES, predeployProperties);
this.compositeMemberEmSetupImpls = new HashSet<>(compositeMemberPuInfos.size());
this.processor = new MetadataProcessor();
if (enableWeaving) {
this.weaver = new PersistenceWeaver(new HashMap<String, ClassDetails>());
}
// all composite members should complete a stage before any of them can move to the next one.
for (SEPersistenceUnitInfo compositeMemberPuInfo : compositeMemberPuInfos) {
// set composite's temporary classloader
compositeMemberPuInfo.setNewTempClassLoader(tempClassLoader);
String containedPuName = compositeMemberPuInfo.getPersistenceUnitName();
EntityManagerSetupImpl containedEmSetupImpl = new EntityManagerSetupImpl(containedPuName, containedPuName);
// set composite
containedEmSetupImpl.setCompositeEmSetupImpl(this);
// non-null only in case predeploy is used for static weaving
containedEmSetupImpl.setStaticWeaveInfo(this.staticWeaveInfo);
// the properties guaranteed to be non-null after updateCompositeMemberProperties call
Map compositeMemberProperties = (Map) compositeMemberMapOfProperties.get(containedPuName);
containedEmSetupImpl.predeploy(compositeMemberPuInfo, compositeMemberProperties);
// reset temporary classloader back to the original
compositeMemberPuInfo.setNewTempClassLoader(compositeMemberPuInfo.getClassLoader());
this.compositeMemberEmSetupImpls.add(containedEmSetupImpl);
}
// mode = COMPOSITE_MEMBER_MIDDLE mode
for (EntityManagerSetupImpl containedEmSetupImpl : this.compositeMemberEmSetupImpls) {
// properties not used, puInfo already set
containedEmSetupImpl.predeploy(null, null);
}
// mode = COMPOSITE_MEMBER_FINAL mode
for (EntityManagerSetupImpl containedEmSetupImpl : this.compositeMemberEmSetupImpls) {
// properties not used, puInfo already set
PersistenceWeaver containedWeaver = (PersistenceWeaver) containedEmSetupImpl.predeploy(null, null);
// if both composite and composite member weavings enabled copy class details from member's weaver to composite's one.
if (enableWeaving && containedWeaver != null) {
this.weaver.getClassDetailsMap().putAll(containedWeaver.getClassDetailsMap());
}
}
if (enableWeaving && this.weaver.getClassDetailsMap().isEmpty()) {
this.weaver = null;
}
}
use of org.eclipse.persistence.internal.jpa.weaving.PersistenceWeaver in project eclipselink by eclipse-ee4j.
the class SimpleWeaverTestSuite method buildWeaver.
public PersistenceWeaver buildWeaver(Session session, Collection entities) {
PersistenceWeaver tw = null;
try {
tw = TransformerFactory.createTransformerAndModifyProject(session, entities, Thread.currentThread().getContextClassLoader(), true, false, true, true, true, false);
} catch (Exception e) {
fail(getName() + " failed: " + e.toString());
}
assertNotNull("could not build TopLinkWeaver", tw);
return tw;
}
Aggregations