public Object run() { try { myPC.jdoReplaceStateManager(thisSM); return null; } catch (SecurityException e) { throw new JDOFatalUserException("EXC_CannotSetStateManager", e); } } });
/** * Utility to update our object to use a different state manager. * @param sm The new state manager. **/ private void replaceStateManager(StateManager sm) { try { myPC.jdoReplaceStateManager(sm); } catch (SecurityException e) { throw new JDOFatalUserException(LOCALISER.msg("StateManager.SecurityProblem"), e); } }
om.clearDirty(sm); om.removeStateManager(sm); pc.jdoReplaceStateManager(null); } else {
om.clearDirty(sm); om.removeStateManager(sm); pc.jdoReplaceStateManager(null); } else {
/** * Method to disconnect any cloned persistence capable objects from their * StateManager. * @param pc The PersistenceCapable object * @return Whether the object was disconnected. **/ private boolean disconnectClone(PersistenceCapable pc) { if (detaching) { return false; } if (pc != myPC) { if (JPOXLogger.JDO.isDebugEnabled()) { JPOXLogger.JDO.debug(LOCALISER.msg("StateManager.DisconnectClone", StringUtils.toJVMIDString(pc), this)); } // Reset jdoFlags in the clone to PersistenceCapable.READ_WRITE_OK // and clear its state manager. pc.jdoReplaceFlags(); pc.jdoReplaceStateManager(null); return true; } else { return false; } }
AbstractClassMetaData acmd = thePM.getMetaDataManager().getMetaDataForClass(pc.getClass(), thePM.getClassLoaderResolver()); StateManager sm = StateManagerFactory.newStateManager(thePM, thePM.getPMFContext().getApiAdapter(), pc, acmd, getObjectId(pc), null); pc.jdoReplaceStateManager(sm); // Assign this StateManager to our detached object sm.retrieveDetachState(sm); String[] loadedFieldNames = sm.getLoadedFieldNames(); pc.jdoReplaceStateManager(null); // Remove the StateManager from our detached object
/** * Method to return the names of all fields that are currently dirty in the * passed detached object. * TODO Try to remove the need for the PM. We currently use it to generate the temporary StateManager * @param obj The PersistenceCapable (detached) * @param pm PersistenceManager to use * @return Names of the fields that are dirty * @throws JDOUserException Thrown if the object is not detached */ public static String[] getDetachedObjectDirtyFields(Object obj, PersistenceManager pm) { if (obj == null) { return null; } if (!isDetached(obj)) { throw new JDOUserException(LOCALISER.msg("PM.ObjectNotDetached")); } // Create a StateManager to give us a means of extracting the detached info PersistenceCapable pc = (PersistenceCapable)obj; org.jpox.PersistenceManager thePM = (org.jpox.PersistenceManager)pm; AbstractClassMetaData acmd = thePM.getMetaDataManager().getMetaDataForClass(pc.getClass(), thePM.getClassLoaderResolver()); StateManager sm = StateManagerFactory.newStateManager(thePM, thePM.getPMFContext().getApiAdapter(), pc, acmd, getObjectId(pc), null); pc.jdoReplaceStateManager(sm); // Assign this StateManager to our detached object sm.retrieveDetachState(sm); String[] dirtyFieldNames = sm.getDirtyFieldNames(); pc.jdoReplaceStateManager(null); // Remove the StateManager from our detached object return dirtyFieldNames; }
pcCopy.jdoReplaceStateManager(null);
pcCopy.jdoReplaceStateManager(this); myPC = pcCopy; disconnectClone(pc);
pc.jdoReplaceStateManager(this); myPC.jdoCopyFields(pc, allFieldNumbers);
detachedPC.jdoReplaceStateManager(smDetachedPC); detachedPC.jdoReplaceStateManager(null);
detachedPC.jdoReplaceStateManager(smDetachedPC); detachedPC.jdoReplaceStateManager(null);