/** * When a <code>region-time-to-live</code> element is finished, the * {@link ExpirationAttributes} are on top of the stack followed by the * {@link RegionAttributesCreation} to which the expiration attributes are * assigned. */ private void endRegionTimeToLive() { ExpirationAttributes expire = (ExpirationAttributes) stack.pop(); RegionAttributesCreation attrs = peekRegionAttributesContext("region-time-to-live"); attrs.setRegionTimeToLive(expire); }
/** * When a <code>disk-write-attributes</code> element is finished, the * {@link DiskWriteAttributes} is on top of the stack followed by the * {@link RegionAttributesCreation} to which the expiration attributes are * assigned. */ private void endDiskWriteAttributes() { DiskWriteAttributes dwa = (DiskWriteAttributes) stack.pop(); RegionAttributesCreation attrs = peekRegionAttributesContext(DISK_WRITE_ATTRIBUTES); attrs.setDiskWriteAttributes(dwa); }
/** * When a <code>region-idle-time</code> element is finished, the * {@link ExpirationAttributes} are on top of the stack followed by the * {@link RegionAttributesCreation} to which the expiration attributes are * assigned. */ private void endRegionIdleTime() { ExpirationAttributes expire = (ExpirationAttributes) stack.pop(); RegionAttributesCreation attrs = peekRegionAttributesContext("region-idle-time"); attrs.setRegionIdleTimeout(expire); }
/** * When a <code>region-idle-time</code> element is finished, the * {@link ExpirationAttributes} are on top of the stack followed by the * {@link RegionAttributesCreation} to which the expiration attributes are * assigned. */ private void endRegionIdleTime() { ExpirationAttributes expire = (ExpirationAttributes) stack.pop(); RegionAttributesCreation attrs = peekRegionAttributesContext("region-idle-time"); attrs.setRegionIdleTimeout(expire); }
/** * When a <code>disk-write-attributes</code> element is finished, the * {@link DiskWriteAttributes} is on top of the stack followed by the * {@link RegionAttributesCreation} to which the expiration attributes are * assigned. */ private void endDiskWriteAttributes() { DiskWriteAttributes dwa = (DiskWriteAttributes) stack.pop(); RegionAttributesCreation attrs = peekRegionAttributesContext(DISK_WRITE_ATTRIBUTES); attrs.setDiskWriteAttributes(dwa); }
/** * When a <code>region-time-to-live</code> element is finished, the * {@link ExpirationAttributes} are on top of the stack followed by the * {@link RegionAttributesCreation} to which the expiration attributes are * assigned. */ private void endRegionTimeToLive() { ExpirationAttributes expire = (ExpirationAttributes) stack.pop(); RegionAttributesCreation attrs = peekRegionAttributesContext("region-time-to-live"); attrs.setRegionTimeToLive(expire); }
/** * When a <code>cache-listener</code> element is finished, the {@link * Parameter}s and class names are popped off the stack. The cache listener is * instantiated and initialized with the parameters, if appropriate. */ private void endCacheListener() { Declarable d = createDeclarable(); if (!(d instanceof CacheListener)) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_CACHELISTENER.toLocalizedString(d.getClass().getName())); } RegionAttributesCreation attrs = peekRegionAttributesContext(CACHE_LISTENER); attrs.addCacheListener((CacheListener) d); }
/** * When a <code>cache-listener</code> element is finished, the {@link * Parameter}s and class names are popped off the stack. The cache listener is * instantiated and initialized with the parameters, if appropriate. */ private void endCacheListener() { Declarable d = createDeclarable(); if (!(d instanceof CacheListener)) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_CACHELISTENER.toLocalizedString(d.getClass().getName())); } RegionAttributesCreation attrs = peekRegionAttributesContext(CACHE_LISTENER); attrs.addCacheListener((CacheListener) d); }
/** * When a <code>value-constraint</code> element is finished, the name of the * class should be on top of the stack. * * @throws CacheXmlException If the value constraint class cannot be loaded */ private void endValueConstraint() { String className = ((StringBuffer) stack.pop()).toString().trim(); Class c; try { c = InternalDataSerializer.getCachedClass(className); } catch (Exception ex) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_COULD_NOT_LOAD_VALUECONSTRAINT_CLASS_0.toLocalizedString(className), ex); } // The region attributes should be on top of the stack RegionAttributesCreation attrs = peekRegionAttributesContext("value-constraint"); attrs.setValueConstraint(c); }
/** * When a <code>value-constraint</code> element is finished, the name of the * class should be on top of the stack. * * @throws CacheXmlException If the value constraint class cannot be loaded */ private void endValueConstraint() { String className = ((StringBuffer) stack.pop()).toString().trim(); Class c; try { c = InternalDataSerializer.getCachedClass(className); } catch (Exception ex) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_COULD_NOT_LOAD_VALUECONSTRAINT_CLASS_0.toLocalizedString(className), ex); } // The region attributes should be on top of the stack RegionAttributesCreation attrs = peekRegionAttributesContext("value-constraint"); attrs.setValueConstraint(c); }
/** * Complete the configuration of a <code>lru-heap-percentage</code> eviction controller. * Check for the declaration of an {@link ObjectSizer}. Assign the attributes to the * enclosed <code>region-attributes</code> */ private void endLRUHeapPercentage() { Object declCheck = stack.peek(); Declarable d = null; if (declCheck instanceof String || declCheck instanceof Parameter) { d = createDeclarable(); if (!(d instanceof ObjectSizer)) { String s = "A " + d.getClass().getName() + " is not an instance of a ObjectSizer"; throw new CacheXmlException(s); } } EvictionAttributesImpl eai = (EvictionAttributesImpl) stack.pop(); if (d != null) { eai.setObjectSizer((ObjectSizer) d); } RegionAttributesCreation regAttrs = peekRegionAttributesContext(LRU_HEAP_PERCENTAGE); regAttrs.setEvictionAttributes(eai); }
/** * When a <code>key-constraint</code> element is finished, the name of the * class should be on top of the stack. * * @throws CacheXmlException If the key constraint class cannot be loaded */ private void endKeyConstraint() { String className = ((StringBuffer) stack.pop()).toString().trim(); Class c; try { c = InternalDataSerializer.getCachedClass(className); } catch (Exception ex) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_COULD_NOT_LOAD_KEYCONSTRAINT_CLASS_0.toLocalizedString(className), ex); } // The region attributes should be on top of the stack RegionAttributesCreation attrs = peekRegionAttributesContext("key-constraint"); attrs.setKeyConstraint(c); }
/** * When a <code>key-constraint</code> element is finished, the name of the * class should be on top of the stack. * * @throws CacheXmlException If the key constraint class cannot be loaded */ private void endKeyConstraint() { String className = ((StringBuffer) stack.pop()).toString().trim(); Class c; try { c = InternalDataSerializer.getCachedClass(className); } catch (Exception ex) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_COULD_NOT_LOAD_KEYCONSTRAINT_CLASS_0.toLocalizedString(className), ex); } // The region attributes should be on top of the stack RegionAttributesCreation attrs = peekRegionAttributesContext("key-constraint"); attrs.setKeyConstraint(c); }
/** * Complete the configuration of a <code>lru-heap-percentage</code> eviction controller. * Check for the declaration of an {@link ObjectSizer}. Assign the attributes to the * enclosed <code>region-attributes</code> */ private void endLRUHeapPercentage() { Object declCheck = stack.peek(); Declarable d = null; if (declCheck instanceof String || declCheck instanceof Parameter) { d = createDeclarable(); if (!(d instanceof ObjectSizer)) { String s = "A " + d.getClass().getName() + " is not an instance of a ObjectSizer"; throw new CacheXmlException(s); } } EvictionAttributesImpl eai = (EvictionAttributesImpl) stack.pop(); if (d != null) { eai.setObjectSizer((ObjectSizer) d); } RegionAttributesCreation regAttrs = peekRegionAttributesContext(LRU_HEAP_PERCENTAGE); regAttrs.setEvictionAttributes(eai); }
/** * @param atts */ private void startLRUEntryCount(Attributes atts) { final String maximum = atts.getValue(MAXIMUM); int max = LRUCapacityController.DEFAULT_MAXIMUM_ENTRIES; if (maximum != null) { max = parseInt(maximum); } final String lruAction = atts.getValue(ACTION); EvictionAction action = EvictionAction.DEFAULT_EVICTION_ACTION; if (lruAction != null) { action = EvictionAction.parseAction(lruAction); } RegionAttributesCreation regAttrs = peekRegionAttributesContext(LRU_ENTRY_COUNT); regAttrs.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(max, action)); }
/** * @param atts */ private void startLRUEntryCount(Attributes atts) { final String maximum = atts.getValue(MAXIMUM); int max = LRUCapacityController.DEFAULT_MAXIMUM_ENTRIES; if (maximum != null) { max = parseInt(maximum); } final String lruAction = atts.getValue(ACTION); EvictionAction action = EvictionAction.DEFAULT_EVICTION_ACTION; if (lruAction != null) { action = EvictionAction.parseAction(lruAction); } RegionAttributesCreation regAttrs = peekRegionAttributesContext(LRU_ENTRY_COUNT); regAttrs.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(max, action)); }
/** * Complete the configuration of a <code>lru-memory-size</code> eviction controller. * Check for the declaration of an {@link ObjectSizer}. Assign the attributes to the * enclose <code>region-attributes</code> */ private void endLRUMemorySize() { Object declCheck = stack.peek(); Declarable d = null; if (declCheck instanceof String || declCheck instanceof Parameter) { d = createDeclarable(); if (!(d instanceof ObjectSizer)) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_OBJECTSIZER.toLocalizedString(d.getClass().getName())); } } EvictionAttributesImpl eai = (EvictionAttributesImpl) stack.pop(); if (d != null) { eai.setObjectSizer((ObjectSizer) d); } RegionAttributesCreation regAttrs = peekRegionAttributesContext(LRU_MEMORY_SIZE); regAttrs.setEvictionAttributes(eai); }
/** * Complete the configuration of a <code>lru-memory-size</code> eviction controller. * Check for the declaration of an {@link ObjectSizer}. Assign the attributes to the * enclose <code>region-attributes</code> */ private void endLRUMemorySize() { Object declCheck = stack.peek(); Declarable d = null; if (declCheck instanceof String || declCheck instanceof Parameter) { d = createDeclarable(); if (!(d instanceof ObjectSizer)) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_OBJECTSIZER.toLocalizedString(d.getClass().getName())); } } EvictionAttributesImpl eai = (EvictionAttributesImpl) stack.pop(); if (d != null) { eai.setObjectSizer((ObjectSizer) d); } RegionAttributesCreation regAttrs = peekRegionAttributesContext(LRU_MEMORY_SIZE); regAttrs.setEvictionAttributes(eai); }
/** * When a <code>partition-attributes</code> element is finished, the * {@link PartitionAttributes} are on top of the stack followed by the * {@link RegionAttributesCreation} to which the partition attributes are * assigned. */ private void endPartitionAttributes() { PartitionAttributesImpl paf = (PartitionAttributesImpl) stack.pop(); paf.validateAttributes(); RegionAttributesCreation rattrs = peekRegionAttributesContext(PARTITION_ATTRIBUTES); // change the 5.0 default data policy (EMPTY) to the current default if (rattrs.hasDataPolicy() && rattrs.getDataPolicy() == DataPolicy.EMPTY && (this.version.compareTo(VERSION_5_0) == 0)) { rattrs.setDataPolicy(PartitionedRegionHelper.DEFAULT_DATA_POLICY); } rattrs.setPartitionAttributes(paf); }
/** * When a <code>partition-attributes</code> element is finished, the * {@link PartitionAttributes} are on top of the stack followed by the * {@link RegionAttributesCreation} to which the partition attributes are * assigned. */ private void endPartitionAttributes() { PartitionAttributesImpl paf = (PartitionAttributesImpl) stack.pop(); paf.validateAttributes(); RegionAttributesCreation rattrs = peekRegionAttributesContext(PARTITION_ATTRIBUTES); // change the 5.0 default data policy (EMPTY) to the current default if (rattrs.hasDataPolicy() && rattrs.getDataPolicy().isEmpty() && (this.version.compareTo(CacheXmlVersion.VERSION_5_0) == 0)) { rattrs.setDataPolicy(PartitionedRegionHelper.DEFAULT_DATA_POLICY); } rattrs.setPartitionAttributes(paf); }