[jboss-svn-commits] JBL Code SVN: r20565 - in labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin: META-INF and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jun 17 19:00:47 EDT 2008
Author: KrisVerlaenen
Date: 2008-06-17 19:00:46 -0400 (Tue, 17 Jun 2008)
New Revision: 20565
Removed:
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/RealtimeAuditView.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.drl.template
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rfm.template
Modified:
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/META-INF/MANIFEST.MF
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizard.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rf.template
Log:
- Updated RuleFlow HelloWorld example
- removed .rfm file
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/META-INF/MANIFEST.MF
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/META-INF/MANIFEST.MF 2008-06-17 22:56:15 UTC (rev 20564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/META-INF/MANIFEST.MF 2008-06-17 23:00:46 UTC (rev 20565)
@@ -4,7 +4,7 @@
Bundle-SymbolicName: org.drools.eclipse;singleton:=true
Bundle-Version: 5.0.0.SNAPSHOT
Bundle-Activator: org.drools.eclipse.DroolsEclipsePlugin
-Bundle-Vendor: krisv,mic
+Bundle-Vendor: JBoss Drools
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml 2008-06-17 22:56:15 UTC (rev 20564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml 2008-06-17 23:00:46 UTC (rev 20565)
@@ -27,16 +27,7 @@
class="org.drools.eclipse.debug.ApplicationDataView"
id="org.drools.eclipse.debug.ApplicationDataView">
</view>
- <!--
<view
- name="Realtime Audit View"
- icon="icons/drools.gif"
- category="org.drools.eclipse.views"
- class="org.drools.eclipse.debug.RealtimeAuditView"
- id="org.drools.eclipse.debug.RealtimeAuditView">
- </view>
- -->
- <view
name="Process Instances View"
icon="icons/drools.gif"
category="org.drools.eclipse.views"
@@ -124,7 +115,7 @@
name="Domain Specific Language"/>
<wizard
id = "org.drools.eclipse.wizards.new.project"
- name = "Rule Project"
+ name = "Drools Project"
class= "org.drools.eclipse.wizard.project.NewDroolsProjectWizard"
category= "org.drools.eclipse.new"
project= "true"
Deleted: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/RealtimeAuditView.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/RealtimeAuditView.java 2008-06-17 22:56:15 UTC (rev 20564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/RealtimeAuditView.java 2008-06-17 23:00:46 UTC (rev 20565)
@@ -1,105 +0,0 @@
-package org.drools.eclipse.debug;
-
-import java.io.ObjectInputStream;
-import java.io.StringReader;
-import java.util.List;
-
-import org.drools.eclipse.DroolsEclipsePlugin;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IValue;
-import org.eclipse.debug.core.model.IVariable;
-import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.jdt.debug.core.IJavaObject;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IWorkbenchPart;
-
-import com.thoughtworks.xstream.XStream;
-
-/**
- * An audit view that shows the contents of the selected logger when debugging.
- *
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class RealtimeAuditView extends AuditView implements ISelectionListener {
-
- public void dispose() {
- getSite().getPage().removeSelectionListener(IDebugUIConstants.ID_VARIABLE_VIEW, this);
- super.dispose();
- }
-
- protected Viewer createViewer(Composite parent) {
- getSite().getPage().addSelectionListener(IDebugUIConstants.ID_VARIABLE_VIEW, this);
- return super.createViewer(parent);
- }
-
- protected void setViewerInput(Object context) {
- // if an in memory logger has been explicitly selected as variable
- if (context instanceof IVariable) {
- IVariable variable = (IVariable) context;
- try {
- IValue value = ((IVariable) context).getValue();
- if (value != null && value instanceof IJavaObject
- && "org.drools.audit.WorkingMemoryInMemoryLogger".equals(
- variable.getValue().getReferenceTypeName())) {
- setAuditEvents((IJavaObject) value);
- }
- } catch (Throwable t) {
- DroolsEclipsePlugin.log(t);
- }
- }
- }
-
- protected void becomesHidden() {
- setViewerInput(null);
- super.becomesHidden();
- }
-
- protected void becomesVisible() {
- super.becomesVisible();
- ISelection selection = getSite().getPage().getSelection(
- IDebugUIConstants.ID_VARIABLE_VIEW);
- if (selection instanceof IStructuredSelection) {
- setViewerInput(((IStructuredSelection) selection).getFirstElement());
- }
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if (!isAvailable()) {
- return;
- }
- if (selection == null) {
- setViewerInput(null);
- } else if (selection instanceof IStructuredSelection) {
- setViewerInput(((IStructuredSelection) selection).getFirstElement());
- }
- }
-
- protected void createActions() {
- }
-
- protected void configureToolBar(IToolBarManager tbm) {
- }
-
- private void setAuditEvents(IJavaObject inMemoryLogger) throws DebugException {
- IValue eventString = DebugUtil.getValueByExpression("return getEvents();", inMemoryLogger);
- String s = eventString.getValueString();
- if (s != null) {
- try {
- XStream xstream = new XStream();
- ObjectInputStream in = xstream.createObjectInputStream(
- new StringReader(s));
- getViewer().setInput(createEventList((List) in.readObject()));
- } catch (Throwable t) {
- DroolsEclipsePlugin.log(t);
- getViewer().setInput(null);
- }
- } else {
- getViewer().setInput(null);
- }
- }
-}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor.java 2008-06-17 22:56:15 UTC (rev 20564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor.java 2008-06-17 23:00:46 UTC (rev 20565)
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -41,10 +40,6 @@
import org.drools.xml.XmlProcessReader;
import org.drools.xml.XmlRuleFlowProcessDumper;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPartFactory;
import org.eclipse.gef.palette.CombinedTemplateCreationEntry;
@@ -52,12 +47,9 @@
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.requests.SimpleFactory;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.part.FileEditorInput;
/**
* Graphical editor for a RuleFlow.
@@ -169,54 +161,6 @@
writer.close();
}
- public void doSave(IProgressMonitor monitor) {
- super.doSave(monitor);
- // save process as separate model file as well
- IFile file = ((IFileEditorInput) getEditorInput()).getFile();
- final IFile modelFile = getModelFile(file);
-
- if (!modelFile.exists()) {
- WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
- public void execute(final IProgressMonitor monitor)
- throws CoreException {
- try {
- XmlRuleFlowProcessDumper dumper = XmlRuleFlowProcessDumper.INSTANCE;
- String out = dumper.dump(getRuleFlowModel().getRuleFlowProcess(), false);
- modelFile.create(new ByteArrayInputStream(out.getBytes()), true, monitor);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- };
-
- try {
- new ProgressMonitorDialog(getSite().getWorkbenchWindow().getShell())
- .run(false, true, op);
- setInput(new FileEditorInput(file));
- getCommandStack().markSaveLocation();
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else {
- try {
- XmlRuleFlowProcessDumper dumper = XmlRuleFlowProcessDumper.INSTANCE;
- String out = dumper.dump(getRuleFlowModel().getRuleFlowProcess(), false);
- modelFile.setContents(new ByteArrayInputStream(out.getBytes()), true, false, monitor);
- } catch (Throwable t) {
- DroolsEclipsePlugin.log(t);
- }
- }
- }
-
- private IFile getModelFile(IFile file) {
- IProject project = file.getProject();
- IPath path = file.getProjectRelativePath();
- String fileName = file.getName().substring(0, file.getName().length() - 2) + "rfm";
- IPath modelPath = path.removeLastSegments(1).append(fileName);
- IFile modelFile = project.getFile(modelPath);
- return modelFile;
- }
-
protected void createModel(InputStream is) {
try {
InputStreamReader reader = new InputStreamReader(is);
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizard.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizard.java 2008-06-17 22:56:15 UTC (rev 20564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizard.java 2008-06-17 23:00:46 UTC (rev 20565)
@@ -357,24 +357,6 @@
} else {
file.setContents(inputstream, true, false, monitor);
}
- fileName = "org/drools/eclipse/wizard/project/ruleflow.rfm.template";
- folder = project.getProject().getFolder("src/main/rules");
- file = folder.getFile("ruleflow.rfm");
- inputstream = getClass().getClassLoader().getResourceAsStream(fileName);
- if (!file.exists()) {
- file.create(inputstream, true, monitor);
- } else {
- file.setContents(inputstream, true, false, monitor);
- }
- fileName = "org/drools/eclipse/wizard/project/ruleflow.drl.template";
- folder = project.getProject().getFolder("src/main/rules");
- file = folder.getFile("ruleflow.drl");
- inputstream = getClass().getClassLoader().getResourceAsStream(fileName);
- if (!file.exists()) {
- file.create(inputstream, true, monitor);
- } else {
- file.setContents(inputstream, true, false, monitor);
- }
}
/**
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template 2008-06-17 22:56:15 UTC (rev 20564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template 2008-06-17 23:00:46 UTC (rev 20565)
@@ -5,7 +5,7 @@
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
-import org.drools.WorkingMemory;
+import org.drools.StatefulSession;
import org.drools.compiler.PackageBuilder;
import org.drools.rule.Package;
@@ -14,86 +14,34 @@
*/
public class RuleFlowTest {
- public static final void main(String[] args) {
- try {
-
- //load up the rulebase
- RuleBase ruleBase = readRule();
- WorkingMemory workingMemory = ruleBase.newStatefulSession();
-
- //go !
- Message message = new Message();
- message.setMessage( "Hello World" );
- message.setStatus( Message.HELLO );
- workingMemory.insert( message );
-
- workingMemory.startProcess("com.sample.ruleflow");
- workingMemory.fireAllRules();
-
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
+ public static final void main(String[] args) {
+ try {
+ //load the process
+ RuleBase ruleBase = createKnowledgeBase();
+ // create a new session
+ StatefulSession session = ruleBase.newStatefulSession();
+ // start a new process instance
+ session.startProcess("com.sample.ruleflow");
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
- /**
- * Please note that this is the "low level" rule assembly API.
- */
- private static RuleBase readRule() throws Exception {
- //read in the source
- Reader source = new InputStreamReader( RuleFlowTest.class.getResourceAsStream( "/ruleflow.drl" ) );
-
- //optionally read in the DSL (if you are using it).
- //Reader dsl = new InputStreamReader( DroolsTest.class.getResourceAsStream( "/mylang.dsl" ) );
-
- //Use package builder to build up a rule package.
- //An alternative lower level class called "DrlParser" can also be used...
-
+ /**
+ * Creates the knowledge base by loading the process definition.
+ */
+ private static RuleBase createKnowledgeBase() throws Exception {
+ // create a builder
PackageBuilder builder = new PackageBuilder();
-
- //this will parse and compile in one step
- //NOTE: There are 2 methods here, the one argument one is for normal DRL.
- builder.addPackageFromDrl( source );
-
- //Use the following instead of above if you are using a DSL:
- //builder.addPackageFromDrl( source, dsl );
-
- //add ruleflow
- source = new InputStreamReader( RuleFlowTest.class.getResourceAsStream( "/ruleflow.rfm" ) );
- builder.addRuleFlow(source);
-
- //get the compiled package (which is serializable)
+ // load the process
+ Reader source = new InputStreamReader(
+ RuleFlowTest.class.getResourceAsStream("/ruleflow.rf"));
+ builder.addProcessFromXml(source);
+ // create the knowledge base
Package pkg = builder.getPackage();
-
- //add the package to a rulebase (deploy the rule package).
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
- ruleBase.addPackage( pkg );
-
+ ruleBase.addPackage(pkg);
return ruleBase;
}
-
- public static class Message {
- public static final int HELLO = 0;
- public static final int GOODBYE = 1;
-
- private String message;
-
- private int status;
-
- public String getMessage() {
- return this.message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public int getStatus() {
- return this.status;
- }
-
- public void setStatus( int status ) {
- this.status = status;
- }
- }
-
-}
+
+}
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.drl.template
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.drl.template 2008-06-17 22:56:15 UTC (rev 20564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.drl.template 2008-06-17 23:00:46 UTC (rev 20565)
@@ -1,23 +0,0 @@
-package com.sample
-
-import com.sample.RuleFlowTest.Message;
-
-rule "Hello World" ruleflow-group "hello"
- when
- m : Message( status == Message.HELLO, message : message )
- then
- System.out.println( message );
- m.setMessage( "Goodbye cruel world" );
- m.setStatus( Message.GOODBYE );
- update( m );
-end
-
-rule "GoodBye" ruleflow-group "goodbye"
- no-loop true
- when
- m : Message( status == Message.GOODBYE, message : message )
- then
- System.out.println( message );
- m.setMessage( message );
-
-end
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rf.template
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rf.template 2008-06-17 22:56:15 UTC (rev 20564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rf.template 2008-06-17 23:00:46 UTC (rev 20565)
@@ -8,16 +8,14 @@
</header>
<nodes>
- <start id="1" name="Start" x="61" y="95" width="80" height="40" />
- <ruleSet id="2" name="Hello" x="200" y="94" width="80" height="40" ruleFlowGroup="hello" />
- <ruleSet id="3" name="Goodbye" x="328" y="95" ruleFlowGroup="goodbye" />
- <end id="4" name="End" x="466" y="95" width="80" height="40" />
+ <start id="1" name="Start" x="16" y="16" />
+ <action id="2" name="Hello" x="128" y="16" dialect="mvel" >System.out.println("Hello World");</action>
+ <end id="3" name="End" x="240" y="16" />
</nodes>
<connections>
- <connection from="1" to="2"/>
- <connection from="2" to="3"/>
- <connection from="3" to="4"/>
+ <connection from="1" to="2" />
+ <connection from="2" to="3" />
</connections>
</process>
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rfm.template
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rfm.template 2008-06-17 22:56:15 UTC (rev 20564)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rfm.template 2008-06-17 23:00:46 UTC (rev 20565)
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<process xmlns="http://drools.org/drools-4.0/process"
- xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
- xs:schemaLocation="http://drools.org/drools-4.0/process drools-processes-4.0.xsd"
- type="RuleFlow" name="ruleflow" id="com.sample.ruleflow" package-name="com.sample" >
-
- <header>
- </header>
-
- <nodes>
- <start id="1" name="Start" />
- <ruleSet id="2" name="Hello" ruleFlowGroup="hello" />
- <ruleSet id="3" name="Goodbye" ruleFlowGroup="goodbye" />
- <end id="4" name="End" />
- </nodes>
-
- <connections>
- <connection from="1" to="2"/>
- <connection from="2" to="3"/>
- <connection from="3" to="4"/>
- </connections>
-
-</process>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list