Search in sources :

Example 41 with CacheXmlException

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

Example 42 with CacheXmlException

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

Example 43 with CacheXmlException

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);
    }
}
Also used : FixedPartitionAttributesImpl(org.apache.geode.internal.cache.FixedPartitionAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) CacheXmlException(org.apache.geode.cache.CacheXmlException) Properties(java.util.Properties)

Example 44 with CacheXmlException

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);
}
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 45 with CacheXmlException

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"));
    }
}
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

CacheXmlException (org.apache.geode.cache.CacheXmlException)51 Declarable (org.apache.geode.cache.Declarable)22 SAXException (org.xml.sax.SAXException)13 Test (org.junit.Test)12 IgnoredException (org.apache.geode.test.dunit.IgnoredException)11 IOException (java.io.IOException)10 RegionExistsException (org.apache.geode.cache.RegionExistsException)9 CacheException (org.apache.geode.cache.CacheException)8 SAXParseException (org.xml.sax.SAXParseException)8 File (java.io.File)7 EmptyStackException (java.util.EmptyStackException)7 InternalGemFireException (org.apache.geode.InternalGemFireException)7 CacheWriterException (org.apache.geode.cache.CacheWriterException)7 GatewayException (org.apache.geode.cache.GatewayException)7 TimeoutException (org.apache.geode.cache.TimeoutException)7 Properties (java.util.Properties)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2