[jbpm-commits] JBoss JBPM SVN: r5737 - in jbpm4/trunk/modules: test-cfg/src/test/java/org/jbpm/test and 3 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Oct 13 05:40:40 EDT 2009
Author: tom.baeyens at jboss.com
Date: 2009-10-13 05:40:39 -0400 (Tue, 13 Oct 2009)
New Revision: 5737
Added:
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/CustomVariableTypeTest.java
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/Husky.java
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/HuskyMatcher.java
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/HuskyVariable.java
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/husky.hbm.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.hibernate.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.variable.types.xml
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java
Log:
added cusom variable type example
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java 2009-10-13 01:51:40 UTC (rev 5736)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java 2009-10-13 09:40:39 UTC (rev 5737)
@@ -37,8 +37,9 @@
import org.jbpm.pvm.internal.type.matcher.HibernateLongIdMatcher;
import org.jbpm.pvm.internal.type.matcher.HibernateStringIdMatcher;
import org.jbpm.pvm.internal.type.matcher.SerializableMatcher;
-import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.descriptor.TypesDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
@@ -144,7 +145,8 @@
Element matcherObjectElement = XmlUtil.element(matcherElement);
if (matcherObjectElement!=null) {
try {
- matcher = (Matcher) parser.parseElement(matcherObjectElement, parse);
+ Descriptor descriptor = (Descriptor) parser.parseElement(matcherObjectElement, parse);
+ matcher = (Matcher) WireContext.create(descriptor);
} catch (ClassCastException e) {
parse.addProblem("matcher is not a "+Matcher.class.getName()+": "+(matcher!=null ? matcher.getClass().getName() : "null"), element);
}
Added: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/CustomVariableTypeTest.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/CustomVariableTypeTest.java (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/CustomVariableTypeTest.java 2009-10-13 09:40:39 UTC (rev 5737)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.customtype;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.JbpmCustomCfgTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CustomVariableTypeTest extends JbpmCustomCfgTestCase {
+
+ public void testCustomVariable() {
+ deployJpdlXmlString(
+ "<process name='CustomVariable'>" +
+ " <start>" +
+ " <transition to='s' />" +
+ " </start>" +
+ " <state name='s' />" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("dog", new Husky("max"));
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("CustomVariable", variables);
+
+ String pid = processInstance.getId();
+ Husky husky = (Husky) executionService.getVariable(pid, "dog");
+ assertEquals("max", husky.getName());
+ }
+}
Property changes on: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/CustomVariableTypeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/Husky.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/Husky.java (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/Husky.java 2009-10-13 09:40:39 UTC (rev 5737)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.customtype;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Husky {
+
+ String name;
+
+ public Husky(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
Property changes on: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/Husky.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/HuskyMatcher.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/HuskyMatcher.java (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/HuskyMatcher.java 2009-10-13 09:40:39 UTC (rev 5737)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.customtype;
+
+import org.jbpm.pvm.internal.type.Matcher;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HuskyMatcher implements Matcher {
+
+ private static final long serialVersionUID = 1L;
+
+ public boolean matches(String name, Object value) {
+ return value instanceof Husky;
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/HuskyMatcher.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/HuskyVariable.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/HuskyVariable.java (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/HuskyVariable.java 2009-10-13 09:40:39 UTC (rev 5737)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.customtype;
+
+import org.jbpm.pvm.internal.type.Variable;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HuskyVariable extends Variable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String name;
+
+ protected Object getObject() {
+ return new Husky(name);
+ }
+
+ public boolean isStorable(Object value) {
+ return value instanceof Husky;
+ }
+
+ protected void setObject(Object value) {
+ name = ((Husky)value).getName();
+ }
+}
Property changes on: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/customtype/HuskyVariable.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/husky.hbm.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/husky.hbm.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/husky.hbm.xml 2009-10-13 09:40:39 UTC (rev 5737)
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping default-access="field">
+
+ <subclass name="org.jbpm.test.customtype.HuskyVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="husky">
+ <property name="name" column="STRING_VALUE_" type="string"/>
+ </subclass>
+
+</hibernate-mapping>
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/husky.hbm.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.cfg.xml 2009-10-13 09:40:39 UTC (rev 5737)
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.businesscalendar.cfg.xml" />
+ <import resource="jbpm.tx.hibernate.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.identity.cfg.xml" />
+
+ <process-engine-context>
+
+ <types resource="org/jbpm/test/customtype/jbpm.variable.types.xml" />
+
+ <hibernate-configuration>
+ <cfg resource="org/jbpm/test/customtype/jbpm.hibernate.cfg.xml" />
+ </hibernate-configuration>
+
+
+
+ <repository-service />
+ <repository-cache />
+ <execution-service />
+ <history-service />
+ <management-service />
+ <identity-service />
+ <task-service />
+
+ <hibernate-session-factory />
+
+ <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator" init="eager">
+ <field name="commandService"><ref object="newTxRequiredCommandService" /></field>
+ <invoke method="initialize" />
+ </object>
+
+ <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
+
+ <script-manager default-expression-language="juel"
+ default-script-language="juel">
+ <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
+ </script-manager>
+
+ <address-resolver />
+
+ <mail-template name='task-notification'>
+ <to users="${task.assignee}"/>
+ <subject>${task.name}</subject>
+ <text><![CDATA[Hi ${task.assignee},
+Task "${task.name}" has been assigned to you.
+${task.description}
+
+Sent by JBoss jBPM
+]]></text>
+ </mail-template>
+
+ <mail-template name='task-reminder'>
+ <to users="${task.assignee}"/>
+ <subject>${task.name}</subject>
+ <text><![CDATA[Hey ${task.assignee},
+Do not forget about task "${task.name}".
+${task.description}
+
+Sent by JBoss jBPM
+]]></text>
+ </mail-template>
+
+ </process-engine-context>
+
+ <transaction-context>
+ <repository-session />
+ <db-session />
+
+ <message-session />
+ <timer-session />
+ <history-session />
+ <mail-session>
+ <mail-server>
+ <session-properties resource="jbpm.mail.properties" />
+ </mail-server>
+ </mail-session>
+ </transaction-context>
+
+</jbpm-configuration>
Property changes on: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.cfg.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.hibernate.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.hibernate.cfg.xml 2009-10-13 09:40:39 UTC (rev 5737)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+ <property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
+ <property name="hibernate.connection.username">sa</property>
+ <property name="hibernate.connection.password"></property>
+ <property name="hibernate.hbm2ddl.auto">create-drop</property>
+ <property name="hibernate.format_sql">true</property>
+
+ <mapping resource="org/jbpm/test/customtype/husky.hbm.xml" />
+
+ <mapping resource="jbpm.repository.hbm.xml" />
+ <mapping resource="jbpm.execution.hbm.xml" />
+ <mapping resource="jbpm.history.hbm.xml" />
+ <mapping resource="jbpm.task.hbm.xml" />
+ <mapping resource="jbpm.identity.hbm.xml" />
+
+ </session-factory>
+</hibernate-configuration>
Property changes on: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.hibernate.cfg.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.variable.types.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.variable.types.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.variable.types.xml 2009-10-13 09:40:39 UTC (rev 5737)
@@ -0,0 +1,38 @@
+<types>
+
+ <type name="husky" variable-class="org.jbpm.test.customtype.HuskyVariable">
+ <matcher><object class="org.jbpm.test.customtype.HuskyMatcher" /></matcher>
+ </type>
+
+ <!-- types stored in a native column -->
+ <type name="string" class="java.lang.String" variable-class="org.jbpm.pvm.internal.type.variable.StringVariable" />
+ <type name="long" class="java.lang.Long" variable-class="org.jbpm.pvm.internal.type.variable.LongVariable" />
+ <type name="double" class="java.lang.Double" variable-class="org.jbpm.pvm.internal.type.variable.DoubleVariable" />
+
+ <!-- types converted to a string -->
+ <type name="date" class="java.util.Date" converter="org.jbpm.pvm.internal.type.converter.DateToStringConverter" variable-class="org.jbpm.pvm.internal.type.variable.StringVariable" />
+ <type name="boolean" class="java.lang.Boolean" converter="org.jbpm.pvm.internal.type.converter.BooleanToStringConverter" variable-class="org.jbpm.pvm.internal.type.variable.StringVariable" />
+ <type name="char" class="java.lang.Character" converter="org.jbpm.pvm.internal.type.converter.CharacterToStringConverter" variable-class="org.jbpm.pvm.internal.type.variable.StringVariable" />
+
+ <!-- types converted to a long -->
+ <type name="byte" class="java.lang.Byte" converter="org.jbpm.pvm.internal.type.converter.ByteToLongConverter" variable-class="org.jbpm.pvm.internal.type.variable.LongVariable" />
+ <type name="short" class="java.lang.Short" converter="org.jbpm.pvm.internal.type.converter.ShortToLongConverter" variable-class="org.jbpm.pvm.internal.type.variable.LongVariable" />
+ <type name="integer" class="java.lang.Integer" converter="org.jbpm.pvm.internal.type.converter.IntegerToLongConverter" variable-class="org.jbpm.pvm.internal.type.variable.LongVariable" />
+
+ <!-- types converted to a double -->
+ <type name="float" class="java.lang.Float" converter="org.jbpm.pvm.internal.type.converter.FloatToDoubleConverter" variable-class="org.jbpm.pvm.internal.type.variable.DoubleVariable" />
+
+ <!-- byte[] and char[] -->
+ <type name="byte[]" class="[B" variable-class="org.jbpm.pvm.internal.type.variable.BlobVariable" />
+ <type name="char[]" class="[C" variable-class="org.jbpm.pvm.internal.type.variable.TextVariable" />
+
+ <type name="hibernate-long-id" class="hibernatable" id-type="long" variable-class="org.jbpm.pvm.internal.type.variable.HibernateLongVariable" />
+ <type name="hibernate-string-id" class="hibernatable" id-type="string" variable-class="org.jbpm.pvm.internal.type.variable.HibernateStringVariable" />
+
+ <type name="serializable" class="serializable" converter="org.jbpm.pvm.internal.type.converter.SerializableToBytesConverter" variable-class="org.jbpm.pvm.internal.type.variable.BlobVariable" />
+
+ <!-- TODO: add ejb3 entity bean support -->
+ <!-- TODO: add JCR activity support -->
+ <!-- TODO: add collection support -->
+
+</types>
Property changes on: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.variable.types.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the jbpm-commits
mailing list