org.robotframework.javalib.library
Class KeywordFactoryBasedLibrary<T extends Keyword>

java.lang.Object
  extended by org.robotframework.javalib.library.KeywordFactoryBasedLibrary<T>
All Implemented Interfaces:
RobotJavaLibrary
Direct Known Subclasses:
AnnotationLibrary, ClassPathLibrary, CompositeLibrary, SpringLibrary

public abstract class KeywordFactoryBasedLibrary<T extends Keyword>
extends java.lang.Object
implements RobotJavaLibrary

A library that wraps a keyword factory. The keyword factory is used to create the keyword instance and this library simply executes the keyword. Subclasses must implement factory method createKeywordFactory().


Constructor Summary
KeywordFactoryBasedLibrary()
           
 
Method Summary
protected abstract  KeywordFactory<T> createKeywordFactory()
          Creates a keyword factory.
 java.lang.ClassLoader getClassLoader()
          Gets the classloader.
 java.lang.String[] getKeywordNames()
          Returns all the keywords this library contains
 java.lang.Object runKeyword(java.lang.String keywordName, java.lang.Object[] args)
          Runs a keyword and returns the result.
 void setClassLoader(java.lang.ClassLoader classLoader)
          Sets the classloader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeywordFactoryBasedLibrary

public KeywordFactoryBasedLibrary()
Method Detail

runKeyword

public java.lang.Object runKeyword(java.lang.String keywordName,
                                   java.lang.Object[] args)
Description copied from interface: RobotJavaLibrary
Runs a keyword and returns the result. If an exception is thrown the keyword fails, otherwise it passes.

Specified by:
runKeyword in interface RobotJavaLibrary
Parameters:
keywordName - keyword name to run
args - arguments for the keyword
Returns:
keyword return value
See Also:
RobotJavaLibrary.runKeyword(String, Object[])

getKeywordNames

public java.lang.String[] getKeywordNames()
Description copied from interface: RobotJavaLibrary
Returns all the keywords this library contains

Specified by:
getKeywordNames in interface RobotJavaLibrary
Returns:
names of keywords this library contains
See Also:
RobotJavaLibrary.getKeywordNames()

getClassLoader

public java.lang.ClassLoader getClassLoader()
Gets the classloader. Simply a property that the subclasses can use if the need to. The default classloader is the current thread's context class loader, Thread.getContextClassLoader().

Returns:
classloader

setClassLoader

public void setClassLoader(java.lang.ClassLoader classLoader)
Sets the classloader. Simply a property that the subclasses can use if the need to.

Parameters:
classLoader - new classloader

createKeywordFactory

protected abstract KeywordFactory<T> createKeywordFactory()
Creates a keyword factory. Must be implemented by subclasses. The keyword factory is created lazily, when either getKeywordNames() or runKeyword(String, Object[]) is called for the first time.

Returns:
keyword factory


Copyright © 2009. All Rights Reserved.