[jboss-svn-commits] JBL Code SVN: r33961 - in labs/jbossrules/trunk: drools-core/src/main/java/org/drools and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jul 16 17:32:40 EDT 2010
Author: tirelli
Date: 2010-07-16 17:32:40 -0400 (Fri, 16 Jul 2010)
New Revision: 33961
Added:
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/conf/KeepReferenceOption.java
Modified:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/SessionConfiguration.java
Log:
Adding KeepReferenceOption to be used in session configuration
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/conf/KeepReferenceOption.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/conf/KeepReferenceOption.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/conf/KeepReferenceOption.java 2010-07-16 21:32:40 UTC (rev 33961)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2008 Red Hat
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.runtime.conf;
+
+
+/**
+ * Option to configure if the knowledge base should retain a reference to the
+ * knowledge session or not.
+ *
+ * default == true
+ *
+ * @author etirelli
+ */
+public enum KeepReferenceOption implements SingleValueKnowledgeSessionOption {
+
+ YES(true),
+ NO(false);
+
+ private static final long serialVersionUID = -8461267995706982981L;
+
+ /**
+ * The property name for the keep reference configuration
+ */
+ public static final String PROPERTY_NAME = "drools.keepReference";
+
+ private final boolean keepReference;
+
+ /**
+ * Private constructor to enforce the use of the factory method
+ * @param clockType
+ */
+ private KeepReferenceOption( final boolean keepReference ) {
+ this.keepReference = keepReference;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getPropertyName() {
+ return PROPERTY_NAME;
+ }
+
+ public boolean isKeepReference() {
+ return keepReference;
+ }
+
+}
Property changes on: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/conf/KeepReferenceOption.java
___________________________________________________________________
Name: svn:executable
+ *
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/SessionConfiguration.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/SessionConfiguration.java 2010-07-16 20:35:50 UTC (rev 33960)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/SessionConfiguration.java 2010-07-16 21:32:40 UTC (rev 33961)
@@ -33,6 +33,7 @@
import org.drools.runtime.Environment;
import org.drools.runtime.KnowledgeSessionConfiguration;
import org.drools.runtime.conf.ClockTypeOption;
+import org.drools.runtime.conf.KeepReferenceOption;
import org.drools.runtime.conf.KnowledgeSessionOption;
import org.drools.runtime.conf.MultiValueKnowledgeSessionOption;
import org.drools.runtime.conf.SingleValueKnowledgeSessionOption;
@@ -129,10 +130,10 @@
this.chainedProperties.addProperties( properties );
}
- setKeepReference( Boolean.valueOf( this.chainedProperties.getProperty( "drools.keepReference",
+ setKeepReference( Boolean.valueOf( this.chainedProperties.getProperty( KeepReferenceOption.PROPERTY_NAME,
"true" ) ).booleanValue() );
- setClockType( ClockType.resolveClockType( this.chainedProperties.getProperty( "drools.clockType",
+ setClockType( ClockType.resolveClockType( this.chainedProperties.getProperty( ClockTypeOption.PROPERTY_NAME,
"realtime" ) ) );
}
@@ -149,9 +150,9 @@
return;
}
- if ( name.equals( "drools.keepReference" ) ) {
+ if ( name.equals( KeepReferenceOption.PROPERTY_NAME ) ) {
setKeepReference( StringUtils.isEmpty( value ) ? true : Boolean.parseBoolean( value ) );
- } else if ( name.equals( "drools.clockType" ) ) {
+ } else if ( name.equals( ClockTypeOption.PROPERTY_NAME ) ) {
setClockType( ClockType.resolveClockType( StringUtils.isEmpty( value ) ? "realtime" : value ) );
}
}
@@ -162,9 +163,9 @@
return null;
}
- if ( name.equals( "drools.keepReference" ) ) {
+ if ( name.equals( KeepReferenceOption.PROPERTY_NAME ) ) {
return Boolean.toString( this.keepReference );
- } else if ( name.equals( "drools.clockType" ) ) {
+ } else if ( name.equals( ClockTypeOption.PROPERTY_NAME ) ) {
return this.clockType.toExternalForm();
}
@@ -403,6 +404,8 @@
public <T extends SingleValueKnowledgeSessionOption> T getOption(Class<T> option) {
if ( ClockTypeOption.class.equals( option ) ) {
return (T) ClockTypeOption.get( getClockType().toExternalForm() );
+ } else if( KeepReferenceOption.class.equals( option ) ) {
+ return (T) ( this.keepReference ? KeepReferenceOption.YES : KeepReferenceOption.NO );
}
return null;
}
@@ -415,6 +418,8 @@
public <T extends KnowledgeSessionOption> void setOption(T option) {
if ( option instanceof ClockTypeOption ) {
setClockType( ClockType.resolveClockType( ((ClockTypeOption) option ).getClockType() ) );
+ } else if( option instanceof KeepReferenceOption ) {
+ setKeepReference( ((KeepReferenceOption) option).isKeepReference() );
}
}
More information about the jboss-svn-commits
mailing list