Search in sources :

Example 1 with CacheXmlException

use of org.apache.geode.cache.CacheXmlException 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 CacheXmlException

use of org.apache.geode.cache.CacheXmlException in project geode by apache.

the class CacheXmlParser method endDiskDirs.

/**
   * When a <code>disk-dirs</code> element is finished, the directory {@link File}s are on the stack
   * followed by the {@link RegionAttributesCreation} to which the expiration attributes are
   * assigned.
   */
private void endDiskDirs() {
    List dirs = new ArrayList();
    List sizes = new ArrayList();
    while (stack.peek() instanceof File) {
        dirs.add(stack.pop());
        sizes.add(stack.pop());
    }
    Assert.assertTrue(!dirs.isEmpty());
    Assert.assertTrue(!sizes.isEmpty());
    // should set the disk-dirs and sizes in reverse order since parsers would have reversed
    // the order because of pushing into stack
    File[] disks = new File[dirs.size()];
    int dirsLength = dirs.size();
    for (int i = 0; i < dirsLength; i++) {
        disks[i] = (File) dirs.get((dirsLength - 1) - i);
    }
    int[] diskSizes = new int[sizes.size()];
    for (int i = 0; i < dirsLength; i++) {
        diskSizes[i] = ((Integer) sizes.get((dirsLength - 1) - i)).intValue();
    }
    Object a = stack.peek();
    if (a instanceof RegionAttributesCreation) {
        RegionAttributesCreation attrs = (RegionAttributesCreation) a;
        attrs.setDiskDirsAndSize(disks, diskSizes);
    } else if (a instanceof DiskStoreAttributesCreation) {
        DiskStoreAttributesCreation attrs = (DiskStoreAttributesCreation) a;
        attrs.setDiskDirsAndSize(disks, diskSizes);
    } else {
        throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_MUST_BE_DEFINED_IN_THE_CONTEXT_OF_REGIONATTRIBUTES.toLocalizedString(DISK_DIRS));
    }
}
Also used : CacheXmlException(org.apache.geode.cache.CacheXmlException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Example 3 with CacheXmlException

use of org.apache.geode.cache.CacheXmlException in project geode by apache.

the class CacheXmlParser method getClassFromStack.

private Class getClassFromStack() {
    Object o = this.stack.peek();
    if (!(o instanceof String)) {
        throw new CacheXmlException(LocalizedStrings.CacheXmlParser_NO_CLASSNAME_FOUND.toLocalizedString());
    }
    String className = (String) this.stack.pop();
    try {
        Class c = InternalDataSerializer.getCachedClass(className);
        return c;
    } catch (Exception e) {
        throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_CLASS_NOT_FOUND.toLocalizedString(className), e);
    }
}
Also used : CacheXmlException(org.apache.geode.cache.CacheXmlException) TimeoutException(org.apache.geode.cache.TimeoutException) InternalGemFireException(org.apache.geode.InternalGemFireException) EmptyStackException(java.util.EmptyStackException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) RegionExistsException(org.apache.geode.cache.RegionExistsException) CacheXmlException(org.apache.geode.cache.CacheXmlException) SAXException(org.xml.sax.SAXException) GatewayException(org.apache.geode.cache.GatewayException) CacheWriterException(org.apache.geode.cache.CacheWriterException) SAXParseException(org.xml.sax.SAXParseException)

Example 4 with CacheXmlException

use of org.apache.geode.cache.CacheXmlException 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 5 with CacheXmlException

use of org.apache.geode.cache.CacheXmlException 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)

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