org.locomotive.directory
Class BeanInstantiator

java.lang.Object
  |
  +--org.locomotive.directory.BeanInstantiator

public class BeanInstantiator
extends java.lang.Object

A NameService object delegates the responsibility for creating new bean instances from BeanConfiguration objects to a object of this class. The BeanInstantiator uses the Java reflection mechanism to instatiate beans with the the configured values.

Version:
$Id: BeanInstantiator.java,v 1.4 1999/05/05 10:19:31 gunnar Exp $
Author:
Gunnar Rønning (gunnar@candleweb.no).

Method Summary
 java.lang.String capitalize(java.lang.String str)
           
protected  java.lang.Object createBeanInstance(BeanConfiguration beanConfig)
          Created an instance of a component.
 java.lang.Object getProperty(BeanConfiguration beanConfig, java.lang.Object object, java.lang.String property)
          Get a property for an object.
protected  void setBeanProperty(java.lang.Object o, BeanProperty p, ScopeLookup scopeLookup, BeanConfiguration beanConfig)
          Set a given bean property in an object.
protected  void setProperties(ScopeLookup scopeLookup, java.lang.Object component, BeanConfiguration beanConfig)
          Set the properties of a component according to properties set in a BeanConfiguration object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createBeanInstance

protected java.lang.Object createBeanInstance(BeanConfiguration beanConfig)
Created an instance of a component.
Parameters:
beanConfig - A bean configuration object.
Returns:
The instantiated component.

setProperties

protected void setProperties(ScopeLookup scopeLookup,
                             java.lang.Object component,
                             BeanConfiguration beanConfig)
Set the properties of a component according to properties set in a BeanConfiguration object.
Parameters:
scopeLookup - The scope lookup component. This must be provided in the bean configuration refers to other components.
component - The component to set the properties on.
beanConfig - A bean configuration object.

setBeanProperty

protected void setBeanProperty(java.lang.Object o,
                               BeanProperty p,
                               ScopeLookup scopeLookup,
                               BeanConfiguration beanConfig)
Set a given bean property in an object. If an error occurs, the property is not set.

capitalize

public java.lang.String capitalize(java.lang.String str)

getProperty

public java.lang.Object getProperty(BeanConfiguration beanConfig,
                                    java.lang.Object object,
                                    java.lang.String property)
Get a property for an object.
Parameters:
beanConfig - The BeanConfiguration context for this lookup.
object - The object to lookup the property in.
property - The property to lookup.
Returns:
The property if it exists, or null else. Properties of primitive types are wrapped.