org.springframework.data.hadoop.scripting
Class HdfsScriptFactoryBean

java.lang.Object
  extended by org.springframework.data.hadoop.scripting.HdfsScriptFactoryBean
All Implemented Interfaces:
BeanClassLoaderAware, FactoryBean<Object>, InitializingBean, ApplicationContextAware

public class HdfsScriptFactoryBean
extends Object
implements ApplicationContextAware

Hadoop-customized factory that exposes Hadoop specific variables to scripting languages. The instances exposes are reused from the enclosing context (using naming conventions or autowiring strategies) or created on demand (in case of lightweight objects).

These are :

NameTypeDescription
cfgorg.apache.hadoop.conf.ConfigurationHadoop Configuration (relies on 'hadoop-configuration' bean or singleton type match)
cljava.lang.ClassLoaderClassLoader used for executing this script
ctxorg.springframework.context.ApplicationContextEnclosing application context
ctxRLorg.springframework.io.support.ResourcePatternResolverEnclosing application context ResourceLoader (same as ctx)
distcporg.springframework.data.hadoop.fs.DistributedCopyUtilprogrammatic access to DistCp
fsorg.apache.hadoop.fs.FileSystemHadoop File System (relies on 'hadoop-fs' bean or singleton type match, falls back to creating one based on 'cfg')
fshorg.springframework.data.hadoop.fs.FsShellFile System shell, exposing hadoop 'fs' commands as an API
hdfsRLorg.springframework.data.hadoop.io.HdfsResourceLoaderHdfsResourceLoader (relies on 'hadoop-resource-loader' or singleton type match, falls back to creating one automatically based on 'cfg')

Note that the above variables are added only if found (have a non-null value) and the keys are not bound already.

Author:
Costin Leau
See Also:
HdfsResourceLoader, FsShell, ApplicationContext

Constructor Summary
HdfsScriptFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 Object getObject()
           
 Class<Object> getObjectType()
           
 boolean isRunAtStartup()
          Indicates whether the script gets executed once the factory bean initializes.
 boolean isSingleton()
           
protected  void postProcess(Map<String,Object> args)
          Method for post-processing arguments.
 void setApplicationContext(ApplicationContext applicationContext)
           
 void setArguments(Map<String,Object> arguments)
          Sets the arguments for evaluating this script.
 void setBeanClassLoader(ClassLoader classLoader)
           
 void setEvaluate(EvaluationPolicy evaluation)
          Sets the way the script is evaluated.
 void setExtension(String extension)
          Sets the script extension.
 void setLanguage(String language)
          Sets the script language.
 void setRunAtStartup(boolean runAtStartup)
          Indicates whether to evaluate the script at startup (default) or not.
 void setScriptSource(ScriptSource script)
          Sets the script source to evaluate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HdfsScriptFactoryBean

public HdfsScriptFactoryBean()
Method Detail

postProcess

protected void postProcess(Map<String,Object> args)
Method for post-processing arguments. Useful for enhancing (adding) new arguments to scripts being executed.


setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
                           throws BeansException
Specified by:
setApplicationContext in interface ApplicationContextAware
Throws:
BeansException

getObject

public Object getObject()
Specified by:
getObject in interface FactoryBean<Object>

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface InitializingBean

getObjectType

public Class<Object> getObjectType()
Specified by:
getObjectType in interface FactoryBean<Object>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface FactoryBean<Object>

setBeanClassLoader

public void setBeanClassLoader(ClassLoader classLoader)
Specified by:
setBeanClassLoader in interface BeanClassLoaderAware

setScriptSource

public void setScriptSource(ScriptSource script)
Sets the script source to evaluate.

Parameters:
script - The script to evaluate.

setLanguage

public void setLanguage(String language)
Sets the script language.

Parameters:
language - The script language.

setExtension

public void setExtension(String extension)
Sets the script extension. Used for detecting the language.

Parameters:
extension - The extension to set.

setEvaluate

public void setEvaluate(EvaluationPolicy evaluation)
Sets the way the script is evaluated.

Parameters:
evaluation -

setArguments

public void setArguments(Map<String,Object> arguments)
Sets the arguments for evaluating this script.

Parameters:
arguments - The arguments to set.

isRunAtStartup

public boolean isRunAtStartup()
Indicates whether the script gets executed once the factory bean initializes.

Returns:
true if the script runs or not during startup

setRunAtStartup

public void setRunAtStartup(boolean runAtStartup)
Indicates whether to evaluate the script at startup (default) or not.

Parameters:
runAtStartup - The runStartUp to set.