| java.lang.Object org.drools.agent.RuleAgent
All known Subclasses: org.drools.agent.MockRuleAgent,
RuleAgent | public class RuleAgent (Code) | | This manages a single rulebase, based on the properties given.
You should only have ONE instance of this agent per rulebase configuration.
You can get the rulebase from this agent repeatedly, as needed, or if you keep the rulebase,
under most configurations it will be automatically updated.
How this behaves depends on the properties that you pass into it (documented below)
CONFIG OPTIONS (to be passed in as properties):
newInstance : setting this to "true" means that each time the rules are changed
a new instance of the rulebase is created (as opposed to updated in place)
the default is to update in place. DEFAULT: false. If you set this to true,
then you will need to call getRuleBase() each time you want to use it. If it is false,
then it means you can keep your reference to the rulebase and it will be updated automatically
(as well as any stateful sessions).
poll The number of seconds to poll for changes. Polling
happens in a background thread. eg: poll=30 #30 second polling.
file : a space seperated listing of files that make up the
packages of the rulebase. Each package can only be in one file. You can't have
packages spread across files. eg: file=/your/dir/file1.pkg file=/your/dir/file2.pkg
dir : a single file system directory to monitor for packages.
As with files, each package must be in its own file.
eg: dir=/your/dir
url : A space seperated URL to a binary rulebase in the BRMS.
eg: url=http://server/drools-jbrms/packages/somePakage/VERSION_1
For URL you will also want a local cache directory setup:
eg: localCacheDir=/some/dir/that/exists
This is needed so that the runtime can startup and load packages even if the BRMS
is not available (or the network).
name
the Name is used in any logging, so each agent can be differentiated (you may have one agent per rulebase
that you need in your application).
There is also an AgentEventListener interface which you can provide which will call back when lifecycle
events happen, or errors/warnings occur. As the updating happens in a background thread, this may be important.
The default event listener logs to the System.err output stream.
author: Michael Neale |
Method Summary | |
synchronized void | configure(boolean newInstance, List provs, int secondsToRefresh) | public synchronized RuleBase | getRuleBase() Return a current rulebase. | void | init(Properties config) | boolean | isNewInstance() | public synchronized boolean | isPolling() | static List | list(String property) Convert a space seperated list into a List of stuff. | static Properties | loadFromProperties(String propsFileName) | public static RuleAgent | newRuleAgent(Properties config) Properties configured to load up packages into a rulebase (and monitor them
for changes). | public static RuleAgent | newRuleAgent(Properties config, RuleBaseConfiguration ruleBaseConf) Properties configured to load up packages into a rulebase with the provided
configuration (and monitor them for changes). | public static RuleAgent | newRuleAgent(Properties config, AgentEventListener listener) This allows an optional listener to be passed in. | public static RuleAgent | newRuleAgent(Properties config, AgentEventListener listener, RuleBaseConfiguration ruleBaseConf) This allows an optional listener to be passed in. | public static RuleAgent | newRuleAgent(String propsFileName) Pass in the name and full path to a config file that is on the classpath. | public static RuleAgent | newRuleAgent(String propsFileName, RuleBaseConfiguration ruleBaseConfiguration) Pass in the name and full path to a config file that is on the classpath. | public static RuleAgent | newRuleAgent(String propsFileName, AgentEventListener listener) This takes in an optional listener. | public static RuleAgent | newRuleAgent(String propsFileName, AgentEventListener listener, RuleBaseConfiguration ruleBaseConfiguration) This takes in an optional listener and RuleBaseConfiguration. | public void | refreshRuleBase() | public synchronized void | startPolling() Will start polling. | public synchronized void | startPolling(int secondsToRefresh) Will start polling. | public synchronized void | stopPolling() |
LOCAL_URL_CACHE | final public static String LOCAL_URL_CACHE(Code) | | |
NEW_INSTANCE | final public static String NEW_INSTANCE(Code) | | Following are property keys to be used in the property
config file.
|
PACKAGE_PROVIDERS | public static Map PACKAGE_PROVIDERS(Code) | | Here is where we have a map of providers to the key that appears on the configuration.
|
packages | Map packages(Code) | | This keeps the packages around that have been loaded.
|
providers | List providers(Code) | | The providers that actually do the work.
|
configure | synchronized void configure(boolean newInstance, List provs, int secondsToRefresh)(Code) | | |
getRuleBase | public synchronized RuleBase getRuleBase()(Code) | | Return a current rulebase.
Depending on the configuration, this may be a new object each time
the rules are updated.
|
isNewInstance | boolean isNewInstance()(Code) | | |
isPolling | public synchronized boolean isPolling()(Code) | | |
list | static List list(String property)(Code) | | Convert a space seperated list into a List of stuff.
Parameters: property - |
newRuleAgent | public static RuleAgent newRuleAgent(Properties config)(Code) | | Properties configured to load up packages into a rulebase (and monitor them
for changes).
|
newRuleAgent | public static RuleAgent newRuleAgent(Properties config, RuleBaseConfiguration ruleBaseConf)(Code) | | Properties configured to load up packages into a rulebase with the provided
configuration (and monitor them for changes).
|
newRuleAgent | public static RuleAgent newRuleAgent(Properties config, AgentEventListener listener)(Code) | | This allows an optional listener to be passed in.
The default one prints some stuff out to System.err only when really needed.
|
newRuleAgent | public static RuleAgent newRuleAgent(String propsFileName)(Code) | | Pass in the name and full path to a config file that is on the classpath.
|
refreshRuleBase | public void refreshRuleBase()(Code) | | |
startPolling | public synchronized void startPolling()(Code) | | Will start polling. If polling is already running it does nothing.
|
startPolling | public synchronized void startPolling(int secondsToRefresh)(Code) | | Will start polling. If polling is already happening and of the same interval
it will do nothing, if the interval is different it will stop the current Timer
and create a new Timer for the new interval.
Parameters: secondsToRefresh - |
stopPolling | public synchronized void stopPolling()(Code) | | Stop the polling (if it is happening)
|
|
|