Class XmlMultiConfiguration

java.lang.Object
org.ehcache.xml.multi.XmlMultiConfiguration

public class XmlMultiConfiguration extends Object
A collection of multiple Ehcache configurations.
  • Method Details

    • configuration

      public org.ehcache.config.Configuration configuration(String identity) throws IllegalArgumentException
      Retrieve the singular configuration for identity.

      If the given identity is associated with multiple variant configurations then an IllegalStateException will be thrown. In this case the configuration(String, String) method must be used to select a specific variant.

      Parameters:
      identity - identity to retrieve
      Returns:
      the configuration for the given identity; null if the identity is not in this configuration
      Throws:
      IllegalArgumentException - if the identity is associated with multiple variant configurations
    • configuration

      public org.ehcache.config.Configuration configuration(String identity, String variant)
      Retrieve the singular configuration for identity and variant.

      If the given identity is associated only with a singular configuration then that configuration will be returned for all variants.

      Parameters:
      identity - identity to retrieve
      variant - variant to retrieve
      Returns:
      the configuration for the given identity; null if the identity is not in this configuration
      Throws:
      IllegalArgumentException - if the given variant does not exist
    • variants

      public Set<String> variants(String identity) throws IllegalArgumentException
      Return the set of variants defined for the given configuration.

      If the given identity does not exist then an IllegalArgumentException is thrown. If the given identity is not variant-ed then an empty set is returned.

      Returns:
      the set of variants; possibly empty.
      Throws:
      IllegalArgumentException - if the identity does not exist
    • identities

      public Set<String> identities()
      Return the set of identities defined in this multi-configuration.
      Returns:
      the defined identity set
    • asDocument

      public Document asDocument()
      Return this configuration as an XML Document.
      Returns:
      configuration XML DOM.
    • asRenderedDocument

      public String asRenderedDocument()
      Return this configuration as a rendered XML string.
      Returns:
      configuration XML string
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • from

      public static XmlMultiConfiguration.Builder from(URL xml)
      Create a builder seeded from an XML configuration.

      Enclosed configurations will parsed using XmlConfiguration(Document).

      Parameters:
      xml - xml seed resource
      Returns:
      a builder seeded with the xml configuration
      See Also:
    • from

      public static XmlMultiConfiguration.Builder from(URL xml, ClassLoader classLoader)
      Create a builder seeded from an XML configuration using the supplier class loader.

      Enclosed configurations will parsed using XmlConfiguration(Document, ClassLoader), which will be passed the classloader provided to this method.

      Parameters:
      xml - xml seed resource
      classLoader - loader for the cache managers
      Returns:
      a builder seeded with the xml configuration
      See Also:
    • from

      Create a builder seeded from an existing XmlMultiConfiguration.
      Parameters:
      config - existing configuration seed
      Returns:
      a builder seeded with the xml configuration
    • fromNothing

      public static XmlMultiConfiguration.Builder fromNothing()
      Create an initially empty builder.
      Returns:
      an empty builder