Search in sources :

Example 1 with PropertySetCallback

use of org.apache.derby.iapi.services.property.PropertySetCallback in project derby by apache.

the class PropertyValidation method doMap.

/**
 *	  Call the property set callbacks to map a proposed property value
 *	  to a value to save.
 *	  <P>
 *	  The caller must run this in a block synchronized on this
 *	  to serialize validations with changes to the set of
 *	  property callbacks
 */
public Serializable doMap(String key, Serializable value, Dictionary set) throws StandardException {
    Serializable mappedValue = null;
    if (notifyOnSet != null) {
        for (int i = 0; i < notifyOnSet.size() && mappedValue == null; i++) {
            PropertySetCallback psc = notifyOnSet.get(i);
            mappedValue = psc.map(key, value, set);
        }
    }
    if (mappedValue == null)
        return value;
    else
        return mappedValue;
}
Also used : Serializable(java.io.Serializable) PropertySetCallback(org.apache.derby.iapi.services.property.PropertySetCallback)

Example 2 with PropertySetCallback

use of org.apache.derby.iapi.services.property.PropertySetCallback in project derby by apache.

the class PropertyValidation method doValidateApplyAndMap.

public Serializable doValidateApplyAndMap(TransactionController tc, String key, Serializable value, Dictionary d, boolean dbOnlyProperty) throws StandardException {
    Serializable mappedValue = null;
    if (notifyOnSet != null) {
        synchronized (this) {
            for (int i = 0; i < notifyOnSet.size(); i++) {
                PropertySetCallback psc = notifyOnSet.get(i);
                if (!psc.validate(key, value, d))
                    continue;
                if (mappedValue == null)
                    mappedValue = psc.map(key, value, d);
                if (!dbOnlyProperty && key.startsWith("derby.")) {
                    if (PropertyUtil.whereSet(key, d) == PropertyUtil.SET_IN_JVM)
                        continue;
                }
                Serviceable s;
                if ((s = psc.apply(key, value, d)) != null)
                    ((TransactionManager) tc).addPostCommitWork(s);
            }
        }
    }
    return mappedValue;
}
Also used : Serviceable(org.apache.derby.iapi.services.daemon.Serviceable) Serializable(java.io.Serializable) PropertySetCallback(org.apache.derby.iapi.services.property.PropertySetCallback)

Example 3 with PropertySetCallback

use of org.apache.derby.iapi.services.property.PropertySetCallback in project derby by apache.

the class PropertyValidation method validateSingleProperty.

public void validateSingleProperty(String key, Serializable value, Dictionary set) throws StandardException {
    // RESOLVE: log device cannot be changed on the fly right now
    if (key.equals(Attribute.LOG_DEVICE)) {
        throw StandardException.newException(SQLState.RAWSTORE_CANNOT_CHANGE_LOGDEVICE);
    }
    if (notifyOnSet != null) {
        for (int i = 0; i < notifyOnSet.size(); i++) {
            PropertySetCallback psc = notifyOnSet.get(i);
            psc.validate(key, value, set);
        }
    }
}
Also used : PropertySetCallback(org.apache.derby.iapi.services.property.PropertySetCallback)

Aggregations

PropertySetCallback (org.apache.derby.iapi.services.property.PropertySetCallback)3 Serializable (java.io.Serializable)2 Serviceable (org.apache.derby.iapi.services.daemon.Serviceable)1