Class ConcurrentReferenceCachingMetadataReaderFactory

java.lang.Object
org.springframework.core.type.classreading.SimpleMetadataReaderFactory
org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory
All Implemented Interfaces:
org.springframework.core.type.classreading.MetadataReaderFactory

public class ConcurrentReferenceCachingMetadataReaderFactory extends org.springframework.core.type.classreading.SimpleMetadataReaderFactory
Caching implementation of the MetadataReaderFactory interface backed by a ConcurrentReferenceHashMap, caching MetadataReader per Spring Resource handle (i.e. per ".class" file).
Since:
1.4.0
See Also:
  • CachingMetadataReaderFactory
  • Constructor Details

    • ConcurrentReferenceCachingMetadataReaderFactory

      public ConcurrentReferenceCachingMetadataReaderFactory()
      Create a new ConcurrentReferenceCachingMetadataReaderFactory instance for the default class loader.
    • ConcurrentReferenceCachingMetadataReaderFactory

      public ConcurrentReferenceCachingMetadataReaderFactory(org.springframework.core.io.ResourceLoader resourceLoader)
      Create a new ConcurrentReferenceCachingMetadataReaderFactory instance for the given resource loader.
      Parameters:
      resourceLoader - the Spring ResourceLoader to use (also determines the ClassLoader to use)
    • ConcurrentReferenceCachingMetadataReaderFactory

      public ConcurrentReferenceCachingMetadataReaderFactory(ClassLoader classLoader)
      Create a new ConcurrentReferenceCachingMetadataReaderFactory instance for the given class loader.
      Parameters:
      classLoader - the ClassLoader to use
  • Method Details

    • getMetadataReader

      public org.springframework.core.type.classreading.MetadataReader getMetadataReader(org.springframework.core.io.Resource resource) throws IOException
      Specified by:
      getMetadataReader in interface org.springframework.core.type.classreading.MetadataReaderFactory
      Overrides:
      getMetadataReader in class org.springframework.core.type.classreading.SimpleMetadataReaderFactory
      Throws:
      IOException
    • createMetadataReader

      protected org.springframework.core.type.classreading.MetadataReader createMetadataReader(org.springframework.core.io.Resource resource) throws IOException
      Create the meta-data reader.
      Parameters:
      resource - the source resource.
      Returns:
      the meta-data reader
      Throws:
      IOException - on error
    • clearCache

      public void clearCache()
      Clear the entire MetadataReader cache, removing all cached class metadata.