Question about Object.equals and modifyRetract/Insert
by Michal Bali
Hello,
Let's say we have a simple BeanA with one property that is part of
equal/hashCode method e.g.:
----------------------------------------
public class BeanA {
int someProperty;
public int getSomeProperty() {
return someProperty;
}
public void setSomeProperty(int someProperty) {
this.someProperty = someProperty;
}
@Override
public boolean equals(final Object other) {
if (this == other)
return true;
if (!(other instanceof BeanA))
return false;
BeanA castOther = (BeanA) other;
return new EqualsBuilder().append(someProperty,
castOther.someProperty).isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder(228431015, 1383549405).append(
someProperty).toHashCode();
}
}
------------------------------------
This bean is inserted into the working memory. Is it something wrong with
doing?:
wm.modifyRetract(beanA);
beanA.setSomeProperty(22); //this is changing the object equality key
wm.modifyInsert(beanAHandle, beanA);
I know that simple update is not allowed:
beanA.SetSomeProperty(22);
update(beanAHandle, beanA); //this is wrong
I guess there is no difference if this code is outside the rule engine or
inside (e.g. in a rule consequence).
Thank you,
Best Regards,
Michal
17 years, 2 months
jbrms with tomcat security realm
by hongyu lu
Hi,
Just wonder if anyone has had experience with setting up jbrms security with tomcat realms(memory realm is good enough in our case). Was unable to find an example from the doc/web.
thanks!
Jeff
17 years, 2 months
Sessions, WorkingMemory, Long lived facts
by David Sinclair
I have a question concerning facts. I have a service based application
XML IN -> Business Objects -> Rule Processing -> Business Objects -> XML OUT
Pretty straightforward.
In the rule processing I will lazily load objects into WorkingMemory that
drive some of the business rules. For instance, if a new Windows
Server(Business Object) is installed, ensure its OS is only Windows Server
2007 (lazily loaded DB object).
What I would like to do is be able to either preload the working memory with
this data, or preferably, lazily load the data. So my question is how do you
place facts into working memory when you create a new session each time
without having to assert them everytime? Or this that a stupid
question...Should the question be, since working memory/sessions aren't
thread safe, i.e. one can't be shared by everyone, what is the best way to
place long lived facts into memory of all sessions?
thanks
dave
17 years, 2 months
Re: [rules-users] Re: drools 5.0.0-SNAPSHOT Maven repository broken! please fix!
by tim tim
the maven list found the solution see here:
http://www.nabble.com/mvn2-url-resolution-for-SNAPSHOT-sources-wrong-ts19...
from brett porter on the maven list:
> '.' is not a valid separator for snapshots - it needs to be -SNAPSHOT.
> Drools will need to redeploy it as 5.0.0-SNAPSHOT for it to work.
best, tim
On Wed, Oct 8, 2008 at 6:35 PM, Geoffrey De Smet
<ge0ffrey.spam(a)gmail.com> wrote:
>
> With kind regards,
> Geoffrey De Smet
>
>
> tim tim schreef:
>>
>> hi
>>
>> when i am getting drools snapshot via "mvn eclipse:eclipse"
>> the compiled drools jars are downloaded but the sources are not, although
>> i have
>> <downloadSources>true</downloadSources>
>> defined as parameter in my pom.xml and the sources of the other libraries
>> are downloaded correctly.
>> when i use drools 4.0.7 those sources are downloaded correctly.
>>
>> i can find the sources manually in the http://snapshots.jboss.org/maven2
>> repository, they are just not downloaded
>> automatically.
>>
>> i deleted the |mvn-eclipse-cache.properties |file in my target directory
>> before calling mvn. (see
>> http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html)
>
> Doesn't "mvn eclipse:clean" delete that cache too?
>
>>
>> an extract from my maven output:
>>
>> // the compiled jars are located correctly:
>> ..
>> [INFO] snapshot org.drools.solver:drools-solver:5.0.0.SNAPSHOT: checking
>> for updates from snapshots.jboss.org <http://snapshots.jboss.org>
>> [INFO] snapshot org.drools.solver:drools-solver:5.0.0.SNAPSHOT: checking
>> for updates from repo1.maven.org <http://repo1.maven.org>
>> Downloading:
>> http://snapshots.jboss.org/maven2/org/drools/solver/drools-solver/5.0.0.S...
>> 1K downloaded
>> Downloading:
>> http://snapshots.jboss.org/maven2/org/drools/drools-compiler/5.0.0.SNAPSH...
>> 943K downloaded
>> Downloading:
>> http://snapshots.jboss.org/maven2/org/drools/drools-core/5.0.0.SNAPSHOT/d...
>> 1547K downloaded
>> Downloading:
>> http://snapshots.jboss.org/maven2/org/drools/solver/drools-solver-core/5....
>> 94K downloaded
>> ...
>> // but maven searches for the sources in the wrong repositories:
>>
>> Downloading:
>> http://repository.jboss.org/maven2/org/drools/drools-compiler/5.0.0.20081...
>> Downloading:
>> http://repo1.maven.org/maven2/org/drools/drools-compiler/5.0.0.20081008.1...
>> Downloading:
>> http://repo1.maven.org/maven2/org/drools/drools-compiler/5.0.0.20081008.1...
>> Downloading:
>> http://repository.jboss.org/maven2/org/drools/drools-core/5.0.0.20081008....
>> Downloading:
>> http://repo1.maven.org/maven2/org/drools/drools-core/5.0.0.20081008.10280...
>> Downloading:
>> http://repo1.maven.org/maven2/org/drools/drools-core/5.0.0.20081008.10280...
>> ...
>>
>> does someone else have this problem?
>>
>> or maybe my pom.xml is wrong?
>> the relevant parts of my pom.xml file are:
>>
>> <repositories>
>> <repository>
>> <id>repo1.maven.org <http://repo1.maven.org></id>
>
> I don't think you need to explicitly add this one, it's always automatically
> added, unless you overwrite it with the id "central" I think.
>>
>> <url>http://repo1.maven.org/maven2</url>
>> <snapshots>
>> <enabled>true</enabled>
>
> repo1.maven.org doesn't contain snapshots as far as I know, so it should be
> false
> It could be that the eclipse plugin only searches on the first snapshot repo
> it encounters? Which version of the eclipse plugin are you using?
>>
>> </snapshots>
>> <releases>
>> <enabled>true</enabled>
>> </releases>
>> </repository>
>> <repository>
>> <id>repository.jboss.org <http://repository.jboss.org></id>
>> <url>http://repository.jboss.org/maven2</url>
>> <snapshots>
>> <enabled>false</enabled>
>> </snapshots>
>> <releases>
>> <enabled>true</enabled>
>> </releases>
>> </repository>
>> <repository>
>> <id>snapshots.jboss.org <http://snapshots.jboss.org></id>
>> <url>http://snapshots.jboss.org/maven2</url>
>> <snapshots>
>> <enabled>true</enabled>
>> </snapshots>
>> <releases>
>> <enabled>false</enabled>
>> </releases>
>> </repository>
>> </repositories>
>>
>> <dependencies>
>> <dependency>
>> <groupId>janino</groupId>
>> <artifactId>janino</artifactId>
>> <version>2.5.10</version>
>> </dependency>
>> <dependency>
>> <groupId>org.drools</groupId>
>> <artifactId>drools-core</artifactId>
>> <version>5.0.0.SNAPSHOT</version>
>> </dependency>
>> <dependency>
>> <groupId>org.drools</groupId>
>> <artifactId>drools-compiler</artifactId>
>> <version>5.0.0.SNAPSHOT</version>
>> </dependency>
>> <dependency>
>> <groupId>org.drools.solver</groupId>
>> <artifactId>drools-solver-core</artifactId>
>> <version>5.0.0.SNAPSHOT</version>
>> </dependency>
>> </dependencies>
>>
>> unfortunately i have no idea what the problem might be and installing the
>> sources manually every time i update is no very attractive option..
>>
>>
>> thanks in advance, tim
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
17 years, 2 months
Unable to load dialect java from Ant task
by Soterro
Hi all,
I have a perfectly running Eclipse 3.3 with DRools 4.0.4 and JDK 1.5.14.
The rules are compiled with a post build Ant task which uses Janino (need it for Tomcat compatibility).
Now OUTSIDE Eclipse it seems I cannot use that Ant task to save my life :(
I tried switching from Janino to the default compiler, same thing. I always get this infamous error:
BUILD FAILED
E:\buildRules-hudson.xml:30: RuleBaseTask failed: Unable to load dialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java'
at com.csc.ezbook.eztarif.rules.DroolsCompilerAntTaskStandalone.execute
(DroolsCompilerAntTaskStandalone.java:163)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
[...]
Caused by: org.drools.RuntimeDroolsException: Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java'
at org.drools.compiler.PackageBuilderConfiguration.addDialect(
PackageBuilderConfiguration.java:152)
at org.drools.compiler.PackageBuilderConfiguration.
buildDialectConfigurationMap(PackageBuilderConfiguration.java:140)
at org.drools.compiler.PackageBuilderConfiguration.init(
PackageBuilderConfiguration.java:117)
at org.drools.compiler.PackageBuilderConfiguration.<init>(
PackageBuilderConfiguration.java:94)
at com.my.app.rules.DroolsCompilerAntTaskStandalone.getPackageBuilder(
DroolsCompilerAntTaskStandalone.java:257)
at com.my.app.rules.DroolsCompilerAntTaskStandalone.execute(
DroolsCompilerAntTaskStandalone.java:136)
That "DroolsCompilerAntTaskStandalone" is my task using the default compiler like this:
PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
conf.setClassLoader( loader );
PackageBuilder builder = new PackageBuilder( conf );
If I use Janino like below the error is exactly the same...
PackageBuilderConfiguration pkgBuilderCfg = new
PackageBuilderConfiguration();
pkgBuilderCfg.setClassLoader( loader );
JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
pkgBuilderCfg.getDialectConfiguration( "java" );
javaConf.setCompiler( JavaDialectConfiguration.JANINO );
PackageBuilder builder = new PackageBuilder( pkgBuilderCfg );
Again, in Eclipse all is working fine. I checked Ant's classpath, here it is:
E:\apache-ant-1.7.0\bin\..\lib\ant-launcher.jar
E:\apache-ant-1.7.0\lib\*.jar
C:\Program Files\Java\jdk1.5.0_14\lib\tools.jar
Here is how I provide a classpath:
<taskdef name="rulescompiler" classname="com.my.app.rules.
DroolsCompilerAntTaskStandalone" classpathref="droolsutils.classpath" />
<target depends="newfilesarethere" name="build" unless="rulesCompile.
notRequired">
<rulescompiler srcdir="${THIS_PROJ}/src/com/my/app/rules"
tofile="${THIS_PROJ}/build/classes/com/my/app/rules/
packaged.rules"
classpathref="droolsutils.classpath" >
<include name="*.drl" />
</rulescompiler>
</target>
The classpath I provide contains pretty much all libraries I use normally in the project, but I tried even to add ALL jar's from the Eclipse 3.3 install directory (that would include all DRools 4.0.4 libraries, with antlr and whatnot)
I tried also with DRools 4.0.7, same behaviour...
What does that mean and where is it coming from? Could it have issues with the tools.jar from Java 1.5.0_14?
Thank you for any input,
M
17 years, 2 months
drools solver move factory crash
by tim tim
hello
the new version of the drools-solver supports multiple move factories.
i happily split my move factory to take advantage of the
relativeSelection parameter.
now the problem is that not all move factories can produce moves for
every possible
current solution. and the
org.drools.solver.core.localsearch.decider.selector.MoveFactorySelector
crashes, when a move factory does not return a single move.
public final List<Move> selectMoveList(StepScope stepScope) {
List<Move> moveList =
moveFactory.createMoveList(stepScope.getWorkingSolution());
if (shuffle) {
Collections.shuffle(moveList, stepScope.getWorkingRandom());
}
if (relativeSelection != null) {
int selectionSize = (int) Math.ceil(relativeSelection *
moveList.size());
if (selectionSize == 0) {
selectionSize = 1;
}
moveList = moveList.subList(0, selectionSize); // <--
CRASH, if moveList is empty
}
return moveList;
}
currently i solve it by always returning at least a "null-move".
but a better solution would be to change the
MoveFactorySelector.selectMoveList(), so that it tests for an
empty list.
best, tim
17 years, 2 months
No globals in functions?
by Bagwell, Allen F
There's probably an easy explanation for this. I was wondering about why functions inside of rule files can't access globals?
For example, I have a log4j logger that I pass into my rule files via a global. The logger should never be a part of working memory. It's just there to capture valuable feedback.
But I can't do this:
global Logger log;
function void foo(String cond)
{
if (cond == "error")
log.error("I saw an error");
}
Because the compiler says that in the function it can't resolve 'log'.
-A
Allen F. Bagwell
e-mail: afbagwe(a)sandia.gov
phone: 505/284-4517
fax: 505/ 844-7886
There is no monument dedicated to the memory of a committee. -- Lester J. Pourciau
17 years, 2 months
Drools Rule Analytics Module
by Ralph Jeffery
Hi
I have been looking at the QA Analysis feature in Guvnor, which I
think is the Rule Analytics Module, and was wondering if this feature
is available from Eclipse?
Regards
Ralph
17 years, 3 months
Search a keyword in xml file content using jcr:contains() query in jackrabbit
by Mohamed Riyaz
Hi,
In jackrabbit, How to search a keyword in a xml file using jcr:contains()
Xpath query without interfering xml node?
Eg: I have a content property in a blog entry node 'book'. content is
represented as xml file (<*j2ee*>Introduction to x design pattern</*j2ee*>).
If I search a word 'j2ee', its returning the node which is not currect
conceptually.
Please suggest me the possible approch either to use 'regular expression' or
alternative way to resolve this requirement.
//Keyword search
StringBuffer queryStr = *new* StringBuffer();
queryStr.append("//book[jcr:contains(@bookContent,'");
queryStr.append("j2ee");
//queryStr.append("j??e");
queryStr.append("')]");
Query query = queryManager.createQuery(queryStr.toString(), Query.*XPATH*);
QueryResult queryResult = query.execute();
Regards, Riyaz
17 years, 3 months
Removing history from JBRMS
by Richard Ambridge
Hi,
In drools-jbrms all history information is kept, which is great for
when we are in production to track changes.
However, during development we perform a lot of changes and tests with
the repository.
Is there anyway to remove the history information from the repository?
Cheers
Ric
17 years, 3 months