gnu.beanfactory
Class BeanDefinitionImpl

java.lang.Object
  |
  +--gnu.beanfactory.BeanDefinitionImpl
All Implemented Interfaces:
BeanDefinition

public final class BeanDefinitionImpl
extends java.lang.Object
implements BeanDefinition

Defines the URL, class name, scope and initial properties for a bean. All beans that are instantiated through the BeanFactory framework must be defined by an instance of this class. This class in instantiated by a DefinitionLoader instance.

Normal use of the BeanFactory framework should not involve direct interaction with this class. However, its implementation allows instances to be safely exposed in an immutable manner.

Version:
$Id: BeanDefinitionImpl.java,v 1.9 2001/10/09 02:55:17 rschoening Exp $
Author:
Rob Schoening <rob@beanfactory.net>
See Also:
DefinitionLoader

Constructor Summary
BeanDefinitionImpl()
           
 
Method Summary
 void assertMutable()
          Asserts that the bean definition has not been frozen.
 BeanDefinition copy()
           
 boolean equals(java.lang.Object obj)
          Determines whether two bean definitions define the same instance.
 long getAccessCount()
          Gives an approximate number of times that this bean has been requested.
 BeanSetter getBeanSetter()
          Obtains a BeanSetter instance for the current bean.
 java.lang.ClassLoader getClassLoader()
           
 java.lang.String getClassName()
          Obtains the fully qualified class name for this definition.
 java.lang.Class getClazz()
          Get the class definition for this bean.
 java.lang.String getDelimiter()
           
 java.lang.String getName()
          Obtains the URL for this definition.
 java.util.Properties getOriginalProperties()
           
 java.lang.String getParent()
          Obtains the URL of this definition's "parent".
 java.util.Set getPropertyNames()
          Obtains a set of property names (Strings) defined for this bean.
 java.lang.String getPropertyValue(java.lang.String name)
          Obtains the String value for a particular property.
 int getScopeCode()
          Obtains the int code for this definition's scope.
 java.lang.String getScopeName()
          Obtains the name of this definition's defined scope.
 boolean getStartup()
          Boolean flag indicating whether this bean will be loaded when the BeanFactory container is initialzied.
 java.lang.String getURL()
          Obtains the URL for this definition.
 int hashCode()
          Computes hashcode based on the definition's URL.
 void inherit(DefinitionLoader dl, java.util.Set set)
           
 boolean isMutable()
           
 boolean isScopeExplicit()
          Returns true if the scope has been explicitly set.
 boolean isScopeJ2EE()
          Returns true if the scope is: application, session, or request.
 boolean isValid()
          Returns true if this BeanDefinition has been validated.
 void setClassLoader(java.lang.ClassLoader cl)
           
 void setClassName(java.lang.String className)
          Sets the class name for this definition.
 void setDelimiter(java.lang.String s)
           
 void setName(java.lang.String urn)
          Set the URL for the bean.
 void setParent(java.lang.String parentURL)
          Sets the parent URL.
 void setProperty(java.lang.String propertyName, java.lang.String propertyValue)
          Sets the value of a particular property.
 void setScopeName(java.lang.String scopeName)
          Sets the named scope.
 void setStartup(boolean startup)
           
 java.lang.String toString()
           
 void validate(DefinitionLoader dl)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BeanDefinitionImpl

public BeanDefinitionImpl()
Method Detail

isValid

public boolean isValid()
Description copied from interface: BeanDefinition
Returns true if this BeanDefinition has been validated.
Specified by:
isValid in interface BeanDefinition

getAccessCount

public long getAccessCount()
Gives an approximate number of times that this bean has been requested.

getPropertyNames

public java.util.Set getPropertyNames()
Obtains a set of property names (Strings) defined for this bean.
Specified by:
getPropertyNames in interface BeanDefinition
Following copied from interface: gnu.beanfactory.BeanDefinition
Returns:
java.util.Set containing property names to be initialized

getPropertyValue

public java.lang.String getPropertyValue(java.lang.String name)
Obtains the String value for a particular property. Will return null if the property does not exist or is null.
Specified by:
getPropertyValue in interface BeanDefinition

setProperty

public void setProperty(java.lang.String propertyName,
                        java.lang.String propertyValue)
Sets the value of a particular property. The value may be null.
Parameters:
propertyName - property name (following JavaBean naming conventions)
propertyValue - string representation of the bean property value

hashCode

public int hashCode()
Computes hashcode based on the definition's URL. Tolerates null URL.
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Determines whether two bean definitions define the same instance. Comparison is done on the definition's URL only.
Overrides:
equals in class java.lang.Object

getName

public java.lang.String getName()
Obtains the URL for this definition.
Specified by:
getName in interface BeanDefinition

getURL

public java.lang.String getURL()
Obtains the URL for this definition.
Specified by:
getURL in interface BeanDefinition

getScopeCode

public int getScopeCode()
Obtains the int code for this definition's scope. Valid values are defined as static members of gnu.beanfactory.BeanContext.
Specified by:
getScopeCode in interface BeanDefinition
See Also:
BeanContext

getScopeName

public java.lang.String getScopeName()
Obtains the name of this definition's defined scope. Valid values are defined as static members of gnu.beanfactory.BeanContext.
Specified by:
getScopeName in interface BeanDefinition
See Also:
BeanContext

setClassName

public void setClassName(java.lang.String className)
Sets the class name for this definition.
Parameters:
className - fully qualified class name
Throws:
IllegalStateException - If this method is called after the definition has been validated.

getClassName

public java.lang.String getClassName()
Obtains the fully qualified class name for this definition.
Specified by:
getClassName in interface BeanDefinition
Returns:
fully qualified class name

getClazz

public java.lang.Class getClazz()
                         throws java.lang.ClassNotFoundException
Description copied from interface: BeanDefinition
Get the class definition for this bean.
Specified by:
getClazz in interface BeanDefinition

getBeanSetter

public BeanSetter getBeanSetter()
                         throws java.lang.ClassNotFoundException,
                                BeanFactoryException
Description copied from interface: BeanDefinition
Obtains a BeanSetter instance for the current bean.
Specified by:
getBeanSetter in interface BeanDefinition
Following copied from interface: gnu.beanfactory.BeanDefinition
Returns:
BeanSetter instance

setName

public void setName(java.lang.String urn)
Set the URL for the bean.
Parameters:
urn - Uniform Resource Name
Throws:
IllegalStateException - If this method is called after the definition has been validated.

setScopeName

public void setScopeName(java.lang.String scopeName)
Sets the named scope. Valid values can be found as static members of BeanContext.
Parameters:
scopeName - named scope
Throws:
IllegalStateException - if this method is called after validate()

isScopeExplicit

public boolean isScopeExplicit()
Description copied from interface: BeanDefinition
Returns true if the scope has been explicitly set.
Specified by:
isScopeExplicit in interface BeanDefinition

getParent

public java.lang.String getParent()
Obtains the URL of this definition's "parent". This may be be null, indicating that this bean does not inherit any attributes.
Specified by:
getParent in interface BeanDefinition
Returns:
URL of the parent definition, or null if there is no parent

setParent

public void setParent(java.lang.String parentURL)
Sets the parent URL. May be null, indicating no parent.
Parameters:
parentURL - the URL of the parent bean (may be null)
Throws:
IllegalStateException - if this method is called after validate()

setStartup

public void setStartup(boolean startup)

getStartup

public boolean getStartup()
Description copied from interface: BeanDefinition
Boolean flag indicating whether this bean will be loaded when the BeanFactory container is initialzied.
Specified by:
getStartup in interface BeanDefinition

inherit

public void inherit(DefinitionLoader dl,
                    java.util.Set set)
             throws BeanFactoryException

validate

public void validate(DefinitionLoader dl)
              throws BeanFactoryException

assertMutable

public void assertMutable()
Asserts that the bean definition has not been frozen.
Throws:
IllegalStateException - if the definition is immutable

isMutable

public boolean isMutable()

isScopeJ2EE

public boolean isScopeJ2EE()
Description copied from interface: BeanDefinition
Returns true if the scope is: application, session, or request.
Specified by:
isScopeJ2EE in interface BeanDefinition

copy

public BeanDefinition copy()

toString

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

getDelimiter

public java.lang.String getDelimiter()
Specified by:
getDelimiter in interface BeanDefinition

setDelimiter

public void setDelimiter(java.lang.String s)

getClassLoader

public java.lang.ClassLoader getClassLoader()

setClassLoader

public void setClassLoader(java.lang.ClassLoader cl)

getOriginalProperties

public java.util.Properties getOriginalProperties()