[jboss-svn-commits] JBL Code SVN: r14430 - in labs/jbossrules/trunk/drools-core/src/main/java/org/drools: reteoo and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Aug 21 22:42:33 EDT 2007
Author: michael.neale at jboss.com
Date: 2007-08-21 22:42:33 -0400 (Tue, 21 Aug 2007)
New Revision: 14430
Modified:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DroolsQuery.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/Rete.java
Log:
JBRULES-1086 Initial fact should not be shadowed. Also patched for funky classloading.
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DroolsQuery.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DroolsQuery.java 2007-08-21 22:49:33 UTC (rev 14429)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DroolsQuery.java 2007-08-22 02:42:33 UTC (rev 14430)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,10 +16,10 @@
* limitations under the License.
*/
-public class DroolsQuery {
+public final class DroolsQuery {
private final String name;
private final Object[] args;
-
+
private static final Object[] EMPTY_PARAMS = new Object[0];
public DroolsQuery(final String name) {
@@ -27,7 +27,7 @@
this.name = name;
this.args = EMPTY_PARAMS;
}
-
+
public DroolsQuery(final String name, final Object[] params) {
super();
this.name = name;
@@ -36,12 +36,12 @@
} else {
this.args = EMPTY_PARAMS;
}
- }
+ }
public String getName() {
return this.name;
}
-
+
public Object[] getArguments() {
return this.args;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java 2007-08-21 22:49:33 UTC (rev 14429)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java 2007-08-22 02:42:33 UTC (rev 14430)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,12 +21,12 @@
/**
* We dont want users to be able to instantiate InitialFact so we expose it as
* an interface and make the class and its constructor package protected
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
- *
+ *
*/
-class InitialFactImpl
+final class InitialFactImpl
implements
InitialFact {
private static final InitialFact INSTANCE = new InitialFactImpl();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/Rete.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/Rete.java 2007-08-21 22:49:33 UTC (rev 14429)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/Rete.java 2007-08-22 02:42:33 UTC (rev 14430)
@@ -2,13 +2,13 @@
/*
* Copyright 2005 JBoss Inc
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -47,20 +47,20 @@
/**
* The Rete-OO network.
- *
+ *
* The Rete class is the root <code>Object</code>. All objects are asserted into
* the Rete node where it propagates to all matching ObjectTypeNodes.
- *
+ *
* The first time an instance of a Class type is asserted it does a full
- * iteration of all ObjectTyppeNodes looking for matches, any matches are
+ * iteration of all ObjectTyppeNodes looking for matches, any matches are
* then cached in a HashMap which is used for future assertions.
- *
- * While Rete extends ObjectSource nad implements ObjectSink it nulls the
+ *
+ * While Rete extends ObjectSource nad implements ObjectSink it nulls the
* methods attach(), remove() and updateNewNode() as this is the root node
* they are no applicable
- *
+ *
* @see ObjectTypeNode
- *
+ *
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*/
@@ -74,7 +74,7 @@
// ------------------------------------------------------------
/**
- *
+ *
*/
private static final long serialVersionUID = 400L;
/** The <code>Map</code> of <code>ObjectTypeNodes</code>. */
@@ -106,11 +106,11 @@
* This is the entry point into the network for all asserted Facts. Iterates a cache
* of matching <code>ObjectTypdeNode</code>s asserting the Fact. If the cache does not
* exist it first iteraes and builds the cache.
- *
+ *
* @param handle
* The FactHandle of the fact to assert
* @param context
- * The <code>PropagationContext</code> of the <code>WorkingMemory</code> action
+ * The <code>PropagationContext</code> of the <code>WorkingMemory</code> action
* @param workingMemory
* The working memory session.
*/
@@ -174,7 +174,7 @@
/**
* Retract a fact object from this <code>RuleBase</code> and the specified
* <code>WorkingMemory</code>.
- *
+ *
* @param handle
* The handle of the fact to retract.
* @param workingMemory
@@ -211,7 +211,7 @@
/**
* Adds the <code>TupleSink</code> so that it may receive
* <code>Tuples</code> propagated from this <code>TupleSource</code>.
- *
+ *
* @param tupleSink
* The <code>TupleSink</code> to receive propagated
* <code>Tuples</code>.
@@ -299,7 +299,7 @@
public static class ObjectTypeConf
implements
Serializable {
- // Objenesis instance without cache (false)
+ // Objenesis instance without cache (false)
private static final Objenesis OBJENESIS = new ObjenesisStd( false );
private final Class cls;
@@ -330,8 +330,9 @@
return;
}
- Package pkg = clazz.getPackage();
- String pkgName = (pkg != null) ? pkg.getName() : "";
+
+ //String pkgName = (pkg != null) ? pkg.getName() : "";
+ String pkgName = getPackageName(clazz, clazz.getPackage());
if ( "org.drools.reteoo".equals( pkgName ) || "org.drools.base".equals( pkgName ) ) {
// We don't shadow internal classes
this.shadowEnabled = false;
@@ -362,7 +363,25 @@
}
}
- private Class loadOrGenerateProxy(Class clazz,
+ /**
+ * This will return the package name - if the package is null, it will
+ * work it out from the class name (this is in cases where funky classloading is used).
+ */
+ public static String getPackageName(Class clazz, Package pkg) {
+ String pkgName = "";
+ if (pkg == null) {
+ int index = clazz.getName().lastIndexOf('.');
+ if (index != -1)
+ pkgName = clazz.getName().substring(0, index);
+ }
+ else {
+ pkgName = pkg.getName();
+ }
+ return pkgName;
+
+ }
+
+ private Class loadOrGenerateProxy(Class clazz,
Rete rete) {
Class shadowClass = null;
final String shadowProxyName = ShadowProxyFactory.getProxyClassNameForClass( clazz );
@@ -389,7 +408,7 @@
private Class findAFeasibleSuperclassOrInterface(ObjectTypeNode[] nodes,
Class clazz) {
- // check direct superclass
+ // check direct superclass
Class ret = clazz.getSuperclass();
boolean isOk = ret != null && ret != Object.class; // we don't want to shadow java.lang.Object
if ( isOk ) {
@@ -429,7 +448,7 @@
}
/**
- *
+ *
*/
private void setInstantiator() {
this.instantiator = OBJENESIS.getInstantiatorOf( this.shadowClass );
More information about the jboss-svn-commits
mailing list