com.aurorasoftworks.signal.runtime.core.context
Class LazyInitBeanReference

java.lang.Object
  extended by com.aurorasoftworks.signal.runtime.core.context.AbstractBeanReference
      extended by com.aurorasoftworks.signal.runtime.core.context.LazyInitBeanReference
All Implemented Interfaces:
IBeanReference, IBeanDelegate

public abstract class LazyInitBeanReference
extends AbstractBeanReference

A reference to a lazily-initialized bean. This class acts like a bean factory that creates a bean when getBean() is invoked for the first time. Note: methods of this class are not thread-safe because it is assumed that the calling context is responsible for synchronization.

Author:
Marek

Constructor Summary
LazyInitBeanReference(java.lang.String name, java.lang.Class beanClass)
          Creates a new instance of LazyInitBeanReference.
 
Method Summary
protected abstract  java.lang.Object createBean()
          Creates a wrapped bean on demand.
 java.lang.Object getBean()
          Returns the wrapped bean.
 java.lang.Class getBeanClass()
          Returns the class of the wrapped bean.
 
Methods inherited from class com.aurorasoftworks.signal.runtime.core.context.AbstractBeanReference
getName, setBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LazyInitBeanReference

public LazyInitBeanReference(java.lang.String name,
                             java.lang.Class beanClass)
Creates a new instance of LazyInitBeanReference. The wrapped bean is later created by the createBean() method.

Parameters:
name - name of the wrapped bean
beanClass - class of the wrapped bean
Method Detail

getBean

public java.lang.Object getBean()
                         throws ContextException
Returns the wrapped bean.

Specified by:
getBean in interface IBeanReference
Specified by:
getBean in interface IBeanDelegate
Overrides:
getBean in class AbstractBeanReference
Returns:
wrapped bean
Throws:
ContextException - if an error occurs while retrieving the bean

createBean

protected abstract java.lang.Object createBean()
                                        throws java.lang.Exception
Creates a wrapped bean on demand. This method is only invoked once when getBean() is executed for the first time.

Returns:
wrapped bean
Throws:
java.lang.Exception - if an error occurs while creating the bean

getBeanClass

public java.lang.Class getBeanClass()
Description copied from class: AbstractBeanReference
Returns the class of the wrapped bean. This method is useful for determining a class of a bean that may not actually be created until IBeanDelegate.getBean() is invoked.

Specified by:
getBeanClass in interface IBeanDelegate
Overrides:
getBeanClass in class AbstractBeanReference
Returns:
class of the wrapped bean


Copyright © 2010. All Rights Reserved.