Search in sources :

Example 1 with RegionCreateOperationContext

use of org.apache.geode.cache.operations.RegionCreateOperationContext in project geode by apache.

the class CacheClientProxy method getOperationContext.

private OperationContext getOperationContext(ClientMessage cmsg, String[] regionNameHolder) {
    ClientUpdateMessageImpl cmsgimpl = (ClientUpdateMessageImpl) cmsg;
    OperationContext opctxt = null;
    // TODO SW: Special handling for DynamicRegions; this should be reworked
    // when DynamicRegion API is deprecated
    String regionName = cmsgimpl.getRegionName();
    regionNameHolder[0] = regionName;
    if (cmsgimpl.isCreate()) {
        if (DynamicRegionFactory.regionIsDynamicRegionList(regionName)) {
            regionNameHolder[0] = (String) cmsgimpl.getKeyOfInterest();
            opctxt = new RegionCreateOperationContext(true);
        } else {
            PutOperationContext tmp = new PutOperationContext(cmsgimpl.getKeyOfInterest(), cmsgimpl.getValue(), cmsgimpl.valueIsObject(), PutOperationContext.CREATE, true);
            tmp.setCallbackArg(cmsgimpl.getCallbackArgument());
            opctxt = tmp;
        }
    } else if (cmsgimpl.isUpdate()) {
        if (DynamicRegionFactory.regionIsDynamicRegionList(regionName)) {
            regionNameHolder[0] = (String) cmsgimpl.getKeyOfInterest();
            opctxt = new RegionCreateOperationContext(true);
        } else {
            PutOperationContext tmp = new PutOperationContext(cmsgimpl.getKeyOfInterest(), cmsgimpl.getValue(), cmsgimpl.valueIsObject(), PutOperationContext.UPDATE, true);
            tmp.setCallbackArg(cmsgimpl.getCallbackArgument());
            opctxt = tmp;
        }
    } else if (cmsgimpl.isDestroy()) {
        if (DynamicRegionFactory.regionIsDynamicRegionList(regionName)) {
            regionNameHolder[0] = (String) cmsgimpl.getKeyOfInterest();
            opctxt = new RegionDestroyOperationContext(true);
        } else {
            DestroyOperationContext tmp = new DestroyOperationContext(cmsgimpl.getKeyOfInterest(), true);
            tmp.setCallbackArg(cmsgimpl.getCallbackArgument());
            opctxt = tmp;
        }
    } else if (cmsgimpl.isDestroyRegion()) {
        opctxt = new RegionDestroyOperationContext(true);
    } else if (cmsgimpl.isInvalidate()) {
        InvalidateOperationContext tmp = new InvalidateOperationContext(cmsgimpl.getKeyOfInterest(), true);
        tmp.setCallbackArg(cmsgimpl.getCallbackArgument());
        opctxt = tmp;
    } else if (cmsgimpl.isClearRegion()) {
        RegionClearOperationContext tmp = new RegionClearOperationContext(true);
        tmp.setCallbackArg(cmsgimpl.getCallbackArgument());
        opctxt = tmp;
    }
    return opctxt;
}
Also used : RegionCreateOperationContext(org.apache.geode.cache.operations.RegionCreateOperationContext) DestroyOperationContext(org.apache.geode.cache.operations.DestroyOperationContext) PutOperationContext(org.apache.geode.cache.operations.PutOperationContext) InvalidateOperationContext(org.apache.geode.cache.operations.InvalidateOperationContext) RegionClearOperationContext(org.apache.geode.cache.operations.RegionClearOperationContext) RegionDestroyOperationContext(org.apache.geode.cache.operations.RegionDestroyOperationContext) OperationContext(org.apache.geode.cache.operations.OperationContext) InvalidateOperationContext(org.apache.geode.cache.operations.InvalidateOperationContext) RegionCreateOperationContext(org.apache.geode.cache.operations.RegionCreateOperationContext) RegionDestroyOperationContext(org.apache.geode.cache.operations.RegionDestroyOperationContext) PutOperationContext(org.apache.geode.cache.operations.PutOperationContext) RegionClearOperationContext(org.apache.geode.cache.operations.RegionClearOperationContext) DestroyOperationContext(org.apache.geode.cache.operations.DestroyOperationContext) RegionDestroyOperationContext(org.apache.geode.cache.operations.RegionDestroyOperationContext)

Aggregations

DestroyOperationContext (org.apache.geode.cache.operations.DestroyOperationContext)1 InvalidateOperationContext (org.apache.geode.cache.operations.InvalidateOperationContext)1 OperationContext (org.apache.geode.cache.operations.OperationContext)1 PutOperationContext (org.apache.geode.cache.operations.PutOperationContext)1 RegionClearOperationContext (org.apache.geode.cache.operations.RegionClearOperationContext)1 RegionCreateOperationContext (org.apache.geode.cache.operations.RegionCreateOperationContext)1 RegionDestroyOperationContext (org.apache.geode.cache.operations.RegionDestroyOperationContext)1