/** * Creates and initializes an instance of {@link Declarable} from the contents of the stack. * * @throws CacheXmlException Something goes wrong while instantiating or initializing the * declarable */ private Declarable createDeclarable() { return createDeclarable(cache, stack); }
/** * When we have finished a <code>declarable</code>, instantiate an instance of the * {@link Declarable}and push it on the stack. */ private void endDeclarable() { Declarable d = createDeclarable(); stack.push(d); }
private void endCustomExpiry() { Declarable d = createDeclarable(); if (!(d instanceof CustomExpiry)) { throw new CacheXmlException( String.format("A %s is not an instance of CustomExpiry", d.getClass().getName())); } stack.push(d); }
/** * When a <code>load-probe</code> element is encountered, create a new probe for the current * <code>CacheServer</code>. * * @since GemFire 5.7 */ private void endLoadProbe() { Declarable d = createDeclarable(); if (!(d instanceof ServerLoadProbe)) { throw new CacheXmlException(String.format("A %s is not an instance of a %s", new Object[] {d.getClass().getName(), "BridgeLoadProbe"})); } stack.push(d); }
private void endSerializer() { Declarable d = CacheXmlParser.createDeclarable(cache, stack); if (!(d instanceof LuceneSerializer)) { throw new CacheXmlException( d.getClass().getName() + " is not an instance of LuceneSerializer"); } LuceneIndexCreation indexCreation = (LuceneIndexCreation) stack.peek(); indexCreation.setLuceneSerializer((LuceneSerializer) d); }
private void endPdxSerializer() { Declarable d = createDeclarable(); if (!(d instanceof PdxSerializer)) { throw new CacheXmlException( String.format("A %s is not an instance of a PdxSerializer.", d.getClass().getName())); } PdxSerializer serializer = (PdxSerializer) d; this.cache.setPdxSerializer(serializer); }
/** * When a <code>gateway-conflict-resolver</code> element is encountered, create a new listener for * the <code>Cache</code>. */ private void endGatewayConflictResolver() { Declarable d = createDeclarable(); if (!(d instanceof GatewayConflictResolver)) { throw new CacheXmlException( String.format("A %s is not an instance of a GatewayConflictResolver.", d.getClass().getName())); } CacheCreation c = (CacheCreation) stack.peek(); c.setGatewayConflictResolver((GatewayConflictResolver) d); }
/** * Create a <code>transaction-listener</code> using the declarable interface and set the * transaction manager with the newly instantiated listener. */ private void endTransactionListener() { Declarable d = createDeclarable(); if (!(d instanceof TransactionListener)) { throw new CacheXmlException( String.format("A %s is not an instance of a CacheListener.", d.getClass().getName())); } CacheTransactionManagerCreation txMgrCreation = (CacheTransactionManagerCreation) stack.peek(); txMgrCreation.addListener((TransactionListener) d); }
/** * Create a <code>transaction-writer</code> using the declarable interface and set the transaction * manager with the newly instantiated writer. */ private void endTransactionWriter() { Declarable d = createDeclarable(); if (!(d instanceof TransactionWriter)) { throw new CacheXmlException( String.format("A %s is not an instance of a TransactionWriter.", d.getClass().getName())); } CacheTransactionManagerCreation txMgrCreation = (CacheTransactionManagerCreation) stack.peek(); txMgrCreation.setWriter((TransactionWriter) d); }
private void endAsyncEventListener() { Declarable d = createDeclarable(); if (!(d instanceof AsyncEventListener)) { throw new CacheXmlException( String.format("A %s is not an instance of a AsyncEventListener", d.getClass().getName())); } AsyncEventQueueCreation eventChannel = peekAsyncEventQueueContext(ASYNC_EVENT_LISTENER); eventChannel.setAsyncEventListener((AsyncEventListener) d); }
/** * When a <code>partition-resolver</code> element is finished, the {@link Parameter}s and class * names are popped off the stack. The <code>PartitionResolver</code> is instantiated and * initialized with the parameters, if appropriate. */ private void endPartitionResolver() { Declarable d = createDeclarable(); if (!(d instanceof PartitionResolver)) { throw new CacheXmlException(String.format("A %s is not an instance of a %s", new Object[] {d.getClass().getName(), "PartitionResolver"})); } PartitionAttributesImpl pai = peekPartitionAttributesImpl(PARTITION_ATTRIBUTES); pai.setPartitionResolver((PartitionResolver) d); }
/** * When a <code>partition-listener</code> element is finished, the {@link Parameter}s and class * names are popped off the stack. The <code>PartitionListener</code> is instantiated and * initialized with the parameters, if appropriate. */ private void endPartitionListener() { Declarable d = createDeclarable(); if (!(d instanceof PartitionListener)) { throw new CacheXmlException(String.format("A %s is not an instance of a %s", new Object[] {d.getClass().getName(), "PartitionListener"})); } PartitionAttributesImpl pai = peekPartitionAttributesImpl(PARTITION_ATTRIBUTES); pai.addPartitionListener((PartitionListener) 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( String.format("A %s is not an instance of a CacheListener.", d.getClass().getName())); } RegionAttributesCreation attrs = peekRegionAttributesContext(CACHE_LISTENER); attrs.addCacheListener((CacheListener) d); }
/** * When we have finished a function element, we create the Declarable and push it onto stack */ private void endFunctionName() { Declarable d = createDeclarable(); if (!(d instanceof Function)) { String s = String.format("A %s is not an instance of a Function", d.getClass().getName()); throw new CacheXmlException(s); } Object fs = stack.peek(); if (!(fs instanceof FunctionServiceCreation)) { throw new CacheXmlException( String.format("A %s is only allowed in the context of %s MJTDEBUG e=%s", new Object[] {FUNCTION, FUNCTION_SERVICE, fs})); } FunctionServiceCreation funcService = (FunctionServiceCreation) fs; funcService.registerFunction((Function) d); }
private void endGatewayEventFilter() { Declarable d = createDeclarable(); if (!(d instanceof GatewayEventFilter)) { throw new CacheXmlException(String.format("A %s is not an instance of a %s", new Object[] {d.getClass().getName(), "GatewayEventFilter"})); } Object obj = stack.peek(); if (obj instanceof GatewaySenderFactory) { GatewaySenderFactory senderFactory = (GatewaySenderFactory) obj; senderFactory.addGatewayEventFilter((GatewayEventFilter) d); } else if (obj instanceof AsyncEventQueueCreation) { AsyncEventQueueCreation asyncEventQueueCreation = (AsyncEventQueueCreation) obj; asyncEventQueueCreation.addGatewayEventFilter((GatewayEventFilter) d); } else { throw new CacheXmlException( String.format( "A %s must be defined in the context of gateway-sender or async-event-queue.", "GatewayEventFilter")); } }
private void endGatewayEventSubstitutionFilter() { Declarable d = createDeclarable(); if (!(d instanceof GatewayEventSubstitutionFilter)) { throw new CacheXmlException( String.format("A %s is not an instance of a %s", new Object[] {d.getClass().getName(), "GatewayEventSubstitutionFilter"})); } Object obj = stack.peek(); if (obj instanceof GatewaySenderFactory) { GatewaySenderFactory senderFactory = (GatewaySenderFactory) obj; senderFactory.setGatewayEventSubstitutionFilter((GatewayEventSubstitutionFilter) d); } else if (obj instanceof AsyncEventQueueCreation) { AsyncEventQueueCreation asyncEventQueueCreation = (AsyncEventQueueCreation) obj; asyncEventQueueCreation.setGatewayEventSubstitutionFilter((GatewayEventSubstitutionFilter) d); } else { throw new CacheXmlException( String.format( "A %s must be defined in the context of gateway-sender or async-event-queue.", "GatewayEventSubstitutionFilter")); } }
private void endGatewayTransportFilter() { Declarable d = createDeclarable(); if (!(d instanceof GatewayTransportFilter)) { throw new CacheXmlException(String.format("A %s is not an instance of a %s", d.getClass().getName(), "GatewayTransportFilter")); } Object a = stack.peek(); if (a instanceof GatewaySenderFactory) { GatewaySenderFactory senderFactory = (GatewaySenderFactory) a; senderFactory.addGatewayTransportFilter((GatewayTransportFilter) d); } else if (a instanceof GatewayReceiverFactory) { GatewayReceiverFactory receiverFactory = (GatewayReceiverFactory) a; receiverFactory.addGatewayTransportFilter((GatewayTransportFilter) d); } else { throw new CacheXmlException( String.format( "A %s must be defined in the context of gateway-sender or gateway-receiver.", GATEWAY_TRANSPORT_FILTER)); } }
/** * 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( String.format("A %s is not an instance of a ObjectSizer.", 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-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); }
Declarable d = createDeclarable(); if (!(d instanceof CacheLoader)) { throw new CacheXmlException(