[rules-users] Rules integration with Java -need help

Dinesh kumar dinp87 at gmail.com
Wed Jul 14 05:58:00 EDT 2010


Hi,

Need help in integrating guvnor with my java application.

I have the set rules to executed for a particular module as individual
packages within guvnor. To fire these rules, I have separate properties file
specifying the URL of each package and mention it within the application as
below.


For module1:

Properties properties = new Properties();
properties.load(new FileInputStream(module1PropertiesFilePath));
RuleAgent agent = RuleAgent.newRuleAgent(properties);
RuleBase ruleBase = agent.getRuleBase();
WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.insert(module1Object);
workingMemory.fireAllRules();


For module2:

Properties properties = new Properties();
properties.load(new FileInputStream(module2PropertiesFilePath));
RuleAgent agent = RuleAgent.newRuleAgent(properties);
RuleBase ruleBase = agent.getRuleBase();
WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.insert(module2Object);
workingMemory.fireAllRules();


My properties file looks like this. There will be one properties file for
each module.


##
## RuleAgent configuration file example
##

#setting this means the rulebase will be created fresh whenever there are
#changes
newInstance=true

#this points to a binary compiled rule package, you can have spaces
#seperating multiple files
#file=/foo/bar/boo.pkg /foo/bar/boo2.pkg

#this specifies that packages may appear in a directory
#it will pick up whatever files are dumped in there (.pkg files like above)
#dir=/my/dir

#this specifies a list of urls for packages - these urls
#are those that are exposed by the BRMS
url=
http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Module1/LATEST
#the following can be used with the urls to keep a local cache
#so if the runtime server is restarted, the BRMS does not need
#to be available
#localCacheDir=

#this specifies the frequency at which the sources will be checked for
#changes (in seconds). If you don't set this, it will mean that you have
#to manually poll
poll=30


#this specifies the name of this config, necessary in case logging is used.
name=MyConfig


Instead of specifying the url in the properties file, can i directly have
the url in my java..
How to directly specify the url in java instead of using properties file?

Any suggestions will be of great help..

Regards,
Dinesh

-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rules-integration-with-Java-need-help-tp966070p966070.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list