Class SimpleMetadataReaderFactory
- java.lang.Object
- org.springframework.core.type.classreading.SimpleMetadataReaderFactory
- All Implemented Interfaces:
MetadataReaderFactory
- Direct Known Subclasses:
CachingMetadataReaderFactory
public class SimpleMetadataReaderFactory extends Object implements MetadataReaderFactory
Simple implementation of theMetadataReaderFactory
interface, creating a new ASMClassReader
for every request.- Since:
- 2.5
- Author:
- Juergen Hoeller
Constructor Summary
Constructors Constructor Description SimpleMetadataReaderFactory()
Create a new SimpleMetadataReaderFactory for the default class loader.SimpleMetadataReaderFactory(ClassLoader classLoader)
Create a new SimpleMetadataReaderFactory for the given class loader.SimpleMetadataReaderFactory(ResourceLoader resourceLoader)
Create a new SimpleMetadataReaderFactory for the given resource loader.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MetadataReader
getMetadataReader(String className)
Obtain a MetadataReader for the given class name.MetadataReader
getMetadataReader(Resource resource)
Obtain a MetadataReader for the given resource.ResourceLoader
getResourceLoader()
Return the ResourceLoader that this MetadataReaderFactory has been constructed with.
Constructor Detail
SimpleMetadataReaderFactory
public SimpleMetadataReaderFactory()
Create a new SimpleMetadataReaderFactory for the default class loader.
SimpleMetadataReaderFactory
public SimpleMetadataReaderFactory(@Nullable ResourceLoader resourceLoader)
Create a new SimpleMetadataReaderFactory for the given resource loader.- Parameters:
resourceLoader
- the Spring ResourceLoader to use (also determines the ClassLoader to use)
SimpleMetadataReaderFactory
public SimpleMetadataReaderFactory(@Nullable ClassLoader classLoader)
Create a new SimpleMetadataReaderFactory for the given class loader.- Parameters:
classLoader
- the ClassLoader to use
Method Detail
getResourceLoader
public final ResourceLoader getResourceLoader()
Return the ResourceLoader that this MetadataReaderFactory has been constructed with.
getMetadataReader
public MetadataReader getMetadataReader(String className) throws IOException
Description copied from interface:MetadataReaderFactory
Obtain a MetadataReader for the given class name.- Specified by:
getMetadataReader
in interfaceMetadataReaderFactory
- Parameters:
className
- the class name (to be resolved to a ".class" file)- Returns:
- a holder for the ClassReader instance (never
null
) - Throws:
IOException
- in case of I/O failure
getMetadataReader
public MetadataReader getMetadataReader(Resource resource) throws IOException
Description copied from interface:MetadataReaderFactory
Obtain a MetadataReader for the given resource.- Specified by:
getMetadataReader
in interfaceMetadataReaderFactory
- Parameters:
resource
- the resource (pointing to a ".class" file)- Returns:
- a holder for the ClassReader instance (never
null
) - Throws:
IOException
- in case of I/O failure