Search in sources :

Example 1 with Declarable

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"));
    }
}
Also used : Declarable(org.apache.geode.cache.Declarable) CacheXmlException(org.apache.geode.cache.CacheXmlException) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) GatewayEventSubstitutionFilter(org.apache.geode.cache.wan.GatewayEventSubstitutionFilter)

Example 2 with Declarable

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));
    }
}
Also used : Declarable(org.apache.geode.cache.Declarable) CacheXmlException(org.apache.geode.cache.CacheXmlException) GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter)

Example 3 with Declarable

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);
}
Also used : Declarable(org.apache.geode.cache.Declarable) CacheXmlException(org.apache.geode.cache.CacheXmlException) CacheListener(org.apache.geode.cache.CacheListener)

Example 4 with Declarable

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);
}
Also used : Declarable(org.apache.geode.cache.Declarable) CacheXmlException(org.apache.geode.cache.CacheXmlException) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 5 with Declarable

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));
    }
}
Also used : Declarable(org.apache.geode.cache.Declarable) CacheXmlException(org.apache.geode.cache.CacheXmlException) ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)

Aggregations

Declarable (org.apache.geode.cache.Declarable)29 CacheXmlException (org.apache.geode.cache.CacheXmlException)22 Properties (java.util.Properties)5 PartitionAttributesImpl (org.apache.geode.internal.cache.PartitionAttributesImpl)4 ObjectSizer (org.apache.geode.cache.util.ObjectSizer)3 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)3 File (java.io.File)2 IOException (java.io.IOException)2 EmptyStackException (java.util.EmptyStackException)2 InternalGemFireException (org.apache.geode.InternalGemFireException)2 CacheException (org.apache.geode.cache.CacheException)2 CacheWriterException (org.apache.geode.cache.CacheWriterException)2 ExpirationAttributes (org.apache.geode.cache.ExpirationAttributes)2 GatewayException (org.apache.geode.cache.GatewayException)2 RegionExistsException (org.apache.geode.cache.RegionExistsException)2 TimeoutException (org.apache.geode.cache.TimeoutException)2 Function (org.apache.geode.cache.execute.Function)2 DiskWriteAttributesImpl (org.apache.geode.internal.cache.DiskWriteAttributesImpl)2 EvictionAttributesImpl (org.apache.geode.internal.cache.EvictionAttributesImpl)2 FixedPartitionAttributesImpl (org.apache.geode.internal.cache.FixedPartitionAttributesImpl)2