Isn't the simplest solution just to add the imports at the start of the
imported drl file?
That is the users don't need to worry about writing the imports but before you
feed the files into your code simply prepends the required imports.
You can do this easily in memory with something like the following:
StringWriter drlContents = new StringWriter();
drlContents.write("import ...\n");
FileInputStream stream = new FileInputStream(drlFile);
InputStreamReader inR = new InputStreamReader(stream, "UTF-8");
IOUtils.copy(inR, drlContents);
kbuilder.add(ResourceFactory.newReaderResource(new
StringReader(drlContents.toString())),
ResourceType.DRL);
Thomas
> -----Original Message-----
> From: [email protected] [mailto:rules-users-
> [email protected]] On Behalf Of Dave Cracauer
> Sent: 28 April 2010 19:35
> To: Rules Users List; [email protected]
> Subject: Re: [rules-users] Challenge! Using javassist and drools presents an
> issue with drl
>
>
> It sounds like the stated goal is to make things easier for non-developers to
> write rules. What about a dsl?
>
> What about using a templating language? I have used velocity in the past for
> dynamically generating rules based on templates, and I think that there is
> built in support for templates using mvel.
>
> -----Original Message-----
> >From: markricard <[email protected]>
> >Sent: Apr 28, 2010 11:53 AM
> >To: [email protected]
> >Subject: Re: [rules-users] Challenge! Using javassist and drools presents an
> issue with drl
> >
> >
> >Perhaps there is an easier way to ask this question....
> >
> >Rather than having to do an 'import' of a class in a drl text file, is there
> >a way in the Java code that constructs the KnowledgeBase to via java
> >dynamically import any class file required by any drl file that is added?
> >
> >Instead of the drl having:
> >
> >import com.foo.Instance;
> >rule "Walgreens Test"
> > ....
> >
> >It just has:
> >
> >rule "Walgreens Test"
> > ....
> >
> >
> >And in the KnowledgeBuilder does something like this:
> >
> >KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
> >kbuilder.addImport("com.foo.Instance");
> >...
> >
> >
> >
> >--
> >View this message in context: http://drools-java-rules-
> engine.46999.n3.nabble.com/Challenge-Using-javassist-and-drools-presents-an-
> issue-with-drl-tp763086p763118.html
> >Sent from the Drools - User mailing list archive at Nabble.com.
> >_______________________________________________
> >rules-users mailing list
> >[email protected]
> >https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users
**************************************************************************************
This message is confidential and intended only for the addressee. If you have
received this message in error, please immediately notify the
[email protected] and delete it from your system as well as any copies. The
content of e-mails as well as traffic data may be monitored by NDS for
employment and security purposes. To protect the environment please do not
print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX,
United Kingdom. A company registered in England and Wales. Registered no.
3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
This message is confidential and intended only for the addressee. If you have
received this message in error, please immediately notify the
[email protected] and delete it from your system as well as any copies. The
content of e-mails as well as traffic data may be monitored by NDS for
employment and security purposes.
To protect the environment please do not print this e-mail unless necessary.
An NDS Group Limited company. www.nds.com
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users