use of org.apache.geode.cache.Declarable in project geode by apache.
the class CacheXmlParser method endGatewayEventSubstitutionFilter.
private void endGatewayEventSubstitutionFilter() {
Declarable d = createDeclarable();
if (!(d instanceof GatewayEventSubstitutionFilter)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_1.toLocalizedString(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(LocalizedStrings.CacheXmlParser_A_0_MUST_BE_DEFINED_IN_THE_CONTEXT_OF_GATEWAY_SENDER_OR_ASYNC_EVENT_QUEUE.toLocalizedString("GatewayEventSubstitutionFilter"));
}
}
use of org.apache.geode.cache.Declarable in project geode by apache.
the class CacheXmlParser method endGatewayTransportFilter.
private void endGatewayTransportFilter() {
Declarable d = createDeclarable();
if (!(d instanceof GatewayTransportFilter)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_1.toLocalizedString(new Object[] { 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(LocalizedStrings.CacheXmlParser_A_0_MUST_BE_DEFINED_IN_THE_CONTEXT_OF_GATEWAYSENDER_OR_GATEWAYRECEIVER.toLocalizedString(GATEWAY_TRANSPORT_FILTER));
}
}
use of org.apache.geode.cache.Declarable in project geode by apache.
the class CacheXmlParser method endCacheListener.
/**
* 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(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_CACHELISTENER.toLocalizedString(d.getClass().getName()));
}
RegionAttributesCreation attrs = peekRegionAttributesContext(CACHE_LISTENER);
attrs.addCacheListener((CacheListener) d);
}
use of org.apache.geode.cache.Declarable in project geode by apache.
the class CacheXmlParser method endAsyncEventListener.
private void endAsyncEventListener() {
Declarable d = createDeclarable();
if (!(d instanceof AsyncEventListener)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_ASYNCEVENTLISTENER.toLocalizedString(d.getClass().getName()));
}
AsyncEventQueueCreation eventChannel = peekAsyncEventQueueContext(ASYNC_EVENT_LISTENER);
eventChannel.setAsyncEventListener((AsyncEventListener) d);
}
use of org.apache.geode.cache.Declarable in project geode by apache.
the class CacheXmlParser method endEntryTimeToLive.
/**
* When a <code>entry-time-to-live</code> element is finished, an optional Declarable (the
* custom-expiry) is followed by the {@link ExpirationAttributes} are on top of the stack followed
* by either the {@link RegionAttributesCreation} to which the expiration attributes are assigned,
* or the attributes for a {@link PartitionAttributes} to which the attributes are assigned.
*/
private void endEntryTimeToLive() {
Declarable custom = null;
if (stack.peek() instanceof Declarable) {
custom = (Declarable) stack.pop();
}
ExpirationAttributes expire = (ExpirationAttributes) stack.pop();
Object a = stack.peek();
// } else
if (a instanceof RegionAttributesCreation) {
((RegionAttributesCreation) a).setEntryTimeToLive(expire);
if (custom != null) {
((RegionAttributesCreation) a).setCustomEntryTimeToLive((CustomExpiry) custom);
}
} else {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_MUST_BE_DEFINED_IN_THE_CONTEXT_OF_REGIONATTRIBUTES_OR_PARTITIONATTRIBUTES.toLocalizedString(ENTRY_TIME_TO_LIVE));
}
}
Aggregations