use of org.apache.geode.cache.Declarable in project geode by apache.
the class CacheXmlParser method endGatewayConflictResolver.
/**
* 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(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_GATEWAYCONFLICTRESOLVER.toLocalizedString(d.getClass().getName()));
}
CacheCreation c = (CacheCreation) stack.peek();
c.setGatewayConflictResolver((GatewayConflictResolver) d);
}
use of org.apache.geode.cache.Declarable 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.Declarable 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.Declarable 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.Declarable 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