com.vbs.spring.versioning
Class VersionDependentBean

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

public final class VersionDependentBean
extends java.lang.Object

Wrapper for each Spring bean annotated as a VersionDependentClass.

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

Constructor Summary
VersionDependentBean(java.lang.Object bean, java.lang.String beanName)
          Creates a wrapper for a Spring bean annotated as a VersionDependentClass.
 
Method Summary
(package private)  boolean checkDuplicateBeanType(VersionDependentBean other)
          Returns true if this bean is of the same underlying type as that of the other bean.
 boolean equals(java.lang.Object obj)
           
(package private)  java.lang.Object getBean()
          Returns the Spring bean.
 java.lang.String getBeanName()
          Returns the name of the bean within the application context.
 java.lang.String[] getImplementedVersions()
          Returns the array of version identifiers that this bean implements.
 java.lang.Class<?> getTargetClass()
          Returns the underlying class of the Spring bean.
 int hashCode()
           
 boolean isImplementationFor(java.lang.String versionedBeanName)
          Returns true if this is the version dependent implementation for the versioned bean, used when beans have been wired by name.
 boolean isImplementingVersion(java.lang.String activeVersion)
          Returns true if this implements the active version.
 boolean isUniqueForType()
          Returns true if this is the only bean configured for the bean's class.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VersionDependentBean

VersionDependentBean(java.lang.Object bean,
                     java.lang.String beanName)
Creates a wrapper for a Spring bean annotated as a VersionDependentClass.

Parameters:
bean - the Spring bean.
beanName - the name of the bean within the application context.
Method Detail

getImplementedVersions

public java.lang.String[] getImplementedVersions()
Returns the array of version identifiers that this bean implements.

Obtained from the VersionDependentClass annotation.

Returns:
the array of version identifiers that this bean implements.

getBean

java.lang.Object getBean()
Returns the Spring bean.

Returns:
the Spring bean.

getBeanName

public java.lang.String getBeanName()
Returns the name of the bean within the application context.

Returns:
the name of the bean within the application context.

getTargetClass

public java.lang.Class<?> getTargetClass()
Returns the underlying class of the Spring bean.

The bean may have been proxied or enhanced.

Returns:
the underlying class of the Spring bean.

checkDuplicateBeanType

boolean checkDuplicateBeanType(VersionDependentBean other)
Returns true if this bean is of the same underlying type as that of the other bean. If the types are the same, then the isUniqueForType method will return false.

Parameters:
other - another VersionDependentBean
Returns:
true if this bean is of the same underlying type as that of the other bean.

isUniqueForType

public boolean isUniqueForType()
Returns true if this is the only bean configured for the bean's class.

Returns:
true if this is the only bean configured for the bean's class.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isImplementationFor

public boolean isImplementationFor(java.lang.String versionedBeanName)
Returns true if this is the version dependent implementation for the versioned bean, used when beans have been wired by name.

If this implementation is for a single version, then the name of this bean must be of the format versionedBeanName + versionId.

If this implementation is for multiple versions, then the name of this bean must be of the format versionedBeanName + versionid1_versionid2 etc (each version being separated by an underscore).

Parameters:
versionedBeanName - the name of the versioned bean within the application context.
Returns:
true if this is the version dependent implementation for the versioned bean.

isImplementingVersion

public boolean isImplementingVersion(java.lang.String activeVersion)
Returns true if this implements the active version.

Parameters:
activeVersion - the active version.
Returns:
true if this implements the active version.