Spring BlazeDS Integration

org.springframework.flex.core.io
Class ClassPathScanningAmfConversionServiceConfigProcessor

java.lang.Object
  extended by org.springframework.flex.core.io.AbstractAmfConversionServiceConfigProcessor
      extended by org.springframework.flex.core.io.ClassPathScanningAmfConversionServiceConfigProcessor
All Implemented Interfaces:
BeanClassLoaderAware, InitializingBean, ResourceLoaderAware, MessageBrokerConfigProcessor

public class ClassPathScanningAmfConversionServiceConfigProcessor
extends AbstractAmfConversionServiceConfigProcessor
implements ResourceLoaderAware, BeanClassLoaderAware

Generic extension of AbstractAmfConversionServiceConfigProcessor that configures the Spring ConversionService-based AMF serialization/deserialization support via classpath scanning.

This implementation will recursively scan for classes starting with the base package provided in the constructor. By default, a SpringPropertyProxy will be registered for every class found in the scan.

The scanning process may be more finely tuned by providing TypeFilter implementations to be used in including and excluding specific classes. For example, you can filter by RegEx patterns, custom annotations, or anything else that can be used for matching in a TypeFilter.

This implementation does not register any additional Converters beyond those registered in the parent class. Additional TypeConverters may be registered by extending this class and overriding configureConverters.

The implementation is heavily derived from ClassPathScanningCandidateComponentProvider.

Author:
Jeremy Grelle

Field Summary
 
Fields inherited from class org.springframework.flex.core.io.AbstractAmfConversionServiceConfigProcessor
log
 
Constructor Summary
ClassPathScanningAmfConversionServiceConfigProcessor(String basePackage)
          Create a ClassPathScanningAmfConversionServiceConfigProcessor
 
Method Summary
 void addExcludeFilter(TypeFilter excludeFilter)
          Add an exclude type filter to the front of the exclusion list.
 void addIncludeFilter(TypeFilter includeFilter)
          Add an include type filter to the end of the inclusion list.
 void afterPropertiesSet()
          
protected  boolean applyFilters(MetadataReader metadataReader)
          Determine whether the given class does not match any exclude filter and does match at least one include filter.
protected  Set<Class<?>> findTypesToRegister()
          Returns the set of types for which SpringPropertyProxy instances should be registered.
 ResourceLoader getResourceLoader()
          Return the ResourceLoader used in locating matching resources.
protected  boolean isCandidateForAmf(AnnotationMetadata metadata)
          Determine whether the given class qualifies for AMF conversion The default implementation checks whether the class is concrete (i.e. not abstract and not an interface).
protected  String resolveBasePackage(String basePackage)
          Resolve the specified base package into a pattern specification for the package search path.
 void setBeanClassLoader(ClassLoader classLoader)
          
 void setExcludeFilters(List<TypeFilter> excludeFilters)
          Sets the list of type filters to use for exclusion.
 void setIncludeFilters(List<TypeFilter> includeFilters)
          Sets the list of type filters to use for inclusion.
 void setResourceLoader(ResourceLoader resourceLoader)
          Set the ResourceLoader to use for resource locations.
 void setResourcePattern(String resourcePattern)
          Set the resource pattern to use when scanning the classpath.
 
Methods inherited from class org.springframework.flex.core.io.AbstractAmfConversionServiceConfigProcessor
configureConverters, processAfterStartup, processBeforeStartup, registerAmfProxies, registerPropertyProxy, setConversionService, setUseDirectFieldAccess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassPathScanningAmfConversionServiceConfigProcessor

public ClassPathScanningAmfConversionServiceConfigProcessor(String basePackage)
Create a ClassPathScanningAmfConversionServiceConfigProcessor

Parameters:
basePackage - the base package to scan for classes to be registered for AMF serialization/deserialization
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception

Specified by:
afterPropertiesSet in interface InitializingBean
Overrides:
afterPropertiesSet in class AbstractAmfConversionServiceConfigProcessor
Throws:
Exception

setBeanClassLoader

public void setBeanClassLoader(ClassLoader classLoader)

Specified by:
setBeanClassLoader in interface BeanClassLoaderAware

setResourceLoader

public void setResourceLoader(ResourceLoader resourceLoader)
Set the ResourceLoader to use for resource locations. This will typically be a ResourcePatternResolver implementation.

Default is PathMatchingResourcePatternResolver, also capable of resource pattern resolving through the ResourcePatternResolver interface.

Specified by:
setResourceLoader in interface ResourceLoaderAware
See Also:
ResourcePatternResolver, PathMatchingResourcePatternResolver

getResourceLoader

public final ResourceLoader getResourceLoader()
Return the ResourceLoader used in locating matching resources.


setResourcePattern

public void setResourcePattern(String resourcePattern)
Set the resource pattern to use when scanning the classpath. This value will be appended to each base package name.

See Also:
findTypesToRegister(), DEFAULT_RESOURCE_PATTERN

setIncludeFilters

public void setIncludeFilters(List<TypeFilter> includeFilters)
Sets the list of type filters to use for inclusion.


setExcludeFilters

public void setExcludeFilters(List<TypeFilter> excludeFilters)
Sets the list of type filters to use for exclusion.


addIncludeFilter

public void addIncludeFilter(TypeFilter includeFilter)
Add an include type filter to the end of the inclusion list.


addExcludeFilter

public void addExcludeFilter(TypeFilter excludeFilter)
Add an exclude type filter to the front of the exclusion list.


findTypesToRegister

protected Set<Class<?>> findTypesToRegister()
Returns the set of types for which SpringPropertyProxy instances should be registered.

Specified by:
findTypesToRegister in class AbstractAmfConversionServiceConfigProcessor
Returns:
the set of types to register

resolveBasePackage

protected String resolveBasePackage(String basePackage)
Resolve the specified base package into a pattern specification for the package search path.

The default implementation resolves placeholders against system properties, and converts a "."-based package path to a "/"-based resource path.

Parameters:
basePackage - the base package as specified by the user
Returns:
the pattern specification to be used for package searching

applyFilters

protected boolean applyFilters(MetadataReader metadataReader)
                        throws IOException
Determine whether the given class does not match any exclude filter and does match at least one include filter.

Parameters:
metadataReader - the ASM ClassReader for the class
Returns:
whether the class passes the configured filters
Throws:
IOException

isCandidateForAmf

protected boolean isCandidateForAmf(AnnotationMetadata metadata)
Determine whether the given class qualifies for AMF conversion

The default implementation checks whether the class is concrete (i.e. not abstract and not an interface). Can be overridden in subclasses.

Parameters:
metadata - the metadata for the class to check
Returns:
whether the class qualifies for AMF conversion

Spring BlazeDS Integration

Copyright © 2011. All Rights Reserved.