Package org.springframework.core.type.classreading

# 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 the `MetadataReaderFactory` interface, creating a new ASM `ClassReader` 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

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.
`final ResourceLoader`
`getResourceLoader()`
Return the ResourceLoader that this MetadataReaderFactory has been constructed with.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### 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 Details

### 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 interface `MetadataReaderFactory`
Parameters:
  `className` - the class name (to be resolved to a ".class" file)
Returns:
  a holder for the ClassReader instance (never `null`)
Throws:
  `ClassFormatException` - in case of an incompatible class format
  `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 interface `MetadataReaderFactory`
Parameters:
  `resource` - the resource (pointing to a ".class" file)
Returns:
  a holder for the ClassReader instance (never `null`)
Throws:
  `ClassFormatException` - in case of an incompatible class format
  `IOException` - in case of I/O failure