org.skyscreamer.yoga.selector.parser
Class DynamicPropertyResolver

java.lang.Object
  extended by org.skyscreamer.yoga.selector.parser.DynamicPropertyResolver
All Implemented Interfaces:
AliasSelectorResolver

public class DynamicPropertyResolver
extends Object
implements AliasSelectorResolver

An implementation of AliasSelectorResolver that uses a Properties object accessed from a InputStream (likely a resource or file) to translate the alias. The key of each property is the alias, and the value is the fully-formed selector expression.


Constructor Summary
DynamicPropertyResolver()
           
DynamicPropertyResolver(InputStream propertyFile)
           
 
Method Summary
 String resolveSelector(String aliasSelectorExpression)
          The method that translates an alias into a fully-formed selector expression
 void setPropertyFile(InputStream propertyFile)
          Defines the InputStream, such as a FileInputStream, that provides access to the Properties object
 void setReloadIntervalSeconds(int reloadIntervalSeconds)
          Setting this interval will instruct the resolver to reload the Properties object from the InputStream before resolving the alias, if the specified number of seconds has elapsed since the last time the Properties object was loaded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicPropertyResolver

public DynamicPropertyResolver()

DynamicPropertyResolver

public DynamicPropertyResolver(InputStream propertyFile)
Method Detail

resolveSelector

public String resolveSelector(String aliasSelectorExpression)
                       throws ParseSelectorException
Description copied from interface: AliasSelectorResolver
The method that translates an alias into a fully-formed selector expression

Specified by:
resolveSelector in interface AliasSelectorResolver
Parameters:
aliasSelectorExpression - the alias expression passed in on the URI
Returns:
the complete selector expression represented by the alias
Throws:
ParseSelectorException - thrown if the input alias expression is not valid

setReloadIntervalSeconds

public void setReloadIntervalSeconds(int reloadIntervalSeconds)
Setting this interval will instruct the resolver to reload the Properties object from the InputStream before resolving the alias, if the specified number of seconds has elapsed since the last time the Properties object was loaded. This can be useful to force the resolver to pick up changes made to the input file while the application is running. Setting this value to 0 will prevent it from reloading the Properties object

Parameters:
reloadIntervalSeconds - interval in seconds, 0 is default

setPropertyFile

public void setPropertyFile(InputStream propertyFile)
Defines the InputStream, such as a FileInputStream, that provides access to the Properties object

Parameters:
propertyFile - the input stream


Copyright © 2013. All Rights Reserved.