org.robotframework.javalib.library
Class ClassPathLibrary

java.lang.Object
  extended by org.robotframework.javalib.library.KeywordFactoryBasedLibrary<Keyword>
      extended by org.robotframework.javalib.library.ClassPathLibrary
All Implemented Interfaces:
RobotJavaLibrary

public class ClassPathLibrary
extends KeywordFactoryBasedLibrary<Keyword>

A Robot keyword library that finds keywords dynamically from the classpath.

To add keywords to the library, first make sure that the pattern and package prefix are correct. The pattern is used to find potential keywords according to their name. E.g. if your class name is com.acme.mycomponent.keyword.DoSomething and you want it to be registered as a keyword, the keyword pattern could be com/**/keyword/**/**.class. Try to set it as restrictive as possible in order to avoid keyword name collisions with other libraries using javalib-core. For example, it is perhaps not a good idea to set it to com/**/**.class. The pattern is resolved by PathMatchingResourcePatternResolver.

The package prefix is used to determine the class path location of the class from the filesystem path. Do not use it for filtering out keywords, that's what the pattern is for. The package prefix must match for all keywords the pattern finds. The default package prefix is "org.".

Then make sure your keyword fills all the requirements of InterfaceBasedKeywordFilter.

After that, all you need to do is to add your keywords to your class path and this library will automatically find them. Contents of JAR files are also searched.


Constructor Summary
ClassPathLibrary()
           
ClassPathLibrary(java.lang.String keywordPattern)
           
 
Method Summary
protected  KeywordFactory<Keyword> createKeywordFactory()
          Creates a keyword factory.
 void setKeywordPattern(java.lang.String pattern)
          Sets a new pattern.
 
Methods inherited from class org.robotframework.javalib.library.KeywordFactoryBasedLibrary
getClassLoader, getKeywordNames, runKeyword, setClassLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassPathLibrary

public ClassPathLibrary()

ClassPathLibrary

public ClassPathLibrary(java.lang.String keywordPattern)
Method Detail

createKeywordFactory

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

Specified by:
createKeywordFactory in class KeywordFactoryBasedLibrary<Keyword>
Returns:
keyword factory

setKeywordPattern

public void setKeywordPattern(java.lang.String pattern)
Sets a new pattern. See class description for details. Must be set before Robot calls RobotJavaLibrary.runKeyword(String, Object[]) or RobotJavaLibrary.getKeywordNames().

Parameters:
pattern - new pattern


Copyright © 2009. All Rights Reserved.