getUnmarshaller().getUnmarshalListener().afterUnmarshal(currentObject, null);
}
}
// HANDLE POST BUILD EVENTS
ClassDescriptor xmlDescriptor = treeObjectBuilder.getDescriptor();
if(xmlDescriptor.hasEventManager()) {
DescriptorEventManager eventManager = xmlDescriptor.getEventManager();
if (null != eventManager && eventManager.hasAnyEventListeners()) {
DescriptorEvent event = new DescriptorEvent(currentObject);
event.setSession(session);
event.setRecord(this);
event.setEventCode(DescriptorEventManager.PostBuildEvent);
eventManager.executeEvent(event);
}
}
} catch (EclipseLinkException e) {
if (null == xmlReader.getErrorHandler()) {
throw e;
} else {
SAXParseException saxParseException = new SAXParseException(null, null, null, 0, 0, e);
xmlReader.getErrorHandler().error(saxParseException);
}
}
// if the object has any primary key fields set, add it to the cache
if (session.isUnitOfWork()) {
ClassDescriptor xmlDescriptor = treeObjectBuilder.getDescriptor();
if(null != xmlDescriptor) {
List primaryKeyFields = xmlDescriptor.getPrimaryKeyFields();
if(null != primaryKeyFields) {
int primaryKeyFieldsSize = primaryKeyFields.size();
if (primaryKeyFieldsSize > 0) {
Object pk = treeObjectBuilder.extractPrimaryKeyFromObject(currentObject, session);
for (int x=0; x<primaryKeyFieldsSize; x++) {
Object value = ((CacheId)pk).getPrimaryKey()[x];
if (null == value) {
XMLField pkField = (XMLField) xmlDescriptor.getPrimaryKeyFields().get(x);
((CacheId)pk).set(x, getUnmarshaller().getXMLContext().getValueByXPath(currentObject, pkField.getXPath(), pkField.getNamespaceResolver(), Object.class));
}
}
CacheKey key = session.getIdentityMapAccessorInstance().acquireDeferredLock(pk, xmlDescriptor.getJavaClass(), xmlDescriptor);
key.setRecord(this);
key.setObject(currentObject);
key.releaseDeferredLock();
}
}