[jboss-svn-commits] JBL Code SVN: r12251 - in labs/jbossrules/trunk/drools-compiler/src: main/java/org/drools/rule/builder and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed May 30 23:36:53 EDT 2007
Author: mark.proctor at jboss.com
Date: 2007-05-30 23:36:53 -0400 (Wed, 30 May 2007)
New Revision: 12251
Added:
labs/jbossrules/trunk/drools-compiler/src/main/resources/META-INF/drools.default.packagebuilder.conf
Modified:
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DialectRegistry.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilderConfiguration.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuildContext.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderConfigurationTest.java
Log:
JBRULES-713 Make Dialects Pluggeable
-Default dialects are no longer hard coded and the DialectRegistry is now built by the configuration object.
JBRULES-895
-The properties handling has been extended to support chaining.
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DialectRegistry.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DialectRegistry.java 2007-05-31 03:36:42 UTC (rev 12250)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DialectRegistry.java 2007-05-31 03:36:53 UTC (rev 12251)
@@ -1,7 +1,9 @@
package org.drools.compiler;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.drools.rule.builder.Dialect;
@@ -22,6 +24,24 @@
public Dialect getDialect(final String name) {
return (Dialect) this.map.get( name );
}
+
+ public void compileAll() {
+ for ( Iterator it = this.map.values().iterator(); it.hasNext(); ) {
+ Dialect dialect = ( Dialect ) it.next();
+ dialect.compileAll();
+ }
+ }
+
+ public List addResults(List list) {
+ if ( list == null ) {
+ list = new ArrayList();
+ }
+ for ( Iterator it = this.map.values().iterator(); it.hasNext(); ) {
+ Dialect dialect = ( Dialect ) it.next();
+ list.addAll( dialect.getResults() );
+ }
+ return list;
+ }
public void addImport(String importEntry) {
for ( Iterator it = this.map.values().iterator(); it.hasNext(); ) {
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java 2007-05-31 03:36:42 UTC (rev 12250)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java 2007-05-31 03:36:53 UTC (rev 12251)
@@ -33,6 +33,7 @@
import org.drools.facttemplates.FactTemplateImpl;
import org.drools.facttemplates.FieldTemplate;
import org.drools.facttemplates.FieldTemplateImpl;
+import org.drools.lang.descr.AttributeDescr;
import org.drools.lang.descr.BaseDescr;
import org.drools.lang.descr.FactTemplateDescr;
import org.drools.lang.descr.FieldTemplateDescr;
@@ -47,8 +48,6 @@
import org.drools.rule.builder.Dialect;
import org.drools.rule.builder.RuleBuildContext;
import org.drools.rule.builder.RuleBuilder;
-import org.drools.rule.builder.dialect.java.JavaDialect;
-import org.drools.rule.builder.dialect.mvel.MVELDialect;
import org.drools.ruleflow.common.core.Process;
import org.drools.ruleflow.core.impl.RuleFlowProcessImpl;
import org.drools.xml.XmlPackageReader;
@@ -69,7 +68,7 @@
private TypeResolver typeResolver;
- private ClassFieldExtractorCache classFieldExtractorCache;
+ private ClassFieldExtractorCache classFieldExtractorCache;
private RuleBuilder builder;
@@ -77,7 +76,7 @@
private DialectRegistry dialects;
- private ProcessBuilder processBuilder;
+ private ProcessBuilder processBuilder;
/**
* Use this when package is starting from scratch.
@@ -119,28 +118,18 @@
this.results = new ArrayList();
this.pkg = pkg;
this.classFieldExtractorCache = new ClassFieldExtractorCache();
+
+ this.dialects = configuration.buildDialectRegistry( this );
+ this.dialect = this.dialects.getDialect( configuration.getDefaultDialect() );
- this.dialects = new DialectRegistry();
-
if ( this.pkg != null ) {
this.typeResolver = new ClassTypeResolver( this.pkg.getImports(),
this.pkg.getPackageCompilationData().getClassLoader() );
// make an automatic import for the current package
- this.typeResolver.addImport( this.pkg.getName() + ".*" );
- this.dialects.addDialect( "java",
- new JavaDialect( this ) );
- this.dialects.addDialect( "mvel",
- new MVELDialect( this ) );
- this.dialect = this.dialects.getDialect( "java" ); // TODO this should from the package
-
+ this.typeResolver.addImport( this.pkg.getName() + ".*" );
} else {
- this.typeResolver = new ClassTypeResolver( new ArrayList(), configuration.getClassLoader() );
- this.dialects.addDialect( "java",
- new JavaDialect( this ) );
- this.dialects.addDialect( "mvel",
- new MVELDialect( this ) );
- this.dialects.addDialect( "default", this.dialects.getDialect( configuration.getDialect() ) );
- this.dialect = this.dialects.getDialect( configuration.getDialect() );
+ this.typeResolver = new ClassTypeResolver( new ArrayList(),
+ configuration.getClassLoader() );
}
//this.dialect = this.dialects.getDialect( "java" );
@@ -201,21 +190,22 @@
this.results.addAll( parser.getErrors() );
addPackage( pkg );
}
-
+
/**
* Add a ruleflow (.rt) asset to this package.
*/
public void addRuleFlow(Reader processSource) {
- if (this.processBuilder == null) {
- this.processBuilder = new ProcessBuilder(this);
+ if ( this.processBuilder == null ) {
+ this.processBuilder = new ProcessBuilder( this );
}
try {
this.processBuilder.addProcessFromFile( processSource );
} catch ( Exception e ) {
- if (e instanceof RuntimeException) {
+ if ( e instanceof RuntimeException ) {
throw (RuntimeException) e;
}
- throw new RuntimeDroolsException("Unable to load process.", e);
+ throw new RuntimeDroolsException( "Unable to load process.",
+ e );
}
}
@@ -223,11 +213,29 @@
* This adds a package from a Descr/AST This will also trigger a compile, if
* there are any generated classes to compile of course.
*/
- public void addPackage(final PackageDescr packageDescr) {
-
+ public void addPackage(final PackageDescr packageDescr) {
validatePackageName( packageDescr );
validateUniqueRuleNames( packageDescr );
+
+ String dialectName = null;
+ for ( Iterator it = packageDescr.getAttributes().iterator(); it.hasNext(); ) {
+ String value = ( String ) it.next();
+ if ( "dialect".equals( value )) {
+ dialectName = value;
+ break;
+ }
+ }
+
+ // The Package does not have a default dialect, so set it
+ if ( dialectName == null ) {
+ dialectName = configuration.getDefaultDialect();
+ packageDescr.addAttribute( new AttributeDescr("dialect",
+ dialectName ) );
+ }
+
+ this.dialect = this.dialects.getDialect( dialectName );
+
if ( this.pkg != null ) {
// mergePackage( packageDescr ) ;
mergePackage( this.pkg,
@@ -236,7 +244,7 @@
this.pkg = newPackage( packageDescr );
}
- this.builder = new RuleBuilder( );
+ this.builder = new RuleBuilder();
// only try to compile if there are no parse errors
if ( !hasErrors() ) {
@@ -255,9 +263,8 @@
}
}
- this.dialect.compileAll();
-
- this.results.addAll( this.dialect.getResults() );
+ this.dialects.compileAll();
+ this.results = this.dialects.addResults( this.results );
}
private void validatePackageName(final PackageDescr packageDescr) {
@@ -286,9 +293,7 @@
private Package newPackage(final PackageDescr packageDescr) {
final Package pkg = new Package( packageDescr.getName(),
- this.configuration.getClassLoader() );
-
- this.dialect = this.dialects.getDialect( "java" ); // TODO this should from the package
+ this.configuration.getClassLoader() );
this.dialect.init( pkg );
@@ -305,7 +310,7 @@
if ( this.typeResolver.getImports().isEmpty() ) {
this.typeResolver.addImport( pkg.getName() + ".*" );
}
-
+
final List imports = packageDescr.getImports();
for ( final Iterator it = imports.iterator(); it.hasNext(); ) {
String importEntry = ((ImportDescr) it.next()).getTarget();
@@ -315,13 +320,13 @@
}
for ( final Iterator it = packageDescr.getFunctionImports().iterator(); it.hasNext(); ) {
- String importEntry = ((FunctionImportDescr) it.next()).getTarget();
+ String importEntry = ((FunctionImportDescr) it.next()).getTarget();
this.dialects.addImport( importEntry );
pkg.addStaticImport( importEntry );
}
-
- ((ClassTypeResolver)this.typeResolver).setClassLoader( pkg.getPackageCompilationData().getClassLoader() );
+ ((ClassTypeResolver) this.typeResolver).setClassLoader( pkg.getPackageCompilationData().getClassLoader() );
+
final List globals = packageDescr.getGlobals();
for ( final Iterator it = globals.iterator(); it.hasNext(); ) {
final GlobalDescr global = (GlobalDescr) it.next();
@@ -370,14 +375,14 @@
private void addRule(final RuleDescr ruleDescr) {
//this.dialect.init( ruleDescr );
-
+
RuleBuildContext context = new RuleBuildContext( pkg,
ruleDescr,
- this.dialects );
+ this.dialects );
this.builder.build( context );
-
- this.results.addAll( context.getErrors() );
+ this.results.addAll( context.getErrors() );
+
context.getDialect().addRule( context );
this.pkg.addRule( context.getRule() );
@@ -403,16 +408,18 @@
if ( hasErrors() ) {
this.pkg.setError( getErrors().toString() );
}
- addRuleFlowsToPackage(this.processBuilder, pkg);
-
+ addRuleFlowsToPackage( this.processBuilder,
+ pkg );
+
return this.pkg;
}
-
+
public PackageBuilderConfiguration getPackageBuilderConfiguration() {
return this.configuration;
}
- private void addRuleFlowsToPackage(ProcessBuilder processBuilder, Package pkg) {
+ private void addRuleFlowsToPackage(ProcessBuilder processBuilder,
+ Package pkg) {
if ( processBuilder != null ) {
Process[] processes = processBuilder.getProcesses();
for ( int i = 0; i < processes.length; i++ ) {
@@ -421,11 +428,10 @@
}
}
-
public ClassFieldExtractorCache getClassFieldExtractorCache() {
return this.classFieldExtractorCache;
}
-
+
/**
* This will return true if there were errors in the package building and
* compiling phase
@@ -526,7 +532,7 @@
this.message = message;
}
- public DroolsError getError() {
+ public DroolsError getError() {
return new RuleError( this.rule,
this.descr,
collectCompilerProblems(),
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilderConfiguration.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilderConfiguration.java 2007-05-31 03:36:42 UTC (rev 12250)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilderConfiguration.java 2007-05-31 03:36:53 UTC (rev 12251)
@@ -16,10 +16,27 @@
* limitations under the License.
*/
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Map.Entry;
import org.drools.RuntimeDroolsException;
+import org.drools.rule.builder.Dialect;
+import org.drools.util.ChainedProperties;
+import sun.security.action.GetLongAction;
+
/**
* This class configures the package compiler.
* There are options to use various flavours of runtime compilers.
@@ -34,31 +51,79 @@
* system property "drools.compiler.lnglevel". Valid values are 1.4, 1.5 and 1.6.
*/
public class PackageBuilderConfiguration {
- public static final int ECLIPSE = 0;
- public static final int JANINO = 1;
+ public static final int ECLIPSE = 0;
+ public static final int JANINO = 1;
- public static final String[] LANGUAGE_LEVELS = new String[]{"1.4", "1.5", "1.6"};
- public static final String DEFAULT_LANGUAGE_LEVEL = "1.4";
+ public static final String[] LANGUAGE_LEVELS = new String[]{"1.4", "1.5", "1.6"};
- /** These will be only setup once. It tries to look for a system property */
- private static final int CONFIGURED_COMPILER = getDefaultCompiler();
- private static final String CONFIGURED_LANGUAGE_LEVEL = getDefaultLanguageLevel();
+ private Map dialects;
- public static final String[] DIALECTS = new String[]{"java", "mvel"};
- private String dialect = getDefaultDialect();
+ private String defaultDialect;
- private int compiler = PackageBuilderConfiguration.CONFIGURED_COMPILER;
+ private int compiler;
private ClassLoader classLoader;
- private String languageLevel = PackageBuilderConfiguration.CONFIGURED_LANGUAGE_LEVEL;
+ private String languageLevel;
+ private ChainedProperties chainedProperties;
+
+ /**
+ * Programmatic properties file, added with lease precedence
+ * @param properties
+ */
+ public PackageBuilderConfiguration(Properties properties) {
+ init( null,
+ properties );
+ }
+
+ /**
+ * Programmatic properties file, added with lease precedence
+ * @param classLoader
+ * @param properties
+ */
+ public PackageBuilderConfiguration(ClassLoader classLoader,
+ Properties properties) {
+ init( classLoader,
+ properties );
+ }
+
public PackageBuilderConfiguration() {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ init( null,
+ null );
+ }
+
+ public PackageBuilderConfiguration(ClassLoader classLoader) {
+ init( classLoader,
+ null );
+ }
+
+ private void init(ClassLoader classLoader,
+ Properties properties) {
if ( classLoader == null ) {
- classLoader = this.getClass().getClassLoader();
+ classLoader = Thread.currentThread().getContextClassLoader();
+ if ( classLoader == null ) {
+ classLoader = this.getClass().getClassLoader();
+ }
+ setClassLoader( classLoader );
}
- this.classLoader = classLoader;
+ setClassLoader( classLoader );
+
+ this.chainedProperties = new ChainedProperties( this.classLoader,
+ "packagebuilder.conf" );
+
+ if ( properties != null ) {
+ this.chainedProperties.addProperties( properties );
+ }
+
+ setJavaLanguageLevel( getDefaultLanguageLevel() );
+
+ setCompiler( getDefaultCompiler() );
+
+ this.dialects = new HashMap();
+ this.chainedProperties.mapStartsWith( this.dialects,
+ "drools.dialect" );
+ setDefaultDialect( (String) this.dialects.remove( "drools.dialect.default" ) );
}
public int getCompiler() {
@@ -66,11 +131,6 @@
}
public String getJavaLanguageLevel() {
- if ( this.languageLevel != null ) {
- return this.languageLevel;
- }
- setJavaLanguageLevel( System.getProperty( "drools.compiler.lnglevel",
- DEFAULT_LANGUAGE_LEVEL ) );
return this.languageLevel;
}
@@ -78,22 +138,41 @@
* You cannot set language level below 1.5, as we need static imports, 1.5 is now the default.
* @param level
*/
- public void setJavaLanguageLevel(final String level) {
+ public void setJavaLanguageLevel(final String languageLevel) {
if ( Arrays.binarySearch( LANGUAGE_LEVELS,
- this.languageLevel ) < 0 ) {
- throw new RuntimeDroolsException( "value '" + this.languageLevel + "' is not a valid language level" );
+ languageLevel ) < 0 ) {
+ throw new RuntimeDroolsException( "value '" + languageLevel + "' is not a valid language level" );
}
- this.languageLevel = level;
+ this.languageLevel = languageLevel;
}
- public String getDialect() {
- return this.dialect;
+ public DialectRegistry buildDialectRegistry(PackageBuilder packageBuilder) {
+ DialectRegistry registry = new DialectRegistry();
+ for ( Iterator it = this.dialects.entrySet().iterator(); it.hasNext(); ) {
+ Entry entry = (Entry) it.next();
+ String str = (String) entry.getKey();
+ String dialectName = str.substring( str.lastIndexOf( "." ) + 1 );
+ String dialectClass = (String) entry.getValue();
+ try {
+ Class cls = this.classLoader.loadClass( dialectClass );
+ Constructor cons = cls.getConstructor( new Class[] { PackageBuilder.class } );
+ registry.addDialect( dialectName,
+ (Dialect) cons.newInstance( new Object[] { packageBuilder } ) );
+ } catch ( Exception e ) {
+ throw new RuntimeDroolsException( "Unable to load dialect '" + dialectClass + ":" + dialectName + "'" );
+ }
+ }
+ return registry;
}
- public void setDialect(String dialect) {
- this.dialect = dialect;
+ public String getDefaultDialect() {
+ return this.defaultDialect;
}
+ public void setDefaultDialect(String defaultDialect) {
+ this.defaultDialect = defaultDialect;
+ }
+
/**
* Set the compiler to be used when building the rules semantic code blocks.
* This overrides the default, and even what was set as a system property.
@@ -122,26 +201,15 @@
}
}
- static String getDefaultDialect() {
- String dialect = System.getProperty( "drools.dialect",
- "java" );
-
- if ( Arrays.binarySearch( DIALECTS,
- dialect ) < 0 ) {
- throw new RuntimeDroolsException( " dialect is not a valid registered dialect" );
- }
- return dialect;
- }
-
/**
* This will attempt to read the System property to work out what default to set.
* This should only be done once when the class is loaded. After that point, you will have
* to programmatically override it.
*/
- static int getDefaultCompiler() {
+ private int getDefaultCompiler() {
try {
- final String prop = System.getProperty( "drools.compiler",
- "ECLIPSE" );
+ final String prop = this.chainedProperties.getProperty( "drools.compiler",
+ "ECLIPSE" );
if ( prop.equals( "ECLIPSE".intern() ) ) {
return PackageBuilderConfiguration.ECLIPSE;
} else if ( prop.equals( "JANINO" ) ) {
@@ -156,20 +224,29 @@
}
}
- static String getDefaultLanguageLevel() {
- try {
- final String languageLevel = System.getProperty( "drools.compiler.languagelevel",
- DEFAULT_LANGUAGE_LEVEL );
+ private String getDefaultLanguageLevel() {
+ String level = this.chainedProperties.getProperty( "drools.compiler.lnglevel",
+ null );
- if ( Arrays.binarySearch( LANGUAGE_LEVELS,
- languageLevel ) < 0 ) {
- throw new RuntimeDroolsException( "value '" + languageLevel + "' is not a valid language level" );
+ if ( level == null ) {
+ String version = System.getProperty( "java.version" );
+ if ( version.startsWith( "1.4" ) ) {
+ level = "1.4";
+ } else if ( version.startsWith( "1.5" ) ) {
+ level = "1.5";
+ } else if ( version.startsWith( "1.6" ) ) {
+ level = "1.6";
+ } else {
+ level = "1.4";
}
+ }
- return languageLevel;
- } catch ( final Exception e ) {
- System.err.println( "Drools config: unable to read the drools.compiler.lnglevel property. Using default." );
- return DEFAULT_LANGUAGE_LEVEL;
+ if ( Arrays.binarySearch( LANGUAGE_LEVELS,
+ level ) < 0 ) {
+ throw new RuntimeDroolsException( "value '" + level + "' is not a valid language level" );
}
+
+ return level;
}
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuildContext.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuildContext.java 2007-05-31 03:36:42 UTC (rev 12250)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuildContext.java 2007-05-31 03:36:53 UTC (rev 12251)
@@ -113,12 +113,12 @@
ruleDescr,
ruleDescr.getAttributes() );
- String dialectName = (this.rule.getDialect() != null) ? this.rule.getDialect() : "default";
+ String dialectName = this.rule.getDialect();
this.defaultDialectName = dialectName;
this.dialectRegistry = dialectRegistry;
- dialectRegistry.getDialect( this.defaultDialectName ).init( ruleDescr );
+ getDialect().init( ruleDescr );
}
public Dialect getDialect() {
Added: labs/jbossrules/trunk/drools-compiler/src/main/resources/META-INF/drools.default.packagebuilder.conf
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/resources/META-INF/drools.default.packagebuilder.conf (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/resources/META-INF/drools.default.packagebuilder.conf 2007-05-31 03:36:53 UTC (rev 12251)
@@ -0,0 +1,4 @@
+drools.dialect.default = java
+drools.dialect.java = org.drools.rule.builder.dialect.java.JavaDialect
+drools.dialect.mvel = org.drools.rule.builder.dialect.mvel.MVELDialect
+drools.compiler = ECLIPSE
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderConfigurationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderConfigurationTest.java 2007-05-31 03:36:42 UTC (rev 12250)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderConfigurationTest.java 2007-05-31 03:36:53 UTC (rev 12251)
@@ -1,18 +1,21 @@
package org.drools.compiler;
+import java.util.Properties;
+
import junit.framework.TestCase;
public class PackageBuilderConfigurationTest extends TestCase {
- public void testSystemProperty() {
- final PackageBuilderConfiguration cfg = new PackageBuilderConfiguration();
- assertEquals( cfg.getCompiler(),
- PackageBuilderConfiguration.getDefaultCompiler() );
+ public void testSystemProperties() {
+ PackageBuilderConfiguration cfg = new PackageBuilderConfiguration();
+ assertEquals( PackageBuilderConfiguration.ECLIPSE,
+ cfg.getCompiler() );
System.setProperty( "drools.compiler",
"JANINO" );
+ cfg = new PackageBuilderConfiguration();
assertEquals( PackageBuilderConfiguration.JANINO,
- PackageBuilderConfiguration.getDefaultCompiler() );
+ cfg.getCompiler() );
final PackageBuilderConfiguration cfg2 = new PackageBuilderConfiguration();
assertEquals( cfg.getCompiler(),
@@ -20,8 +23,9 @@
System.setProperty( "drools.compiler",
"ECLIPSE" );
+ cfg = new PackageBuilderConfiguration();
assertEquals( PackageBuilderConfiguration.ECLIPSE,
- PackageBuilderConfiguration.getDefaultCompiler() );
+ cfg.getCompiler() );
cfg2.setCompiler( PackageBuilderConfiguration.ECLIPSE );
assertEquals( PackageBuilderConfiguration.ECLIPSE,
@@ -38,4 +42,40 @@
}
+ public void testProgrammaticProperties() {
+ PackageBuilderConfiguration cfg = new PackageBuilderConfiguration();
+ assertEquals( "java",
+ cfg.getDefaultDialect() );
+
+ Properties properties = new Properties();
+ properties.setProperty( "drools.dialect.default",
+ "tea" );
+ PackageBuilderConfiguration cfg1 = new PackageBuilderConfiguration( properties );
+ assertEquals( "tea",
+ cfg1.getDefaultDialect() );
+
+ final PackageBuilderConfiguration cfg2 = new PackageBuilderConfiguration(properties);
+ assertEquals( cfg1.getDefaultDialect(),
+ cfg2.getDefaultDialect() );
+
+ properties = new Properties();
+ properties.setProperty( "drools.dialect.default",
+ "coke" );
+ PackageBuilderConfiguration cfg3 = new PackageBuilderConfiguration( properties );
+ assertEquals( "coke",
+ cfg3.getDefaultDialect() );
+
+ cfg2.setDefaultDialect( "orange" );
+ assertEquals( "orange",
+ cfg2.getDefaultDialect() );
+
+ cfg2.setDefaultDialect( "lemonade" );
+ assertEquals( "lemonade",
+ cfg2.getDefaultDialect() );
+
+ final PackageBuilderConfiguration cfg4 = new PackageBuilderConfiguration();
+
+ assertEquals( cfg.getDefaultDialect(),
+ cfg4.getDefaultDialect() );
+ }
}
More information about the jboss-svn-commits
mailing list