/** * Ending the <code>compressor</code> registration should leave us with a * class name on the stack. Pull it off and setup the {@link Compressor} * on the region attributes. */ private void endCompressor() { Class<?> klass = getClassFromStack(); if(!Compressor.class.isAssignableFrom(klass)) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_COMPRESSOR .toLocalizedString(klass.getName())); } Compressor compressor; try { compressor = (Compressor) klass.newInstance(); } catch (Exception ex) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_WHILE_INSTANTIATING_A_0.toLocalizedString(klass.getName()), ex); } Object a = stack.peek(); if (a instanceof RegionAttributesCreation) { RegionAttributesCreation attrs = (RegionAttributesCreation) a; attrs.setCompressor(compressor); } else { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_MUST_BE_DEFINED_IN_THE_CONTEXT_OF_REGIONATTRIBUTES_OR_1.toLocalizedString(new Object[] {COMPRESSOR, DYNAMIC_REGION_FACTORY})); } }
/** * Ending the <code>compressor</code> registration should leave us with a * class name on the stack. Pull it off and setup the {@link Compressor} * on the region attributes. */ private void endCompressor() { Class<?> klass = getClassFromStack(); if(!Compressor.class.isAssignableFrom(klass)) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_COMPRESSOR .toLocalizedString(klass.getName())); } Compressor compressor; try { compressor = (Compressor) klass.newInstance(); } catch (Exception ex) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_WHILE_INSTANTIATING_A_0.toLocalizedString(klass.getName()), ex); } Object a = stack.peek(); if (a instanceof RegionAttributesCreation) { RegionAttributesCreation attrs = (RegionAttributesCreation) a; attrs.setCompressor(compressor); } else { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_MUST_BE_DEFINED_IN_THE_CONTEXT_OF_REGIONATTRIBUTES_OR_1.toLocalizedString(new Object[] {COMPRESSOR, DYNAMIC_REGION_FACTORY})); } }
@SuppressWarnings("rawtypes") public void testCompressor() { final String regionName = "testCompressor"; final CacheCreation cache = new CacheCreation(); final RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setCompressor(SnappyCompressor.getDefaultInstance()); /* Region regionBefore = */ cache.createRegion(regionName, attrs); testXml(cache); final Cache c = getCache(); assertNotNull(c); final Region regionAfter = c.getRegion(regionName); assertNotNull(regionAfter); assertTrue(SnappyCompressor.getDefaultInstance().equals(regionAfter.getAttributes().getCompressor())); regionAfter.localDestroyRegion(); }
if (parentIsUserSpecified) { if (parentWithHas.hasCompressor()) { setCompressor(parent.getCompressor()); setCompressor(parent.getCompressor());
if (parentIsUserSpecified) { if (parentWithHas.hasCompressor()) { setCompressor(parent.getCompressor()); setCompressor(parent.getCompressor());