This is an automated email from the ASF dual-hosted git repository.

jinmeiliao pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 088fd4d  GEODE-5971: refactor expiration config objects (#2991)
088fd4d is described below

commit 088fd4d558926e74e7747c786b1e1f7fc700b6dc
Author: jinmeiliao <[email protected]>
AuthorDate: Fri Dec 14 15:53:05 2018 -0800

    GEODE-5971: refactor expiration config objects (#2991)
    
    * GEODE-5971: refactor expiration config objects
    
    * maintain the xml structure
    * ease of use when setting/getting expiration attributes
---
 .../integrationTest/resources/assembly_content.txt |   7 +-
 ...egionCommandPersistsConfigurationDUnitTest.java |  23 +-
 .../apache/geode/cache/ExpirationAttributes.java   |   9 -
 .../configuration/ExpirationAttributesType.java    | 155 ----------
 .../cache/configuration/RegionAttributesType.java  | 287 ++++++++----------
 .../internal/cli/domain/RegionConfigFactory.java   | 321 +++++++++------------
 .../cli/functions/RegionAlterFunction.java         |  42 ---
 .../geode/cache/configuration/CacheConfigTest.java |  38 ++-
 .../cli/domain/RegionConfigFactoryTest.java        |  20 +-
 9 files changed, 312 insertions(+), 590 deletions(-)

diff --git a/geode-assembly/src/integrationTest/resources/assembly_content.txt 
b/geode-assembly/src/integrationTest/resources/assembly_content.txt
index 1101719..7501b75 100644
--- a/geode-assembly/src/integrationTest/resources/assembly_content.txt
+++ b/geode-assembly/src/integrationTest/resources/assembly_content.txt
@@ -304,7 +304,6 @@ 
javadoc/org/apache/geode/cache/configuration/DiskStoreType.html
 javadoc/org/apache/geode/cache/configuration/DynamicRegionFactoryType.html
 javadoc/org/apache/geode/cache/configuration/EnumActionDestroyOverflow.html
 javadoc/org/apache/geode/cache/configuration/EnumReadableWritable.html
-javadoc/org/apache/geode/cache/configuration/ExpirationAttributesType.html
 javadoc/org/apache/geode/cache/configuration/FunctionServiceType.html
 
javadoc/org/apache/geode/cache/configuration/JndiBindingsType.JndiBinding.ConfigProperty.html
 javadoc/org/apache/geode/cache/configuration/JndiBindingsType.JndiBinding.html
@@ -321,18 +320,16 @@ 
javadoc/org/apache/geode/cache/configuration/RegionAttributesMirrorType.html
 javadoc/org/apache/geode/cache/configuration/RegionAttributesScope.html
 
javadoc/org/apache/geode/cache/configuration/RegionAttributesType.DiskWriteAttributes.AsynchronousWrites.html
 
javadoc/org/apache/geode/cache/configuration/RegionAttributesType.DiskWriteAttributes.html
-javadoc/org/apache/geode/cache/configuration/RegionAttributesType.EntryIdleTime.html
-javadoc/org/apache/geode/cache/configuration/RegionAttributesType.EntryTimeToLive.html
 
javadoc/org/apache/geode/cache/configuration/RegionAttributesType.EvictionAttributes.LruEntryCount.html
 
javadoc/org/apache/geode/cache/configuration/RegionAttributesType.EvictionAttributes.LruHeapPercentage.html
 
javadoc/org/apache/geode/cache/configuration/RegionAttributesType.EvictionAttributes.LruMemorySize.html
 
javadoc/org/apache/geode/cache/configuration/RegionAttributesType.EvictionAttributes.html
+javadoc/org/apache/geode/cache/configuration/RegionAttributesType.ExpirationAttributesDetail.html
+javadoc/org/apache/geode/cache/configuration/RegionAttributesType.ExpirationAttributesType.html
 
javadoc/org/apache/geode/cache/configuration/RegionAttributesType.MembershipAttributes.RequiredRole.html
 
javadoc/org/apache/geode/cache/configuration/RegionAttributesType.MembershipAttributes.html
 
javadoc/org/apache/geode/cache/configuration/RegionAttributesType.PartitionAttributes.FixedPartitionAttributes.html
 
javadoc/org/apache/geode/cache/configuration/RegionAttributesType.PartitionAttributes.html
-javadoc/org/apache/geode/cache/configuration/RegionAttributesType.RegionIdleTime.html
-javadoc/org/apache/geode/cache/configuration/RegionAttributesType.RegionTimeToLive.html
 
javadoc/org/apache/geode/cache/configuration/RegionAttributesType.SubscriptionAttributes.html
 javadoc/org/apache/geode/cache/configuration/RegionAttributesType.html
 javadoc/org/apache/geode/cache/configuration/RegionConfig.Entry.html
diff --git 
a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandPersistsConfigurationDUnitTest.java
 
b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandPersistsConfigurationDUnitTest.java
index c4e14f0..1e4b227 100644
--- 
a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandPersistsConfigurationDUnitTest.java
+++ 
b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandPersistsConfigurationDUnitTest.java
@@ -36,7 +36,6 @@ import org.apache.geode.cache.PartitionResolver;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.configuration.CacheConfig;
 import org.apache.geode.cache.configuration.CacheElement;
-import org.apache.geode.cache.configuration.ExpirationAttributesType;
 import org.apache.geode.cache.configuration.RegionAttributesDataPolicy;
 import org.apache.geode.cache.configuration.RegionAttributesScope;
 import org.apache.geode.cache.configuration.RegionAttributesType;
@@ -175,7 +174,7 @@ public class 
CreateRegionCommandPersistsConfigurationDUnitTest {
       assertThat(attr.isStatisticsEnabled()).isTrue();
       assertThat(attr.isEnableAsyncConflation()).isTrue();
 
-      ExpirationAttributesType entryIdleTimeExp = 
attr.getEntryIdleTime().getExpirationAttributes();
+      RegionAttributesType.ExpirationAttributesType entryIdleTimeExp = 
attr.getEntryIdleTime();
       assertThat(entryIdleTimeExp.getTimeout()).isEqualTo("100");
     });
 
@@ -225,7 +224,7 @@ public class 
CreateRegionCommandPersistsConfigurationDUnitTest {
       assertThat(attr.isStatisticsEnabled()).isTrue();
       assertThat(attr.isEnableAsyncConflation()).isTrue();
 
-      ExpirationAttributesType entryIdleTimeExp = 
attr.getEntryIdleTime().getExpirationAttributes();
+      RegionAttributesType.ExpirationAttributesType entryIdleTimeExp = 
attr.getEntryIdleTime();
       assertThat(entryIdleTimeExp.getTimeout()).isEqualTo("100");
     });
   }
@@ -318,18 +317,18 @@ public class 
CreateRegionCommandPersistsConfigurationDUnitTest {
             .describedAs("Expecting subscription conflation to be enabled for 
region "
                 + name)
             .isTrue();
-        
assertThat(attr.getEntryIdleTime().getExpirationAttributes().getTimeout())
+        assertThat(attr.getEntryIdleTime().getTimeout())
             .describedAs("Entry idle time timeout should be 100 for region " + 
name)
             .isEqualTo("100");
-        
assertThat(attr.getEntryIdleTime().getExpirationAttributes().getAction())
+        assertThat(attr.getEntryIdleTime().getAction())
             .describedAs("Entry idle time expiration action should be 
local-destroy for region "
                 + name)
             .isEqualTo("local-destroy");
-        
assertThat(attr.getEntryTimeToLive().getExpirationAttributes().getTimeout())
+        assertThat(attr.getEntryTimeToLive().getTimeout())
             .describedAs("Expecting entry time to live expiration to be 200 
for region "
                 + name)
             .isEqualTo("200");
-        
assertThat(attr.getEntryTimeToLive().getExpirationAttributes().getAction())
+        assertThat(attr.getEntryTimeToLive().getAction())
             .describedAs("Entry time to live expiration action should be 
local-destroy "
                 + "for region " + name)
             .isEqualTo("local-destroy");
@@ -343,19 +342,19 @@ public class 
CreateRegionCommandPersistsConfigurationDUnitTest {
         assertThat(attr.isOffHeap())
             .describedAs("Expected off heap to be false for region " + name)
             .isFalse();
-        
assertThat(attr.getRegionIdleTime().getExpirationAttributes().getTimeout())
+        assertThat(attr.getRegionIdleTime().getTimeout())
             .describedAs("Expecting region idle time expiration to be 100 for 
region "
                 + name)
             .isEqualTo("100");
-        
assertThat(attr.getRegionIdleTime().getExpirationAttributes().getAction())
+        assertThat(attr.getRegionIdleTime().getAction())
             .describedAs("Expecting region idle time expiration action to be "
                 + "local-destroy for region " + name)
             .isEqualTo("local-destroy");
-        
assertThat(attr.getRegionTimeToLive().getExpirationAttributes().getTimeout())
+        assertThat(attr.getRegionTimeToLive().getTimeout())
             .describedAs("Expecting region idle time timeout to be 200 for "
                 + "region " + name)
             .isEqualTo("200");
-        
assertThat(attr.getRegionTimeToLive().getExpirationAttributes().getAction())
+        assertThat(attr.getRegionTimeToLive().getAction())
             .describedAs("Expecting region ttl action to be local-destroy for "
                 + "region " + name)
             .isEqualTo("local-destroy");
@@ -739,7 +738,7 @@ public class 
CreateRegionCommandPersistsConfigurationDUnitTest {
       assertThat(regionConfig.getName()).isEqualTo(regionName);
       assertThat(regionConfig.getRegionAttributes()).isNotNull();
       RegionAttributesType attr = regionConfig.getRegionAttributes();
-      
assertThat(attr.getEntryIdleTime().getExpirationAttributes().getCustomExpiry().toString())
+      assertThat(attr.getEntryIdleTime().getCustomExpiry().toString())
           .describedAs("Entry expiration custom expiration should be 
DummyCustomExpiry")
           .isEqualTo(DummyCustomExpiry.class.getName());
     });
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/ExpirationAttributes.java 
b/geode-core/src/main/java/org/apache/geode/cache/ExpirationAttributes.java
index ebd08ee..c97da56 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/ExpirationAttributes.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/ExpirationAttributes.java
@@ -21,7 +21,6 @@ import java.io.IOException;
 
 import org.apache.geode.DataSerializable;
 import org.apache.geode.DataSerializer;
-import org.apache.geode.cache.configuration.ExpirationAttributesType;
 import org.apache.geode.internal.InternalDataSerializer;
 
 /**
@@ -159,14 +158,6 @@ public class ExpirationAttributes implements 
DataSerializable {
     DataSerializer.writeObject(this.action, out);
   }
 
-  public ExpirationAttributesType toConfigType() {
-    ExpirationAttributesType t = new ExpirationAttributesType();
-    t.setTimeout(Integer.toString(this.timeout));
-    t.setAction(this.action.toXmlString());
-
-    return t;
-  }
-
   public boolean isDefault() {
     return (this.action == null || this.action == ExpirationAction.INVALIDATE)
         && (this.timeout == 0);
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/configuration/ExpirationAttributesType.java
 
b/geode-core/src/main/java/org/apache/geode/cache/configuration/ExpirationAttributesType.java
deleted file mode 100644
index b6a5d54..0000000
--- 
a/geode-core/src/main/java/org/apache/geode/cache/configuration/ExpirationAttributesType.java
+++ /dev/null
@@ -1,155 +0,0 @@
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.geode.cache.configuration;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.apache.geode.annotations.Experimental;
-
-
-/**
- *
- * An "expiration-attributes" element describes expiration.
- *
- *
- * <p>
- * Java class for expiration-attributes-type complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained 
within this class.
- *
- * <pre>
- * &lt;complexType name="expiration-attributes-type">
- *   &lt;complexContent>
- *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType";>
- *       &lt;sequence>
- *         &lt;element name="custom-expiry" minOccurs="0">
- *           &lt;complexType>
- *             &lt;complexContent>
- *               &lt;restriction 
base="{http://www.w3.org/2001/XMLSchema}anyType";>
- *                 &lt;sequence>
- *                   &lt;element name="class-name" 
type="{http://geode.apache.org/schema/cache}class-name-type"/>
- *                   &lt;element name="parameter" 
type="{http://geode.apache.org/schema/cache}parameter-type"; 
maxOccurs="unbounded" minOccurs="0"/>
- *                 &lt;/sequence>
- *               &lt;/restriction>
- *             &lt;/complexContent>
- *           &lt;/complexType>
- *         &lt;/element>
- *       &lt;/sequence>
- *       &lt;attribute name="action">
- *         &lt;simpleType>
- *           &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string";>
- *             &lt;enumeration value="destroy"/>
- *             &lt;enumeration value="invalidate"/>
- *             &lt;enumeration value="local-destroy"/>
- *             &lt;enumeration value="local-invalidate"/>
- *           &lt;/restriction>
- *         &lt;/simpleType>
- *       &lt;/attribute>
- *       &lt;attribute name="timeout" use="required" 
type="{http://www.w3.org/2001/XMLSchema}string"; />
- *     &lt;/restriction>
- *   &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "expiration-attributes-type", namespace = 
"http://geode.apache.org/schema/cache";,
-    propOrder = {"customExpiry"})
-@Experimental
-public class ExpirationAttributesType {
-
-  @XmlElement(name = "custom-expiry", namespace = 
"http://geode.apache.org/schema/cache";)
-  protected DeclarableType customExpiry;
-  @XmlAttribute(name = "action")
-  protected String action;
-  @XmlAttribute(name = "timeout", required = true)
-  protected String timeout;
-
-  /**
-   * Gets the value of the customExpiry property.
-   *
-   * possible object is
-   * {@link DeclarableType }
-   *
-   */
-  public DeclarableType getCustomExpiry() {
-    return customExpiry;
-  }
-
-  /**
-   * Sets the value of the customExpiry property.
-   *
-   * allowed object is
-   * {@link DeclarableType }
-   *
-   */
-  public void setCustomExpiry(DeclarableType value) {
-    this.customExpiry = value;
-  }
-
-  /**
-   * Gets the value of the action property.
-   *
-   * possible object is
-   * {@link String }
-   *
-   */
-  public String getAction() {
-    return action;
-  }
-
-  /**
-   * Sets the value of the action property.
-   *
-   * allowed object is
-   * {@link String }
-   *
-   */
-  public void setAction(String value) {
-    this.action = value;
-  }
-
-  /**
-   * Gets the value of the timeout property.
-   *
-   * possible object is
-   * {@link String }
-   *
-   */
-  public String getTimeout() {
-    return timeout;
-  }
-
-  /**
-   * Sets the value of the timeout property.
-   *
-   * allowed object is
-   * {@link String }
-   *
-   */
-  public void setTimeout(String value) {
-    this.timeout = value;
-  }
-}
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/configuration/RegionAttributesType.java
 
b/geode-core/src/main/java/org/apache/geode/cache/configuration/RegionAttributesType.java
index 436bd36..3a89bd0 100644
--- 
a/geode-core/src/main/java/org/apache/geode/cache/configuration/RegionAttributesType.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/configuration/RegionAttributesType.java
@@ -340,13 +340,13 @@ public class RegionAttributesType {
   @XmlElement(name = "value-constraint", namespace = 
"http://geode.apache.org/schema/cache";)
   protected String valueConstraint;
   @XmlElement(name = "region-time-to-live", namespace = 
"http://geode.apache.org/schema/cache";)
-  protected RegionAttributesType.RegionTimeToLive regionTimeToLive;
+  protected ExpirationAttributesType regionTimeToLive;
   @XmlElement(name = "region-idle-time", namespace = 
"http://geode.apache.org/schema/cache";)
-  protected RegionAttributesType.RegionIdleTime regionIdleTime;
+  protected ExpirationAttributesType regionIdleTime;
   @XmlElement(name = "entry-time-to-live", namespace = 
"http://geode.apache.org/schema/cache";)
-  protected RegionAttributesType.EntryTimeToLive entryTimeToLive;
+  protected ExpirationAttributesType entryTimeToLive;
   @XmlElement(name = "entry-idle-time", namespace = 
"http://geode.apache.org/schema/cache";)
-  protected RegionAttributesType.EntryIdleTime entryIdleTime;
+  protected ExpirationAttributesType entryIdleTime;
   @XmlElement(name = "disk-write-attributes", namespace = 
"http://geode.apache.org/schema/cache";)
   protected RegionAttributesType.DiskWriteAttributes diskWriteAttributes;
   @XmlElement(name = "disk-dirs", namespace = 
"http://geode.apache.org/schema/cache";)
@@ -475,7 +475,7 @@ public class RegionAttributesType {
    * {@link RegionAttributesType.RegionTimeToLive }
    *
    */
-  public RegionAttributesType.RegionTimeToLive getRegionTimeToLive() {
+  public ExpirationAttributesType getRegionTimeToLive() {
     return regionTimeToLive;
   }
 
@@ -486,7 +486,7 @@ public class RegionAttributesType {
    * {@link RegionAttributesType.RegionTimeToLive }
    *
    */
-  public void setRegionTimeToLive(RegionAttributesType.RegionTimeToLive value) 
{
+  public void setRegionTimeToLive(ExpirationAttributesType value) {
     this.regionTimeToLive = value;
   }
 
@@ -497,7 +497,7 @@ public class RegionAttributesType {
    * {@link RegionAttributesType.RegionIdleTime }
    *
    */
-  public RegionAttributesType.RegionIdleTime getRegionIdleTime() {
+  public ExpirationAttributesType getRegionIdleTime() {
     return regionIdleTime;
   }
 
@@ -508,7 +508,7 @@ public class RegionAttributesType {
    * {@link RegionAttributesType.RegionIdleTime }
    *
    */
-  public void setRegionIdleTime(RegionAttributesType.RegionIdleTime value) {
+  public void setRegionIdleTime(ExpirationAttributesType value) {
     this.regionIdleTime = value;
   }
 
@@ -519,7 +519,7 @@ public class RegionAttributesType {
    * {@link RegionAttributesType.EntryTimeToLive }
    *
    */
-  public RegionAttributesType.EntryTimeToLive getEntryTimeToLive() {
+  public ExpirationAttributesType getEntryTimeToLive() {
     return entryTimeToLive;
   }
 
@@ -530,7 +530,7 @@ public class RegionAttributesType {
    * {@link RegionAttributesType.EntryTimeToLive }
    *
    */
-  public void setEntryTimeToLive(RegionAttributesType.EntryTimeToLive value) {
+  public void setEntryTimeToLive(ExpirationAttributesType value) {
     this.entryTimeToLive = value;
   }
 
@@ -541,7 +541,7 @@ public class RegionAttributesType {
    * {@link RegionAttributesType.EntryIdleTime }
    *
    */
-  public RegionAttributesType.EntryIdleTime getEntryIdleTime() {
+  public ExpirationAttributesType getEntryIdleTime() {
     return entryIdleTime;
   }
 
@@ -552,7 +552,7 @@ public class RegionAttributesType {
    * {@link RegionAttributesType.EntryIdleTime }
    *
    */
-  public void setEntryIdleTime(RegionAttributesType.EntryIdleTime value) {
+  public void setEntryIdleTime(ExpirationAttributesType value) {
     this.entryIdleTime = value;
   }
 
@@ -1615,7 +1615,6 @@ public class RegionAttributesType {
       }
 
     }
-
   }
 
 
@@ -1642,90 +1641,151 @@ public class RegionAttributesType {
    */
   @XmlAccessorType(XmlAccessType.FIELD)
   @XmlType(name = "", propOrder = {"expirationAttributes"})
-  public static class EntryIdleTime {
+  public static class ExpirationAttributesType {
 
     @XmlElement(name = "expiration-attributes", namespace = 
"http://geode.apache.org/schema/cache";,
         required = true)
-    protected ExpirationAttributesType expirationAttributes;
+    protected ExpirationAttributesDetail expirationAttributes = new 
ExpirationAttributesDetail();
+
+    public DeclarableType getCustomExpiry() {
+      return expirationAttributes.getCustomExpiry();
+    }
+
+    /**
+     * Sets the value of the customExpiry property.
+     *
+     * allowed object is
+     * {@link DeclarableType }
+     *
+     */
+    public void setCustomExpiry(DeclarableType value) {
+      expirationAttributes.setCustomExpiry(value);
+    }
 
     /**
-     * Gets the value of the expirationAttributes property.
+     * Gets the value of the action property.
      *
      * possible object is
-     * {@link ExpirationAttributesType }
+     * {@link String }
      *
      */
-    public ExpirationAttributesType getExpirationAttributes() {
-      return expirationAttributes;
+    public String getAction() {
+      return expirationAttributes.getAction();
     }
 
     /**
-     * Sets the value of the expirationAttributes property.
+     * Sets the value of the action property.
      *
      * allowed object is
-     * {@link ExpirationAttributesType }
+     * {@link String }
      *
      */
-    public void setExpirationAttributes(ExpirationAttributesType value) {
-      this.expirationAttributes = value;
+    public void setAction(String value) {
+      expirationAttributes.setAction(value);
     }
 
-  }
+    /**
+     * Gets the value of the timeout property.
+     *
+     * possible object is
+     * {@link String }
+     *
+     */
+    public String getTimeout() {
+      return expirationAttributes.getTimeout();
+    }
 
+    /**
+     * Sets the value of the timeout property.
+     *
+     * allowed object is
+     * {@link String }
+     *
+     */
+    public void setTimeout(String value) {
+      expirationAttributes.setTimeout(value);
+    }
+
+  }
 
-  /**
-   * <p>
-   * Java class for anonymous complex type.
-   *
-   * <p>
-   * The following schema fragment specifies the expected content contained 
within this class.
-   *
-   * <pre>
-   * &lt;complexType>
-   *   &lt;complexContent>
-   *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType";>
-   *       &lt;sequence>
-   *         &lt;element name="expiration-attributes" 
type="{http://geode.apache.org/schema/cache}expiration-attributes-type"/>
-   *       &lt;/sequence>
-   *     &lt;/restriction>
-   *   &lt;/complexContent>
-   * &lt;/complexType>
-   * </pre>
-   *
-   *
-   */
   @XmlAccessorType(XmlAccessType.FIELD)
-  @XmlType(name = "", propOrder = {"expirationAttributes"})
-  public static class EntryTimeToLive {
+  @XmlType(name = "expiration-attributes-type", namespace = 
"http://geode.apache.org/schema/cache";,
+      propOrder = {"customExpiry"})
+  @Experimental
+  public static class ExpirationAttributesDetail {
+    @XmlElement(name = "custom-expiry", namespace = 
"http://geode.apache.org/schema/cache";)
+    protected DeclarableType customExpiry;
+    @XmlAttribute(name = "action")
+    protected String action;
+    @XmlAttribute(name = "timeout", required = true)
+    protected String timeout;
 
-    @XmlElement(name = "expiration-attributes", namespace = 
"http://geode.apache.org/schema/cache";,
-        required = true)
-    protected ExpirationAttributesType expirationAttributes;
+    /**
+     * Gets the value of the customExpiry property.
+     *
+     * possible object is
+     * {@link DeclarableType }
+     *
+     */
+    public DeclarableType getCustomExpiry() {
+      return customExpiry;
+    }
+
+    /**
+     * Sets the value of the customExpiry property.
+     *
+     * allowed object is
+     * {@link DeclarableType }
+     *
+     */
+    public void setCustomExpiry(DeclarableType value) {
+      this.customExpiry = value;
+    }
 
     /**
-     * Gets the value of the expirationAttributes property.
+     * Gets the value of the action property.
      *
      * possible object is
-     * {@link ExpirationAttributesType }
+     * {@link String }
      *
      */
-    public ExpirationAttributesType getExpirationAttributes() {
-      return expirationAttributes;
+    public String getAction() {
+      return action;
     }
 
     /**
-     * Sets the value of the expirationAttributes property.
+     * Sets the value of the action property.
      *
      * allowed object is
-     * {@link ExpirationAttributesType }
+     * {@link String }
      *
      */
-    public void setExpirationAttributes(ExpirationAttributesType value) {
-      this.expirationAttributes = value;
+    public void setAction(String value) {
+      this.action = value;
     }
 
-  }
+    /**
+     * Gets the value of the timeout property.
+     *
+     * possible object is
+     * {@link String }
+     *
+     */
+    public String getTimeout() {
+      return timeout;
+    }
 
+    /**
+     * Sets the value of the timeout property.
+     *
+     * allowed object is
+     * {@link String }
+     *
+     */
+    public void setTimeout(String value) {
+      this.timeout = value;
+    }
+  }
 
   /**
    * <p>
@@ -2674,115 +2734,6 @@ public class RegionAttributesType {
     }
   }
 
-
-  /**
-   * <p>
-   * Java class for anonymous complex type.
-   *
-   * <p>
-   * The following schema fragment specifies the expected content contained 
within this class.
-   *
-   * <pre>
-   * &lt;complexType>
-   *   &lt;complexContent>
-   *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType";>
-   *       &lt;sequence>
-   *         &lt;element name="expiration-attributes" 
type="{http://geode.apache.org/schema/cache}expiration-attributes-type"/>
-   *       &lt;/sequence>
-   *     &lt;/restriction>
-   *   &lt;/complexContent>
-   * &lt;/complexType>
-   * </pre>
-   *
-   *
-   */
-  @XmlAccessorType(XmlAccessType.FIELD)
-  @XmlType(name = "", propOrder = {"expirationAttributes"})
-  public static class RegionIdleTime {
-
-    @XmlElement(name = "expiration-attributes", namespace = 
"http://geode.apache.org/schema/cache";,
-        required = true)
-    protected ExpirationAttributesType expirationAttributes;
-
-    /**
-     * Gets the value of the expirationAttributes property.
-     *
-     * possible object is
-     * {@link ExpirationAttributesType }
-     *
-     */
-    public ExpirationAttributesType getExpirationAttributes() {
-      return expirationAttributes;
-    }
-
-    /**
-     * Sets the value of the expirationAttributes property.
-     *
-     * allowed object is
-     * {@link ExpirationAttributesType }
-     *
-     */
-    public void setExpirationAttributes(ExpirationAttributesType value) {
-      this.expirationAttributes = value;
-    }
-
-  }
-
-
-  /**
-   * <p>
-   * Java class for anonymous complex type.
-   *
-   * <p>
-   * The following schema fragment specifies the expected content contained 
within this class.
-   *
-   * <pre>
-   * &lt;complexType>
-   *   &lt;complexContent>
-   *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType";>
-   *       &lt;sequence>
-   *         &lt;element name="expiration-attributes" 
type="{http://geode.apache.org/schema/cache}expiration-attributes-type"/>
-   *       &lt;/sequence>
-   *     &lt;/restriction>
-   *   &lt;/complexContent>
-   * &lt;/complexType>
-   * </pre>
-   *
-   *
-   */
-  @XmlAccessorType(XmlAccessType.FIELD)
-  @XmlType(name = "", propOrder = {"expirationAttributes"})
-  public static class RegionTimeToLive {
-
-    @XmlElement(name = "expiration-attributes", namespace = 
"http://geode.apache.org/schema/cache";,
-        required = true)
-    protected ExpirationAttributesType expirationAttributes;
-
-    /**
-     * Gets the value of the expirationAttributes property.
-     *
-     * possible object is
-     * {@link ExpirationAttributesType }
-     *
-     */
-    public ExpirationAttributesType getExpirationAttributes() {
-      return expirationAttributes;
-    }
-
-    /**
-     * Sets the value of the expirationAttributes property.
-     *
-     * allowed object is
-     * {@link ExpirationAttributesType }
-     *
-     */
-    public void setExpirationAttributes(ExpirationAttributesType value) {
-      this.expirationAttributes = value;
-    }
-
-  }
-
-
   /**
    * <p>
    * Java class for anonymous complex type.
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionConfigFactory.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionConfigFactory.java
index 39df779..efcf313 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionConfigFactory.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionConfigFactory.java
@@ -14,15 +14,15 @@
  */
 package org.apache.geode.management.internal.cli.domain;
 
-import java.util.Optional;
-import java.util.function.Consumer;
-import java.util.function.Function;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
+import org.apache.geode.cache.CustomExpiry;
+import org.apache.geode.cache.ExpirationAction;
+import org.apache.geode.cache.ExpirationAttributes;
 import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.cache.configuration.ClassNameType;
 import org.apache.geode.cache.configuration.DeclarableType;
-import org.apache.geode.cache.configuration.ExpirationAttributesType;
 import org.apache.geode.cache.configuration.RegionAttributesScope;
 import org.apache.geode.cache.configuration.RegionAttributesType;
 import org.apache.geode.cache.configuration.RegionConfig;
@@ -32,186 +32,106 @@ public class RegionConfigFactory {
   public RegionConfig generate(RegionFunctionArgs args) {
     RegionConfig regionConfig = new RegionConfig();
     regionConfig.setName(getLeafRegion(args.getRegionPath()));
+    RegionAttributesType regionAttributesType = new RegionAttributesType();
+    regionConfig.setRegionAttributes(regionAttributesType);
 
     RegionAttributes<?, ?> regionAttributes = args.getRegionAttributes();
+
     if (args.getKeyConstraint() != null) {
-      addAttribute(regionConfig, a -> 
a.setKeyConstraint(args.getKeyConstraint()));
+      regionAttributesType.setKeyConstraint(args.getKeyConstraint());
     }
 
     if (args.getValueConstraint() != null) {
-      addAttribute(regionConfig, a -> 
a.setValueConstraint(args.getValueConstraint()));
+      regionAttributesType.setValueConstraint(args.getValueConstraint());
     }
 
     if (args.getStatisticsEnabled() != null) {
-      addAttribute(regionConfig, a -> 
a.setStatisticsEnabled(args.getStatisticsEnabled()));
+      regionAttributesType.setStatisticsEnabled(args.getStatisticsEnabled());
     } else if (regionAttributes != null) {
-      addAttribute(regionConfig, a -> a.setStatisticsEnabled(regionAttributes
-          .getStatisticsEnabled()));
+      
regionAttributesType.setStatisticsEnabled(regionAttributes.getStatisticsEnabled());
     }
 
-    if (args.getEntryExpirationIdleTime() != null) {
-      RegionAttributesType.EntryIdleTime entryIdleTime = new 
RegionAttributesType.EntryIdleTime();
-      entryIdleTime.setExpirationAttributes(
-          
args.getEntryExpirationIdleTime().getExpirationAttributes().toConfigType());
-      addAttribute(regionConfig, a -> a.setEntryIdleTime(entryIdleTime));
-    } else if (regionAttributes != null &&
-        regionAttributes.getEntryIdleTimeout() != null &&
-        !regionAttributes.getEntryIdleTimeout().isDefault()) {
-      RegionAttributesType.EntryIdleTime entryIdleTime = new 
RegionAttributesType.EntryIdleTime();
-      entryIdleTime.setExpirationAttributes(regionAttributes
-          .getEntryIdleTimeout().toConfigType());
-      addAttribute(regionConfig, a -> a.setEntryIdleTime(entryIdleTime));
-    }
-
-    if (args.getEntryIdleTimeCustomExpiry() != null) {
-      Object maybeEntryIdleAttr = getAttribute(regionConfig, a -> 
a.getEntryIdleTime());
-      RegionAttributesType.EntryIdleTime entryIdleTime =
-          maybeEntryIdleAttr != null ? (RegionAttributesType.EntryIdleTime) 
maybeEntryIdleAttr
-              : new RegionAttributesType.EntryIdleTime();
-
-      ExpirationAttributesType expirationAttributes;
-      if (entryIdleTime.getExpirationAttributes() == null) {
-        expirationAttributes = new ExpirationAttributesType();
-        expirationAttributes.setTimeout("0");
-      } else {
-        expirationAttributes = entryIdleTime.getExpirationAttributes();
+    // first get the expiration attributes from the command options
+    
regionAttributesType.setEntryIdleTime(getExpirationAttributes(args.getEntryExpirationIdleTime(),
+        args.getEntryIdleTimeCustomExpiry()));
+    regionAttributesType.setEntryTimeToLive(
+        getExpirationAttributes(args.getEntryExpirationTTL(), 
args.getEntryTTLCustomExpiry()));
+    regionAttributesType
+        
.setRegionIdleTime(getExpirationAttributes(args.getRegionExpirationIdleTime(), 
null));
+    regionAttributesType
+        
.setRegionTimeToLive(getExpirationAttributes(args.getRegionExpirationTTL(), 
null));
+
+    // if regionAttributes has these attributes, then use that
+    if (regionAttributes != null) {
+      if (regionAttributesType.getEntryIdleTime() == null) {
+        regionAttributesType.setEntryIdleTime(getExpirationAttributes(
+            regionAttributes.getEntryIdleTimeout(), 
regionAttributes.getCustomEntryIdleTimeout()));
       }
-
-      DeclarableType customExpiry = new DeclarableType();
-      
customExpiry.setClassName(args.getEntryIdleTimeCustomExpiry().getClassName());
-      expirationAttributes.setCustomExpiry(customExpiry);
-      entryIdleTime.setExpirationAttributes(expirationAttributes);
-
-      if (maybeEntryIdleAttr == null) {
-        addAttribute(regionConfig, a -> a.setEntryIdleTime(entryIdleTime));
+      if (regionAttributesType.getEntryTimeToLive() == null) {
+        regionAttributesType.setEntryTimeToLive(getExpirationAttributes(
+            regionAttributes.getEntryTimeToLive(), 
regionAttributes.getCustomEntryTimeToLive()));
       }
-    }
 
-    if (args.getEntryExpirationTTL() != null) {
-      RegionAttributesType.EntryTimeToLive entryExpTime =
-          new RegionAttributesType.EntryTimeToLive();
-      entryExpTime.setExpirationAttributes(
-          
args.getEntryExpirationTTL().getExpirationAttributes().toConfigType());
-      addAttribute(regionConfig, a -> a.setEntryTimeToLive(entryExpTime));
-    } else if (regionAttributes != null
-        && regionAttributes.getEntryTimeToLive() != null
-        && !regionAttributes.getEntryTimeToLive().isDefault()) {
-      RegionAttributesType.EntryTimeToLive entryExpTime =
-          new RegionAttributesType.EntryTimeToLive();
-      entryExpTime.setExpirationAttributes(
-          regionAttributes.getEntryTimeToLive().toConfigType());
-      addAttribute(regionConfig, a -> a.setEntryTimeToLive(entryExpTime));
-    }
-
-    if (args.getRegionExpirationIdleTime() != null) {
-      RegionAttributesType.RegionIdleTime regionIdleTime =
-          new RegionAttributesType.RegionIdleTime();
-      regionIdleTime.setExpirationAttributes(
-          
args.getRegionExpirationIdleTime().getExpirationAttributes().toConfigType());
-      addAttribute(regionConfig, a -> a.setRegionIdleTime(regionIdleTime));
-    } else if (regionAttributes != null
-        && regionAttributes.getRegionIdleTimeout() != null
-        && !regionAttributes.getRegionIdleTimeout().isDefault()) {
-      RegionAttributesType.RegionIdleTime regionIdleTime =
-          new RegionAttributesType.RegionIdleTime();
-      regionIdleTime.setExpirationAttributes(
-          regionAttributes.getRegionIdleTimeout().toConfigType());
-      addAttribute(regionConfig, a -> a.setRegionIdleTime(regionIdleTime));
-    }
-
-    if (args.getRegionExpirationTTL() != null) {
-      RegionAttributesType.RegionTimeToLive regionExpTime =
-          new RegionAttributesType.RegionTimeToLive();
-      regionExpTime.setExpirationAttributes(
-          
args.getRegionExpirationTTL().getExpirationAttributes().toConfigType());
-      addAttribute(regionConfig, a -> a.setRegionTimeToLive(regionExpTime));
-    } else if (regionAttributes != null
-        && regionAttributes.getRegionTimeToLive() != null
-        && !regionAttributes.getRegionTimeToLive().isDefault()) {
-      RegionAttributesType.RegionTimeToLive regionExpTime =
-          new RegionAttributesType.RegionTimeToLive();
-      regionExpTime.setExpirationAttributes(
-          regionAttributes.getRegionTimeToLive().toConfigType());
-      addAttribute(regionConfig, a -> a.setRegionTimeToLive(regionExpTime));
-    }
-
-    if (args.getEntryTTLCustomExpiry() != null) {
-      Object maybeEntryTTLAttr = getAttribute(regionConfig, a -> 
a.getEntryTimeToLive());
-      RegionAttributesType.EntryTimeToLive entryTimeToLive =
-          maybeEntryTTLAttr != null ? (RegionAttributesType.EntryTimeToLive) 
maybeEntryTTLAttr
-              : new RegionAttributesType.EntryTimeToLive();
-
-      ExpirationAttributesType expirationAttributes;
-      if (entryTimeToLive.getExpirationAttributes() == null) {
-        expirationAttributes = new ExpirationAttributesType();
-        expirationAttributes.setTimeout("0");
-      } else {
-        expirationAttributes = entryTimeToLive.getExpirationAttributes();
+      if (regionAttributesType.getRegionIdleTime() == null) {
+        regionAttributesType.setRegionIdleTime(
+            getExpirationAttributes(regionAttributes.getRegionIdleTimeout(), 
null));
       }
 
-      DeclarableType customExpiry = new DeclarableType();
-      customExpiry.setClassName(args.getEntryTTLCustomExpiry().getClassName());
-      expirationAttributes.setCustomExpiry(customExpiry);
-      entryTimeToLive.setExpirationAttributes(expirationAttributes);
-
-      if (maybeEntryTTLAttr == null) {
-        addAttribute(regionConfig, a -> a.setEntryTimeToLive(entryTimeToLive));
+      if (regionAttributesType.getRegionTimeToLive() == null) {
+        regionAttributesType.setRegionTimeToLive(
+            getExpirationAttributes(regionAttributes.getRegionTimeToLive(), 
null));
       }
     }
 
+
     if (args.getDiskStore() != null) {
-      addAttribute(regionConfig, a -> a.setDiskStoreName(args.getDiskStore()));
+      regionAttributesType.setDiskStoreName(args.getDiskStore());
     } else if (regionAttributes != null) {
-      addAttribute(regionConfig, a -> 
a.setDiskStoreName(regionAttributes.getDiskStoreName()));
+      
regionAttributesType.setDiskStoreName(regionAttributes.getDiskStoreName());
     }
 
     if (args.getDiskSynchronous() != null) {
-      addAttribute(regionConfig, a -> 
a.setDiskSynchronous(args.getDiskSynchronous()));
+      regionAttributesType.setDiskSynchronous(args.getDiskSynchronous());
     } else if (regionAttributes != null) {
-      addAttribute(regionConfig, a -> 
a.setDiskSynchronous(regionAttributes.isDiskSynchronous()));
+      
regionAttributesType.setDiskSynchronous(regionAttributes.isDiskSynchronous());
     }
 
     if (args.getEnableAsyncConflation() != null) {
-      addAttribute(regionConfig, a -> 
a.setEnableAsyncConflation(args.getEnableAsyncConflation()));
+      
regionAttributesType.setEnableAsyncConflation(args.getEnableAsyncConflation());
     } else if (regionAttributes != null) {
-      addAttribute(regionConfig, a -> 
a.setEnableAsyncConflation(regionAttributes
-          .getEnableAsyncConflation()));
+      
regionAttributesType.setEnableAsyncConflation(regionAttributes.getEnableAsyncConflation());
     }
 
     if (args.getEnableSubscriptionConflation() != null) {
-      addAttribute(regionConfig,
-          a -> 
a.setEnableSubscriptionConflation(args.getEnableSubscriptionConflation()));
+      
regionAttributesType.setEnableSubscriptionConflation(args.getEnableSubscriptionConflation());
     } else if (regionAttributes != null) {
-      addAttribute(regionConfig, a -> 
a.setEnableSubscriptionConflation(regionAttributes
-          .getEnableSubscriptionConflation()));
+      regionAttributesType
+          
.setEnableSubscriptionConflation(regionAttributes.getEnableSubscriptionConflation());
     }
 
     if (args.getConcurrencyChecksEnabled() != null) {
-      addAttribute(regionConfig, a -> a.setConcurrencyChecksEnabled(
-          args.getConcurrencyChecksEnabled()));
+      
regionAttributesType.setConcurrencyChecksEnabled(args.getConcurrencyChecksEnabled());
     } else if (regionAttributes != null) {
-      addAttribute(regionConfig, a -> 
a.setConcurrencyChecksEnabled(regionAttributes
-          .getConcurrencyChecksEnabled()));
+      regionAttributesType
+          
.setConcurrencyChecksEnabled(regionAttributes.getConcurrencyChecksEnabled());
     }
 
     if (args.getCloningEnabled() != null) {
-      addAttribute(regionConfig, a -> 
a.setCloningEnabled(args.getCloningEnabled()));
+      regionAttributesType.setCloningEnabled(args.getCloningEnabled());
     } else if (regionAttributes != null) {
-      addAttribute(regionConfig, a -> a.setCloningEnabled(regionAttributes
-          .getCloningEnabled()));
+      
regionAttributesType.setCloningEnabled(regionAttributes.getCloningEnabled());
     }
 
     if (args.getOffHeap() != null) {
-      addAttribute(regionConfig, a -> a.setOffHeap(args.getOffHeap()));
+      regionAttributesType.setOffHeap(args.getOffHeap());
     } else if (regionAttributes != null) {
-      addAttribute(regionConfig, a -> 
a.setOffHeap(regionAttributes.getOffHeap()));
+      regionAttributesType.setOffHeap(regionAttributes.getOffHeap());
     }
 
     if (args.getMcastEnabled() != null) {
-      addAttribute(regionConfig, a -> 
a.setMulticastEnabled(args.getMcastEnabled()));
+      regionAttributesType.setMulticastEnabled(args.getMcastEnabled());
     } else if (regionAttributes != null) {
-      addAttribute(regionConfig, a -> a.setMulticastEnabled(regionAttributes
-          .getMulticastEnabled()));
+      
regionAttributesType.setMulticastEnabled(regionAttributes.getMulticastEnabled());
     }
 
     if (args.getPartitionArgs() != null) {
@@ -219,13 +139,15 @@ public class RegionConfigFactory {
           new RegionAttributesType.PartitionAttributes();
       RegionFunctionArgs.PartitionArgs partitionArgs = args.getPartitionArgs();
       partitionAttributes.setColocatedWith(partitionArgs.getPrColocatedWith());
-      
partitionAttributes.setLocalMaxMemory(int2string(partitionArgs.getPrLocalMaxMemory()));
-      
partitionAttributes.setRecoveryDelay(long2string(partitionArgs.getPrRecoveryDelay()));
-      
partitionAttributes.setRedundantCopies(int2string(partitionArgs.getPrRedundantCopies()));
+      
partitionAttributes.setLocalMaxMemory(Objects.toString(partitionArgs.getPrLocalMaxMemory()));
+      
partitionAttributes.setRecoveryDelay(Objects.toString(partitionArgs.getPrRecoveryDelay()));
       partitionAttributes
-          
.setStartupRecoveryDelay(long2string(partitionArgs.getPrStartupRecoveryDelay()));
-      
partitionAttributes.setTotalMaxMemory(long2string(partitionArgs.getPrTotalMaxMemory()));
-      
partitionAttributes.setTotalNumBuckets(int2string(partitionArgs.getPrTotalNumBuckets()));
+          
.setRedundantCopies(Objects.toString(partitionArgs.getPrRedundantCopies()));
+      partitionAttributes
+          
.setStartupRecoveryDelay(Objects.toString(partitionArgs.getPrStartupRecoveryDelay()));
+      
partitionAttributes.setTotalMaxMemory(Objects.toString(partitionArgs.getPrTotalMaxMemory()));
+      partitionAttributes
+          
.setTotalNumBuckets(Objects.toString(partitionArgs.getPrTotalNumBuckets()));
 
       if (partitionArgs.getPartitionResolver() != null) {
         DeclarableType partitionResolverType = new DeclarableType();
@@ -233,109 +155,132 @@ public class RegionConfigFactory {
         partitionAttributes.setPartitionResolver(partitionResolverType);
       }
 
-      addAttribute(regionConfig, a -> 
a.setPartitionAttributes(partitionAttributes));
+      regionAttributesType.setPartitionAttributes(partitionAttributes);
     } else if (regionAttributes != null && 
regionAttributes.getPartitionAttributes() != null) {
-      addAttribute(regionConfig, a -> a.setPartitionAttributes(
-          
regionAttributes.getPartitionAttributes().convertToConfigPartitionAttributes()));
+      regionAttributesType.setPartitionAttributes(
+          
regionAttributes.getPartitionAttributes().convertToConfigPartitionAttributes());
     }
 
     if (args.getGatewaySenderIds() != null && 
!args.getGatewaySenderIds().isEmpty()) {
-      addAttribute(regionConfig, a -> a.setGatewaySenderIds(String.join(",",
-          args.getGatewaySenderIds())));
+      regionAttributesType.setGatewaySenderIds(String.join(",", 
args.getGatewaySenderIds()));
     }
 
     if (args.getEvictionAttributes() != null) {
-      addAttribute(regionConfig, a -> a.setEvictionAttributes(
-          args.getEvictionAttributes().convertToConfigEvictionAttributes()));
+      regionAttributesType
+          
.setEvictionAttributes(args.getEvictionAttributes().convertToConfigEvictionAttributes());
     } else if (regionAttributes != null &&
         regionAttributes.getEvictionAttributes() != null &&
         !regionAttributes.getEvictionAttributes().isEmpty()) {
-      addAttribute(regionConfig, a -> a.setEvictionAttributes(
-          
regionAttributes.getEvictionAttributes().convertToConfigEvictionAttributes()));
+      regionAttributesType.setEvictionAttributes(
+          
regionAttributes.getEvictionAttributes().convertToConfigEvictionAttributes());
     }
 
     if (args.getAsyncEventQueueIds() != null && 
!args.getAsyncEventQueueIds().isEmpty()) {
-      addAttribute(regionConfig,
-          a -> a.setAsyncEventQueueIds(String.join(",", 
args.getAsyncEventQueueIds())));
+      regionAttributesType.setAsyncEventQueueIds(String.join(",", 
args.getAsyncEventQueueIds()));
     }
 
     if (args.getCacheListeners() != null && 
!args.getCacheListeners().isEmpty()) {
-      addAttribute(regionConfig, a -> a.getCacheListeners().addAll(
-          args.getCacheListeners().stream().map(l -> {
-            DeclarableType declarableType = new DeclarableType();
-            declarableType.setClassName(l.getClassName());
-            return declarableType;
-          }).collect(Collectors.toList())));
+      
regionAttributesType.getCacheListeners().addAll(args.getCacheListeners().stream().map(l
 -> {
+        DeclarableType declarableType = new DeclarableType();
+        declarableType.setClassName(l.getClassName());
+        return declarableType;
+      }).collect(Collectors.toList()));
     }
 
     if (args.getCacheLoader() != null) {
       DeclarableType declarableType = new DeclarableType();
       declarableType.setClassName(args.getCacheLoader().getClassName());
-      addAttribute(regionConfig, a -> a.setCacheLoader(declarableType));
+      regionAttributesType.setCacheLoader(declarableType);
     }
 
     if (args.getCacheWriter() != null) {
       DeclarableType declarableType = new DeclarableType();
       declarableType.setClassName(args.getCacheWriter().getClassName());
-      addAttribute(regionConfig, a -> a.setCacheWriter(declarableType));
+      regionAttributesType.setCacheWriter(declarableType);
     }
 
     if (args.getCompressor() != null) {
-      addAttribute(regionConfig, a -> a.setCompressor(new 
ClassNameType(args.getCompressor())));
-      addAttribute(regionConfig, a -> a.setCloningEnabled(true));
+      regionAttributesType.setCompressor(new 
ClassNameType(args.getCompressor()));
+      regionAttributesType.setCloningEnabled(true);
     }
 
     if (args.getConcurrencyLevel() != null) {
-      addAttribute(regionConfig, a -> 
a.setConcurrencyLevel(args.getConcurrencyLevel().toString()));
+      
regionAttributesType.setConcurrencyLevel(args.getConcurrencyLevel().toString());
     } else if (regionAttributes != null) {
-      addAttribute(regionConfig, a -> a.setConcurrencyLevel(Integer.toString(
-          regionAttributes.getConcurrencyLevel())));
+      regionAttributesType
+          
.setConcurrencyLevel(Integer.toString(regionAttributes.getConcurrencyLevel()));
     }
 
     if (regionAttributes != null && regionAttributes.getDataPolicy() != null) {
-      addAttribute(regionConfig,
-          a -> 
a.setDataPolicy(regionAttributes.getDataPolicy().toConfigType()));
+      
regionAttributesType.setDataPolicy(regionAttributes.getDataPolicy().toConfigType());
     }
 
     if (regionAttributes != null && regionAttributes.getScope() != null
         && !regionAttributes.getDataPolicy().withPartitioning()) {
-      addAttribute(regionConfig,
-          a -> a.setScope(
-              
RegionAttributesScope.fromValue(regionAttributes.getScope().toConfigTypeString())));
+      regionAttributesType.setScope(
+          
RegionAttributesScope.fromValue(regionAttributes.getScope().toConfigTypeString()));
     }
 
     return regionConfig;
   }
 
-  private String int2string(Integer i) {
-    return Optional.ofNullable(i).map(j -> j.toString()).orElse(null);
+  public static RegionAttributesType.ExpirationAttributesType 
getExpirationAttributes(
+      ExpirationAttributes entryIdleTimeout, CustomExpiry<?, ?> 
customEntryIdleTimeout) {
+
+    if ((entryIdleTimeout == null || entryIdleTimeout.isDefault())
+        && customEntryIdleTimeout == null) {
+      return null;
+    }
+
+    if (entryIdleTimeout == null || entryIdleTimeout.isDefault()) {
+      return getExpirationAttributes(null, null,
+          new ClassName<>(customEntryIdleTimeout.getClass().getName()));
+    } else if (customEntryIdleTimeout == null) {
+      return getExpirationAttributes(entryIdleTimeout.getTimeout(), 
entryIdleTimeout.getAction(),
+          null);
+    } else {
+      return getExpirationAttributes(entryIdleTimeout.getTimeout(), 
entryIdleTimeout.getAction(),
+          new ClassName<>(customEntryIdleTimeout.getClass().getName()));
+    }
   }
 
-  private String long2string(Long i) {
-    return Optional.ofNullable(i).map(j -> j.toString()).orElse(null);
+  public static RegionAttributesType.ExpirationAttributesType 
getExpirationAttributes(
+      RegionFunctionArgs.ExpirationAttrs expirationAttrs, 
ClassName<CustomExpiry> customExpiry) {
+    if (expirationAttrs == null) {
+      return getExpirationAttributes(null, null, customExpiry);
+    } else {
+      return getExpirationAttributes(expirationAttrs.getTime(), 
expirationAttrs.getAction(),
+          customExpiry);
+    }
   }
 
-  private String getLeafRegion(String fullPath) {
-    String regionPath = fullPath;
-    String[] regions = regionPath.split("/");
+  public static RegionAttributesType.ExpirationAttributesType 
getExpirationAttributes(
+      Integer timeout, ExpirationAction action, ClassName<CustomExpiry> 
expiry) {
+    if (timeout == null && action == null && expiry == null) {
+      return null;
+    }
+    RegionAttributesType.ExpirationAttributesType attributesType =
+        new RegionAttributesType.ExpirationAttributesType();
 
-    return regions[regions.length - 1];
-  }
+    attributesType.setTimeout(Objects.toString(timeout, "0"));
+    if (action == null) {
+      action = ExpirationAction.INVALIDATE;
+    }
+    attributesType.setAction(action.toXmlString());
 
-  private void addAttribute(RegionConfig config, 
Consumer<RegionAttributesType> consumer) {
-    if (config.getRegionAttributes() == null) {
-      config.setRegionAttributes(new RegionAttributesType());
+    if (expiry != null) {
+      attributesType
+          .setCustomExpiry(new DeclarableType(expiry.getClassName(), 
expiry.getInitProperties()));
     }
 
-    consumer.accept(config.getRegionAttributes());
+    return attributesType;
   }
 
-  private Object getAttribute(RegionConfig config,
-      Function<RegionAttributesType, Object> function) {
-    if (config.getRegionAttributes() == null) {
-      return null;
-    }
 
-    return function.apply(config.getRegionAttributes());
+  private String getLeafRegion(String fullPath) {
+    String regionPath = fullPath;
+    String[] regions = regionPath.split("/");
+
+    return regions[regions.length - 1];
   }
 }
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionAlterFunction.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionAlterFunction.java
index d568041..b93e752 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionAlterFunction.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionAlterFunction.java
@@ -30,7 +30,6 @@ import org.apache.geode.cache.CustomExpiry;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.execute.ResultSender;
-import org.apache.geode.internal.ClassPathLoader;
 import org.apache.geode.internal.cache.AbstractRegion;
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.PartitionedRegion;
@@ -317,47 +316,6 @@ public class RegionAlterFunction implements 
InternalFunction {
     }
   }
 
-  @SuppressWarnings("unchecked")
-  private static <K> Class<K> forName(String classToLoadName, String 
neededFor) {
-    Class<K> loadedClass = null;
-    try {
-      // Set Constraints
-      ClassPathLoader classPathLoader = ClassPathLoader.getLatest();
-      if (classToLoadName != null && !classToLoadName.isEmpty()) {
-        loadedClass = (Class<K>) classPathLoader.forName(classToLoadName);
-      }
-    } catch (ClassNotFoundException e) {
-      throw new RuntimeException(
-          
CliStrings.format(CliStrings.ALTER_REGION__MSG__COULD_NOT_FIND_CLASS_0_SPECIFIED_FOR_1,
-              classToLoadName, neededFor),
-          e);
-    } catch (ClassCastException e) {
-      throw new RuntimeException(CliStrings.format(
-          
CliStrings.ALTER_REGION__MSG__CLASS_SPECIFIED_FOR_0_SPECIFIED_FOR_1_IS_NOT_OF_EXPECTED_TYPE,
-          classToLoadName, neededFor), e);
-    }
-
-    return loadedClass;
-  }
-
-  private static <K> K newInstance(Class<K> klass, String neededFor) {
-    K instance = null;
-    try {
-      instance = klass.newInstance();
-    } catch (InstantiationException e) {
-      throw new RuntimeException(CliStrings.format(
-          
CliStrings.ALTER_REGION__MSG__COULD_NOT_INSTANTIATE_CLASS_0_SPECIFIED_FOR_1, 
klass,
-          neededFor), e);
-    } catch (IllegalAccessException e) {
-      throw new RuntimeException(
-          
CliStrings.format(CliStrings.ALTER_REGION__MSG__COULD_NOT_ACCESS_CLASS_0_SPECIFIED_FOR_1,
-              klass, neededFor),
-          e);
-    }
-
-    return instance;
-  }
-
   @Override
   public String getId() {
     return RegionAlterFunction.class.getName();
diff --git 
a/geode-core/src/test/java/org/apache/geode/cache/configuration/CacheConfigTest.java
 
b/geode-core/src/test/java/org/apache/geode/cache/configuration/CacheConfigTest.java
index b15a95d..4dbc325 100644
--- 
a/geode-core/src/test/java/org/apache/geode/cache/configuration/CacheConfigTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/cache/configuration/CacheConfigTest.java
@@ -163,7 +163,7 @@ public class CacheConfigTest {
     
assertThat(regionAttributes.getCompressor().toString()).isEqualTo("my.className");
     
assertThat(regionAttributes.getCacheLoader()).isEqualTo(declarableWithString);
     
assertThat(regionAttributes.getCacheWriter()).isEqualTo(declarableWithString);
-    
assertThat(regionAttributes.getRegionTimeToLive().getExpirationAttributes().getCustomExpiry())
+    assertThat(regionAttributes.getRegionTimeToLive().getCustomExpiry())
         .isEqualTo(declarableWithString);
   }
 
@@ -184,4 +184,40 @@ public class CacheConfigTest {
     CacheConfig newCache = service.unMarshall(xml);
     
assertThat(cacheConfig).isEqualToComparingFieldByFieldRecursively(newCache);
   }
+
+  @Test
+  public void regionAttributeType() throws Exception {
+    String xml = "<region name=\"test\">\n"
+        + "        <region-attributes>\n"
+        + "            <region-time-to-live>\n"
+        + "                <expiration-attributes action=\"invalidate\" 
timeout=\"20\">\n"
+        + "                    <custom-expiry>\n"
+        + "                        <class-name>bar</class-name>\n"
+        + "                    </custom-expiry>\n"
+        + "                </expiration-attributes>\n"
+        + "            </region-time-to-live>\n"
+        + "            <entry-time-to-live>\n"
+        + "                <expiration-attributes action=\"destroy\" 
timeout=\"10\">\n"
+        + "                    <custom-expiry>\n"
+        + "                        <class-name>foo</class-name>\n"
+        + "                    </custom-expiry>\n"
+        + "                </expiration-attributes>\n"
+        + "            </entry-time-to-live>\n"
+        + "        </region-attributes>\n"
+        + "    </region>";
+
+    RegionConfig regionConfig = service.unMarshall(xml, RegionConfig.class);
+    RegionAttributesType.ExpirationAttributesType entryTimeToLive =
+        regionConfig.getRegionAttributes().getEntryTimeToLive();
+    assertThat(entryTimeToLive.getTimeout()).isEqualTo("10");
+    assertThat(entryTimeToLive.getAction()).isEqualTo("destroy");
+    
assertThat(entryTimeToLive.getCustomExpiry().getClassName()).isEqualTo("foo");
+    RegionAttributesType.ExpirationAttributesType regionTimeToLive =
+        regionConfig.getRegionAttributes().getRegionTimeToLive();
+    assertThat(regionTimeToLive.getTimeout()).isEqualTo("20");
+    assertThat(regionTimeToLive.getAction()).isEqualTo("invalidate");
+    
assertThat(regionTimeToLive.getCustomExpiry().getClassName()).isEqualTo("bar");
+
+    cacheConfig.getRegions().add(regionConfig);
+  }
 }
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/domain/RegionConfigFactoryTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/domain/RegionConfigFactoryTest.java
index 4eec7e5..4f4b45c 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/domain/RegionConfigFactoryTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/domain/RegionConfigFactoryTest.java
@@ -56,9 +56,9 @@ public class RegionConfigFactoryTest {
   }
 
   @Test
-  public void generatesNullWithNoAttributes() {
+  public void generatesNotNullWithNoAttributes() {
     RegionConfig config = subject.generate(args);
-    assertThat(config.getRegionAttributes()).isNull();
+    assertThat(config.getRegionAttributes()).isNotNull();
   }
 
   @Test
@@ -81,22 +81,22 @@ public class RegionConfigFactoryTest {
     args.setEntryIdleTimeCustomExpiry(new ClassName<>("java.lang.String"));
 
     RegionConfig config = subject.generate(args);
-    RegionAttributesType.RegionTimeToLive regionTimeToLive =
+    RegionAttributesType.ExpirationAttributesType regionTimeToLive =
         config.getRegionAttributes().getRegionTimeToLive();
-    
assertThat(regionTimeToLive.getExpirationAttributes().getTimeout()).isEqualTo("10");
+    assertThat(regionTimeToLive.getTimeout()).isEqualTo("10");
 
-    RegionAttributesType.EntryTimeToLive entryTimeToLive =
+    RegionAttributesType.ExpirationAttributesType entryTimeToLive =
         config.getRegionAttributes().getEntryTimeToLive();
-    assertThat(entryTimeToLive.getExpirationAttributes().getAction())
+    assertThat(entryTimeToLive.getAction())
         .isEqualTo(ExpirationAction.LOCAL_DESTROY.toXmlString());
 
-    RegionAttributesType.EntryIdleTime entryIdleTime =
+    RegionAttributesType.ExpirationAttributesType entryIdleTime =
         config.getRegionAttributes().getEntryIdleTime();
-    DeclarableType customExpiry = 
entryIdleTime.getExpirationAttributes().getCustomExpiry();
+    DeclarableType customExpiry = entryIdleTime.getCustomExpiry();
     assertThat(customExpiry.getClassName()).isEqualTo("java.lang.String");
-    assertThat(entryIdleTime.getExpirationAttributes().getAction())
+    assertThat(entryIdleTime.getAction())
         .isEqualTo(ExpirationAction.LOCAL_DESTROY.toXmlString());
-    assertThat(entryIdleTime.getExpirationAttributes().getTimeout())
+    assertThat(entryIdleTime.getTimeout())
         .isEqualTo("12");
   }
 

Reply via email to