use of org.apache.geode.cache.CacheXmlException in project geode by apache.
the class CacheXmlParser method endTransactionListener.
/**
* 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(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_CACHELISTENER.toLocalizedString(d.getClass().getName()));
}
CacheTransactionManagerCreation txMgrCreation = (CacheTransactionManagerCreation) stack.peek();
txMgrCreation.addListener((TransactionListener) d);
}
use of org.apache.geode.cache.CacheXmlException in project geode by apache.
the class CacheXmlParser method endCustomExpiry.
private void endCustomExpiry() {
Declarable d = createDeclarable();
if (!(d instanceof CustomExpiry)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_CUSTOMEXPIRY.toLocalizedString(d.getClass().getName()));
}
stack.push(d);
}
use of org.apache.geode.cache.CacheXmlException in project geode by apache.
the class CacheXmlParser method endPartitionProperites.
/**
* Process either the <code>local-properties</code> or <code>global-properties</code> for a
* {@link org.apache.geode.internal.cache.PartitionedRegion}
*
* @param globalOrLocal either the string {@link CacheXml#LOCAL_PROPERTIES} or
* {@link CacheXml#GLOBAL_PROPERTIES}
*/
private void endPartitionProperites(String globalOrLocal) {
Properties props = new Properties();
Object top = stack.pop();
while (!top.equals(globalOrLocal)) {
if (!(top instanceof Parameter)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_ONLY_A_PARAMETER_IS_ALLOWED_IN_THE_CONTEXT_OF_0.toLocalizedString(globalOrLocal));
}
Parameter param = (Parameter) top;
props.put(param.getName(), param.getValue());
top = stack.pop();
}
if (globalOrLocal.equals(GLOBAL_PROPERTIES)) {
PartitionAttributesImpl pai = peekPartitionAttributesImpl(GLOBAL_PROPERTIES);
pai.setGlobalProperties(props);
} else if (globalOrLocal.equals(LOCAL_PROPERTIES)) {
PartitionAttributesImpl pai = peekPartitionAttributesImpl(LOCAL_PROPERTIES);
pai.setLocalProperties(props);
} else {
Assert.assertTrue(false, "Argument globalOrLocal has unexpected value " + globalOrLocal);
}
}
use of org.apache.geode.cache.CacheXmlException in project geode by apache.
the class CacheXmlParser method endLRUMemorySize.
/**
* 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);
}
use of org.apache.geode.cache.CacheXmlException in project geode by apache.
the class CacheXmlParser method endGatewayEventFilter.
private void endGatewayEventFilter() {
Declarable d = createDeclarable();
if (!(d instanceof GatewayEventFilter)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_1.toLocalizedString(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(LocalizedStrings.CacheXmlParser_A_0_MUST_BE_DEFINED_IN_THE_CONTEXT_OF_GATEWAY_SENDER_OR_ASYNC_EVENT_QUEUE.toLocalizedString("GatewayEventFilter"));
}
}
Aggregations