* if trackChanges is true, set the value in the object as if the user was setting it. Allow change tracking to pick up the change.
*/
public void setRealAttributeValueInObject(Object target, Object attributeValue, boolean trackChanges) {
// If the target object is using change tracking, it must be disable first to avoid thinking the value changed.
PropertyChangeListener listener = null;
ChangeTracker trackedObject = null;
if (!trackChanges && target instanceof ChangeTracker) {
trackedObject = (ChangeTracker)target;
listener = trackedObject._persistence_getPropertyChangeListener();
trackedObject._persistence_setPropertyChangeListener(null);
}
Object[] parameters = new Object[1];
parameters[0] = attributeValue;
try {
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
try {
AccessController.doPrivileged(new PrivilegedMethodInvoker(getSetMethod(), target, parameters));
} catch (PrivilegedActionException exception) {
Exception throwableException = exception.getException();
if (throwableException instanceof IllegalAccessException) {
throw DescriptorException.illegalAccessWhileSettingValueThruMethodAccessor(setMethod.getName(), attributeValue, throwableException);
} else {
throw DescriptorException.targetInvocationWhileSettingValueThruMethodAccessor(setMethod.getName(), attributeValue, throwableException);
}
}
} else {
PrivilegedAccessHelper.invokeMethod(getSetMethod(), target, parameters);
}
} catch (IllegalAccessException exception) {
throw DescriptorException.illegalAccessWhileSettingValueThruMethodAccessor(setMethod.getName(), attributeValue, exception);
} catch (IllegalArgumentException exception) {
throw DescriptorException.illegalArgumentWhileSettingValueThruMethodAccessor(setMethod.getName(), attributeValue, exception);
} catch (InvocationTargetException exception) {
throw DescriptorException.targetInvocationWhileSettingValueThruMethodAccessor(setMethod.getName(), attributeValue, exception);
} finally {
if (!trackChanges && trackedObject != null) {
trackedObject._persistence_setPropertyChangeListener(listener);
}
}
}