private void generateRegion(Region root) throws SAXException { if (this.version.compareTo(CacheXmlVersion.VERSION_5_0) >= 0) { generate(root, REGION); } else { generate(root, VM_ROOT_REGION); } }
/** * Writes the generator's state to pw */ private void generate(PrintWriter pw) { // Use JAXP's transformation API to turn SAX events into pretty // XML text try { Source src = new SAXSource(this, new InputSource()); Result res = new StreamResult(pw); TransformerFactory xFactory = TransformerFactory.newInstance(); Transformer xform = xFactory.newTransformer(); xform.setOutputProperty(OutputKeys.METHOD, "xml"); xform.setOutputProperty(OutputKeys.INDENT, "yes"); if (!useSchema) { // set the doctype system and public ids from version for older DTDs. xform.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, version.getSystemId()); xform.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, version.getPublicId()); } xform.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); xform.transform(src, res); pw.flush(); } catch (Exception ex) { RuntimeException ex2 = new RuntimeException(LocalizedStrings.CacheXmlGenerator_AN_EXCEPTION_WAS_THROWN_WHILE_GENERATING_XML.toLocalizedString()); ex2.initCause(ex); throw ex2; } }
version = CacheXmlVersion.valueForVersion(VERSION_LATEST); // we won't know the version, so assume the latest return resolveEntityByEntityResolvers(name, publicId, baseURI, systemId);
if (null == version.getSchemaLocation()) { throw new IllegalStateException("No schema for version " + version.getVersion()); addAttribute(atts, W3C_XML_SCHEMA_INSTANCE_PREFIX, W3C_XML_SCHEMA_INSTANCE_ATTRIBUTE_SCHEMA_LOCATION, NAMESPACE + " " + version.getSchemaLocation()); addAttribute(atts, VERSION, this.version.getVersion()); if (this.version.compareTo(CacheXmlVersion.VERSION_5_5) >= 0) { if (this.version.compareTo(CacheXmlVersion.VERSION_5_7) >= 0) { if (this.version.compareTo(CacheXmlVersion.VERSION_5_8) >= 0) { if (this.version.compareTo(CacheXmlVersion.VERSION_6_0) >= 0) { if (this.version.compareTo(CacheXmlVersion.VERSION_6_5) >= 0) { if (this.version.compareTo(CacheXmlVersion.VERSION_7_0) >= 0) { if (this.version.compareTo(CacheXmlVersion.VERSION_7_0) >= 0) { if (this.version.compareTo(CacheXmlVersion.VERSION_5_1) >= 0) { if (creation.hasMessageSyncInterval()) { atts.addAttribute("", "", MESSAGE_SYNC_INTERVAL, "", String if (this.version.compareTo(CacheXmlVersion.VERSION_4_0) >= 0) { if (creation.hasServer()) { atts.addAttribute("", "", IS_SERVER, "",
/** * Generates XML for the client-subscription tag * @param bridge instance of <code>CacheServer</code> * * @since 5.7 */ private void generateClientHaQueue(CacheServer bridge) throws SAXException { AttributesImpl atts = new AttributesImpl(); ClientSubscriptionConfigImpl csc = (ClientSubscriptionConfigImpl)bridge.getClientSubscriptionConfig(); try { atts.addAttribute("", "", CLIENT_SUBSCRIPTION_EVICTION_POLICY, "", csc.getEvictionPolicy()); atts.addAttribute("", "", CLIENT_SUBSCRIPTION_CAPACITY, "", String.valueOf(csc.getCapacity())); if (this.version.compareTo(CacheXmlVersion.VERSION_6_5) >= 0) { String dsVal = csc.getDiskStoreName(); if (dsVal != null) { atts.addAttribute("", "", DISK_STORE_NAME, "", dsVal); } } if (csc.getDiskStoreName() == null && csc.hasOverflowDirectory()) { atts.addAttribute("", "", OVERFLOW_DIRECTORY, "", csc.getOverflowDirectory()); } handler.startElement("", CLIENT_SUBSCRIPTION, CLIENT_SUBSCRIPTION, atts); handler.endElement("", CLIENT_SUBSCRIPTION, CLIENT_SUBSCRIPTION); } catch (Exception ex) { ex.printStackTrace(); } }
/** * Creates a generator for a default cache. */ private CacheXmlGenerator() { this.cache = null; this.useSchema = true; this.version = CacheXmlVersion.valueForVersion(VERSION_LATEST); this.generateDefaults = true; this.creation = new CacheCreation(); creation.setLockLease(GemFireCacheImpl.DEFAULT_LOCK_LEASE); creation.setLockTimeout(GemFireCacheImpl.DEFAULT_LOCK_TIMEOUT); creation.setSearchTimeout(GemFireCacheImpl.DEFAULT_SEARCH_TIMEOUT); // No cache proxy creation.setIsServer(false); creation.setCopyOnRead(GemFireCacheImpl.DEFAULT_COPY_ON_READ); }
if (this.version.compareTo(CacheXmlVersion.VERSION_4_1) < 0) { return;
/** * Creates a new <code>CacheXmlGenerator</code> that generates XML * for a given <code>ClientCache</code>. */ private CacheXmlGenerator(ClientCache cache, boolean useSchema, String version, boolean includeKeysValues) { this.cache = (Cache)cache; this.useSchema = useSchema; this.version = CacheXmlVersion.valueForVersion(version); this.includeKeysValues = includeKeysValues; this.generateDefaults = true; if (cache instanceof ClientCacheCreation) { this.creation = (ClientCacheCreation) cache; this.creation.startingGenerate(); } else { this.creation = new ClientCacheCreation(); if (generateDefaults() || cache.getCopyOnRead()) { this.creation.setCopyOnRead(cache.getCopyOnRead()); } } } /**
handler.startElement("", LRU_HEAP_PERCENTAGE, LRU_HEAP_PERCENTAGE, atts); if (this.version.compareTo(CacheXmlVersion.VERSION_6_0) >= 0) { ObjectSizer os = ea.getObjectSizer(); if (!(os instanceof SizeClassOnceObjectSizer)) {
this.cache = cache; this.useSchema = useSchema; this.version = CacheXmlVersion.valueForVersion(version); this.includeKeysValues = includeKeysValues; this.generateDefaults = generateDefaults;
if (this.version.compareTo(CacheXmlVersion.VERSION_4_0) < 0) { return; if (this.version.compareTo(CacheXmlVersion.VERSION_4_1) < 0) { return; if (this.version.compareTo(CacheXmlVersion.VERSION_5_0) < 0) { return; if (this.version.compareTo(CacheXmlVersion.VERSION_5_1) < 0) { return; if (this.version.compareTo(CacheXmlVersion.VERSION_5_7) < 0) { return; if (this.version.compareTo(CacheXmlVersion.VERSION_8_0) < 0) { return; if (this.version.compareTo(CacheXmlVersion.VERSION_5_7) >= 0) { handler.startElement("", CACHE_SERVER, CACHE_SERVER, atts); } else { if (this.version.compareTo(CacheXmlVersion.VERSION_5_7) >= 0) { String[] groups = bridge.getGroups(); if (groups.length > 0) { if (this.version.compareTo(CacheXmlVersion.VERSION_5_7) >= 0) { handler.endElement("", "", CACHE_SERVER); } else {
/** * Generates XML for a CacheTransactionManager * * @since 4.0 */ private void generate(CacheTransactionManager txMgr) throws SAXException { if (this.version.compareTo(CacheXmlVersion.VERSION_4_0) < 0) { return; } if (txMgr == null) { return; } if (!generateDefaults() && txMgr.getWriter() == null && txMgr.getListeners().length == 0) { return; } handler.startElement("", TRANSACTION_MANAGER, TRANSACTION_MANAGER, EMPTY); { TransactionListener[] listeners = txMgr.getListeners(); for (int i=0; i < listeners.length; i++) { generate(TRANSACTION_LISTENER, listeners[i]); } if(txMgr.getWriter()!=null) { generate(TRANSACTION_WRITER, txMgr.getWriter()); } } handler.endElement("", TRANSACTION_MANAGER, TRANSACTION_MANAGER); }
/** * 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); }
if (this.version.compareTo(CacheXmlVersion.VERSION_5_1) >= 0) { if (generateDefaults() || pa.getLocalMaxMemory() != ((PartitionAttributesImpl) pa).getLocalMaxMemoryDefault()) atts.addAttribute("", "", LOCAL_MAX_MEMORY, "", if (this.version.compareTo(CacheXmlVersion.VERSION_5_8) >= 0) { if(pa.getColocatedWith() != null) atts.addAttribute("", "", PARTITION_COLOCATED_WITH, "", if (this.version.compareTo(CacheXmlVersion.VERSION_6_0) >= 0) { if (generateDefaults() || pa.getRecoveryDelay() != PartitionAttributesFactory.RECOVERY_DELAY_DEFAULT) atts.addAttribute("", "", RECOVERY_DELAY, "", if (this.version.compareTo(CacheXmlVersion.VERSION_5_8) >= 0) { PartitionResolver rr = pa.getPartitionResolver(); if (rr != null) { if (this.version.compareTo(CacheXmlVersion.VERSION_6_1) >= 0) { PartitionListener[] listeners = pa.getPartitionListeners(); for (int i = 0; i < listeners.length; i++) { if (this.version.compareTo(CacheXmlVersion.VERSION_6_6) >= 0) { List<FixedPartitionAttributes> staticAttrs = pa .getFixedPartitionAttributes(); if (this.version.compareTo(CacheXmlVersion.VERSION_5_1) < 0) { Properties p = pa.getLocalProperties(); generate(p, LOCAL_PROPERTIES);
if (this.version.compareTo(CacheXmlVersion.VERSION_5_7) < 0) { return; String.valueOf(cp.getThreadLocalConnections())); if (this.version.compareTo(CacheXmlVersion.VERSION_6_1) > 0) { if (generateDefaults() || cp.getPRSingleHopEnabled() != PoolFactory.DEFAULT_PR_SINGLE_HOP_ENABLED) atts.addAttribute("", "", PR_SINGLE_HOP_ENABLED, "", if (this.version.compareTo(CacheXmlVersion.VERSION_6_1) > 0) { if (generateDefaults() || cp.getMultiuserAuthentication() != PoolFactory.DEFAULT_MULTIUSER_AUTHENTICATION) atts.addAttribute("", "", MULTIUSER_SECURE_MODE_ENABLED, "", String.valueOf(cp
String.valueOf(receiver.getSocketBufferSize())); if (this.version.compareTo(CacheXmlVersion.VERSION_8_0) < 0) { return;
if (this.version.compareTo(CacheXmlVersion.VERSION_5_0) >= 0) { if (this.version.compareTo(CacheXmlVersion.VERSION_5_7) >= 0) { dpString = PERSISTENT_PARTITION_DP; } else if (dp.isPartition()) { if (this.version.compareTo(CacheXmlVersion.VERSION_5_1) >= 0) { dpString = PARTITION_DP; if (this.version.compareTo(CacheXmlVersion.VERSION_7_0) >= 0) { if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasConcurrencyChecksEnabled())) { if (this.version.compareTo(CacheXmlVersion.VERSION_4_0) >= 0) { if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasIsLockGrantor())) { if (this.version.compareTo(CacheXmlVersion.VERSION_5_7) >= 0) { if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasPoolName())) { if (this.version.compareTo(CacheXmlVersion.VERSION_6_5) >= 0) { if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasDiskStoreName())) { if(this.version.compareTo(CacheXmlVersion.VERSION_6_1) >= 0) if ((!(attrs instanceof RegionAttributesCreation)|| ((RegionAttributesCreation) attrs).hasCloningEnabled())) {