com.vbs.spring.versioning
Class VersionDependentBeanResolver

java.lang.Object
  extended by com.vbs.spring.versioning.VersionDependentBeanResolver

public final class VersionDependentBeanResolver
extends java.lang.Object

Resolves a VersionedBean instance to it's VersionDependentBean delegate if registered.

Any beans the are either versioned (annotated by the VersionedClass class) or version dependent (annotated by the VersionDependentClass class) other than prototype beans are registered.

An IllegalStateException is thrown if the annotations associated with the bean are invalid. This will be the case if:

Once the application context is fully loaded, the registered beans are validated and VersionDependentBean attached to their associated VersionedBean instance.

Protoype beans (and hence inner beans) are not supported by versioning. If such a VersionedBean instance is found, an INFO log will be written and the bean will be ignored for versioning purposes.

A given version can only be implemented by one dependent bean attached to a given VersionedBean. An IllegalStateException will be thrown if multiple dependent beans implement the same version.

Author:
Mike Whitfield (mike@virtual-businesses.com)

Constructor Summary
VersionDependentBeanResolver()
           
 
Method Summary
(package private)  void checkForVersioningAwareBean(java.lang.Object bean, java.lang.String beanName)
          Registers each bean that is annotated by VersionedClass or VersionDependentClass.
(package private)  java.lang.Object getVersionDependentBean(java.lang.Object bean, java.lang.Class<?> versionedClass, java.lang.String activeVersion)
          Returns the version dependent instance for the intercepted bean, or null if no such bean was found.
 void onContextRefresh(org.springframework.context.ApplicationContext context)
          On receipt of a ContextRefreshedEvent, the registered beans are validated and VersionDependentBean attached to their associated VersionedBean instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersionDependentBeanResolver

VersionDependentBeanResolver()
Method Detail

checkForVersioningAwareBean

void checkForVersioningAwareBean(java.lang.Object bean,
                                 java.lang.String beanName)
Registers each bean that is annotated by VersionedClass or VersionDependentClass.

Parameters:
bean - the candidate bean.
beanName - the name of the bean.

onContextRefresh

public void onContextRefresh(org.springframework.context.ApplicationContext context)
On receipt of a ContextRefreshedEvent, the registered beans are validated and VersionDependentBean attached to their associated VersionedBean instance.


getVersionDependentBean

java.lang.Object getVersionDependentBean(java.lang.Object bean,
                                         java.lang.Class<?> versionedClass,
                                         java.lang.String activeVersion)
Returns the version dependent instance for the intercepted bean, or null if no such bean was found.

This will be the case if the bean was identified as a prototype, not supported by versioning.

Parameters:
bean - the intercepted bean or it's proxy.
versionedClass - the target class of the intercepted bean.
activeVersion - the currently active version which must not be null.
Returns:
the version dependent bean, or null if no such bean was found.