org.weblab_project.core.helper
Class BeanHelper

java.lang.Object
  extended by org.weblab_project.core.helper.BeanHelper

public abstract class BeanHelper
extends java.lang.Object

Abstract class which enable to load dynamically the implementation. It aims to load JAVA bean in accordance to a configuration file.

Author:
EADS WebLab Team
Date:
2008-03-18

Field Summary
static java.lang.String FILENAME
          The properties file used.
 
Constructor Summary
protected BeanHelper()
          The default constructor to be called by implementations.
 
Method Summary
abstract
<T> T
getBean(java.lang.String name, java.lang.Class<T> beanClass)
          Get the bean defined by its name in the configuration file.
static BeanHelper getInstance()
           
abstract  BeanHelper getSpecificInstance(java.lang.String path)
          Return the current instance of Bean factory with respect to the configuration file.
abstract  BeanHelper getSpecificInstance(java.lang.String fileNameOrPath, boolean isName)
          This method is similar to getSpecificInstance(String) but when name is true, it's loaded from the classpath, without the whole path if possible.
abstract  boolean isBeanDefined(java.lang.String name, java.lang.Class<?> beanClass)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILENAME

public static final java.lang.String FILENAME
The properties file used.

See Also:
Constant Field Values
Constructor Detail

BeanHelper

protected BeanHelper()
The default constructor to be called by implementations.

Method Detail

getInstance

public static BeanHelper getInstance()
Returns:
The current BeanHelper instance.

getSpecificInstance

public abstract BeanHelper getSpecificInstance(java.lang.String path)
Return the current instance of Bean factory with respect to the configuration file.

Parameters:
path - The path to the configuration file.
Returns:
The instance of BeanHelper in accordance with the configuration file.
See Also:
getSpecificInstance(String, boolean)

getSpecificInstance

public abstract BeanHelper getSpecificInstance(java.lang.String fileNameOrPath,
                                               boolean isName)
This method is similar to getSpecificInstance(String) but when name is true, it's loaded from the classpath, without the whole path if possible.
Return the current instance of Bean factory with respect to the configuration file.

Parameters:
fileNameOrPath - The name of (or the path to) the configuration file.
isName - Whether fileNameOrPath is a name or a path.
Returns:
The instance of BeanHelper in accordance with the configuration file.
See Also:
getSpecificInstance(String)

getBean

public abstract <T> T getBean(java.lang.String name,
                              java.lang.Class<T> beanClass)
Get the bean defined by its name in the configuration file.

Type Parameters:
T - The class of the bean to be instantiated
Parameters:
name - The name of the bean to retrieve.
beanClass - The class of the bean to be instantiated.
Returns:
The bean defined with name in the BeanHelper.
Throws:
org.weblab_project.core.exception.WebLabUncheckedException - If bean does not exist in configuration file loaded.

isBeanDefined

public abstract boolean isBeanDefined(java.lang.String name,
                                      java.lang.Class<?> beanClass)
Parameters:
name - The name of the bean to test existence in the configuration file.
beanClass - The class of the bean.
Returns:
Whether or not a bean named name and of a type (or subtype, or implementation) or beanClass exists in configuration file.


Copyright © 2004-2009. All Rights Reserved.