|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.drools.agent.RuleAgent
public class RuleAgent
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
If the file has a .pkg extension, then it will be loaded as a binary Package (eg from the BRMS). If its a
DRL file (ie a file with a .drl extension with rule source in it), then it will attempt to compile it (of course, you will need the drools-compiler and its dependencies
available on your classpath).
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/guvnor-webapp/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.
Field Summary | |
---|---|
static String |
CONFIG_NAME
|
static String |
DIRECTORY
|
static String |
ENABLE_BASIC_AUTHENTICATION
|
static String |
FILES
|
static String |
LOCAL_URL_CACHE
|
static String |
NEW_INSTANCE
Following are property keys to be used in the property config file. |
static Map |
PACKAGE_PROVIDERS
Here is where we have a map of providers to the key that appears on the configuration. |
static String |
PASSWORD
|
static String |
POLL_INTERVAL
|
static String |
URLS
|
static String |
USER_NAME
|
Method Summary | |
---|---|
RuleBase |
getRuleBase()
Return a current rulebase. |
boolean |
isPolling()
|
static RuleAgent |
newRuleAgent(Properties config)
Properties configured to load up packages into a rulebase (and monitor them for changes). |
static RuleAgent |
newRuleAgent(Properties config,
AgentEventListener listener)
This allows an optional listener to be passed in. |
static RuleAgent |
newRuleAgent(Properties config,
AgentEventListener listener,
RuleBaseConfiguration ruleBaseConf)
This allows an optional listener to be passed in. |
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). |
static RuleAgent |
newRuleAgent(String propsFileName)
Pass in the name and full path to a config file that is on the classpath. |
static RuleAgent |
newRuleAgent(String propsFileName,
AgentEventListener listener)
This takes in an optional listener. |
static RuleAgent |
newRuleAgent(String propsFileName,
AgentEventListener listener,
RuleBaseConfiguration ruleBaseConfiguration)
This takes in an optional listener and RuleBaseConfiguration. |
static RuleAgent |
newRuleAgent(String propsFileName,
RuleBaseConfiguration ruleBaseConfiguration)
Pass in the name and full path to a config file that is on the classpath. |
void |
refreshRuleBase()
|
void |
setName(String name)
|
void |
startPolling()
Will start polling. |
void |
startPolling(int secondsToRefresh)
Will start polling. |
void |
stopPolling()
Stop the polling (if it is happening) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String NEW_INSTANCE
public static final String FILES
public static final String DIRECTORY
public static final String URLS
public static final String POLL_INTERVAL
public static final String CONFIG_NAME
public static final String USER_NAME
public static final String PASSWORD
public static final String ENABLE_BASIC_AUTHENTICATION
public static final String LOCAL_URL_CACHE
public static Map PACKAGE_PROVIDERS
Method Detail |
---|
public static RuleAgent newRuleAgent(Properties config)
public static RuleAgent newRuleAgent(Properties config, RuleBaseConfiguration ruleBaseConf)
public static RuleAgent newRuleAgent(Properties config, AgentEventListener listener)
public static RuleAgent newRuleAgent(Properties config, AgentEventListener listener, RuleBaseConfiguration ruleBaseConf)
public static RuleAgent newRuleAgent(String propsFileName)
public static RuleAgent newRuleAgent(String propsFileName, RuleBaseConfiguration ruleBaseConfiguration)
public static RuleAgent newRuleAgent(String propsFileName, AgentEventListener listener)
public static RuleAgent newRuleAgent(String propsFileName, AgentEventListener listener, RuleBaseConfiguration ruleBaseConfiguration)
public void setName(String name)
public void refreshRuleBase()
public RuleBase getRuleBase()
public void stopPolling()
public void startPolling()
public void startPolling(int secondsToRefresh)
secondsToRefresh
- public boolean isPolling()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |