Search in sources :

Example 21 with Declarable

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

Example 22 with Declarable

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

Example 23 with Declarable

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

Example 24 with Declarable

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

Example 25 with Declarable

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

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