How to correctly setup RUTA config parameters in the script? - ruta

Help is needed with a code example for proper understanding of setting parameters in own RUTA script.
In my case I need to setup the configuration parameter "emptyIsInvisible" to false. The root cause is described in Are some extra settings in RUTA script needed to detect annotations with the same begin and end attributes?
I made two attempts
1) use the name of standard Ruta Engine:
ENGINE BasicEngine;
Document{->CONFIGURE(BasicEngine, "emptyIsInvisible" = false)};`
That part of the script does not change the default settings.
2) use the name of own engine:
ENGINE xxx.yyy.zzz.TagEngine;
Document{->CONFIGURE(TagEngine, "emptyIsInvisible" = false)};
In that case the script raises the following exception:
Exception in thread "main" java.lang.StackOverflowError
at java.io.UnixFileSystem.getBooleanAttributes0(Native Method)
at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:242)
at java.io.File.exists(File.java:819)
at sun.misc.URLClassPath$FileLoader.getResource(URLClassPath.java:1081)
at sun.misc.URLClassPath$FileLoader.findResource(URLClassPath.java:1048)
at sun.misc.URLClassPath$1.next(URLClassPath.java:226)
at sun.misc.URLClassPath$1.hasMoreElements(URLClassPath.java:236)
at java.net.URLClassLoader$3$1.run(URLClassLoader.java:589)
at java.net.URLClassLoader$3$1.run(URLClassLoader.java:587)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader$3.next(URLClassLoader.java:586)
at java.net.URLClassLoader$3.hasMoreElements(URLClassLoader.java:611)
at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:45)
at sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:54)
at java.util.ServiceLoader$LazyIterator.hasNextService(ServiceLoader.java:354)
at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:393)
at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:474)
at javax.xml.parsers.FactoryFinder$1.run(FactoryFinder.java:293)
at java.security.AccessController.doPrivileged(Native Method)
at javax.xml.parsers.FactoryFinder.findServiceProvider(FactoryFinder.java:289)
at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:267)
at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:127)
at org.apache.uima.internal.util.XMLUtils.createSAXParserFactory(XMLUtils.java:543)
at org.apache.uima.util.impl.XMLParser_impl.parse(XMLParser_impl.java:159)
at org.apache.uima.util.impl.XMLParser_impl.parseResourceSpecifier(XMLParser_impl.java:399)
at org.apache.uima.util.impl.XMLParser_impl.parseResourceSpecifier(XMLParser_impl.java:381)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:278)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:270)
at org.apache.uima.ruta.engine.RutaEngine.initializeEngines(RutaEngine.java:896)
at org.apache.uima.ruta.engine.RutaEngine.initializeScript(RutaEngine.java:820)
at org.apache.uima.ruta.engine.RutaEngine.initialize(RutaEngine.java:527)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:267)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:172)
at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:448)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:279)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:270)
at org.apache.uima.ruta.engine.RutaEngine.initializeEngines(RutaEngine.java:896)
at org.apache.uima.ruta.engine.RutaEngine.initializeScript(RutaEngine.java:820)
at org.apache.uima.ruta.engine.RutaEngine.initialize(RutaEngine.java:527)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:267)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:172)
at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:448)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:279)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:270)
at org.apache.uima.ruta.engine.RutaEngine.initializeEngines(RutaEngine.java:896)
at org.apache.uima.ruta.engine.RutaEngine.initializeScript(RutaEngine.java:820)
at org.apache.uima.ruta.engine.RutaEngine.initialize(RutaEngine.java:527)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:267)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:172)
at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:448)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:279)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:270)
at org.apache.uima.ruta.engine.RutaEngine.initializeEngines(RutaEngine.java:896)
at org.apache.uima.ruta.engine.RutaEngine.initializeScript(RutaEngine.java:820)
at org.apache.uima.ruta.engine.RutaEngine.initialize(RutaEngine.java:527)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:267)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:172)
at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
....

This parameter will not solve the problems in the linked question. The parameter controls the basic matching if there are no annotations at all at some positions. This means that is will only affect the matching if a different seeding is applied, e.g., there is no seeding.
Concerning this question:
You cannot configure the RutaEngine analysis engine within the script the analysis engine tries to execute. You need to set the configuration parameter on framework level. This depends on how you create and run the UIMA analysis engines in your code.
In a simple Ruta project, you need to modify the template analysis engine description (BasicEngine.xml) so that the generated descriptions will contain the parameter value.
Using uimaFIT or other factory methods, you need to pass the parameter and its value when creating the description or analysis engine.
DISCLAIMER: I am a developer of UIMA Ruta

Related

IBM BPM JS Calling external Service from another Toolkit (from dependency)

im using
integration toolkit for each external system ... externalService
definition, Servers registation datas, ENV refers the J2C creds to use, datamapping, bussines-errors handling etc.
(Bussines-Layer TK ex. TK_SAP)
for the common functionality such as logging, tokenizing,
pseudomizing, common http-error handling i want to use another one
toolkit (Generic implementation for Transport-layer ex. TK_COM).
So its looks like this dependicies chain:
ProcessApp -> TK_SAP -> TK_COM
There is the serviceFlow with inputs externalServiceName, operationName and a serviceFlow ask for oAuth-token and call to target system using externalServiceName, operationName.
The problem is - when i try to invoke the BPMRESTRequest from TK_COM, i get NullPointerException because "externalServiceName" cant be resolved.
var request = new BPMRESTRequest();
request.externalServiceName = "language-translator-v2";
request.operationName="checkout";
...
var response = tw.system.invokeREST(request);
is it possible to store service definition in another TK (upper) and refer it from Toolkit-invoker?
Or is there callbacks for BPMRESTRequest-Construct to say which ServiceDefinition must be used and avoid NPE.
Or another way to call Rest programmaticaly supporting Environments.
Im understand that switching the layers can help (serviceDefinition in lower TK-dependency), but it unlogisch is:
ProcessApp -> TK_COM -> TK_SAP
the answer is: JS-lib implementation.
Implementing common functionality as JS-Server-file in TK_COM makes that a call to it from TK_SAP will instatiate JS-execution context in the TK_SAP namespace so all defined in TK_SAP externalServices and variables will be accesible by executing of JS-code (actualy provided by lower-dependency Toolkit)

UIMA Ruta - basic example

I am trying the example of uima ruta:
here.
I want to create ruta script and apply it to my text (from plain java without any workbench).
1.how do i get the type system descriptor from plain java (without workbench)?
2. when do i get it with workbench? (if i "run" the ruta script, no description were made.)
The main question is whether the script declares new types.
If no new types are declared, the linked examples in the documentation should be sufficient.
If new types are declared in the script, then a type system description needs to be created and included in the creation process of the CAS before the script can be applied on the CAS.
The type system description of a script containing the type descriptions of the types declared within the script can be created the following ways:
The Ruta Workbench creates the type system description automatically for each script within a simple Ruta Project when the script is saved. If no description is created, the script is most likely not parseable and contains syntax errors.
In maven-built projects, the ruta-maven-plugin can be utilized to create the type system descriptions of Ruta scripts.
In plain Java, the RutaDescriptorFactory can be utilized to create the type system description programmatically. Here's a code example.
There are several ways to create and execute a ruta-based analysis engine in plain java code. Here's an example without using additional files:
String rutaScript = "DECLARE MyType; CW{-> MyType};";
RutaDescriptorFactory descriptorFactory = new RutaDescriptorFactory();
RutaBuildOptions options = new RutaBuildOptions();
options.setResolveImports(true);
options.setImportByName(true);
RutaDescriptorInformation descriptorInformation = descriptorFactory
.parseDescriptorInformation(rutaScript, options);
// replace null values for build environment if necessary (e.g., location in classpath)
Pair<AnalysisEngineDescription, TypeSystemDescription> descriptions = descriptorFactory
.createDescriptions(null, null, descriptorInformation, options, null, null, null);
AnalysisEngineDescription rutaAnalysisEngineDescription = descriptions.getKey();
rutaAnalysisEngineDescription.getAnalysisEngineMetaData().getConfigurationParameterSettings().setParameterValue(RutaEngine.PARAM_RULES, rutaScript);
TypeSystemDescription rutaTypeSystemDescription = descriptions.getValue();
// directly set type system description since no file will be created
rutaAnalysisEngineDescription.getAnalysisEngineMetaData().setTypeSystem(rutaTypeSystemDescription);
ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager();
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(rutaAnalysisEngineDescription);
List<TypeSystemDescription> typeSystemDescriptions = new ArrayList<>();
TypeSystemDescription scannedTypeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescription();
typeSystemDescriptions.add(scannedTypeSystemDescription);
typeSystemDescriptions.add(rutaTypeSystemDescription);
TypeSystemDescription mergeTypeSystemDescription = CasCreationUtils.mergeTypeSystems(typeSystemDescriptions, resourceManager);
JCas jCas = JCasFactory.createJCas(mergeTypeSystemDescription);
CAS cas = jCas.getCas();
jCas.setDocumentText("This is my document.");
ae.process(jCas);
Collection<AnnotationFS> select = CasUtil.select(cas, cas.getTypeSystem().getType("Anonymous.MyType"));
for (AnnotationFS each : select) {
System.out.println(each.getCoveredText());
}
DISCLAIMER: I am a developer of UIMA Ruta

Is hot code replace supposed to work for Groovy in Eclipse?

I was wondering if anyone was able to get Groovy hot replace working in Eclipse reliably. I can't find any useful info about this, so I am not sure if it's b/c it's just working for everyone else? Or is nobody using Eclipse to do Groovy development?
I have tried using the latest Eclipse (4.5 Mars) with latest Groovy-Eclipse plugin (Groovy Eclipse 2.9.2 from http://dist.springsource.org/snapshot/GRECLIPSE/e4.5/), and I still can't get reliable hot replace.
Some simple hot replace scenarios work fine. However, just a little bit of complexity leads to strange Groovy exceptions. I get different errors in different situations, but I was able to reproduce one in a simple junit, so I'll demonstrate that one with some simplified domain objects.
HotSwapTests.groovy:
class HotSwapTests {
#Test
public void testHotReplace() {
DefaultTxView transactionGroup = new DefaultTxView();
List<Default> defaults = [];
Default d1 = new Default(ProducerAccountTransactionType.REPAID_AMOUNT, ParticipantAccountType.DEFAULT);
Default d2 = new Default(ProducerAccountTransactionType.REPAID_AMOUNT, ParticipantAccountType.DEFAULT);
d1.setCancelledDefault(d2);
defaults << d1;
transactionGroup.setDefaultTransactions(defaults);
while (true) {
Default result = transactionGroup.getRepaymentTransaction();
println result
}
}
}
DefaultTxView.groovy:
public class DefaultTxView {
def List<Default> defaultTransactions;
public Default getRepaymentTransaction() { return getTransactionOfType(REPAID_AMOUNT); }
public Default getTransactionOfType(ProducerAccountTransactionType type) {
return defaultTransactions.find { it.getType() == type };
}
Default.java:
The contents of this domain object are not really important - it's a simple POJO.
Now, to test hotswap I place a breakpoint at the marked line:
while (true) {
Default result = transactionGroup.getRepaymentTransaction(); <<< break
println result
}
And then I go to DefaultTxView.groovy and modify the code inside the closure passed in to the find method:
public Default getTransactionOfType(ProducerAccountTransactionType type) {
return defaultTransactions.find { it.getType() == type && it.getCancelledDefault() == null};
}
I don't get any warning or error messages when I save the file, but if I attempt to step over the modified line now, I get the following exception:
java.lang.ArrayIndexOutOfBoundsException: 2
at ca.gc.agr.app.web.jsf.producer.DefaultTxView$_getTransactionOfType_closure1.doCall(DefaultTxView.groovy:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:278)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.BooleanReturningMethodInvoker.invoke(BooleanReturningMethodInvoker.java:48)
at org.codehaus.groovy.runtime.callsite.BooleanClosureWrapper.call(BooleanClosureWrapper.java:50)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.find(DefaultGroovyMethods.java:3060)
at org.codehaus.groovy.runtime.dgm$175.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at ca.gc.agr.app.web.jsf.producer.DefaultTxView.getTransactionOfType(DefaultTxView.groovy:15)
at ca.gc.agr.app.web.jsf.producer.DefaultTxView$getTransactionOfType$1.callCurrent(Unknown Source)
at ca.gc.agr.app.web.jsf.producer.DefaultTxView.getRepaymentTransaction(DefaultTxView.groovy:11)
at ca.gc.agr.app.web.jsf.producer.DefaultTxView$getRepaymentTransaction$0.call(Unknown Source)
at ca.gc.agr.app.web.jsf.temp.HotSwapTests.testHotReplace(HotSwapTests.groovy:29)
I get very similar results when running my webapp in TomCat, with the same exception after modifying that line. Restarting the junit, or TomCat makes the new line work fine, so it's definitely a hot replace issue.
So what am I doing wrong? Any advice would be appreciated.
I've used hot deploy in a web dev environment with groovy successfully in the past using the eclipse plugin.
IIRC, I used groovyReset.jar, DCEVM and jdk1.7.
groovyReset.jar should be in the classpath and set as java agent. I've used the one found inside the groovy-eclipse plugin folder (like eclipse/plugins/org.codehaus.groovy_2.3.7.xx-201411061335-e44-RELEASE/extras/groovyReset.jar)
-javaagent:/groovyReset.jar
New closures and methods were instantly visible without redeploy. Of course including a simple LOC in a method worked too. Sometimes i needed to restart the VM, but still a breath of fresh air.
In your case, i think at least groovyReset.jar must be present. It is responsible for resetting the metaclass. If you decompile a groovy class you can check method calls being called by reflection using an array of java.lang.Method. Upon hot code swap this array gets out of order, needing a reset.

Prefix is null when using client stubs

I had to use axis to generate stubs because the SOAP I am working with uses RPC. After setting up the code to post I am receiving the below stack trace. If anyone has had this issue please help. From using the debug tool in Eclipse I can see that Axis is using default prefixes, but the issue is that one of the prefixes it uses has already been used so it returns null. Does anyone know why this may be happening?
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.io.IOException: java.io.IOException: Non nillable element 'prefix' is null.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.io.IOException: java.io.IOException: Non nillable element 'prefix' is null.
at org.apache.axis.encoding.ser.BeanSerializer.serialize(BeanSerializer.java:275)
at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1504)
at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:980)
at org.apache.axis.encoding.SerializationContext.outputMultiRefs(SerializationContext.java:1055)
at org.apache.axis.message.SOAPBody.outputImpl(SOAPBody.java:145)
at org.apache.axis.message.SOAPEnvelope.outputImpl(SOAPEnvelope.java:478)
at org.apache.axis.message.MessageElement.output(MessageElement.java:1208)
at org.apache.axis.client.Call.invoke(Call.java:2757)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
Though that this question is not answered after one year I thought that it might help you since you are working with RPC and probably a legacy system.
In your generated client stub with Apache Axis under packaging that ends with "_xsd" where the Objects of the web service provider are created open classes one by one.
Somewhere in the middle of the class you will find a static block code like this:
static {
typeDesc.setXmlType(...);
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("prefix");
elemField.setXmlName(new javax.xml.namespace.QName("", "prefix"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
}
just change the value of nillable to true like this:
elemField.setNillable(true);
You should repeat this action for all classes and all fields of those classes if they do not match with their corresponding values in your WSDL (i.e. based on the definition of your WSDL they are nullable).
I've noticed that Apache Axis 1.2 - 1.4 automatically makes attributes not 'nillable' by default. I don't know why is this the case but I think this is the solution.

Problem with DSL and Business Rules creation in Drools

I am using Eclipse with the Drools plugin to create rules.
I want to create business rules and main aim is to try and provide the user a set of options which he can use to create rules.
For eg:If an Apple can have only 3 colors: I want to provide an option like a drop down so that the user can know before hand which are the options he can use in his rules.
Is it possible?
I am creating a dsl but unable to still provide the above functionality for a business rule.
I am having an error implementing a basic dsl also.
The code to add the dsl is as follows in my RuleRunner class()
InputStream ruleSource = RuleRunner.class.getClassLoader().getResourceAsStream("/Rule1.dslr");
InputStream dslSource = RuleRunner.class.getClassLoader().getResourceAsStream("/sample-dsl.dsl");
//Load the rules , using DSL
addRulesToThisPackage.addPackageFromDrl(
new InputStreamReader(ruleSource),new InputStreamReader(dslSource));
I have both the sample-dsl .dsl and Rule1.dslr in my working directory.
Error encountered at adding the dsl to the package (last line)
Error stack:
Exception in thread "main" java.lang.NullPointerException
at java.io.Reader.<init>(Unknown Source)
at java.io.InputStreamReader.<init>(Unknown Source)
at com.org.RuleRunner.loadRuleFile(RuleRunner.java:96)
at com.org.RuleRunner.loadRules(RuleRunner.java:48)
at com.org.RuleRunner.runStatelessRules(RuleRunner.java:109)
at com.org.RulesTest.main(RulesTest.java:41)
my dsl file has basic mapping as per the online documentations.
The dsl rule I created is:
expander sample-dsl.dsl
rule "A status changes B status"
when
There is an A
- has an address
There is a B
- has name
then
- print updated A and Aaddress
End
I have created DSL in eclipse.
Is the code I added for it to be loaded to my package correct?? Or am I missing something????
It seems like my program is unable to find the dsl?
Please help. Can you point me towards the right direction to create a user friendly business rule ??
Thanks.
J
I am not quite familiar with the method you are trying to use to create a knowledge session, but I will show a example of what's used in my applications.
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(<KnowledgeBaseConfiguration>);
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( "rules/myRuleFile.drl", getClass() ),
ResourceType.DRL );
kbuilder.add( ResourceFactory.newClassPathResource( "rules/myDslFile.dsl", getClass() ),
ResourceType.DSL );
if ( kbuilder.hasErrors() ) {
System.err.println( builder.getErrors().toString() );
}
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
Now as far as giving your users the ability to author rule files, with built in constraints, have you looked at Drools Guvnor?(http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-guvnor/html_single/index.html) I have not incorporated it into my project yet, but have researched it a bit. I think it may provide the functionality your seeking for allowing your users to create and edit rule files. Good luck!