Class ScopedCacheFactoryBuilder

    • Field Detail

      • f_scopeResolver

        protected final ScopeResolver f_scopeResolver
        Scope resolver used to resolve scope name upon CCF construction.
      • m_mapByLoader

        protected Map<ClassLoader,​Map<String,​ConfigurableCacheFactory>> m_mapByLoader
        Mapping used to associate class loaders with the cache factories that are configured on them. The map is (weakly) keyed by class loader instances and holds a maps of URI to ConfigurableCacheFactory as a values (e.g. Map<ClassLoader, Map<URI, ConfigurableCacheFactory>>).
      • m_mapConfigByLoader

        protected Map<ClassLoader,​Map<URI,​XmlElement>> m_mapConfigByLoader
        Mapping used to associate class loaders with specific configuration elements. The map is (weakly) keyed by class loader instances and holds a map of URL to XmlElement as values.
    • Constructor Detail

      • ScopedCacheFactoryBuilder

        public ScopedCacheFactoryBuilder()
        Default constructor; reads scope resolver configuration from operational configuration file (tangosol-coherence.xml).
      • ScopedCacheFactoryBuilder

        public ScopedCacheFactoryBuilder​(ScopeResolver resolver)
        Constructor to provide a custom scope resolver.
        Parameters:
        resolver - scope resolver
    • Method Detail

      • getScopeResolver

        public ScopeResolver getScopeResolver()
        Obtain the scope resolver for this builder.
        Returns:
        scope resolver
      • getConfigurableCacheFactory

        public ConfigurableCacheFactory getConfigurableCacheFactory​(ClassLoader loader)
        Return the default ConfigurableCacheFactory for a given class loader.
        Specified by:
        getConfigurableCacheFactory in interface CacheFactoryBuilder
        Parameters:
        loader - class loader for which the configuration should be used; must not be null
        Returns:
        the default ConfigurableCacheFactory for a given class loader
      • getConfigurableCacheFactory

        public ConfigurableCacheFactory getConfigurableCacheFactory​(String sConfigURI,
                                                                    ClassLoader loader)
        Return the ConfigurableCacheFactory for a given URI and class loader.
        Specified by:
        getConfigurableCacheFactory in interface CacheFactoryBuilder
        Parameters:
        sConfigURI - the configuration URI; must not be null
        loader - class loader for which the configuration should be used; must not be null
        Returns:
        the ConfigurableCacheFactory for a given URI and class loader
      • getConfigurableCacheFactory

        public ConfigurableCacheFactory getConfigurableCacheFactory​(String sConfigURI,
                                                                    ClassLoader loader,
                                                                    ParameterResolver resolver)
        Return the ConfigurableCacheFactory for a given URI and class loader.
        Specified by:
        getConfigurableCacheFactory in interface CacheFactoryBuilder
        Parameters:
        sConfigURI - the configuration URI; must not be null
        loader - class loader for which the configuration should be used; must not be null
        resolver - the optional ParameterResolver to use to resolve configuration parameters
        Returns:
        the ConfigurableCacheFactory for a given URI and class loader
      • setCacheConfiguration

        public void setCacheConfiguration​(ClassLoader loader,
                                          XmlElement xmlConfig)
        Dynamically set the default cache configuration for a given class loader. If a ConfigurableCacheFactory for the given class loader already exists, the factory will be released.
        Specified by:
        setCacheConfiguration in interface CacheFactoryBuilder
        Parameters:
        loader - class loader for which the configuration should be used; must not be null
        xmlConfig - cache configuration in xml element format
      • setCacheConfiguration

        public void setCacheConfiguration​(String sConfigURI,
                                          ClassLoader loader,
                                          XmlElement xmlConfig)
        Dynamically set the cache configuration for a given URI and class loader. If a ConfigurableCacheFactory for the given URI and class loader already exists, the factory will be released.
        Specified by:
        setCacheConfiguration in interface CacheFactoryBuilder
        Parameters:
        sConfigURI - the configuration URI; must not be null
        loader - class loader for which the configuration should be used; must not be null
        xmlConfig - cache configuration in xml element format
      • setConfigurableCacheFactory

        public ConfigurableCacheFactory setConfigurableCacheFactory​(ConfigurableCacheFactory ccf,
                                                                    String sConfigURI,
                                                                    ClassLoader loader,
                                                                    boolean fReplace)
        Dynamically set the ConfigurableCacheFactory for a given URI and class loader. If a ConfigurableCacheFactory for the given URI and class loader already exists and the replacement is requested, the factory will be released.
        Specified by:
        setConfigurableCacheFactory in interface CacheFactoryBuilder
        Parameters:
        ccf - the ConfigurableCacheFactory instance
        sConfigURI - the configuration URI; must not be null
        loader - class loader for which the configuration should be used; must not be null
        fReplace - specifies whether to replace a ConfigurableCacheFactory if one is already registered
        Returns:
        the previous ConfigurableCacheFactory associated with the URI and loader, if any
      • releaseAll

        public void releaseAll​(ClassLoader loader)
        Release all ConfigurableCacheFactory objects for a given ClassLoader.
        Specified by:
        releaseAll in interface CacheFactoryBuilder
        Parameters:
        loader - the class loader for which all associated cache factories should be released
      • instantiateScopeResolver

        protected ScopeResolver instantiateScopeResolver()
        Instantiate the default ScopeResolver.

        If the the scope-resolver element of the cache-factory-builder element of the operational configuration has been specified this will be used to determine the ScopeResolver implementation to use otherwise the NullImplementation resolver will be used.

        Returns:
        the default ScopeResolver
      • ensureConfigCCFMap

        protected Map<String,​ConfigurableCacheFactory> ensureConfigCCFMap​(ClassLoader loader)
        Ensure that a map from URI to ConfigurableCacheFactory for the specified loader exists (creating it if necessary).
        Parameters:
        loader - the class loader to which the map corresponds
        Returns:
        a map from URI to ConfigurableCacheFactory
      • ensureConfigMap

        protected Map<URI,​XmlElement> ensureConfigMap​(ClassLoader loader)
        Ensure that a map from URL to ConfigurableCacheFactory for the specified loader exists (creating it if necessary).
        Parameters:
        loader - the class loader to which the map corresponds
        Returns:
        a Map from URL to ConfigurableCacheFactory
      • getXmlConfig

        protected XmlElement getXmlConfig​(ClassLoader loader,
                                          URL url)
        Return the XML config relating to the provided ClassLoader and URL, or null.
        Parameters:
        loader - the ClassLoader the XML was registered with
        url - the URL the XML was registered with
        Returns:
        the XML config relating to the provided ClassLoader and URL, or null
      • setXmlConfig

        protected void setXmlConfig​(ClassLoader loader,
                                    URL url,
                                    XmlElement xml)
        Register the provided XML config with the ClassLoader and URL.
        Parameters:
        loader - the ClassLoader the XML is to be registered with
        url - the URL the XML is to be registered with
        xml - the XML config to register
      • loadConfigFromURI

        protected XmlElement loadConfigFromURI​(String sConfigURI,
                                               ClassLoader loader)
        Load the XML configuration from the specified URI.
        Parameters:
        sConfigURI - the configuration URI; must not be null
        loader - class loader to use
        Returns:
        the XML configuration, or null if the config could not be loaded
      • getConfigurableCacheFactoryConfig

        protected XmlElement getConfigurableCacheFactoryConfig()
        Return the XML configuration used for the construction of a ConfigurableCacheFactory.
        Returns:
        the XmlElement that contains construction configuration
      • resolveURI

        protected String resolveURI​(String sConfigURI)
        Resolve the URI that identifies the cache configuration. The URI provided may be a normal URL or Resource, or it may be a "special" default URI that is used when a specific cache configuration file is not indicated (for example, if the user requests a factory via CacheFactory.getConfigurableCacheFactory(). If the "default" URI is requested, the URI is resolved to the default cache configuration name indicated in the operational configuration file; otherwise the provided URI is returned.
        Parameters:
        sConfigURI - the passed in URI
        Returns:
        the resolved URI
        See Also:
        CacheFactoryBuilder.URI_DEFAULT
      • resolveURL

        protected URL resolveURL​(String sConfigURI,
                                 ClassLoader loader)
        Resolve the URL based on the provided configuration URI. The resolution consists of locating the URI as a resource or a file and the creation of a corresponding URL. If the URI cannot be located, a "placeholder" file URL will be created.
        Parameters:
        sConfigURI - the configuration URI to make a URL out of
        loader - the ClassLoader to use
        Returns:
        a URL for the resource