You can provide the properties to the Rule agent by using properties file or
java.util.properties.I am using java properties object and creating rule
agent by specifying the below properties.Created rule base and caching
rulebase.
Properties dynamicRueProperties = new Properties();
dynamicRueProperties.setProperty("name", "SampleRuleAgent");
dynamicRueProperties.setProperty("dir",
"C:/Project/Workspace/DroolsTest/rules");
dynamicRueProperties.setProperty("file",
C:/Project/Workspace/DroolsTest/rules/file.drl");
dynamicRueProperties.setProperty("localCacheDir",
"C:/Project/Workspace/DroolsTest/dump");
dynamicRueProperties.setProperty("poll", "30");
dynamicRueProperties.setProperty("newInstance", "false");
RuleBase ruleBase = null;
RuleAgent ruleAgent = null;
ruleAgent = RuleAgent.newRuleAgent(ruleProperties);
Cache using ur own technique i am using hashmap.....
cacheRuleBaseMap.put("OWN_RULEBASE",ruleAgent.getRuleBase());
ruleBase = cacheRuleBaseMap.get("OWN_RULEBASE");
ruleBase.newStatefulSession();
I am having problem to add DSL to the rule agent.
Thanks & Regards
Surya.
Mike Dean wrote:
My problem is not knowing what directory it is actually scanning. If I
put anything in the property file except 'dir=/' then I get an invalid
directory error. It accepts this entry, tells me it found 34 files, none
of which of course is a rule file, and I can't even find a place on my
machine that has 34 unique files in it. I am a little hobbled by Eclipse
because it is difficult sometimes to tell where the root of an RCP
actually lives.
- Mike
dave sinclair wrote:
>
> Mike,
>
> For question #1, check out the Javadoc for RuleAgent. The class header
> provides some decent documentation. As far as what it is reading, it
> takes
> the path specified by dir and scans that directory.
>
> dir = new File(d);
> if (!(dir.isDirectory() && dir.exists())) {
> throw new IllegalArgumentException("The directory " + d
> + "is not valid.");
> }
>
> scanner = new FileScanner();
> scanner.setFiles( dir.listFiles() );
>
>
>
> On Tue, Nov 25, 2008 at 8:58 AM, J Michael Dean <mdean77(a)comcast.net>
> wrote:
>
>> Two questions. I am interested in using RuleAgent but with the file or
>> dir
>> property rather than the URL. However, it is not clear to me where the
>> directories or files must actually be located. If I use
>>
>> dir=/
>>
>> then the DirectoryScanner is invoked and claims to have found some
>> number
>> of files, but I have no idea WHERE it is scanning. If I add anything
>> like
>> dir=/foo then I get an invalid directory exception.
>>
>> If I try file=/foo.pkg then I get exception that this is invalid file.
>>
>> Question 1 - is there an example somewhere that can help me understand
>> where I am going off the track? I am working Eclipse environment.
>>
>
>
--
View this message in context:
http://www.nabble.com/RuleAgent-question-tp20681831p22465777.html
Sent from the drools - user mailing list archive at
Nabble.com.