Search in sources :

Example 6 with PersistenceManager

use of com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager in project Payara by payara.

the class SqlTimestamp method makeDirty.

/**
 * Marks object dirty
 */
public StateManager makeDirty() {
    if (owner != null) {
        StateManager stateManager = owner.jdoGetStateManager();
        if (stateManager != null) {
            PersistenceManager pm = (PersistenceManager) stateManager.getPersistenceManagerInternal();
            pm.acquireShareLock();
            try {
                synchronized (stateManager) {
                    // 
                    if (owner != null) {
                        stateManager.makeDirty(fieldName);
                        return stateManager;
                    }
                }
            } finally {
                pm.releaseShareLock();
            }
        }
    }
    return null;
}
Also used : StateManager(com.sun.jdo.spi.persistence.support.sqlstore.StateManager) PersistenceManager(com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager)

Example 7 with PersistenceManager

use of com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager in project Payara by payara.

the class Date method makeDirty.

/**
 * Marks object dirty
 */
public StateManager makeDirty() {
    if (owner != null) {
        StateManager stateManager = owner.jdoGetStateManager();
        if (stateManager != null) {
            PersistenceManager pm = (PersistenceManager) stateManager.getPersistenceManagerInternal();
            pm.acquireShareLock();
            try {
                synchronized (stateManager) {
                    // 
                    if (owner != null) {
                        stateManager.makeDirty(fieldName);
                        return stateManager;
                    }
                }
            } finally {
                pm.releaseShareLock();
            }
        }
    }
    return null;
}
Also used : StateManager(com.sun.jdo.spi.persistence.support.sqlstore.StateManager) PersistenceManager(com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager)

Example 8 with PersistenceManager

use of com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager in project Payara by payara.

the class HashSet method removeAll.

/**
 * Removes from this collection all of its elements that are contained in
 * the specified collection (optional operation). <p>
 *
 * @param c elements to be removed from this collection.
 * @return <tt>true</tt> if this collection changed as a result of the
 * call.
 *
 * @throws    UnsupportedOperationException removeAll is not supported
 *            by this collection.
 *
 * @see java.util.HashSet
 * @see java.util.AbstractCollection
 */
public boolean removeAll(Collection c) {
    if (owner != null) {
        StateManager stateManager = owner.jdoGetStateManager();
        if (stateManager != null) {
            PersistenceManager pm = (PersistenceManager) stateManager.getPersistenceManagerInternal();
            pm.acquireShareLock();
            try {
                pm.acquireFieldUpdateLock();
                try {
                    stateManager.makeDirty(fieldName);
                    for (Iterator iter = c.iterator(); iter.hasNext(); ) {
                        Object o = iter.next();
                        if (super.contains(o)) {
                            if (added.remove(o) == false) {
                                removed.add(o);
                            }
                        }
                    }
                    boolean modified = super.removeAll(c);
                    // Apply updates
                    if (modified) {
                        stateManager.applyUpdates(fieldName, this);
                    }
                    return modified;
                } finally {
                    pm.releaseFieldUpdateLock();
                }
            } finally {
                pm.releaseShareLock();
            }
        }
    }
    return super.removeAll(c);
}
Also used : StateManager(com.sun.jdo.spi.persistence.support.sqlstore.StateManager) PersistenceManager(com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager) Iterator(java.util.Iterator)

Example 9 with PersistenceManager

use of com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager in project Payara by payara.

the class HashSet method addAll.

/**
 * Adds all of the elements in the specified collection to this collection
 *
 * @param c collection whose elements are to be added to this collection.
 * @return <tt>true</tt> if this collection changed as a result of the
 * call.
 * @throws UnsupportedOperationException if the <tt>addAll</tt> method is
 *            not supported by this collection.
 *
 * @see java.util.AbstractCollection
 * @see java.util.HashSet
 */
public boolean addAll(Collection c) {
    if (allowNulls == false && c.contains(null)) {
        throw new JDOUserException(I18NHelper.getMessage(messages, // NOI18N
        "sco.nulls_not_allowed"));
    }
    ArrayList errc = new ArrayList();
    if (elementType != null) {
        // iterate the collection and make a list of wrong elements.
        Iterator i = c.iterator();
        while (i.hasNext()) {
            Object o = i.next();
            if (!elementType.isAssignableFrom(o.getClass()))
                errc.add(o);
        }
    }
    if (errc != null && errc.size() > 0) {
        throw new JDOUserException(I18NHelper.getMessage(messages, "sco.classcastexception", // NOI18N
        elementType.getName()), new ClassCastException(), errc.toArray());
    }
    boolean modified = false;
    if (owner != null) {
        StateManager stateManager = owner.jdoGetStateManager();
        if (stateManager != null) {
            PersistenceManager pm = (PersistenceManager) stateManager.getPersistenceManagerInternal();
            pm.acquireShareLock();
            try {
                pm.acquireFieldUpdateLock();
                try {
                    // Mark the field as dirty
                    stateManager.makeDirty(fieldName);
                    for (Iterator iter = c.iterator(); iter.hasNext(); ) {
                        Object o = iter.next();
                        if (!super.contains(o)) {
                            if (removed.remove(o) == false) {
                                added.add(o);
                            }
                            super.add(o);
                            modified = true;
                        }
                    }
                    // Apply updates
                    if (modified) {
                        stateManager.applyUpdates(fieldName, this);
                    }
                    return modified;
                } finally {
                    pm.releaseFieldUpdateLock();
                }
            } catch (JDOUserException e) {
                Object[] failedObjects = e.getFailedObjectArray();
                if (modified && (failedObjects != null)) {
                    for (int i = 0; i < failedObjects.length; i++) {
                        super.remove(failedObjects[i]);
                    }
                }
                throw e;
            } finally {
                pm.releaseShareLock();
            }
        }
    }
    return super.addAll(c);
}
Also used : StateManager(com.sun.jdo.spi.persistence.support.sqlstore.StateManager) PersistenceManager(com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) JDOUserException(com.sun.jdo.api.persistence.support.JDOUserException)

Example 10 with PersistenceManager

use of com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager in project Payara by payara.

the class SqlTime method makeDirty.

/**
 * Marks object dirty
 */
public StateManager makeDirty() {
    if (owner != null) {
        StateManager stateManager = owner.jdoGetStateManager();
        if (stateManager != null) {
            PersistenceManager pm = (PersistenceManager) stateManager.getPersistenceManagerInternal();
            pm.acquireShareLock();
            try {
                synchronized (stateManager) {
                    // 
                    if (owner != null) {
                        stateManager.makeDirty(fieldName);
                        return stateManager;
                    }
                }
            } finally {
                pm.releaseShareLock();
            }
        }
    }
    return null;
}
Also used : StateManager(com.sun.jdo.spi.persistence.support.sqlstore.StateManager) PersistenceManager(com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager)

Aggregations

PersistenceManager (com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager)11 StateManager (com.sun.jdo.spi.persistence.support.sqlstore.StateManager)10 Iterator (java.util.Iterator)4 JDOUserException (com.sun.jdo.api.persistence.support.JDOUserException)2 ArrayList (java.util.ArrayList)1