Class ResourceMapping

  • Direct Known Subclasses:
    CacheMapping, TopicMapping

    public abstract class ResourceMapping
    extends Object
    A base class for mapping elements.
    Since:
    Coherence 14.1.1
    Author:
    jk 2015.05.21
    • Constructor Detail

      • ResourceMapping

        public ResourceMapping​(String sNamePattern,
                               String sSchemeName)
        Construct a ResourceMapping for resources that will use raw types by default.
        Parameters:
        sNamePattern - the pattern that maps resource names to caching schemes
        sSchemeName - the name of the caching scheme to which a resource matching this ResourceMapping will be associated
    • Method Detail

      • getConfigElementName

        public abstract String getConfigElementName()
        Obtain the xml element name of this mapping.
        Returns:
        the xml element name of this mapping
      • validateScheme

        public abstract void validateScheme​(Scheme scheme)
        Determine whether the specified schem is valid for this mapping type.
        Parameters:
        scheme - the scheme to validate
        Throws:
        IllegalStateException - if the scheme is not valid
      • setInternal

        public ResourceMapping setInternal​(boolean fInternal)
        Set the flag to indicate if this mapping is for internal resources used by the service.
        Parameters:
        fInternal - true if this is for internal resource
        Returns:
        this ResourceMapping object
      • isInternal

        public boolean isInternal()
        Check if this ResourceMapping is for internal resources.
        Returns:
        true if this is for internal resources
      • getNamePattern

        public String getNamePattern()
        Obtains the pattern used to match resource names to this ResourceMapping.
        Returns:
        the pattern
      • getSchemeName

        public String getSchemeName()
        Obtains the name of the caching scheme to be used that match this ResourceMapping.
        Returns:
        the name of the associated caching scheme
      • isForName

        public boolean isForName​(String sName)
        Determines if the ResourceMapping is for (matches) the specified resource name.
        Parameters:
        sName - the resource name to check for a match
        Returns:
        true if the ResourceMapping is for the specified resource name, false otherwise
      • usesWildcard

        public boolean usesWildcard()
        Determines if the ResourceMapping pattern contains a * wildcard.
        Returns:
        true if the pattern contains a * wildcard, false otherwise
      • getWildcardMatch

        public String getWildcardMatch​(String sName)
        Determines the value the wildcard * declared in the resource name pattern for the ResourceMapping matches. If the pattern does not contain a wildcard * or the resource name does not match the mapping, null is returned.

        Examples:

        1. Calling mapping.getWildcardMatch("dist-test") on a ResourceMapping with the resource name pattern "dist-*" will return "test".

        2. Calling mapping.getWildcardMatch("dist-*") on a ResourceMapping with the resource name pattern "dist-*" will return "*".

        3. Calling mapping.getWildcardMatch("dist-fred") on a ResourceMapping with the resource name pattern "dist-fred" will return null.

        4. Calling mapping.getWildcardMatch("dist-fred") on a ResourceMapping with the resource name pattern "repl-*" will return null.

        5. Calling mapping.getWildcardMatch("dist-fred") on a ResourceMapping with the resource name pattern "*" will return "dist-fred".

        Parameters:
        sName - the resource name to match
        Returns:
        the resource name string that matches the wildcard.
      • getValue

        public <T> T getValue​(String sParamName,
                              Class<T> paramValueType)
        Get value of sParamName associated with this CacheMapping
        Type Parameters:
        T - parameter value type
        Parameters:
        sParamName - parameter name to look up
        paramValueType - parameter value type
        Returns:
        parameter value as an instance of paramValueType or null if parameter is not defined
      • getValue

        public Object getValue​(String sParamName)
        Get value of sParamName associated with this CacheMapping
        Parameters:
        sParamName - parameter name to look up
        Returns:
        parameter value or null if parameter is not found
      • getNameUsing

        public String getNameUsing​(String sWildCardValue)
        Determines the name of a resource given a value for the wildcard (assuming the resource name pattern for the mapping is using a wildcard). If the pattern does not contain a wildcard *, null will be returned.

        Examples:

        1. Calling mapping.getNameUsing("test") on a ResourceMapping with the resource name pattern "dist-*" will return "dist-test".

        2. Calling mapping.getNameUsing("*") on a ResourceMapping with the resource name pattern "dist-*" will return "dist-*".

        3. Calling mapping.getNameUsing("fred") on a ResourceMapping with the resource name pattern "dist-fred" will return null.

        4. Calling mapping.getNameUsing("dist-fred") on a ResourceMapping with the resource name pattern "*" will return "dist-fred".

        Parameters:
        sWildCardValue - the value to replace the wildcard * with
        Returns:
        the resource name with the wildcard replaced with the specified value
      • getSubMappings

        public List<ResourceMapping> getSubMappings()
        Obtain the list of sub-mappings that this mapping contains
        Returns:
        the list of sub-mappings that this mapping contains.