JBoss JBPM SVN: r4765 - in jbpm4/trunk/modules/userguide/src/main/docbook/en: modules and 1 other directory.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-05-07 16:20:07 -0400 (Thu, 07 May 2009)
New Revision: 4765
Removed:
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.open.in.xml.png
Modified:
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch01-Introduction.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Gpd.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Services.xml
Log:
userguide updates explaining the new build scripts
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.open.in.xml.png
===================================================================
(Binary files differ)
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch01-Introduction.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch01-Introduction.xml 2009-05-07 20:19:13 UTC (rev 4764)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch01-Introduction.xml 2009-05-07 20:20:07 UTC (rev 4765)
@@ -51,48 +51,5 @@
are not part of the support offerings.
</para>
</section>
-
- <section id="processdefinitionprocessinstanceandexecutions">
- <title>Process definition, process instance and executions</title>
- <para>A process definition is description of the steps in a procedure.
- For example, an insurance company could have a <literal>loan</literal>
- process definition that describes the steps of how the company deals
- with loan requests.
- </para>
- <figure id="loan.process.definition.example">
- <title>The loan process definition example</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/loan.process.definition.png"/></imageobject></mediaobject>
- </figure>
- <para>One process instance represents one particular run of a process definition.
- For example, the loan request of John Doe last Friday to finance his new boat
- is represented in one process instance of the loan process definition.
- </para>
- <para>A process instance contains all the runtime state. The
- most prominent property is the pointer that keeps track of the current activity.
- </para>
- <figure id="loan.process.instance.example">
- <title>The loan process instance example</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/loan.process.instance.png"/></imageobject></mediaobject>
- </figure>
- <para>Suppose that wiring the money and archiving can be done in parallel.
- Then the main process instance will have two child executions to keep
- track of the state like this:
- </para>
- <figure id="loan.executions.example">
- <title>The loan executions example</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/loan.executions.png"/></imageobject></mediaobject>
- </figure>
- <para>More general, a process instance is the root of a tree of executions.
- When a new process instance is started, the process instance is in fact the root
- execution scope. Only leaf executions can be active.
- </para>
- <para>The motivation to work with a tree structure like this is that
- this conceptually remains simple in the case where there is only one path
- of execution. The services API doesn't need to make a functional difference
- between process instances and executions. Therefore, the API has only
- one Execution type to refer to both <literal>ProcessInstance</literal>s and
- <literal>Execution</literal>s.
- </para>
- </section>
</chapter>
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml 2009-05-07 20:19:13 UTC (rev 4764)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml 2009-05-07 20:20:07 UTC (rev 4765)
@@ -2,78 +2,170 @@
<title>Installation</title>
<para>This chapter describes how to install jBPM in different
- application environments.
+ application environments.
</para>
<section id="thedistribution">
<title>The distribution</title>
<para>Just unzip the jBPM download to some location on your hard drive.
- You'll see following subdirectories.
+ You'll see following subdirectories:
</para>
+ <itemizedlist>
+ <listitem><literal>db</literal>: DB schema creation scripts</listitem>
+ <listitem><literal>doc</literal>: User guide, javadocs and developers guide</listitem>
+ <listitem><literal>examples</literal>: Example processes that are used in the user guide</listitem>
+ <listitem><literal>gpd</literal>: Graphical process designer plugin as an eclipse archived site</listitem>
+ <listitem><literal>jboss</literal>: JBoss installer to install jBPM into JBoss</listitem>
+ <listitem><literal>lib</literal>: Third party libs and some special jBPM libraries</listitem>
+ <listitem><literal>src</literal>: Sources</listitem>
+ <listitem><literal>jbpm.jar</literal>: The jBPM main library archive</listitem>
+ </itemizedlist>
</section>
- <section id="libraries">
- <title>Libraries</title>
- <para>The lib directory you'll find the jbpm libs and the third party libs.
- Including all the libraries in the lib directory, is the simplest way to get
- started. To minimize the number of jars that you need to include, see
- the developers guide.
+ <section id="gettingstartedquickly">
+ <title>Getting started quickly</title>
+ <para>The <emphasis role="bold">demo setup</emphasis> is the simplest way to get started.
+ This section describes the steps to complete the demo setup.
</para>
+ <para>If you have jboss-5.0.0.GA on locally on your machine, create a directory
+ called <literal>downloads</literal> in your jBPM home directory and copy
+ the jboss distribution zip file in there. Same for an Eclipse Ganymede SR2 JEE distribution
+ (eclipse-jee-ganymede-SR2-win32.zip). If you have it already locally, copy it to
+ the downloads directory. If you don't have those files in that place, they will be downloaded
+ automatically by the demo setup ant script.
+ </para>
+ <para>Open a command prompt and go do directory <literal>${jbpm.home}/jboss</literal>. Then
+ run
+ </para>
+ <programlisting>ant demo.setup</programlisting>
+ <para>That will</para>
+ <itemizedlist>
+ <listitem>Install JBoss into the <literal>${jbpm.home}/jboss-5.0.0.GA</literal> directory</listitem>
+ <listitem>Install jBPM into that JBoss installation. By default, this includes a hypersonic
+ database that is accessable over TCP/IP.
+ </listitem>
+ <listitem>Start JBoss. This will also start the hypersonic DB.</listitem>
+ <listitem>Create the DB Schema</listitem>
+ <listitem>Create an examples.bar business archive from the examples and deploy it to the jBPM DB.</listitem>
+ <listitem>Load the example users and groups from <literal>${jbpm.home}/db/example.identities.sql</literal> </listitem>
+ <listitem>Install eclipse into <literal>${jbpm.home}/eclipse</literal></listitem>
+ <listitem>Start eclipse</listitem>
+ </itemizedlist>
+ <para>Once this is done and eclipse has started, you can continue to follow the instructions
+ of <xref linkend="graphicalprocessdesigner" />
+ </para>
+ <para>And you can surf to <ulink url="http://localhost:8080/gwt-console">the jBPM console</ulink>
+ You can login as one of the following users:
+ </para>
+ <table><title>Example console users:</title>
+ <tgroup cols="2" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Username</entry>
+ <entry>Password</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>alex</entry>
+ <entry>password</entry>
+ </row>
+ <row>
+ <entry>mike</entry>
+ <entry>password</entry>
+ </row>
+ <row>
+ <entry>peter</entry>
+ <entry>password</entry>
+ </row>
+ <row>
+ <entry>mary</entry>
+ <entry>password</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
</section>
-
- <section id="tomcat-xxx">
- <title>Tomcat xxx</title>
- <para>TODO: this will contain a description of how to use the
- installer to install jbpm on tomcat</para>
+
+ <section id="antscripts">
+ <title>Ant scripts</title>
+ <para>As you already saw one example in the demo setup, the distribution a couple of ant
+ scripts:
+ </para>
+ <itemizedlist>
+ <listitem><literal>${jbpm.home}/jboss/build.xml</literal></listitem>
+ <listitem><literal>${jbpm.home}/db/build.xml</literal></listitem>
+ <listitem><literal>${jbpm.home}/gpd/build.xml</literal></listitem>
+ <listitem><literal>${jbpm.home}/examples/build.xml</literal></listitem>
+ </itemizedlist>
+ <para>With <literal>ant -p</literal> you can find out what each of these scripts can do.
+ </para>
+ <para>The scripts are parametrized with default values. Following properties you might
+ want to customize:
+ </para>
+ <itemizedlist>
+ <listitem><literal>database</literal> : Default value is <literal>hsqldb</literal>. Alternative values
+ are <literal>mysql</literal>, <literal>oracle</literal> and <literal>postgresql</literal></listitem>
+ <listitem><literal>jboss.version</literal> : Default value is <literal>5.0.0.GA</literal>. Alternative
+ value is <literal>5.0.1.GA</literal></listitem>
+ </itemizedlist>
+ <para>To customize the values for these properties, just use <literal>-D</literal> like this
+ </para>
+ <programlisting>ant -Ddatabase=postgresql demo.setup</programlisting>
+ <para>Or specify the customized values in <literal>${user.home}/.jbpm4/build.properties</literal>
+ </para>
+ <para>To specify your jdbc properties that are used in the DB schema generation, direct DB access like
+ deployment and for the JBoss datasource creation, the easiest is to update the appropriate
+ properties file in directory <literal>${jbpm.home}/db/jdbc</literal>. The appropriate properties
+ file will be loaded by the scripts that are DB related.
+ </para>
</section>
- <section id="jboss-xxx">
- <title>JBoss xxx</title>
- <para>TODO: this will contain a description of how to use the
- installer to install jbpm on jboss</para>
+ <section id="jboss">
+ <title>JBoss</title>
+ <para>The build file <literal>${jbpm.home}/jboss/build.xml</literal> contains scripts for
+ installing jBPM into JBoss 5. Navigate to that directory and run <literal>ant -p</literal>
+ for more details.
+ </para>
</section>
<section id="database">
<title>Database</title>
- <para>jBPM works with your database of choice. That way, jBPM's data
- tables can be placed next to your application tables in the same
- database. In case you're working outside an application server
- you can combine your application updates with jBPM's process updates in a
- single transaction by using the same JDBC connection.
+ <para>The build file <literal>${jbpm.home}/db/build.xml</literal> contains scripts for
+ DB operations like creating and dropping the schema. Navigate to that directory and run <literal>ant -p</literal>
+ for more details.
</para>
- <section>
- <title>Creating the DB tables</title>
- <para>In directory <literal>db</literal> the sql scripts to create
- the DB schema can be found for the supported databases.
- </para>
- </section>
</section>
+ <section id="tomcat">
+ <title>Tomcat</title>
+ <para>TODO: this will contain a description of how to use the
+ installer to install jbpm on tomcat</para>
+ </section>
+
<section id="configurationfiles">
<title>Configuration files</title>
- <para>TODO
+ <para>If you're not deploying in JBoss, then the example configuration files
+ in the examples <literal>src</literal> are the best starting point.
</para>
- <para>In the meantime, see in the examples for a set of example
- configuration files. Central file is jbpm.cfg.xml. All other files
- are referenced from that file.
- </para>
</section>
<section id="graphicalprocessdesigner">
<title>Graphical Process Designer (GPD)</title>
<para>Eclipse is used as the platform to host the jPDL graphical process
- designer. This section will describe how to obtain Eclipse, install it
- the GPD.</para>
+ designer. This section will describe how to obtain and install Eclipse and
+ how to install the GPD plugin in Eclipse.</para>
<section>
- <title>Download Eclipse</title>
- <para>You'll need Eclipse 3.4.1.
+ <title>Get Eclipse</title>
+ <para>You'll need Eclipse 3.4.2.
</para>
- <para>Download the
- <ulink url="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downlo...">Eclipse IDE for Java Developers (85 MB)</ulink> or
- <ulink url="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downlo...">Eclipse IDE for Java EE Developers (163 MB)</ulink>.
+ <para>Use the <link linkend="gettingstarted">demo setup</link> or download
+ eclipse manually:
+ <ulink url="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downlo...">Eclipse IDE for Java EE Developers (163 MB)</ulink>.
</para>
<para>The classic version of eclipse will not be sufficient as it does
- not have an XML editor.
+ not have an XML editor. Eclipse for Java developers should also
+ work.
</para>
</section>
<section>
@@ -176,5 +268,18 @@
</itemizedlist>
<para>You're all set to start playing with the coolest Java process technology!</para>
</section>
+
+ <section>
+ <title>Adding deployment with ant</title>
+ <para>You can leverage the eclipse ant integration to ease deployment of processes.
+ We'll show you how it works with the examples. Then you can copy this practice in your
+ own project. First, open up the Ant view.
+ </para>
+ <itemizedlist>
+ <listitem>Select <literal>Window</literal> --> <literal>Show View</literal> --> <literal>Other...</literal> --> <literal>Ant</literal> --> <literal>Ant</literal></listitem>
+ <listitem>Then drag the build file <literal>build.xml</literal> in the examples project from the package explorer to the Ant view</listitem>
+ </itemizedlist>
+ </section>
+
</section>
</chapter>
\ No newline at end of file
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Gpd.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Gpd.xml 2009-05-07 20:19:13 UTC (rev 4764)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Gpd.xml 2009-05-07 20:20:07 UTC (rev 4765)
@@ -39,19 +39,6 @@
<title>Editing jPDL using the source view</title>
<mediaobject><imageobject><imagedata align="center" fileref="images/gpd.xml.view.png"/></imageobject></mediaobject>
</figure>
- <para>You can of course still edit the process XML sources using the built in XML editor.
- To do this, select the process file, right click
- and select 'Open with...' --> 'XML editor'
- </para>
- <figure id="gpd.open.in.xml">
- <title>Open a process file in XML editor</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.open.in.xml.png"/></imageobject></mediaobject>
- </figure>
- <para>After you've done this, eclipse will remember that and the next time
- you double click it, eclipse will open your process file in the XML Editor
- automatically. To open up the process file in the GPD, perform the
- same Open-with-action, but select 'jBPM jPDL 4 Editor'
- </para>
</section>
</chapter>
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Services.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Services.xml 2009-05-07 20:19:13 UTC (rev 4764)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Services.xml 2009-05-07 20:20:07 UTC (rev 4765)
@@ -1,14 +1,55 @@
<chapter id="services">
<title>Services</title>
- <para>Interacting with jBPM occurs through services.
- The service interfaces can be obtained from the <literal>ProcessEngine</literal>
- which is build from a <literal>Configuration</literal>.
- </para>
-
+ <section id="processdefinitionprocessinstanceandexecutions">
+ <title>Process definition, process instance and executions</title>
+ <para>A process definition is description of the steps in a procedure.
+ For example, an insurance company could have a <literal>loan</literal>
+ process definition that describes the steps of how the company deals
+ with loan requests.
+ </para>
+ <figure id="loan.process.definition.example">
+ <title>The loan process definition example</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/loan.process.definition.png"/></imageobject></mediaobject>
+ </figure>
+ <para>One process instance represents one particular run of a process definition.
+ For example, the loan request of John Doe last Friday to finance his new boat
+ is represented in one process instance of the loan process definition.
+ </para>
+ <para>A process instance contains all the runtime state. The
+ most prominent property is the pointer that keeps track of the current activity.
+ </para>
+ <figure id="loan.process.instance.example">
+ <title>The loan process instance example</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/loan.process.instance.png"/></imageobject></mediaobject>
+ </figure>
+ <para>Suppose that wiring the money and archiving can be done in parallel.
+ Then the main process instance will have two child executions to keep
+ track of the state like this:
+ </para>
+ <figure id="loan.executions.example">
+ <title>The loan executions example</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/loan.executions.png"/></imageobject></mediaobject>
+ </figure>
+ <para>More general, a process instance is the root of a tree of executions.
+ When a new process instance is started, the process instance is in fact the root
+ execution scope. Only leaf executions can be active.
+ </para>
+ <para>The motivation to work with a tree structure like this is that
+ this conceptually remains simple in the case where there is only one path
+ of execution. The services API doesn't need to make a functional difference
+ between process instances and executions. Therefore, the API has only
+ one Execution type to refer to both <literal>ProcessInstance</literal>s and
+ <literal>Execution</literal>s.
+ </para>
+ </section>
+
<section id="processengine">
<title>ProcessEngine</title>
-
+ <para>Interacting with jBPM occurs through services.
+ The service interfaces can be obtained from the <literal>ProcessEngine</literal>
+ which is build from a <literal>Configuration</literal>.
+ </para>
<para>A <literal>ProcessEngine</literal> is thread safe and can be stored in a
static member field or even better in JNDI or some other central location.
One <literal>ProcessEngine</literal> object can be used by all requests and
16 years, 12 months
JBoss JBPM SVN: r4764 - jbpm4/trunk/modules/enterprise.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-05-07 16:19:13 -0400 (Thu, 07 May 2009)
New Revision: 4764
Modified:
jbpm4/trunk/modules/enterprise/pom.xml
Log:
removed generation of unused enterprise artifacts
Modified: jbpm4/trunk/modules/enterprise/pom.xml
===================================================================
--- jbpm4/trunk/modules/enterprise/pom.xml 2009-05-07 20:14:13 UTC (rev 4763)
+++ jbpm4/trunk/modules/enterprise/pom.xml 2009-05-07 20:19:13 UTC (rev 4764)
@@ -81,7 +81,17 @@
<!-- Plugins -->
<build>
-
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+<!--
<testResources>
<testResource>
<directory>src/test/resources</directory>
@@ -169,4 +179,5 @@
</profiles>
+ -->
</project>
\ No newline at end of file
16 years, 12 months
JBoss JBPM SVN: r4763 - jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-05-07 16:14:13 -0400 (Thu, 07 May 2009)
New Revision: 4763
Modified:
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java
Log:
Added due and create date, priority to TaskRef
Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java 2009-05-07 18:52:11 UTC (rev 4762)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java 2009-05-07 20:14:13 UTC (rev 4763)
@@ -151,6 +151,11 @@
}
+ // prio and duedate
+ task.setPriority(t0.getPriority());
+ task.setDueDate(t0.getDueDate());
+ task.setCreateDate(t0.getCreate());
+
// task form url
String url = t0.getForm()!=null ? t0.getForm() : "";
task.setUrl( url );
16 years, 12 months
JBoss JBPM SVN: r4762 - in jbpm3/branches/jbpm-3.2.5.SP/modules: core/src/main/java/org/jbpm/job/executor and 18 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-05-07 14:52:11 -0400 (Thu, 07 May 2009)
New Revision: 4762
Added:
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/AbstractEnterpriseTestCase.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/console/
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/JBPM1952Test.java
Removed:
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobsCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/JBPM1952Test.java
Modified:
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/ContextSession.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/svc/Services.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/etc/jbpm.cfg.xml
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/config/AppServerConfigurationsTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1903/JBPM1903Test.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jms/JmsMessageTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java
Log:
[JBPM-1952] merge r4073 from trunk
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/ContextSession.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/ContextSession.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/ContextSession.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -30,10 +30,12 @@
*/
public class ContextSession {
- JbpmSession jbpmSession = null;
- Session session = null;
-
-
+ final JbpmSession jbpmSession;
+ final Session session;
+
+ /**
+ * @deprecated use {@link #ContextSession(Session)} instead
+ */
public ContextSession(JbpmSession jbpmSession) {
this.jbpmSession = jbpmSession;
this.session = jbpmSession.getSession();
@@ -41,10 +43,10 @@
public ContextSession(Session session) {
this.session = session;
- this.jbpmSession = new JbpmSession(session);
+ this.jbpmSession = null;
}
- /**
+ /*
* converts all newly created variable values that are inside the
* variableUpdates into {@link VariableInstance}s
* as a preparation for storage in the database.
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -10,7 +10,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.HibernateException;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
@@ -18,8 +17,8 @@
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.job.Job;
import org.jbpm.persistence.JbpmPersistenceException;
+import org.jbpm.persistence.db.DbPersistenceService;
import org.jbpm.persistence.db.StaleObjectLogConfigurer;
-import org.jbpm.svc.Services;
public class JobExecutorThread extends Thread {
@@ -140,8 +139,8 @@
log.debug("acquired lock on jobs: " + acquiredJobs);
}
catch (JbpmPersistenceException e) {
- // if this is a stale object exception, keep it quiet
- if (Services.isCausedByStaleState(e)) {
+ // if this is a stale state exception, keep it quiet
+ if (DbPersistenceService.isStaleStateException(e)) {
StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
"failed to acquire lock on jobs " + jobsToLock);
acquiredJobs = Collections.EMPTY_LIST;
@@ -173,7 +172,7 @@
}
catch (Exception e) {
log.debug("exception while executing " + job, e);
- if (!isPersistenceException(e)) {
+ if (!DbPersistenceService.isPersistenceException(e)) {
StringWriter memoryWriter = new StringWriter();
e.printStackTrace(new PrintWriter(memoryWriter));
job.setException(memoryWriter.toString());
@@ -197,7 +196,7 @@
}
catch (JbpmPersistenceException e) {
// if this is a stale state exception, keep it quiet
- if (Services.isCausedByStaleState(e)) {
+ if (DbPersistenceService.isStaleStateException(e)) {
StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
"failed to complete job " + job);
}
@@ -208,14 +207,6 @@
}
}
- private static boolean isPersistenceException(Throwable throwable) {
- do {
- if (throwable instanceof HibernateException) return true;
- throwable = throwable.getCause();
- } while (throwable != null);
- return false;
- }
-
protected Date getNextDueDate() {
Date nextDueDate = null;
String threadName = getName();
@@ -238,8 +229,8 @@
jbpmContext.close();
}
catch (JbpmPersistenceException e) {
- // if this is a stale object exception, keep it quiet
- if (Services.isCausedByStaleState(e)) {
+ // if this is a stale state exception, keep it quiet
+ if (DbPersistenceService.isStaleStateException(e)) {
StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
"failed to determine next due date for job executor thread " + threadName);
nextDueDate = null;
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -12,8 +12,8 @@
import org.jbpm.db.JobSession;
import org.jbpm.job.Job;
import org.jbpm.persistence.JbpmPersistenceException;
+import org.jbpm.persistence.db.DbPersistenceService;
import org.jbpm.persistence.db.StaleObjectLogConfigurer;
-import org.jbpm.svc.Services;
public class LockMonitorThread extends Thread {
@@ -93,8 +93,8 @@
jbpmContext.close();
}
catch (JbpmPersistenceException e) {
- // if this is a stale object exception, keep it quiet
- if (Services.isCausedByStaleState(e)) {
+ // if this is a stale state exception, keep it quiet
+ if (DbPersistenceService.isStaleStateException(e)) {
StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
"optimistic locking failed, could not unlock overdue jobs: " + overdueJobs);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -27,6 +27,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.StaleStateException;
@@ -45,60 +46,44 @@
import org.jbpm.tx.TxService;
public class DbPersistenceService implements Service, PersistenceService {
-
+
private static final long serialVersionUID = 1L;
- protected DbPersistenceServiceFactory persistenceServiceFactory = null;
+ protected final DbPersistenceServiceFactory persistenceServiceFactory;
- protected Connection connection = null;
- protected boolean mustConnectionBeClosed = false;
+ protected Connection connection;
+ protected boolean mustConnectionBeClosed;
- protected Transaction transaction = null;
+ protected Transaction transaction;
protected boolean isTransactionEnabled = true;
- protected boolean isCurrentSessionEnabled = false;
+ protected boolean isCurrentSessionEnabled;
- // boolean isRollbackOnly = false;
-
protected Session session;
- protected boolean mustSessionBeFlushed = false;
- protected boolean mustSessionBeClosed = false;
+ protected boolean mustSessionBeFlushed;
+ protected boolean mustSessionBeClosed;
- protected Services services = null;
+ protected GraphSession graphSession;
+ protected TaskMgmtSession taskMgmtSession;
+ protected JobSession jobSession;
+ protected ContextSession contextSession;
+ protected LoggingSession loggingSession;
- protected GraphSession graphSession = null;
- protected TaskMgmtSession taskMgmtSession = null;
- protected JobSession jobSession = null;
- protected ContextSession contextSession = null;
- protected LoggingSession loggingSession = null;
+ /** @deprecated for access to other services, invoke {@link JbpmContext#getServices()} */
+ protected Services services;
public DbPersistenceService(DbPersistenceServiceFactory persistenceServiceFactory) {
- this(persistenceServiceFactory, getCurrentServices());
- }
-
- static Services getCurrentServices() {
- Services services = null;
- JbpmContext currentJbpmContext = JbpmContext.getCurrentJbpmContext();
- if (currentJbpmContext!=null) {
- services = currentJbpmContext.getServices();
- }
- return services;
- }
-
- DbPersistenceService(DbPersistenceServiceFactory persistenceServiceFactory, Services services) {
this.persistenceServiceFactory = persistenceServiceFactory;
this.isTransactionEnabled = persistenceServiceFactory.isTransactionEnabled();
this.isCurrentSessionEnabled = persistenceServiceFactory.isCurrentSessionEnabled();
- this.services = services;
}
public SessionFactory getSessionFactory() {
- return session != null ? session.getSessionFactory() : persistenceServiceFactory.getSessionFactory();
+ return session != null ? session.getSessionFactory() : persistenceServiceFactory
+ .getSessionFactory();
}
public Session getSession() {
- if ( (session==null)
- && (getSessionFactory()!=null)
- ) {
+ if (session == null && getSessionFactory() != null) {
Connection connection = getConnection(false);
if (isCurrentSessionEnabled) {
log.debug("using current hibernate session");
@@ -106,20 +91,22 @@
mustSessionBeClosed = false;
mustSessionBeFlushed = false;
mustConnectionBeClosed = false;
- } else if (connection!=null) {
- log.debug("creating hibernate session with connection "+connection);
+ }
+ else if (connection != null) {
+ log.debug("creating hibernate session on " + connection);
session = getSessionFactory().openSession(connection);
mustSessionBeClosed = true;
mustSessionBeFlushed = true;
mustConnectionBeClosed = false;
- } else {
+ }
+ else {
log.debug("creating hibernate session");
session = getSessionFactory().openSession();
mustSessionBeClosed = true;
mustSessionBeFlushed = true;
mustConnectionBeClosed = false;
}
-
+
if (isTransactionEnabled) {
beginTransaction();
}
@@ -130,41 +117,34 @@
public void beginTransaction() {
log.debug("beginning hibernate transaction");
transaction = session.beginTransaction();
- log.debug("begun hibernate transaction " + transaction.toString());
+ log.debug("begun " + transaction);
}
public void endTransaction() {
- if ( (isTransactionEnabled)
- && (transaction!=null)
- ) {
- if (isRollbackOnly()) {
- try {
- log.debug("rolling back hibernate transaction " + transaction.toString());
- mustSessionBeFlushed = false; // flushing updates that will be rolled back is not very clever :-)
- transaction.rollback();
- } catch (Exception e) {
- // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
- throw new JbpmPersistenceException("couldn't rollback hibernate session", e);
- }
- } else {
- try {
- log.debug("committing hibernate transaction " + transaction.toString());
- mustSessionBeFlushed = false; // commit does a flush anyway
- transaction.commit();
- } catch (Exception e) {
- // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
- try {
- // if the commit fails, we must do a rollback
- transaction.rollback();
- } catch (Exception e2) {
- // if the rollback fails, we did what we could and you're in
- // deep shit :-(
- log.error("problem rolling back after failed commit", e2);
- }
- throw new JbpmPersistenceException("couldn't commit hibernate session", e);
- }
+ if (isTransactionManagedExternally()) {
+ if (session != null && getTxService().isRollbackOnly()) {
+ throw new JbpmException("cannot mark externally managed transaction for rollback");
}
+ return;
}
+
+ if (!isTransactionRollbackOnly()) {
+ Exception commitException = commit();
+ if (commitException != null) {
+ rollback();
+ closeSession();
+ closeConnection();
+ throw new JbpmPersistenceException("transaction commit failed", commitException);
+ }
+ }
+ else { // isRollbackOnly==true
+ Exception rollbackException = rollback();
+ if (rollbackException != null) {
+ closeSession();
+ closeConnection();
+ throw new JbpmPersistenceException("transaction rollback failed", rollbackException);
+ }
+ }
}
public Connection getConnection() {
@@ -172,167 +152,160 @@
}
public Connection getConnection(boolean resolveSession) {
- if (connection==null) {
- if (persistenceServiceFactory.getDataSource()!=null) {
+ if (connection == null) {
+ if (persistenceServiceFactory.getDataSource() != null) {
try {
log.debug("fetching jdbc connection from datasource");
connection = persistenceServiceFactory.getDataSource().getConnection();
mustConnectionBeClosed = true;
- } catch (Exception e) {
- // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
- throw new JbpmException("couldn't obtain connection from datasource", e);
}
- } else {
+ catch (Exception e) {
+ // NOTE that Errors are not caught because that might halt the JVM
+ // and mask the original Error.
+ throw new JbpmException("could not obtain connection from datasource", e);
+ }
+ }
+ else {
if (resolveSession) {
// initializes the session member
getSession();
}
- if (session!=null) {
+ if (session != null) {
connection = session.connection();
- log.debug("fetching connection from hibernate session. this transfers responsibility for closing the jdbc connection to the user! "+connection);
+ log.debug("fetched "
+ + connection
+ + " from hibernate session, client is responsible for closing it!");
mustConnectionBeClosed = false;
}
}
}
return connection;
}
-
+
public boolean isTransactionActive() {
return transaction != null && transaction.isActive();
}
- protected boolean isTransactionExternallyManaged() {
- return !(isTransactionEnabled && transaction != null);
+ protected boolean isTransactionManagedExternally() {
+ return !isTransactionEnabled || transaction == null;
}
+ protected boolean isTransactionRollbackOnly() {
+ return getTxService().isRollbackOnly();
+ }
+
public void close() {
+ endTransaction();
- if ( (session!=null)
- && isTransactionExternallyManaged()
- && (isRollbackOnly())
- ) {
- throw new JbpmException("setRollbackOnly was invoked while transaction is being managed externally");
- }
-
- if ( (isTransactionEnabled)
- && (transaction!=null)
- ) {
-
- if (! isRollbackOnly()) {
- Exception commitException = commit();
- if (commitException!=null) {
- rollback();
- closeSession();
- closeConnection();
- throw new JbpmPersistenceException("hibernate commit failed", commitException);
- }
-
- } else { // isRollbackOnly==true
- Exception rollbackException = rollback();
- if (rollbackException!=null) {
- closeSession();
- closeConnection();
- throw new JbpmPersistenceException("hibernate rollback failed", rollbackException);
- }
- }
- }
-
Exception flushException = flushSession();
- if (flushException!=null) {
- // JBPM-1465: transaction is either committed or rolled back at this point;
- // it is also possible that the transaction was initiated externally
+ if (flushException != null) {
+ // JBPM-1465: at this point, the transaction is already committed or rolled back
+ // alternatively, the transaction is being managed externally
// hence rolling back here is redundant and possibly dangerous
closeSession();
closeConnection();
- throw new JbpmPersistenceException("hibernate flush failed", flushException);
+ throw new JbpmPersistenceException("hibernate flush session failed", flushException);
}
Exception closeSessionException = closeSession();
- if (closeSessionException!=null) {
+ if (closeSessionException != null) {
closeConnection();
throw new JbpmPersistenceException("hibernate close session failed", closeSessionException);
}
Exception closeConnectionException = closeConnection();
- if (closeConnectionException!=null) {
- throw new JbpmPersistenceException("hibernate close connection failed", closeConnectionException);
+ if (closeConnectionException != null) {
+ throw new JbpmPersistenceException("hibernate close connection failed",
+ closeConnectionException);
}
}
- Exception commit() {
+ protected Exception commit() {
try {
log.debug("committing " + transaction);
- mustSessionBeFlushed = false; // commit does a flush anyway
+ mustSessionBeFlushed = false; // commit does a flush anyway
transaction.commit();
- } catch (StaleStateException e) {
- log.info("problem committing transaction: optimistic locking failed");
- StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error("optimistic locking failed while committing " + transaction, e);
+ }
+ catch (Exception e) {
+ if (isStaleStateException(e)) {
+ log.info("problem committing transaction: optimistic locking failed");
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "optimistic locking failed while committing " + transaction, e);
+ }
+ else {
+ log.error("transaction commit failed", e);
+ }
return e;
- } catch (Exception e) {
- log.error("hibernate commit failed", e);
+ }
+ return null;
+ }
+
+ protected Exception rollback() {
+ try {
+ log.debug("rolling back " + transaction);
+ // flushing updates that will be rolled back is not very clever :-)
+ mustSessionBeFlushed = false;
+ transaction.rollback();
+ }
+ catch (Exception e) {
+ log.error("transaction rollback failed", e);
return e;
}
return null;
}
- Exception flushSession() {
+ private Exception flushSession() {
if (mustSessionBeFlushed) {
try {
log.debug("flushing " + session);
session.flush();
- } catch (StaleStateException e) {
- log.info("problem flushing session: optimistic locking failed");
- StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error("optimistic locking failed while flushing " + session, e);
+ }
+ catch (Exception e) {
+ if (isStaleStateException(e)) {
+ log.info("problem flushing session: optimistic locking failed");
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "optimistic locking failed while flushing " + session, e);
+ }
+ else {
+ log.error("hibernate flush failed", e);
+ }
return e;
- } catch (Exception e) {
- log.error("hibernate flush failed", e);
- return e;
}
}
return null;
}
- Exception closeConnection() {
- if (mustConnectionBeClosed) {
+ private Exception closeSession() {
+ if (mustSessionBeClosed) {
try {
- if ( (connection!=null)
- && (! connection.isClosed())
- ) {
- log.debug("closing jdbc connection");
- connection.close();
- } else {
- log.warn("jdbc connection was already closed");
+ if (session.isOpen()) {
+ log.debug("closing hibernate session");
+ session.close();
}
- } catch (Exception e) {
- log.error("hibernate session close failed", e);
+ else {
+ log.warn("hibernate session was already closed");
+ }
+ }
+ catch (Exception e) {
return e;
}
}
return null;
}
- Exception rollback() {
- try {
- log.debug("rolling back hibernate transaction");
- mustSessionBeFlushed = false; // flushing updates that will be rolled back is not very clever :-)
- transaction.rollback();
- } catch (Exception e) {
- log.error("hibernate rollback failed", e);
- return e;
- }
- return null;
- }
-
- Exception closeSession() {
- if (mustSessionBeClosed) {
+ private Exception closeConnection() {
+ if (mustConnectionBeClosed) {
try {
- if(session.isOpen()) {
- log.debug("closing hibernate session");
- session.close();
- } else {
- log.warn("hibernate session was already closed");
+ if (connection != null) {
+ log.debug("closing jdbc connection");
+ connection.close();
}
- } catch (Exception e) {
+ else {
+ log.warn("jdbc connection was already closed");
+ }
+ }
+ catch (Exception e) {
+ log.error("hibernate session close failed", e);
return e;
}
}
@@ -342,54 +315,60 @@
public void assignId(Object object) {
try {
getSession().save(object);
- } catch (Exception e) {
- // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
- throw new JbpmPersistenceException("couldn't assign id to "+object, e);
}
+ catch (Exception e) {
+ // NOTE that Errors are not caught because that might halt the JVM
+ // and mask the original Error.
+ throw new JbpmPersistenceException("couldn't assign id to " + object, e);
+ }
}
// getters and setters //////////////////////////////////////////////////////
public GraphSession getGraphSession() {
- if (graphSession==null) {
+ if (graphSession == null) {
Session session = getSession();
- if (session!=null) {
+ if (session != null) {
graphSession = new GraphSession(session);
}
}
return graphSession;
}
+
public LoggingSession getLoggingSession() {
- if (loggingSession==null) {
+ if (loggingSession == null) {
Session session = getSession();
- if (session!=null) {
+ if (session != null) {
loggingSession = new LoggingSession(session);
}
}
return loggingSession;
}
+
public JobSession getJobSession() {
- if (jobSession==null) {
+ if (jobSession == null) {
Session session = getSession();
- if (session!=null) {
+ if (session != null) {
jobSession = new JobSession(session);
}
}
return jobSession;
}
+
public ContextSession getContextSession() {
- if (contextSession==null) {
+ if (contextSession == null) {
Session session = getSession();
- if (session!=null) {
+ if (session != null) {
contextSession = new ContextSession(session);
}
}
return contextSession;
}
+
public TaskMgmtSession getTaskMgmtSession() {
- if (taskMgmtSession==null) {
+ if (taskMgmtSession == null) {
Session session = getSession();
- if (session!=null) {
+ if (session != null) {
taskMgmtSession = new TaskMgmtSession(session);
}
}
@@ -401,77 +380,146 @@
}
/**
- * @deprecated use {@link org.jbpm.tx.TxService} instead.
+ * @deprecated use {@link TxService#isRollbackOnly()} instead
*/
public boolean isRollbackOnly() {
- TxService txService = (services!=null ? services.getTxService() : null);
- if (txService==null) {
- throw new JbpmException("no jbpm tx service configured");
- }
- return txService.isRollbackOnly();
+ return getTxService().isRollbackOnly();
}
+
/**
- * @deprecated use {@link org.jbpm.tx.TxService} instead.
+ * @deprecated use {@link TxService#setRollbackOnly()} instead
*/
- public void setRollbackOnly(boolean isRollbackOnly) {
- throw new UnsupportedOperationException("method setRollbackOnly has been removed. Use TxService instead.");
+ public void setRollbackOnly() {
+ getTxService().setRollbackOnly();
}
+
/**
- * @deprecated use {@link org.jbpm.tx.TxService} instead.
+ * @throws UnsupportedOperationException if <code>rollbackOnly</code> is <code>false</code>
+ * @deprecated use {@link TxService#setRollbackOnly()} instead
*/
- public void setRollbackOnly() {
- TxService txService = (services!=null ? services.getTxService() : null);
- if (txService==null) {
- throw new JbpmException("no jbpm tx service configured");
+ public void setRollbackOnly(boolean rollbackOnly) {
+ if (!rollbackOnly) {
+ throw new UnsupportedOperationException();
}
- txService.setRollbackOnly();
+ setRollbackOnly();
}
+ private TxService getTxService() {
+ return (TxService) Services.getCurrentService(Services.SERVICENAME_TX);
+ }
+
+ /**
+ * Injects an external Hibernate session, disabling transaction management.
+ */
public void setSession(Session session) {
- this.session = session;
- log.debug("injecting a session disables transaction");
- isTransactionEnabled = false;
+ setSession(session, false);
}
+ /**
+ * Injects an external Hibernate session without affecting transaction management.
+ *
+ * @deprecated use {@link #setSession(Session, boolean) setSession(session, true)} instead
+ */
public void setSessionWithoutDisablingTx(Session session) {
+ setSession(session, true);
+ }
+
+ /**
+ * Injects an external Hibernate session. Injecting a session would normally disable transaction
+ * management. The <code>keepTransactionEnabled</code> parameter can be used to prevent
+ * transaction management from being disabled, according to the following table.
+ * <table border="1">
+ * <tr>
+ * <th>is currently enabled?</th>
+ * <th>keep enabled?</th>
+ * <th>enabled onward</th>
+ * </tr>
+ * <tr>
+ * <td>true</td>
+ * <td>true</td>
+ * <td>true (no change)</td>
+ * </tr>
+ * <tr>
+ * <td>true</td>
+ * <td>false</td>
+ * <td>false</td>
+ * </tr>
+ * <tr>
+ * <td>false</td>
+ * <td>n/a</td>
+ * <td>false (no change)</td>
+ * </tr>
+ * </table>
+ */
+ public void setSession(Session session, boolean keepTransactionEnabled) {
this.session = session;
+ if (isTransactionEnabled && !keepTransactionEnabled) {
+ log.debug("disabling transaction due to session injection");
+ isTransactionEnabled = false;
+ }
}
public void setConnection(Connection connection) {
this.connection = connection;
}
+
public void setContextSession(ContextSession contextSession) {
this.contextSession = contextSession;
}
+
public void setDataSource(DataSource dataSource) {
this.persistenceServiceFactory.dataSource = dataSource;
}
+
public void setGraphSession(GraphSession graphSession) {
this.graphSession = graphSession;
}
+
public void setLoggingSession(LoggingSession loggingSession) {
this.loggingSession = loggingSession;
}
+
public void setJobSession(JobSession jobSession) {
this.jobSession = jobSession;
}
+
public void setTaskMgmtSession(TaskMgmtSession taskMgmtSession) {
this.taskMgmtSession = taskMgmtSession;
}
+
public void setSessionFactory(SessionFactory sessionFactory) {
this.persistenceServiceFactory.sessionFactory = sessionFactory;
}
+
public Transaction getTransaction() {
return transaction;
}
+
public void setTransaction(Transaction transaction) {
this.transaction = transaction;
}
+
public boolean isTransactionEnabled() {
return isTransactionEnabled;
}
+
public void setTransactionEnabled(boolean isTransactionEnabled) {
this.isTransactionEnabled = isTransactionEnabled;
}
+
+ public static boolean isPersistenceException(Exception exception) {
+ for (Throwable t = exception; t != null; t = t.getCause()) {
+ if (t instanceof HibernateException) return true;
+ }
+ return false;
+ }
+
+ public static boolean isStaleStateException(Exception exception) {
+ for (Throwable t = exception; t != null; t = t.getCause()) {
+ if (t instanceof StaleStateException) return true;
+ }
+ return false;
+ }
+
private static Log log = LogFactory.getLog(DbPersistenceService.class);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -21,6 +21,7 @@
*/
package org.jbpm.persistence.jta;
+import javax.transaction.Status;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
@@ -29,84 +30,101 @@
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.util.JTAHelper;
import org.jbpm.JbpmException;
-import org.jbpm.persistence.JbpmPersistenceException;
import org.jbpm.persistence.db.DbPersistenceService;
+import org.jbpm.persistence.db.StaleObjectLogConfigurer;
public class JtaDbPersistenceService extends DbPersistenceService {
+ private UserTransaction transaction;
+
private static final long serialVersionUID = 1L;
private static Log log = LogFactory.getLog(JtaDbPersistenceService.class);
- private UserTransaction userTransaction;
-
public JtaDbPersistenceService(JtaDbPersistenceServiceFactory persistenceServiceFactory) {
super(persistenceServiceFactory);
- if (!isJtaTransactionInProgress()) {
- beginUserTransaction();
+ if (!isTransactionActive()) {
+ beginTransaction();
}
}
public boolean isTransactionActive() {
- return isJtaTransactionInProgress();
+ SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) getSessionFactory();
+ return JTAHelper.isTransactionInProgress(sessionFactory);
}
- protected boolean isTransactionExternallyManaged() {
- return !isJtaTxCreated();
+ protected boolean isTransactionManagedExternally() {
+ return transaction == null;
}
- public void close() {
- super.close();
+ protected boolean isTransactionRollbackOnly() {
+ return super.isTransactionRollbackOnly()
+ || JTAHelper.isMarkedForRollback(getTransactionStatus());
+ }
- if (userTransaction != null) {
- endUserTransaction();
+ public void beginTransaction() {
+ try {
+ log.debug("beginning " + transaction);
+ JtaDbPersistenceServiceFactory jtaFactory = (JtaDbPersistenceServiceFactory) persistenceServiceFactory;
+ transaction = jtaFactory.getUserTransaction();
+ transaction.begin();
}
+ catch (Exception e) {
+ throw new JbpmException("transaction begin failed", e);
+ }
}
- boolean isJtaTransactionInProgress() {
- SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) getSessionFactory();
- return JTAHelper.isTransactionInProgress(sessionFactory);
+ private int getTransactionStatus() {
+ try {
+ return transaction.getStatus();
+ }
+ catch (SystemException e) {
+ log.error("could not get transaction status", e);
+ return Status.STATUS_UNKNOWN;
+ }
}
- void beginUserTransaction() {
+ protected Exception commit() {
+ log.debug("committing " + transaction);
try {
- log.debug("begin user transaction");
- userTransaction = ((JtaDbPersistenceServiceFactory) persistenceServiceFactory)
- .getUserTransaction();
- userTransaction.begin();
- } catch (Exception e) {
- throw new JbpmException("couldn't begin user transaction", e);
+ transaction.commit();
+ return null;
}
- }
-
- void endUserTransaction() {
- if (isRollbackOnly() || JTAHelper.isRollback(getUserTransactionStatus())) {
- log.debug("rolling back user transaction");
- try {
- userTransaction.rollback();
- } catch (Exception e) {
- throw new JbpmPersistenceException("couldn't rollback user transaction", e);
+ catch (Exception e) {
+ if (isStaleStateException(e)) {
+ log.debug("optimistic locking failed, could not commit " + transaction);
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "optimistic locking failed, could not commit " + transaction, e);
}
- } else {
- log.debug("committing user transaction");
- try {
- userTransaction.commit();
- } catch (Exception e) {
- throw new JbpmPersistenceException("couldn't commit user transaction", e);
+ else {
+ // Switched to debug because either handle OR log
+ // an exception is best practice, not both!
+ // Example: Clustered JobExecutor may have
+ // Exceptions which should be kept quiet
+ log.debug("transaction commit failed", e);
}
+ return e;
}
}
- int getUserTransactionStatus() {
+ protected Exception rollback() {
+ log.debug("rolling back " + transaction);
try {
- return userTransaction.getStatus();
- } catch (SystemException e) {
- throw new JbpmPersistenceException("couldn't get status for user transaction", e);
+ transaction.rollback();
+ return null;
}
+ catch (Exception e) {
+ // Switched to debug because either handle OR log
+ // an exception is best practice, not both!
+ // Example: Clustered JobExecutor may have
+ // Exceptions which should be kept quiet
+ log.debug("transaction rollback failed", e);
+ return e;
+ }
}
public boolean isJtaTxCreated() {
- return userTransaction != null;
+ return !isTransactionManagedExternally();
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/svc/Services.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/svc/Services.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/svc/Services.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -31,8 +31,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.StaleStateException;
-import org.hibernate.exception.LockAcquisitionException;
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
@@ -41,6 +39,7 @@
import org.jbpm.msg.MessageService;
import org.jbpm.persistence.JbpmPersistenceException;
import org.jbpm.persistence.PersistenceService;
+import org.jbpm.persistence.db.DbPersistenceService;
import org.jbpm.persistence.db.StaleObjectLogConfigurer;
import org.jbpm.scheduler.SchedulerService;
import org.jbpm.security.AuthenticationService;
@@ -71,19 +70,19 @@
private static List createDefaultSaveOperations() {
SaveOperation[] operations = new SaveOperation[4];
operations[0] = new CheckUnpersistableVariablesOperation();
- // first we save the runtime data (process instance)
+ // first, save the execution data (process instance)
operations[1] = new HibernateSaveOperation();
- // then we insert the logs cause the logs can have references
- // to the runtime data
+ // then, insert the logs, which may have references to the execution data
operations[2] = new SaveLogsOperation();
+ // last, save subprocess instances in cascade
operations[3] = new CascadeSaveOperation();
return Arrays.asList(operations);
}
Map serviceFactories;
Map services;
- List serviceNames = null;
- List saveOperations = null;
+ List serviceNames;
+ List saveOperations;
public static Service getCurrentService(String name) {
return getCurrentService(name, true);
@@ -163,8 +162,6 @@
}
public void save(ProcessInstance processInstance, JbpmContext jbpmContext) {
- Iterator iter = saveOperations.iterator();
-
if (log.isDebugEnabled()) {
if (saveOperations == defaultSaveOperations) {
log.debug("executing default save operations");
@@ -174,7 +171,7 @@
}
}
- while (iter.hasNext()) {
+ for (Iterator iter = saveOperations.iterator(); iter.hasNext();) {
SaveOperation saveOperation = (SaveOperation) iter.next();
saveOperation.save(processInstance, jbpmContext);
}
@@ -241,8 +238,7 @@
public void close() {
if (services != null) {
Exception firstException = null;
- Iterator iter = serviceNames.iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = serviceNames.iterator(); iter.hasNext();) {
String serviceName = (String) iter.next();
Service service = (Service) services.get(serviceName);
if (service != null) {
@@ -251,10 +247,11 @@
service.close();
}
catch (JbpmPersistenceException e) {
- // if this is a stale state exception, the jbpm configuration has control over the logging
- if (isCausedByStaleState(e)) {
+ // if this is a stale state exception, keep it quiet
+ if (DbPersistenceService.isStaleStateException(e)) {
+ log.info("optimistic locking failed, could not close service: " + serviceName);
StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
- "problem closing service '" + serviceName + "': optimistic locking failed", e);
+ "optimistic locking failed, could not close service: " + serviceName, e);
}
else {
log.error("problem closing service '" + serviceName + "'", e);
@@ -264,7 +261,8 @@
}
}
catch (Exception e) {
- // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
+ // NOTE that Error's are not caught because that might halt the JVM
+ // and mask the original Error.
log.error("problem closing service '" + serviceName + "'", e);
if (firstException == null) {
firstException = e;
@@ -273,26 +271,16 @@
}
}
if (firstException != null) {
- if (firstException instanceof JbpmException) {
- throw (JbpmException) firstException;
- }
- throw new JbpmException("problem closing services", firstException);
+ throw firstException instanceof JbpmException ? (JbpmException) firstException
+ : new JbpmException("problem closing services", firstException);
}
}
}
- public static boolean isCausedByStaleState(JbpmPersistenceException persistenceException) {
- for (Throwable cause = persistenceException.getCause(); cause != null; cause = cause.getCause()) {
- if (cause instanceof StaleStateException || cause instanceof LockAcquisitionException)
- return true;
- }
- return false;
- }
-
public static void assignId(Object object) {
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
if (jbpmContext != null) {
- // give this process instance an id
+ // assign id to the given object
Services services = jbpmContext.getServices();
if (services.hasService(Services.SERVICENAME_PERSISTENCE)) {
PersistenceService persistenceService = services.getPersistenceService();
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -25,6 +25,9 @@
import java.io.InputStream;
import java.util.Properties;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmException;
@@ -40,7 +43,7 @@
/**
* Bad usage of ClassLoader.loadClass() under JDK 6.
*
- * @deprecated Use {@linkplain #classForName(String) classForName()} instead
+ * @deprecated Use {@linkplain #classForName(String)} instead
* @see <a href="https://jira.jboss.org/jira/browse/JBPM-1976">JBPM-1976</a>
*/
public static Class loadClass(String className) {
@@ -48,7 +51,7 @@
return getClassLoader().loadClass(className);
}
catch (ClassNotFoundException e) {
- throw new JbpmException("class not found '" + className + "'", e);
+ throw new JbpmException("class not found: " + className, e);
}
}
@@ -57,7 +60,7 @@
return Class.forName(className, true, getClassLoader());
}
catch (ClassNotFoundException e) {
- throw new JbpmException("class not found '" + className + "'", e);
+ throw new JbpmException("class not found: " + className, e);
}
}
@@ -75,7 +78,7 @@
}
catch (ClassNotFoundException e2) {
// give up
- throw new JbpmException("class not found '" + className + "'", e);
+ throw new JbpmException("class not found: " + className, e2);
}
}
}
@@ -148,15 +151,24 @@
}
public static Properties getProperties(String resource) {
- Properties properties = new Properties();
+ InputStream inStream = getStream(resource);
+ if (inStream == null) throw new JbpmException("resource not found: " + resource);
try {
- InputStream inStream = getStream(resource);
+ Properties properties = new Properties();
properties.load(inStream);
- inStream.close();
+ return properties;
}
catch (IOException e) {
- throw new JbpmException("couldn't load properties file '" + resource + "'", e);
+ throw new JbpmException("could not load properties from resource: " + resource, e);
}
- return properties;
+ finally {
+ try {
+ inStream.close();
+ }
+ catch (IOException e) {
+ Log log = LogFactory.getLog(ClassLoaderUtil.class);
+ log.warn("failed to close stream from resource: " + resource, e);
+ }
+ }
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2009-05-07 18:52:11 UTC (rev 4762)
@@ -32,8 +32,9 @@
<string name="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml" />
<string name="resource.mail.templates" value="jbpm.mail.templates.xml" />
- <!-- class loading -->
+ <!-- class loading
<string name="jbpm.class.loader" value="context" />
+ -->
<bean name="process.class.loader.factory" class="org.jbpm.instantiation.SharedProcessClassLoaderFactory" singleton="true" />
<!-- make sure the block size matches the length in ByteArray.hbm.xml -->
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -114,7 +114,7 @@
public void testContextClassLoader() {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
- + " <string name='jbpm.classLoader' value='context' />"
+ + " <string name='jbpm.class.loader' value='context' />"
+ "</jbpm-configuration>");
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
@@ -176,7 +176,7 @@
public void testContextClassLoaderException() {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
- + " <string name='jbpm.classLoader' value='context' />"
+ + " <string name='jbpm.class.loader' value='context' />"
+ "</jbpm-configuration>");
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -10,8 +10,8 @@
import org.jbpm.graph.exe.Comment;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.persistence.JbpmPersistenceException;
+import org.jbpm.persistence.db.DbPersistenceService;
import org.jbpm.persistence.db.StaleObjectLogConfigurer;
-import org.jbpm.svc.Services;
import org.jbpm.util.Semaphore;
/**
@@ -147,7 +147,7 @@
}
catch (JbpmPersistenceException e) {
// if this is a stale object exception, keep it quiet
- if (Services.isCausedByStaleState(e)) {
+ if (DbPersistenceService.isStaleStateException(e)) {
StaleObjectLogConfigurer.getStaleObjectExceptionsLog()
.error(getName() + " rolled back");
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -230,7 +230,6 @@
jbpmContext.close();
}
- persistenceService.close();
assertNull(persistenceService.transaction);
assertNotNull(persistenceService.session);
assertTrue(persistenceService.session.isOpen());
@@ -266,7 +265,7 @@
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
DbPersistenceService dbPersistenceService = null;
- Connection connection = null;
+ Connection connection;
try {
dbPersistenceService = (DbPersistenceService) jbpmContext.getServices().getPersistenceService();
connection = jbpmContext.getConnection();
@@ -276,7 +275,7 @@
assertFalse(dbPersistenceService.session.isOpen());
assertFalse(dbPersistenceService.session.isConnected());
- // Since 3.2.1, hibernate hides direct access to the connecion after session has closed. Bummer...
- // assertFalse(connection.isClosed());
+
+ connection.close();
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/etc/jbpm.cfg.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/etc/jbpm.cfg.xml 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/etc/jbpm.cfg.xml 2009-05-07 18:52:11 UTC (rev 4762)
@@ -10,12 +10,12 @@
</jbpm-context>
<!-- use the context class loader -->
- <string name="jbpm.classLoader" value="context" />
+ <string name="jbpm.class.loader" value="context" />
<!--
- Note, that the default job executor needs to be overwritten with a null value.
- In the enterprise configuration there should be no job executor.
- Async messaging is there bound to jms and scheduling to ejb timers.
+ The default job executor needs to be overwritten with a null value.
+ There should be no job executor in the enterprise configuration.
+ Async messaging is bound to JMS and scheduling, to EJB timers.
-->
<null name="jbpm.job.executor" />
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -23,26 +23,15 @@
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.util.List;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.naming.NamingException;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.jbpm.JbpmContext;
+import org.jbpm.JbpmException;
import org.jbpm.command.Command;
-import org.jbpm.db.JobSession;
+import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.job.Job;
-import org.jbpm.msg.jms.JmsMessageService;
-import org.jbpm.msg.jms.JmsMessageServiceFactory;
-import org.jbpm.svc.Services;
-import org.jbpm.util.ArrayUtil;
+import org.jbpm.persistence.db.DbPersistenceService;
/**
* Individual job processing command.
@@ -60,84 +49,50 @@
}
public Object execute(JbpmContext jbpmContext) throws Exception {
- JobSession jobSession = jbpmContext.getJobSession();
- Job job = jobSession.getJob(jobId);
- if (job == null) {
- log.debug("job " + jobId + " was deleted");
- return null;
- }
- String lockOwner = job.getLockOwner();
- if (lockOwner != null) {
- log.debug(job + " is locked by " + lockOwner);
- return null;
- }
- lockOwner = Long.toString(jobId);
+ Job job = acquireJob(jbpmContext);
+ executeJob(job, jbpmContext);
+ return job;
+ }
+
+ private Job acquireJob(JbpmContext jbpmContext) {
+ Job job = jbpmContext.getJobSession().loadJob(jobId);
+
+ // register process instance for automatic save
+ // see https://jira.jboss.org/jira/browse/JBPM-1015
+ ProcessInstance processInstance = job.getProcessInstance();
+ jbpmContext.addAutoSaveProcessInstance(processInstance);
+
+ // if job is exclusive, lock process instance
if (job.isExclusive()) {
- List exclusiveJobs = jobSession.findExclusiveJobs(lockOwner, job.getProcessInstance());
- // lock exclusive jobs
- int jobCount = exclusiveJobs.size();
- if (jobCount == 0) {
- // may happen if isolation level is below repeatable read
- log.debug(job + " was locked during attempt to lock other jobs");
- return null;
- }
- long[] exclusiveJobIds = new long[jobCount];
- for (int i = 0; i < jobCount; i++) {
- Job exclusiveJob = (Job) exclusiveJobs.get(i);
- exclusiveJob.setLockOwner(lockOwner);
- exclusiveJobIds[i] = exclusiveJob.getId();
- }
- log.debug("locking jobs " + ArrayUtil.toString(exclusiveJobIds));
- // execute exclusive jobs in separate transaction
- postJobsExecution(jbpmContext, exclusiveJobIds);
+ jbpmContext.getGraphSession().lockProcessInstance(processInstance);
}
- else {
- // lock job to prevent others from deleting it
- job.setLockOwner(lockOwner);
- log.debug("executing " + job);
- executeJob(job, jbpmContext);
- }
- return null;
+
+ // mark job as locked to prevent other parts of the engine from deleting it
+ job.setLockOwner(toString());
+ return job;
}
static void executeJob(Job job, JbpmContext jbpmContext) {
+ log.debug("executing " + job);
try {
if (job.execute(jbpmContext)) {
jbpmContext.getJobSession().deleteJob(job);
}
}
- catch (RuntimeException e) {
- // nothing to do but clean up and exit
- throw e;
- }
catch (Exception e) {
- // save data about recoverable error condition
- log.error("exception while executing " + job, e);
- StringWriter memoryWriter = new StringWriter();
- e.printStackTrace(new PrintWriter(memoryWriter));
- job.setException(memoryWriter.toString());
- job.setRetries(job.getRetries() - 1);
+ log.debug("exception while executing " + job, e);
+ if (!DbPersistenceService.isPersistenceException(e)) {
+ StringWriter memoryWriter = new StringWriter();
+ e.printStackTrace(new PrintWriter(memoryWriter));
+ job.setException(memoryWriter.toString());
+ }
+ else {
+ // allowing a transaction to proceed after a persistence exception is unsafe
+ throw e instanceof RuntimeException ? (RuntimeException) e :
+ new JbpmException("failed to execute " + job, e);
+ }
}
}
- private static void postJobsExecution(JbpmContext jbpmContext, long[] exclusiveJobIds)
- throws NamingException, JMSException {
- Services services = jbpmContext.getServices();
- JmsMessageServiceFactory messageServiceFactory = (JmsMessageServiceFactory) services.getServiceFactory(Services.SERVICENAME_MESSAGE);
- Destination destination = messageServiceFactory.getCommandDestination();
-
- JmsMessageService messageService = (JmsMessageService) services.getMessageService();
- Session session = messageService.getSession();
- MessageProducer producer = session.createProducer(destination);
- try {
- Command command = new ExecuteJobsCommand(exclusiveJobIds);
- Message message = session.createObjectMessage(command);
- producer.send(message);
- }
- finally {
- producer.close();
- }
- }
-
private static Log log = LogFactory.getLog(ExecuteJobCommand.class);
}
Deleted: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobsCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobsCommand.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobsCommand.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -1,61 +0,0 @@
-/*
- * 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.ejb.impl;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.jbpm.JbpmContext;
-import org.jbpm.command.Command;
-import org.jbpm.job.Job;
-import org.jbpm.util.ArrayUtil;
-
-/**
- * Batch job processing command.
- *
- * @author Alejandro Guizar
- */
-public class ExecuteJobsCommand implements Command {
-
- private long[] jobIds;
-
- private static final long serialVersionUID = 1L;
- private static Log log = LogFactory.getLog(ExecuteJobsCommand.class);
-
- public ExecuteJobsCommand(long[] jobIds) {
- this.jobIds = jobIds;
- }
-
- public Object execute(JbpmContext jbpmContext) throws Exception {
- log.debug("executing jobs " + ArrayUtil.toString(jobIds));
- List jobs = jbpmContext.getJobSession().loadJobs(jobIds);
- for (Iterator i = jobs.iterator(); i.hasNext();) {
- Job job = (Job) i.next();
- job.execute(jbpmContext);
- }
- return null;
- }
-
-}
Added: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/AbstractEnterpriseTestCase.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/AbstractEnterpriseTestCase.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/AbstractEnterpriseTestCase.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -0,0 +1,200 @@
+/*
+ * 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.enterprise;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.Session;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.cactus.ServletTestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.cfg.Environment;
+import org.jbpm.JbpmContext;
+import org.jbpm.command.Command;
+import org.jbpm.command.CommandService;
+import org.jbpm.command.DeleteProcessDefinitionCommand;
+import org.jbpm.command.DeployProcessCommand;
+import org.jbpm.command.GetProcessInstanceCommand;
+import org.jbpm.command.SignalCommand;
+import org.jbpm.command.StartProcessInstanceCommand;
+import org.jbpm.ejb.LocalCommandServiceHome;
+import org.jbpm.graph.def.EventCallback;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.persistence.db.DbPersistenceServiceFactory;
+import org.jbpm.svc.Services;
+
+public abstract class AbstractEnterpriseTestCase extends ServletTestCase {
+
+ protected CommandService commandService;
+
+ private List processDefinitions = new ArrayList();
+
+ private static Context environment;
+ private static LocalCommandServiceHome commandServiceHome;
+ private static Destination commandQueue;
+ private static ConnectionFactory jmsConnectionFactory;
+
+ private static final Log log = LogFactory.getLog(AbstractEnterpriseTestCase.class);
+
+ protected AbstractEnterpriseTestCase() {
+ }
+
+ protected void setUp() throws Exception {
+ commandService = createCommandService();
+ log.info("### " + getName() + " started ###");
+ }
+
+ protected void tearDown() throws Exception {
+ log.info("### " + getName() + " done ###");
+ for (Iterator i = processDefinitions.iterator(); i.hasNext();) {
+ ProcessDefinition processDefinition = (ProcessDefinition) i.next();
+ deleteProcessDefinition(processDefinition.getId());
+ }
+ commandService = null;
+ EventCallback.clear();
+ }
+
+ protected CommandService createCommandService() throws Exception {
+ if (commandServiceHome == null) {
+ commandServiceHome = (LocalCommandServiceHome) getEnvironment()
+ .lookup("ejb/CommandServiceBean");
+ }
+ return commandServiceHome.create();
+ }
+
+ protected ProcessDefinition deployProcessDefinition(String xml) {
+ ProcessDefinition processDefinition = (ProcessDefinition) commandService.execute(
+ new DeployProcessCommand(xml));
+ processDefinitions.add(processDefinition);
+ return processDefinition;
+ }
+
+ protected ProcessDefinition deployProcessDefinition(byte[] processArchive) {
+ ProcessDefinition processDefinition = (ProcessDefinition) commandService.execute(
+ new DeployProcessCommand(processArchive));
+ processDefinitions.add(processDefinition);
+ return processDefinition;
+ }
+
+ protected ProcessInstance startProcessInstance(String processName) {
+ StartProcessInstanceCommand command = new StartProcessInstanceCommand();
+ command.setProcessDefinitionName(processName);
+ command.setVariables(Collections.singletonMap("eventCallback", new EventCallback()));
+ return (ProcessInstance) commandService.execute(command);
+ }
+
+ protected void signalToken(long tokenId) {
+ commandService.execute(new SignalCommand(tokenId, null));
+ }
+
+ protected boolean hasProcessInstanceEnded(final long processInstanceId) {
+ ProcessInstance processInstance = (ProcessInstance) commandService.execute(
+ new GetProcessInstanceCommand(processInstanceId));
+ return processInstance.hasEnded();
+ }
+
+ protected Object getVariable(final long processInstanceId, final String variableName) {
+ return commandService.execute(new Command() {
+ private static final long serialVersionUID = 1L;
+
+ public Object execute(JbpmContext jbpmContext) throws Exception {
+ ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
+ return processInstance.getContextInstance().getVariable(variableName);
+ }
+ });
+ }
+
+ protected String getHibernateDialect() {
+ return (String) commandService.execute(new Command() {
+ private static final long serialVersionUID = 1L;
+
+ public Object execute(JbpmContext jbpmContext) throws Exception {
+ DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory) jbpmContext
+ .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ return factory.getConfiguration().getProperty(Environment.DIALECT);
+ }
+ });
+ }
+
+ private void deleteProcessDefinition(long processDefinitionId) throws Exception {
+ if (true) {
+ // [JBPM-1812] Fix tests that don't cleanup the database
+ // deleting process definition makes subsequent tests unstable
+ return;
+ }
+
+ Connection jmsConnection = getConnectionFactory().createConnection();
+ try {
+ Session jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ try {
+ Command command = new DeleteProcessDefinitionCommand(processDefinitionId);
+ jmsSession.createProducer(getCommandQueue()).send(jmsSession.createObjectMessage(command));
+ }
+ finally {
+ jmsSession.close();
+ }
+ }
+ finally {
+ jmsConnection.close();
+ }
+ }
+
+ private Destination getCommandQueue() throws NamingException {
+ if (commandQueue == null) {
+ commandQueue = (Destination) getEnvironment().lookup("jms/CommandQueue");
+ }
+ return commandQueue;
+ }
+
+ private ConnectionFactory getConnectionFactory() throws NamingException {
+ if (jmsConnectionFactory == null) {
+ jmsConnectionFactory = (ConnectionFactory) getEnvironment()
+ .lookup("jms/JbpmConnectionFactory");
+ }
+ return jmsConnectionFactory;
+ }
+
+ private static Context getEnvironment() throws NamingException {
+ if (environment == null) {
+ Context initial = new InitialContext();
+ try {
+ environment = (Context) initial.lookup("java:comp/env");
+ }
+ finally {
+ initial.close();
+ }
+ }
+ return environment;
+ }
+
+}
\ No newline at end of file
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/config/AppServerConfigurationsTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/config/AppServerConfigurationsTest.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/config/AppServerConfigurationsTest.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -24,7 +24,6 @@
import junit.framework.Test;
import org.apache.cactus.ServletTestCase;
-
import org.jbpm.JbpmConfiguration;
import org.jbpm.enterprise.IntegrationTestSetup;
import org.jbpm.msg.jms.JmsMessageServiceFactory;
Added: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.enterprise.console;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class ConsoleAvailabilityTest extends TestCase
+{
+ /**
+ * Verify if the console has been deployed successfully
+ */
+ public void testConsoleDeployment() throws IOException
+ {
+ String host = "localhost";
+ int port = 8080;
+
+ String bindAddress = System.getProperty("jboss.bind.address");
+ if (bindAddress != null)
+ {
+ int colonIndex = bindAddress.lastIndexOf(':');
+ if (colonIndex != -1)
+ {
+ host = bindAddress.substring(0, colonIndex);
+ port = Integer.parseInt(bindAddress.substring(colonIndex + 1));
+ }
+ else
+ host = bindAddress;
+ }
+
+ URL url = new URL("http", host, port, "/jbpm-console");
+ System.out.println("Console URL: " + url);
+
+ List response = doGet(url);
+ String status = (String) response.get(0);
+ assertEquals(HttpURLConnection.HTTP_OK, Integer.parseInt(status));
+ }
+
+ /**
+ * Gets the resource pointed by the given URL.
+ * @param url a pointer to a resource
+ * @return response data in the following order:
+ * <
+ * <li>Code</li>
+ * <li>Message</li>
+ * <li>Body</li>
+ * @throws IOException
+ */
+ static List doGet(URL url) throws IOException
+ {
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ try
+ {
+ List response = new ArrayList();
+ response.add(Integer.toString(connection.getResponseCode()));
+ response.add(connection.getResponseMessage());
+
+ BufferedReader connReader = new BufferedReader(new InputStreamReader(connection
+ .getInputStream()));
+ try
+ {
+ for (String line; (line = connReader.readLine()) != null;)
+ response.add(line);
+ }
+ finally
+ {
+ connReader.close();
+ }
+ return response;
+ }
+ finally
+ {
+ connection.disconnect();
+ }
+ }
+}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -22,29 +22,16 @@
package org.jbpm.enterprise.ejbtimer;
import java.rmi.RemoteException;
-import java.util.Collections;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
import junit.framework.Test;
-import org.apache.cactus.ServletTestCase;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import org.jbpm.JbpmContext;
import org.jbpm.command.Command;
-import org.jbpm.command.DeployProcessCommand;
-import org.jbpm.command.StartProcessInstanceCommand;
-import org.jbpm.ejb.LocalCommandService;
-import org.jbpm.ejb.LocalCommandServiceHome;
+import org.jbpm.enterprise.AbstractEnterpriseTestCase;
import org.jbpm.enterprise.IntegrationTestSetup;
import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.EventCallback;
-import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.graph.exe.Token;
import org.jbpm.scheduler.ejbtimer.EntitySchedulerService;
/**
@@ -52,39 +39,14 @@
*
* @author Alejandro Guizar
*/
-public class EjbSchedulerTest extends ServletTestCase {
+public class EjbSchedulerTest extends AbstractEnterpriseTestCase {
- private LocalCommandService commandService;
-
- private static LocalCommandServiceHome commandServiceHome;
-
- private static final Log log = LogFactory.getLog(EjbSchedulerTest.class);
-
public static Test suite() throws Exception {
return new IntegrationTestSetup(EjbSchedulerTest.class, "enterprise-test.war");
}
- protected void setUp() throws Exception {
- if (commandServiceHome == null) {
- Context initialContext = new InitialContext();
- try {
- commandServiceHome = (LocalCommandServiceHome) initialContext.lookup("java:comp/env/ejb/CommandServiceBean");
- }
- finally {
- initialContext.close();
- }
- }
- commandService = commandServiceHome.create();
- log.info("### " + getName() + " started ###");
- }
-
- protected void tearDown() throws Exception {
- log.info("### " + getName() + " done ###");
- commandService = null;
- }
-
public void testScheduleFuture() throws Exception {
- deployProcess("<process-definition name='future'>"
+ deployProcessDefinition("<process-definition name='future'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}'/>"
+ " </event>"
@@ -97,13 +59,13 @@
+ " </state>"
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("future").getId();
+ long processInstanceId = startProcessInstance("future").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
- assertTrue(isProcessFinished(processId));
+ assertTrue("expected process instance " + processInstanceId + " to have ended", hasProcessInstanceEnded(processInstanceId));
}
public void testSchedulePast() throws Exception {
- deployProcess("<process-definition name='past'>"
+ deployProcessDefinition("<process-definition name='past'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}'/>"
+ " </event>"
@@ -116,13 +78,13 @@
+ " </state>"
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("past").getId();
+ long processInstanceId = startProcessInstance("past").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
- assertTrue(isProcessFinished(processId));
+ assertTrue("expected process instance " + processInstanceId + " to have ended", hasProcessInstanceEnded(processInstanceId));
}
public void testScheduleRepeat() throws Exception {
- deployProcess("<process-definition name='repeat'>"
+ deployProcessDefinition("<process-definition name='repeat'>"
+ " <event type='timer'>"
+ " <action expression='#{eventCallback.timer}'/>"
+ " </event>"
@@ -135,17 +97,18 @@
+ " </state>"
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("repeat").getId();
+ ProcessInstance processInstance = startProcessInstance("repeat");
+ long processInstanceId = processInstance.getId();
for (int i = 0; i < 3; i++) {
EventCallback.waitForEvent(Event.EVENTTYPE_TIMER);
- assertEquals("a", getProcessState(processId));
+ assertEquals("a", getProcessInstanceState(processInstanceId));
}
- signalProcess(processId);
- assertTrue(isProcessFinished(processId));
+ signalToken(processInstance.getRootToken().getId());
+ assertTrue("expected process instance " + processInstanceId + " to have ended", hasProcessInstanceEnded(processInstanceId));
}
public void testCancel() throws Exception {
- deployProcess("<process-definition name='cancel'>"
+ deployProcessDefinition("<process-definition name='cancel'>"
+ " <event type='timer'>"
+ " <action expression='#{eventCallback.timer}'/>"
+ " </event>"
@@ -154,33 +117,41 @@
+ " </start-state>"
+ " <state name='a'>"
+ " <timer duedate='1 second' repeat='1 second' />"
+ + " <transition to='b' />"
+ + " </state>"
+ + " <state name='b'>"
+ " <transition to='end' />"
+ " </state>"
+ " <end-state name='end' />"
+ "</process-definition>");
- ProcessInstance process = launchProcess("cancel");
- long processId = process.getId();
+ ProcessInstance processInstance = startProcessInstance("cancel");
+ long processInstanceId = processInstance.getId();
// first expiration
EventCallback.waitForEvent(Event.EVENTTYPE_TIMER);
- assertEquals("a", getProcessState(processId));
+ assertEquals("a", getProcessInstanceState(processInstanceId));
// repeated expiration
EventCallback.waitForEvent(Event.EVENTTYPE_TIMER);
- assertEquals("a", getProcessState(processId));
+ assertEquals("a", getProcessInstanceState(processInstanceId));
+ // cancel timer
+ long rootTokenId = processInstance.getRootToken().getId();
+ signalToken(rootTokenId);
// no more expirations
- cancelTimer("a", process.getRootToken().getId());
try {
- EventCallback.waitForEvent(Event.EVENTTYPE_TIMER, 2000);
+ EventCallback.waitForEvent(Event.EVENTTYPE_TIMER, 1000);
+ System.out.println("canceled timer fired again, probably due to race condition");
+ EventCallback.waitForEvent(Event.EVENTTYPE_TIMER, 1000);
fail("expected timeout exception");
}
catch (org.jbpm.JbpmException e) {
// timeout exception was expected
}
- signalProcess(processId);
- assertTrue(isProcessFinished(processId));
+ // proceed to end state
+ signalToken(rootTokenId);
+ assertTrue("expected process instance " + processInstanceId + " to have ended", hasProcessInstanceEnded(processInstanceId));
}
public void testScheduleSequence() throws Exception {
- deployProcess("<process-definition name='sequence'>"
+ deployProcessDefinition("<process-definition name='sequence'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}'/>"
+ " </event>"
@@ -191,39 +162,38 @@
+ " <transition to='a' />"
+ " </start-state>"
+ " <state name='a'>"
- + " <timer duedate='500 milliseconds' transition='timeout' />"
+ + " <timer duedate='1 second' transition='timeout' />"
+ " <transition name='timeout' to='b' />"
+ " </state>"
+ " <state name='b'>"
- + " <timer duedate='500 milliseconds' transition='timeout' />"
+ + " <timer duedate='1 second' transition='timeout' />"
+ " <transition name='timeout' to='c' />"
+ " </state>"
+ " <state name='c'>"
- + " <timer duedate='500 milliseconds' transition='timeout' />"
+ + " <timer duedate='1 second' transition='timeout' />"
+ " <transition name='timeout' to='d' />"
+ " </state>"
+ " <state name='d'>"
- + " <timer duedate='500 milliseconds' transition='timeout' />"
+ + " <timer duedate='1 second' transition='timeout' />"
+ " <transition name='timeout' to='e' />"
+ " </state>"
+ " <state name='e'>"
- + " <timer duedate='500 milliseconds' transition='timeout' />"
+ + " <timer duedate='1 second' transition='timeout' />"
+ " <transition name='timeout' to='end' />"
+ " </state>"
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("sequence").getId();
- char state = 'b';
- for (int i = 0; i < 4; i++) {
+ long processInstanceId = startProcessInstance("sequence").getId();
+ for (char state = 'b'; state <= 'e'; state++) {
EventCallback.waitForEvent(Event.EVENTTYPE_TIMER);
- assertEquals(Character.toString(state++), getProcessState(processId));
+ assertEquals(Character.toString(state), getProcessInstanceState(processInstanceId));
}
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
- assertTrue(isProcessFinished(processId));
+ assertTrue("expected process instance " + processInstanceId + " to have ended", hasProcessInstanceEnded(processInstanceId));
}
public void testScheduleFork() throws Exception {
- deployProcess("<process-definition name='fork'>"
+ deployProcessDefinition("<process-definition name='fork'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}'/>"
+ " </event>"
@@ -238,91 +208,46 @@
+ " <transition name='e' to='e' />"
+ " </fork>"
+ " <state name='a'>"
- + " <timer duedate='0.25 seconds' transition='timeout' />"
+ + " <timer duedate='0 seconds' transition='timeout' />"
+ " <transition name='timeout' to='j' />"
+ " </state>"
+ " <state name='b'>"
- + " <timer duedate='0.5 seconds' transition='timeout' />"
+ + " <timer duedate='1 second' transition='timeout' />"
+ " <transition name='timeout' to='j' />"
+ " </state>"
+ " <state name='c'>"
- + " <timer duedate='0.75 seconds' transition='timeout' />"
+ + " <timer duedate='2 seconds' transition='timeout' />"
+ " <transition name='timeout' to='j' />"
+ " </state>"
+ " <state name='d'>"
- + " <timer duedate='1 second' transition='timeout' />"
+ + " <timer duedate='3 seconds' transition='timeout' />"
+ " <transition name='timeout' to='j' />"
+ " </state>"
+ " <state name='e'>"
- + " <timer duedate='1.25 second' transition='timeout' />"
+ + " <timer duedate='4 seconds' transition='timeout' />"
+ " <transition name='timeout' to='j' />"
+ " </state>"
- + " <join name='j' async='exclusive'>"
+ + " <join name='j' async='exclusive' lock='UPGRADE'>"
+ " <transition to='end' />"
+ " </join>"
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("fork").getId();
+ long processInstanceId = startProcessInstance("fork").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
- assertTrue(isProcessFinished(processId));
+ assertTrue("expected process instance " + processInstanceId + " to have ended", hasProcessInstanceEnded(processInstanceId));
}
- private ProcessDefinition deployProcess(String xml) throws RemoteException {
- return (ProcessDefinition) commandService.execute(new DeployProcessCommand(xml));
- }
-
- private ProcessInstance launchProcess(String processName) throws RemoteException {
- StartProcessInstanceCommand command = new StartProcessInstanceCommand();
- command.setProcessDefinitionName(processName);
- command.setVariables(Collections.singletonMap("eventCallback", new EventCallback()));
- return (ProcessInstance) commandService.execute(command);
- }
-
- private void signalProcess(final long processId) throws RemoteException {
- commandService.execute(new Command() {
-
- private static final long serialVersionUID = 1L;
-
- public Object execute(JbpmContext jbpmContext) throws Exception {
- jbpmContext.loadProcessInstanceForUpdate(processId).signal();
- return null;
- }
- });
- }
-
- private String getProcessState(final long processId) throws RemoteException {
+ private String getProcessInstanceState(final long processInstanceId) throws RemoteException {
return (String) commandService.execute(new Command() {
private static final long serialVersionUID = 1L;
public Object execute(JbpmContext jbpmContext) throws Exception {
- return jbpmContext.loadProcessInstance(processId).getRootToken().getNode().getName();
+ return jbpmContext.loadProcessInstance(processInstanceId)
+ .getRootToken()
+ .getNode()
+ .getName();
}
});
}
-
- private boolean isProcessFinished(final long processId) throws RemoteException {
- Boolean isFinished = (Boolean) commandService.execute(new Command() {
-
- private static final long serialVersionUID = 1L;
-
- public Object execute(JbpmContext jbpmContext) throws Exception {
- return Boolean.valueOf(jbpmContext.loadProcessInstance(processId).hasEnded());
- }
- });
- return isFinished.booleanValue();
- }
-
- private void cancelTimer(final String timerName, final long tokenId) throws RemoteException {
- commandService.execute(new Command() {
-
- private static final long serialVersionUID = 1L;
-
- public Object execute(JbpmContext jbpmContext) throws Exception {
- Token token = jbpmContext.loadToken(tokenId);
- jbpmContext.getServices().getSchedulerService().deleteTimersByName(timerName, token);
- return null;
- }
- });
- }
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1903/JBPM1903Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1903/JBPM1903Test.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1903/JBPM1903Test.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -29,58 +29,25 @@
import javax.jms.JMSException;
import javax.jms.Queue;
-import javax.naming.Context;
-import javax.naming.InitialContext;
import junit.framework.Test;
-import org.apache.cactus.ServletTestCase;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.jbpm.JbpmContext;
-import org.jbpm.command.Command;
-import org.jbpm.command.DeployProcessCommand;
-import org.jbpm.command.StartProcessInstanceCommand;
-import org.jbpm.ejb.LocalCommandService;
-import org.jbpm.ejb.LocalCommandServiceHome;
+import org.jbpm.enterprise.AbstractEnterpriseTestCase;
import org.jbpm.enterprise.IntegrationTestSetup;
-import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.util.IoUtil;
/**
+ * ENC is not reachable from within action handlers.
+ *
+ * @see <a href="https://jira.jboss.org/jira/browse/JBPM-1903">JBPM-1903</a>
* @author Alejandro Guizar
*/
-public class JBPM1903Test extends ServletTestCase {
+public class JBPM1903Test extends AbstractEnterpriseTestCase {
- private LocalCommandService commandService;
- private static LocalCommandServiceHome commandServiceHome;
-
- private static final Log log = LogFactory.getLog(JBPM1903Test.class);
-
public static Test suite() throws Exception {
return new IntegrationTestSetup(JBPM1903Test.class, "enterprise-test.war");
}
- protected void setUp() throws Exception {
- if (commandServiceHome == null) {
- Context initialContext = new InitialContext();
- try {
- commandServiceHome = (LocalCommandServiceHome) initialContext.lookup("java:comp/env/ejb/CommandServiceBean");
- }
- finally {
- initialContext.close();
- }
- }
- commandService = commandServiceHome.create();
- log.info("### " + getName() + " started ###");
- }
-
- protected void tearDown() throws Exception {
- log.info("### " + getName() + " done ###");
- commandService = null;
- }
-
public void testENCInActionHandler() throws IOException, JMSException {
byte[] processArchive = createProcessArchive();
deployProcessDefinition(processArchive);
@@ -106,24 +73,4 @@
zipOut.close();
return memoryOut.toByteArray();
}
-
- private void deployProcessDefinition(byte[] processArchive) {
- commandService.execute(new DeployProcessCommand(processArchive));
- }
-
- private ProcessInstance startProcessInstance(String processName) {
- return (ProcessInstance) commandService.execute(new StartProcessInstanceCommand().processDefinitionName(processName));
- }
-
- private Object getVariable(final long processInstanceId, final String variableName) {
- return commandService.execute(new Command() {
-
- private static final long serialVersionUID = 1L;
-
- public Object execute(JbpmContext jbpmContext) throws Exception {
- ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
- return processInstance.getContextInstance().getVariable(variableName);
- }
- });
- }
}
Copied: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952 (from rev 4073, jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952)
Deleted: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/JBPM1952Test.java
===================================================================
--- jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/JBPM1952Test.java 2009-02-28 01:05:43 UTC (rev 4073)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/JBPM1952Test.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -1,72 +0,0 @@
-package org.jbpm.enterprise.jbpm1952;
-
-import junit.framework.Test;
-
-import org.jboss.bpm.api.test.IntegrationTestSetup;
-import org.jbpm.enterprise.AbstractEnterpriseTestCase;
-
-/**
- * Use JMS instead of DBMS for storing jobs, so that each job is not taken by multiple job executor
- * threads.
- *
- * @see <a href="https://jira.jboss.org/jira/browse/JBPM-1952">JBPM-1952</a>
- * @author Alejandro Guizar
- */
-public class JBPM1952Test extends AbstractEnterpriseTestCase {
-
- private static final int PROCESS_EXECUTION_COUNT = 20;
-
- public static Test suite() {
- return new IntegrationTestSetup(JBPM1952Test.class, "enterprise-test.war");
- }
-
- public void testStaleStateInAsyncFork() {
- deployProcessDefinition("<process-definition name='jbpm1952'>"
- + " <event type='process-end'>"
- + " <action expression='#{eventCallback.processEnd}' />"
- + " </event>"
- + " <start-state>"
- + " <transition to='a' />"
- + " </start-state>"
- + " <node name='a' async='true'>"
- + " <transition to='b' />"
- + " </node>"
- + " <node name='b' async='true'>"
- + " <transition to='fork' />"
- + " </node>"
- + " <fork name='fork'>"
- + " <transition to='c1' name='to_c1'/>"
- + " <transition to='c2' name='to_c2'/>"
- + " <transition to='c3' name='to_c3'/>"
- + " </fork>"
- + " <node name='c1' async='true'>"
- + " <transition to='join' />"
- + " </node>"
- + " <node name='c2' async='true'>"
- + " <transition to='join' />"
- + " </node>"
- + " <node name='c3' async='true'>"
- + " <transition to='join' />"
- + " </node>"
- + " <join name='join' async='exclusive'>"
- + " <transition to='d' />"
- + " </join>"
- + " <node name='d' async='true'>"
- + " <transition to='end' />"
- + " </node>"
- + " <end-state name='end'/>"
- + "</process-definition>");
-
- long[] processInstanceIds = new long[PROCESS_EXECUTION_COUNT];
- for (int i = 0; i < PROCESS_EXECUTION_COUNT; i++) {
- processInstanceIds[i] = startProcessInstance("jbpm1952").getId();
- }
-
- for (int i = 0; i < PROCESS_EXECUTION_COUNT; i++) {
- long processInstanceId = processInstanceIds[i];
- assertTrue("expected process instance " + processInstanceId + " to have ended",
- waitForProcessInstanceEnd(processInstanceId));
- }
- }
-
-}
Copied: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/JBPM1952Test.java (from rev 4073, jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/JBPM1952Test.java)
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/JBPM1952Test.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1952/JBPM1952Test.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -0,0 +1,75 @@
+package org.jbpm.enterprise.jbpm1952;
+
+import junit.framework.Test;
+
+import org.jbpm.enterprise.AbstractEnterpriseTestCase;
+import org.jbpm.enterprise.IntegrationTestSetup;
+import org.jbpm.graph.def.Event;
+import org.jbpm.graph.def.EventCallback;
+
+/**
+ * Use JMS instead of DBMS for storing jobs, so that each job is not taken by multiple job executor
+ * threads.
+ *
+ * @see <a href="https://jira.jboss.org/jira/browse/JBPM-1952">JBPM-1952</a>
+ * @author Alejandro Guizar
+ */
+public class JBPM1952Test extends AbstractEnterpriseTestCase {
+
+ private static final int PROCESS_EXECUTION_COUNT = 20;
+
+ public static Test suite() {
+ return new IntegrationTestSetup(JBPM1952Test.class, "enterprise-test.war");
+ }
+
+ public void testStaleStateInAsyncFork() {
+ deployProcessDefinition("<process-definition name='jbpm1952'>"
+ + " <event type='process-end'>"
+ + " <action expression='#{eventCallback.processEnd}' />"
+ + " </event>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <node name='a' async='true'>"
+ + " <transition to='b' />"
+ + " </node>"
+ + " <node name='b' async='true'>"
+ + " <transition to='fork' />"
+ + " </node>"
+ + " <fork name='fork'>"
+ + " <transition to='c1' name='to_c1'/>"
+ + " <transition to='c2' name='to_c2'/>"
+ + " <transition to='c3' name='to_c3'/>"
+ + " </fork>"
+ + " <node name='c1' async='true'>"
+ + " <transition to='join' />"
+ + " </node>"
+ + " <node name='c2' async='true'>"
+ + " <transition to='join' />"
+ + " </node>"
+ + " <node name='c3' async='true'>"
+ + " <transition to='join' />"
+ + " </node>"
+ + " <join name='join' async='exclusive'>"
+ + " <transition to='d' />"
+ + " </join>"
+ + " <node name='d' async='true'>"
+ + " <transition to='end' />"
+ + " </node>"
+ + " <end-state name='end'/>"
+ + "</process-definition>");
+
+ long[] processInstanceIds = new long[PROCESS_EXECUTION_COUNT];
+ for (int i = 0; i < PROCESS_EXECUTION_COUNT; i++) {
+ processInstanceIds[i] = startProcessInstance("jbpm1952").getId();
+ }
+
+ EventCallback.waitForEvent(PROCESS_EXECUTION_COUNT, Event.EVENTTYPE_PROCESS_END);
+
+ for (int i = 0; i < PROCESS_EXECUTION_COUNT; i++) {
+ long processInstanceId = processInstanceIds[i];
+ assertTrue("expected process instance " + processInstanceId + " to have ended", hasProcessInstanceEnded(processInstanceId));
+ }
+ }
+
+}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jms/JmsMessageTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jms/JmsMessageTest.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jms/JmsMessageTest.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -21,75 +21,29 @@
*/
package org.jbpm.enterprise.jms;
-import java.util.Collections;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
import junit.framework.Test;
-import org.apache.cactus.ServletTestCase;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.cfg.Environment;
-
-import org.jbpm.JbpmContext;
-import org.jbpm.command.Command;
-import org.jbpm.command.DeployProcessCommand;
-import org.jbpm.command.StartProcessInstanceCommand;
-import org.jbpm.ejb.LocalCommandService;
-import org.jbpm.ejb.LocalCommandServiceHome;
+import org.jbpm.enterprise.AbstractEnterpriseTestCase;
import org.jbpm.enterprise.IntegrationTestSetup;
import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.EventCallback;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.msg.jms.JmsMessageService;
-import org.jbpm.persistence.db.DbPersistenceServiceFactory;
-import org.jbpm.svc.Services;
/**
* Exercises for the {@linkplain JmsMessageService JMS message service}.
*
* @author Alejandro Guizar
*/
-public class JmsMessageTest extends ServletTestCase {
+public class JmsMessageTest extends AbstractEnterpriseTestCase {
- private LocalCommandService commandService;
+ private static final int PROCESS_INSTANCE_COUNT = 5;
- private static LocalCommandServiceHome commandServiceHome;
-
- static final int processExecutionCount = 5;
- static final int maxWaitTime = 10 * 1000;
-
- private static final Log log = LogFactory.getLog(JmsMessageTest.class);
-
public static Test suite() throws Exception {
return new IntegrationTestSetup(JmsMessageTest.class, "enterprise-test.war");
}
- protected void setUp() throws Exception {
- if (commandServiceHome == null) {
- Context initialContext = new InitialContext();
- try {
- commandServiceHome = (LocalCommandServiceHome) initialContext.lookup("java:comp/env/ejb/CommandServiceBean");
- }
- finally {
- initialContext.close();
- }
- }
- commandService = commandServiceHome.create();
- log.info("### " + getName() + " started ###");
- }
-
- protected void tearDown() throws Exception {
- log.info("### " + getName() + " done ###");
- commandService = null;
- EventCallback.clear();
- }
-
public void testAsyncNode() {
- deployProcess("<process-definition name='node'>"
+ deployProcessDefinition("<process-definition name='node'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}'/>"
+ " </event>"
@@ -102,13 +56,13 @@
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("node").getId();
+ long processInstanceId = startProcessInstance("node").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
- assertTrue("Process has ended", hasProcessEnded(processId));
+ assertTrue("expected process instance " + processInstanceId + " to have ended", hasProcessInstanceEnded(processInstanceId));
}
public void testAsyncAction() {
- deployProcess("<process-definition name='action'>"
+ deployProcessDefinition("<process-definition name='action'>"
+ " <start-state name='start'>"
+ " <transition to='a' />"
+ " </start-state>"
@@ -126,15 +80,15 @@
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("action").getId();
+ long processInstanceId = startProcessInstance("action").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_NODE_ENTER);
EventCallback.waitForEvent(Event.EVENTTYPE_NODE_LEAVE);
EventCallback.waitForEvent(Event.EVENTTYPE_TRANSITION);
- assertTrue("Process has ended", hasProcessEnded(processId));
+ assertTrue("expected process instance " + processInstanceId + " to have ended", hasProcessInstanceEnded(processInstanceId));
}
public void testAsyncSequence() {
- deployProcess("<process-definition name='sequence'>"
+ deployProcessDefinition("<process-definition name='sequence'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}'/>"
+ " </event>"
@@ -159,9 +113,9 @@
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("sequence").getId();
+ long processInstanceId = startProcessInstance("sequence").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
- assertTrue("Process has ended", hasProcessEnded(processId));
+ assertTrue("expected process instance " + processInstanceId + " to have ended", hasProcessInstanceEnded(processInstanceId));
}
public void testAsyncFork() throws Exception {
@@ -170,7 +124,7 @@
return;
}
- deployProcess("<process-definition name='fork'>"
+ deployProcessDefinition("<process-definition name='fork'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}'/>"
+ " </event>"
@@ -205,25 +159,18 @@
+ " <end-state name='end' />"
+ "</process-definition>");
- long processId = launchProcess("fork").getId();
+ long processInstanceId = startProcessInstance("fork").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
- assertTrue("Process has ended", hasProcessEnded(processId));
+ assertTrue("expected process instance " + processInstanceId + " to have ended", hasProcessInstanceEnded(processInstanceId));
}
- private String getHibernateDialect() {
- return (String) commandService.execute(new Command() {
-
- private static final long serialVersionUID = 1L;
-
- public Object execute(JbpmContext jbpmContext) throws Exception {
- DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- return factory.getConfiguration().getProperty(Environment.DIALECT);
- }
- });
- }
-
public void testAsyncExecutions() {
- deployProcess("<process-definition name='execution'>"
+ // [JBPM-1811] JmsMessageTest fails intermittently on HSQLDB
+ if (getHibernateDialect().indexOf("HSQL") != -1) {
+ return;
+ }
+
+ deployProcessDefinition("<process-definition name='execution'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}' />"
+ " </event>"
@@ -254,41 +201,18 @@
+ " <end-state name='end' />"
+ "</process-definition>");
- long[] processIds = new long[processExecutionCount];
- for (int i = 0; i < processExecutionCount; i++) {
- processIds[i] = launchProcess("execution").getId();
+ long[] processInstanceIds = new long[PROCESS_INSTANCE_COUNT];
+ for (int i = 0; i < PROCESS_INSTANCE_COUNT; i++) {
+ processInstanceIds[i] = startProcessInstance("execution").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_NODE_ENTER);
}
- EventCallback.waitForEvent(processExecutionCount, Event.EVENTTYPE_NODE_LEAVE);
- EventCallback.waitForEvent(processExecutionCount, Event.EVENTTYPE_PROCESS_END);
+ EventCallback.waitForEvent(PROCESS_INSTANCE_COUNT, Event.EVENTTYPE_NODE_LEAVE);
+ EventCallback.waitForEvent(PROCESS_INSTANCE_COUNT, Event.EVENTTYPE_PROCESS_END);
- for (int i = 0; i < processExecutionCount; i++) {
- long processId = processIds[i];
- assertTrue("expected process " + processId + " to have ended", hasProcessEnded(processId));
+ for (int i = 0; i < PROCESS_INSTANCE_COUNT; i++) {
+ long processInstanceId = processInstanceIds[i];
+ assertTrue("expected process instance " + processInstanceId + " to have ended", hasProcessInstanceEnded(processInstanceId));
}
}
-
- private ProcessDefinition deployProcess(String xml) {
- return (ProcessDefinition) commandService.execute(new DeployProcessCommand(xml));
- }
-
- private ProcessInstance launchProcess(String processName) {
- StartProcessInstanceCommand command = new StartProcessInstanceCommand();
- command.setProcessDefinitionName(processName);
- command.setVariables(Collections.singletonMap("eventCallback", new EventCallback()));
- return (ProcessInstance) commandService.execute(command);
- }
-
- private boolean hasProcessEnded(final long processId) {
- Boolean isFinished = (Boolean) commandService.execute(new Command() {
-
- private static final long serialVersionUID = 1L;
-
- public Object execute(JbpmContext jbpmContext) throws Exception {
- return Boolean.valueOf(jbpmContext.loadProcessInstance(processId).hasEnded());
- }
- });
- return isFinished.booleanValue();
- }
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java 2009-05-07 16:08:10 UTC (rev 4761)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java 2009-05-07 18:52:11 UTC (rev 4762)
@@ -21,191 +21,80 @@
*/
package org.jbpm.enterprise.jta;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.transaction.UserTransaction;
-
import junit.framework.Test;
-import org.apache.cactus.ServletTestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.HibernateException;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
+import org.jbpm.command.Command;
+import org.jbpm.command.CommandService;
+import org.jbpm.command.impl.CommandServiceImpl;
+import org.jbpm.enterprise.AbstractEnterpriseTestCase;
import org.jbpm.enterprise.IntegrationTestSetup;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.persistence.jta.JtaDbPersistenceService;
-public class JtaDbPersistenceTest extends ServletTestCase {
+public class JtaDbPersistenceTest extends AbstractEnterpriseTestCase {
- private JbpmConfiguration jbpmConfiguration;
- private UserTransaction tx;
- private boolean rollback;
+ private static final Log log = LogFactory.getLog(JtaDbPersistenceTest.class);
- private static long definitionId;
-
public static Test suite() throws Exception {
return new IntegrationTestSetup(JtaDbPersistenceTest.class, "enterprise-test.war");
}
- protected void setUp() throws Exception {
- jbpmConfiguration = JbpmConfiguration.getInstance();
+ protected CommandService createCommandService() throws Exception {
+ return getName().indexOf("CMT") != -1 ? super.createCommandService() : new CommandServiceImpl(
+ JbpmConfiguration.getInstance());
}
- public void testUserTx() throws Exception {
- tx = getUserTransaction();
- testServiceTx();
+ public void testCMTSuccess() throws Exception {
+ playTransaction(false);
}
- public void testUserTxRollback() throws Exception {
- tx = getUserTransaction();
- testServiceTxRollback();
+ public void testCMTFailure() throws Exception {
+ playTransaction(true);
}
- public void testServiceTx() throws Exception {
- long definitionId = deployProcess();
- long instanceId = launchProcess(definitionId);
- signal(instanceId);
- assertTrue(hasEnded(instanceId));
+ public void testBMTSuccess() throws Exception {
+ playTransaction(false);
}
- public void testServiceTxRollback() throws Exception {
- rollback = true;
- long definitionId = deployProcess();
- long instanceId = launchProcess(definitionId);
- signal(instanceId);
- assertFalse(hasEnded(instanceId));
+ public void testBMTFailure() throws Exception {
+ playTransaction(true);
}
- private long deployProcess() throws Exception {
- if (definitionId == 0) {
- try {
- if (tx != null) tx.begin();
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- assertEquals(tx == null, isTxCreatedByService(jbpmContext));
- ProcessDefinition definition = ProcessDefinition.parseXmlString("<process-definition name='tx'>"
- + " <start-state name='start'>"
- + " <transition to='midway' />"
- + " </start-state>"
- + " <state name='midway'>"
- + " <transition to='end' />"
- + " </state>"
- + " <end-state name='end' />"
- + "</process-definition>");
- jbpmContext.deployProcessDefinition(definition);
- definitionId = definition.getId();
- }
- catch (RuntimeException e) {
- if (tx == null) jbpmContext.setRollbackOnly();
- throw e;
- }
- finally {
- jbpmContext.close();
- }
- if (tx != null) tx.commit();
- }
- catch (Exception e) {
- if (tx != null) tx.rollback();
- throw e;
- }
- }
- return definitionId;
- }
-
- private long launchProcess(long definitionId) throws Exception {
+ private void playTransaction(boolean fail) throws Exception {
+ deployProcessDefinition("<process-definition name='jta'>"
+ + " <start-state name='start'>"
+ + " <transition to='midway' />"
+ + " </start-state>"
+ + " <state name='midway'>"
+ + " <transition to='end' />"
+ + " </state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+ long processInstanceId = startProcessInstance("jta").getId();
try {
- if (tx != null) tx.begin();
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- ProcessInstance instance;
- try {
- assertEquals(tx == null, isTxCreatedByService(jbpmContext));
- ProcessDefinition definition = jbpmContext.getGraphSession().loadProcessDefinition(
- definitionId);
- instance = new ProcessInstance(definition);
- instance.signal();
- jbpmContext.save(instance);
- }
- catch (RuntimeException e) {
- if (tx == null) jbpmContext.setRollbackOnly();
- throw e;
- }
- finally {
- jbpmContext.close();
- }
- if (tx != null) tx.commit();
- return instance.getId();
+ signal(processInstanceId, fail);
}
- catch (Exception e) {
- if (tx != null) tx.rollback();
- throw e;
+ catch (RuntimeException e) {
+ log.debug("signal failed on process instance #" + processInstanceId, e);
}
+ assertEquals(!fail, hasProcessInstanceEnded(processInstanceId));
}
- private void signal(long instanceId) throws Exception {
- try {
- if (tx != null) tx.begin();
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- assertEquals(tx == null, isTxCreatedByService(jbpmContext));
- ProcessInstance instance = jbpmContext.loadProcessInstanceForUpdate(instanceId);
- instance.signal();
- if (rollback && tx == null) jbpmContext.setRollbackOnly();
- }
- catch (RuntimeException e) {
- if (tx == null) jbpmContext.setRollbackOnly();
- throw e;
- }
- finally {
- jbpmContext.close();
- }
- if (tx != null) {
- if (rollback)
- tx.rollback();
- else
- tx.commit();
- }
- }
- catch (Exception e) {
- if (tx != null) tx.rollback();
- throw e;
- }
- }
+ private void signal(final long processInstanceId, final boolean fail) throws Exception {
+ commandService.execute(new Command() {
- private boolean hasEnded(long instanceId) throws Exception {
- try {
- if (tx != null) tx.begin();
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- ProcessInstance instance;
- try {
- assertEquals(tx == null, isTxCreatedByService(jbpmContext));
- instance = jbpmContext.loadProcessInstanceForUpdate(instanceId);
+ private static final long serialVersionUID = 1L;
+
+ public Object execute(JbpmContext jbpmContext) throws Exception {
+ jbpmContext.loadProcessInstance(processInstanceId).signal();
+ if (fail) throw new HibernateException("simulated failure");
+ return null;
}
- catch (RuntimeException e) {
- if (tx == null) jbpmContext.setRollbackOnly();
- throw e;
- }
- finally {
- jbpmContext.close();
- }
- if (tx != null) tx.commit();
- return instance.hasEnded();
- }
- catch (Exception e) {
- if (tx != null) tx.rollback();
- throw e;
- }
+ });
}
- private boolean isTxCreatedByService(JbpmContext jbpmContext) {
- JtaDbPersistenceService persistenceService = (JtaDbPersistenceService) jbpmContext.getServices()
- .getPersistenceService();
- return persistenceService.isJtaTxCreated();
- }
-
- private static UserTransaction getUserTransaction() throws NamingException {
- Context initial = new InitialContext();
- return (UserTransaction) initial.lookup("java:comp/UserTransaction");
- }
}
16 years, 12 months
JBoss JBPM SVN: r4761 - in jbpm4/trunk: modules/distro/src/main/files/jboss and 3 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-05-07 12:08:10 -0400 (Thu, 07 May 2009)
New Revision: 4761
Added:
jbpm4/trunk/qa/test.demo.setup.bat
jbpm4/trunk/qa/test.demo.setup.sh
Removed:
jbpm4/trunk/qa/manual.testrun.setup.bat
jbpm4/trunk/qa/manual.testrun.setup.sh
Modified:
jbpm4/trunk/modules/distro/src/main/files/gpd/build.xml
jbpm4/trunk/modules/distro/src/main/files/jboss/build.xml
jbpm4/trunk/modules/integration/form-plugin/
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
jbpm4/trunk/qa/build.xml
Log:
moved demo.setup from qa to distribution
Modified: jbpm4/trunk/modules/distro/src/main/files/gpd/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/gpd/build.xml 2009-05-07 14:14:42 UTC (rev 4760)
+++ jbpm4/trunk/modules/distro/src/main/files/gpd/build.xml 2009-05-07 16:08:10 UTC (rev 4761)
@@ -36,6 +36,7 @@
<target name="get.eclipse"
unless="is.eclipse.distro.available"
description="downloads eclipse to ${eclipse.distro.dir}">
+ <mkdir dir="${eclipse.distro.dir}" />
<get src="${eclipse.distro.url}" dest="${eclipse.distro.path}" />
</target>
Modified: jbpm4/trunk/modules/distro/src/main/files/jboss/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/jboss/build.xml 2009-05-07 14:14:42 UTC (rev 4760)
+++ jbpm4/trunk/modules/distro/src/main/files/jboss/build.xml 2009-05-07 16:08:10 UTC (rev 4761)
@@ -46,6 +46,23 @@
</or>
</condition>
+ <!-- ### DEMO SETUP ##################################################### -->
+ <target name="demo.setup"
+ depends="install.jboss, install.jbpm.into.jboss, start.jboss"
+ description="installs jboss, installs jbpm into jboss, starts jboss, creates the jBPM DB schema, deploys examples, loads example identities, installs and starts eclipse">
+ <ant antfile="${jbpm.home}/db/build.xml" target="create.jbpm.schema" />
+ <ant antfile="${jbpm.home}/examples/build.xml" target="deploy.examples" />
+ <ant antfile="${jbpm.home}/db/build.xml" target="load.example.identities" />
+ <ant antfile="${jbpm.home}/gpd/build.xml" target="install.eclipse" />
+ <ant antfile="${jbpm.home}/gpd/build.xml" target="start.eclipse" />
+ </target>
+
+ <target name="demo.teardown"
+ description="drops the jbpm db schema and stops jboss">
+ <ant antfile="${jbpm.home}/db/build.xml" target="drop.jbpm.schema" />
+ <antcall target="stop.jboss" />
+ </target>
+
<!-- ### REINSTALL JBOSS ################################################ -->
<target name="reinstall.jboss"
depends="log.properties, delete.jboss.installation, install.jboss"
@@ -74,6 +91,7 @@
<target name="get.jboss"
unless="is.jboss.distro.available"
description="downloads jboss into ${jboss.distro.dir}">
+ <mkdir dir="${jboss.distro.dir}" />
<get src="${jboss.distro.url}" dest="${jboss.distro.path}" />
</target>
Property changes on: jbpm4/trunk/modules/integration/form-plugin
___________________________________________________________________
Name: svn:ignore
+ target
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml 2009-05-07 14:14:42 UTC (rev 4760)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml 2009-05-07 16:08:10 UTC (rev 4761)
@@ -5,23 +5,11 @@
application environments.
</para>
- <section id="runningtheinstaller">
- <title>Running the installer</title>
- <para>Start the installer on a command line like this:</para>
- <programlisting>java -jar jbpm-installer-${version}.jar</programlisting>
- <para>The installer has 2 purposes
+ <section id="thedistribution">
+ <title>The distribution</title>
+ <para>Just unzip the jBPM download to some location on your hard drive.
+ You'll see following subdirectories.
</para>
- <itemizedlist>
- <listitem>Install jBPM on your system. This includes the
- jBPM jars, jBPM sources, third party jars, docs, examples,
- db scripts and more. This contains all you need to get
- going with jBPM in your application.
- </listitem>
- <listitem>Install jBPM into JBoss, this part can install jBPM
- into a JBoss server. JBoss will be deployed as a service and
- be accessible to all applications running on it.
- </listitem>
- </itemizedlist>
</section>
<section id="libraries">
Modified: jbpm4/trunk/qa/build.xml
===================================================================
--- jbpm4/trunk/qa/build.xml 2009-05-07 14:14:42 UTC (rev 4760)
+++ jbpm4/trunk/qa/build.xml 2009-05-07 16:08:10 UTC (rev 4761)
@@ -75,19 +75,4 @@
<ant antfile="${jbpm.home}/jboss/build.xml" target="stop.jboss" />
</target>
- <target name="manual.testrun.setup"
- depends="log.properties, integration.testrun.setup"
- description="full integration testrun setup, deploys the examples, loads the identities, installs eclipse and then starts eclipse">
- <ant antfile="${jbpm.home}/examples/build.xml" target="deploy.examples" />
- <ant antfile="${jbpm.home}/db/build.xml" target="load.example.identities" />
- <ant antfile="${jbpm.home}/gpd/build.xml" target="install.eclipse" />
- <ant antfile="${jbpm.home}/gpd/build.xml" target="start.eclipse" />
- </target>
-
- <target name="manual.testrun.teardown"
- depends="log.properties"
- description="stops jboss">
- <ant antfile="${jbpm.home}/jboss/build.xml" target="stop.jboss" />
- </target>
-
</project>
Deleted: jbpm4/trunk/qa/manual.testrun.setup.bat
===================================================================
--- jbpm4/trunk/qa/manual.testrun.setup.bat 2009-05-07 14:14:42 UTC (rev 4760)
+++ jbpm4/trunk/qa/manual.testrun.setup.bat 2009-05-07 16:08:10 UTC (rev 4761)
@@ -1,2 +0,0 @@
-cmd /C mvn -U -Pdistro clean install
-cmd /C ant -f qa/build.xml manual.testrun.setup
Deleted: jbpm4/trunk/qa/manual.testrun.setup.sh
===================================================================
--- jbpm4/trunk/qa/manual.testrun.setup.sh 2009-05-07 14:14:42 UTC (rev 4760)
+++ jbpm4/trunk/qa/manual.testrun.setup.sh 2009-05-07 16:08:10 UTC (rev 4761)
@@ -1,3 +0,0 @@
-set MAVEN_OPTS=-Xms1024M -Xmx1024M
-mvn -U -Pdistro clean install
-ant -f qa/build.xml manual.testrun.setup
Copied: jbpm4/trunk/qa/test.demo.setup.bat (from rev 4757, jbpm4/trunk/qa/manual.testrun.setup.bat)
===================================================================
--- jbpm4/trunk/qa/test.demo.setup.bat (rev 0)
+++ jbpm4/trunk/qa/test.demo.setup.bat 2009-05-07 16:08:10 UTC (rev 4761)
@@ -0,0 +1,4 @@
+echo To run this, make sure that at least you have jbpm.parent.dir specified in your ${user.home}/.jbpm4/build.properties
+cmd /C mvn -U -Pdistro clean install
+cmd /C ant -f qa/build.xml reinstall.jbpm
+cmd /C ant -f modules/distro/src/main/files/jboss/build.xml demo.setup
Copied: jbpm4/trunk/qa/test.demo.setup.sh (from rev 4757, jbpm4/trunk/qa/manual.testrun.setup.sh)
===================================================================
--- jbpm4/trunk/qa/test.demo.setup.sh (rev 0)
+++ jbpm4/trunk/qa/test.demo.setup.sh 2009-05-07 16:08:10 UTC (rev 4761)
@@ -0,0 +1,3 @@
+set MAVEN_OPTS=-Xms1024M -Xmx1024M
+mvn -U -Pdistro clean install
+ant -f qa/build.xml manual.testrun.setup
16 years, 12 months
JBoss JBPM SVN: r4760 - in projects/gwt-console/trunk: gui/war/src/main/java/org/jboss/bpm/console/client/common and 9 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-05-07 10:14:42 -0400 (Thu, 07 May 2009)
New Revision: 4760
Added:
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/catForms.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/collapseDown.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/collapseLeft.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-error.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-information.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-password.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-question.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-warning.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/loading.gif
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-collapse-down.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-collapse-left.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-collapse-right.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-collapse-up.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-minus.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-plus.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-refresh.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/window-button-close.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/window-button-maximize.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/window-button-minimize.png
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/window-button-restore.png
projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/images/icons/loading.gif
Removed:
projects/gwt-console/trunk/server/server-core/src/test/java/org/
Modified:
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/Application.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/Header.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/LoginView.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/MainLayout.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/ServerStatusAction.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/SettingsEditor.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/SettingsEditorNavigation.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/common/AbstractRESTAction.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/ConsoleIconBundle.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/LoadDefinitionsAction.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/LoadInstancesAction.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/LoadTasksAction.java
projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/console.css
projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/util/ConsoleLog.java
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/TaskRef.java
Log:
Added log message console.
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/Application.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/Application.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/Application.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -22,8 +22,11 @@
package org.jboss.bpm.console.client;
import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DeferredCommand;
import com.mvc4g.client.Controller;
import com.mvc4g.client.Event;
+import com.allen_sauer.gwt.log.client.Log;
/**
* Setup the main {@link com.mvc4g.client.Controller} and fire
@@ -34,7 +37,17 @@
public class Application implements EntryPoint
{
- public void onModuleLoad()
+ public void onModuleLoad() {
+ Log.setUncaughtExceptionHandler();
+
+ DeferredCommand.addCommand(new Command() {
+ public void execute() {
+ onModuleLoad2();
+ }
+ });
+ }
+
+ public void onModuleLoad2()
{
Controller mainController = new com.mvc4g.client.Controller();
mainController.addAction("login", new LoginAction());
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/Header.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/Header.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/Header.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -23,12 +23,14 @@
import com.google.gwt.user.client.ui.*;
import com.google.gwt.user.client.Timer;
+import com.google.gwt.core.client.GWT;
import com.mvc4g.client.Controller;
import com.mvc4g.client.ViewInterface;
import java.util.List;
import org.gwt.mosaic.ui.client.layout.LayoutPanel;
+import org.jboss.bpm.console.client.icons.ConsoleIconBundle;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
@@ -70,13 +72,15 @@
// load status image
LayoutPanel loadingImageContainer = new LayoutPanel();
loadingImageContainer.setStyleName("bpm-loading-image");
- loadingImage = new Image("images/loading.gif");
+
+ ConsoleIconBundle icons = GWT.create(ConsoleIconBundle.class);
+ loadingImage = new Image("images/icons/loading.gif");
loadingImageContainer.add(loadingImage);
setLoading(false);
// account info
- Image img = new Image("images/icons/05.png");
+ Image img = icons.userIcon().createImage();
HTML html = new HTML(appContext.getAuthentication().getUsername());
Button btn = new Button("Logout", new ClickListener()
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/LoginView.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/LoginView.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/LoginView.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -38,6 +38,7 @@
import org.jboss.bpm.console.client.ConsoleConfig;
import org.jboss.bpm.console.client.URLBuilder;
import org.jboss.bpm.console.client.MainLayout;
+import org.jboss.bpm.console.client.icons.ConsoleIconBundle;
import org.jboss.bpm.console.client.util.ConsoleLog;
/**
@@ -95,8 +96,8 @@
private void createLayoutWindowPanel() {
window = new WindowPanel("jBPM Management Console");
window.setAnimationEnabled(false);
- window.setSize("320px", "180px");
-
+ window.setSize("320px", "180px");
+
LayoutPanel panel = new LayoutPanel();
window.setWidget(panel);
createLayoutContent(panel);
@@ -160,6 +161,9 @@
}
});
+ // TODO: does this load the imagebundle already?
+ ConsoleIconBundle icons = GWT.create(ConsoleIconBundle.class);
+
layoutPanel.add(createForm(), new BorderLayoutData(BorderLayout.Region.CENTER, 10, 200));
layoutPanel.add(submit, new BorderLayoutData(BorderLayout.Region.SOUTH, 10, 200));
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/MainLayout.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/MainLayout.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/MainLayout.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -21,18 +21,20 @@
*/
package org.jboss.bpm.console.client;
+import com.allen_sauer.gwt.log.client.DivLogger;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.*;
import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.Window;
import com.mvc4g.client.Controller;
import org.gwt.mosaic.ui.client.*;
import org.gwt.mosaic.ui.client.layout.BorderLayout;
import static org.gwt.mosaic.ui.client.layout.BorderLayout.Region;
import org.gwt.mosaic.ui.client.layout.BorderLayoutData;
import org.gwt.mosaic.ui.client.layout.LayoutPanel;
+import org.gwt.mosaic.ui.client.util.ButtonHelper;
+import org.jboss.bpm.console.client.icons.ConsoleIconBundle;
import org.jboss.bpm.console.client.util.WindowUtil;
/**
@@ -42,12 +44,12 @@
*/
public class MainLayout extends Composite implements ApplicationContext
{
-
+
public final static String NAME = "mainLayout";
-
+
private Header header;
private Menu menu;
-
+
private Workspace workspace;
private URLBuilder urlBuilder;
private Authentication auth;
@@ -58,7 +60,7 @@
public MainLayout(Controller controller, Authentication auth, URLBuilder urlBuilder, ConsoleConfig config)
{
- this.controller = controller;
+ this.controller = controller;
this.auth = auth;
this.config = config;
this.urlBuilder = urlBuilder;
@@ -67,13 +69,18 @@
}
public void display()
- {
+ {
viewport = new Viewport();
+ // manually, otherwise it will appear on the login screen
+ Log.addLogger(new DivLogger());
+
LayoutPanel layout = createLayout();
viewport.add(layout);
-
+
RootPanel.get().add(viewport);
+
+
}
private LayoutPanel createLayout()
@@ -95,10 +102,18 @@
// register views and actions
controller.addView(Header.ID, header);
-
+
controller.addAction(LoadingStatusAction.ID, new LoadingStatusAction());
+ // message Panel
+ final CaptionLayoutPanel messagePanel = createMessagePanel(layoutPanel);
+ messagePanel.add(Log.getDivLogger().getWidget());
+ messagePanel.setCollapsed(true);
+ layoutPanel.add(messagePanel, new BorderLayoutData(Region.SOUTH, true));
+ // Turn on DivLogger
+ Log.getDivLogger().getWidget().setVisible(true);
+
// default editor
if(workspace.hasEditor(SettingsEditor.ID))
workspace.showEditor(SettingsEditor.ID);
@@ -106,6 +121,35 @@
return layoutPanel;
}
+ private CaptionLayoutPanel createMessagePanel(final LayoutPanel layoutPanel)
+ {
+ final CaptionLayoutPanel messagePanel = new CaptionLayoutPanel("Messages", true);
+
+ ConsoleIconBundle icons = GWT.create(ConsoleIconBundle.class);
+ Button collapse = new Button(
+ ButtonHelper.createButtonLabel(
+ icons.collapseDownIcon(),
+ "",
+ ButtonHelper.ButtonLabelType.TEXT_ON_TOP)
+ );
+ collapse.addClickListener(
+ new ClickListener()
+ {
+ public void onClick(Widget sender)
+ {
+ messagePanel.setCollapsed(!messagePanel.isCollapsed());
+ layoutPanel.layout();
+ }
+ }
+ );
+
+ messagePanel.getHeader().add(
+ collapse,
+ Caption.CaptionRegion.RIGHT
+ );
+ return messagePanel;
+ }
+
private Workspace createWorkspace()
{
Workspace workspace = new Workspace(menu);
@@ -142,11 +186,11 @@
err.setSize("320px", "240px");
ScrollLayoutPanel scrollLayoutPanel = new ScrollLayoutPanel();
scrollLayoutPanel.add(new HTML(message));
- err.setWidget(scrollLayoutPanel);
+ err.setWidget(scrollLayoutPanel);
WindowUtil.addMaximizeButton(err, Caption.CaptionRegion.RIGHT);
WindowUtil.addMinimizeButton(err, Caption.CaptionRegion.RIGHT);
-
+
err.center();
}
else
@@ -170,7 +214,7 @@
return workspace;
}
- /**
+ /**
* hack in order to correctly display widgets that have
* been rendered hidden
*/
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/ServerStatusAction.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/ServerStatusAction.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/ServerStatusAction.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -24,6 +24,7 @@
import org.jboss.bpm.console.client.common.AbstractRESTAction;
import org.jboss.bpm.console.client.model.ServerStatus;
import org.jboss.bpm.console.client.model.DTOParser;
+import org.jboss.bpm.console.client.util.ConsoleLog;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.Response;
import com.google.gwt.json.client.JSONValue;
@@ -62,6 +63,9 @@
JSONValue json = JSONParser.parse(response.getText());
ServerStatus status = DTOParser.parseStatus(json);
ServerStatusView view = (ServerStatusView)controller.getView(ServerStatusView.ID);
+
+ ConsoleLog.info("Loaded server status");
+
view.update(status);
}
}
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/SettingsEditor.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/SettingsEditor.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/SettingsEditor.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -22,10 +22,11 @@
package org.jboss.bpm.console.client;
import com.google.gwt.user.client.ui.*;
+import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.core.client.GWT;
import com.mvc4g.client.Event;
+import org.gwt.mosaic.ui.client.*;
import org.gwt.mosaic.ui.client.Label;
-import org.gwt.mosaic.ui.client.CaptionLayoutPanel;
import org.gwt.mosaic.ui.client.layout.*;
import org.jboss.bpm.console.client.icons.ConsoleIconBundle;
@@ -37,6 +38,8 @@
public final static String ID = SettingsEditor.class.getName();
+ private TabLayoutPanel tabPanel;
+
public SettingsEditor(ApplicationContext appContext)
{
super(appContext);
@@ -46,22 +49,19 @@
{
if(!isInitialized())
{
-
- final LayoutPanel layoutPanel = new LayoutPanel(
+
+ tabPanel = new DecoratedTabLayoutPanel();
+ tabPanel.setPadding(5);
+
+ final ScrollLayoutPanel layoutPanel = new ScrollLayoutPanel(
new BoxLayout(BoxLayout.Orientation.VERTICAL)
);
- // provide console overview
- CaptionLayoutPanel infoPanel = new CaptionLayoutPanel(
- "System Overview"
- );
-
- infoPanel.setLayout(new BoxLayout(BoxLayout.Orientation.VERTICAL));
-
+
// console info
HTML console = new HTML("<h3>Console Info</h3>");
- infoPanel.add(console);
+ layoutPanel.add(console);
Grid g1 = new Grid(2,2);
g1.setWidget(0,0, new Label("Build:"));
@@ -69,12 +69,12 @@
g1.setWidget(1,0, new Label("Version:"));
g1.setText(1,1, Version.VERSION);
- infoPanel.add(g1);
+ layoutPanel.add(g1);
// server info
HTML server = new HTML("<h3>Server Info</h3>");
- infoPanel.add(server);
+ layoutPanel.add(server);
Grid g2 = new Grid(1,2);
g2.setWidget(0,0, new Label("Host:"));
@@ -82,12 +82,14 @@
ServerStatusView serverStatus = new ServerStatusView(appContext);
- infoPanel.add(g2);
- infoPanel.add(serverStatus); // Doesn't render in grid
+ layoutPanel.add(g2);
+ layoutPanel.add(serverStatus); // Doesn't render in grid
- layoutPanel.add(infoPanel, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL, true));
- this.add(layoutPanel, new BorderLayoutData(BorderLayout.Region.CENTER));
+
+ tabPanel.add(layoutPanel, "System Overview");
+ this.add(tabPanel, new BorderLayoutData(BorderLayout.Region.CENTER));
+
// view and actions
super.controller.addView(ServerStatusView.ID, serverStatus);
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/SettingsEditorNavigation.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/SettingsEditorNavigation.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/SettingsEditorNavigation.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -37,7 +37,7 @@
{
super.setTitle("Settings");
- TreeItem root = addItem("Console");
+ TreeItem root = addItem("System");
root.addItem("Overview");
addTreeListener(
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/common/AbstractRESTAction.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/common/AbstractRESTAction.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/common/AbstractRESTAction.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -27,6 +27,7 @@
import com.mvc4g.client.Controller;
import org.jboss.bpm.console.client.ApplicationContext;
import org.jboss.bpm.console.client.LoadingStatusAction;
+import org.jboss.bpm.console.client.util.ConsoleLog;
import java.io.IOException;
@@ -125,7 +126,8 @@
"<li>Exception: '" + t.getClass() +
"</ul>'\n\n"+
t.getMessage();
-
+
+ ConsoleLog.error(out, t);
appContext.displayMessage(out, true);
}
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/ConsoleIconBundle.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/ConsoleIconBundle.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/ConsoleIconBundle.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -63,4 +63,39 @@
* @gwt.resource userIcon.png
*/
AbstractImagePrototype userIcon();
+
+ /**
+ * @gwt.resource tool-button-collapse-down.png
+ */
+ AbstractImagePrototype collapseDownIcon();
+
+ /**
+ * @gwt.resource tool-button-collapse-left.png
+ */
+ AbstractImagePrototype collapseLeftIcon();
+
+ /**
+ * @gwt.resource dialog-error.png
+ */
+ AbstractImagePrototype errorIcon();
+
+ /**
+ * @gwt.resource dialog-information.png
+ */
+ AbstractImagePrototype infoIcon();
+
+ /**
+ * @gwt.resource dialog-warning.png
+ */
+ AbstractImagePrototype warnIcon();
+
+ /**
+ * @gwt.resource dialog-question.png
+ */
+ AbstractImagePrototype questionIcon();
+
+ /**
+ * @gwt.resource loading.gif
+ */
+ AbstractImagePrototype loadingIcon();
}
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/catForms.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/catForms.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/collapseDown.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/collapseDown.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/collapseLeft.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/collapseLeft.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-error.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-error.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-information.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-information.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-password.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-password.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-question.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-question.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-warning.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/dialog-warning.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/loading.gif
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/loading.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-collapse-down.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-collapse-down.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-collapse-left.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-collapse-left.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-collapse-right.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-collapse-right.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-collapse-up.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-collapse-up.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-minus.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-minus.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-plus.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-plus.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-refresh.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/tool-button-refresh.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/window-button-close.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/window-button-close.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/window-button-maximize.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/window-button-maximize.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/window-button-minimize.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/window-button-minimize.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/window-button-restore.png
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/window-button-restore.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/LoadDefinitionsAction.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/LoadDefinitionsAction.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/LoadDefinitionsAction.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -27,6 +27,7 @@
import com.google.gwt.json.client.JSONValue;
import com.mvc4g.client.Controller;
import org.jboss.bpm.console.client.ApplicationContext;
+import org.jboss.bpm.console.client.util.ConsoleLog;
import org.jboss.bpm.console.client.common.AbstractRESTAction;
import org.jboss.bpm.console.client.model.DTOParser;
import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
@@ -71,16 +72,16 @@
DefinitionListView view = (DefinitionListView) controller.getView(DefinitionListView.ID);
view.update(definitions);
- appContext.displayMessage("Loaded " + definitions.size() + " process definitions", false);
+ ConsoleLog.info("Loaded " + definitions.size() + " process definitions");
}
else
{
// Handle the error. Can get the status text from response.getStatusText()
- appContext.displayMessage("Failed to load instances. " +
- "HTTP " + response.getStatusCode()+
- ": " +response.getText(),
- true
- );
+ String message = "Failed to load instances. " +
+ "HTTP " + response.getStatusCode() +
+ ": " + response.getText();
+ ConsoleLog.error(message);
+ appContext.displayMessage(message,true);
}
}
}
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/LoadInstancesAction.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/LoadInstancesAction.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/LoadInstancesAction.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -27,6 +27,7 @@
import com.google.gwt.json.client.JSONValue;
import com.mvc4g.client.Controller;
import org.jboss.bpm.console.client.ApplicationContext;
+import org.jboss.bpm.console.client.util.ConsoleLog;
import org.jboss.bpm.console.client.common.AbstractRESTAction;
import org.jboss.bpm.console.client.model.DTOParser;
import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
@@ -74,7 +75,7 @@
InstanceListView view = (InstanceListView) controller.getView(InstanceListView.ID);
view.update(def, instances);
- appContext.displayMessage("Loaded " + instances.size() + " process instances", false);
+ ConsoleLog.info("Loaded " + instances.size() + " process instances");
}
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/LoadTasksAction.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/LoadTasksAction.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/LoadTasksAction.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -23,6 +23,7 @@
import org.jboss.bpm.console.client.common.AbstractRESTAction;
import org.jboss.bpm.console.client.ApplicationContext;
+import org.jboss.bpm.console.client.util.ConsoleLog;
import org.jboss.bpm.console.client.model.DTOParser;
import org.jboss.bpm.console.client.model.TaskRef;
import com.google.gwt.http.client.RequestBuilder;
@@ -73,6 +74,7 @@
OpenTasksView openTasks = (OpenTasksView)controller.getView(OpenTasksView.ID);
AssignedTasksView personalTasks = (AssignedTasksView)controller.getView(AssignedTasksView.ID);
+ ConsoleLog.info("Loaded " + tasks.size() + " tasks");
openTasks.update(identity, tasks);
personalTasks.update(identity, tasks);
}
Modified: projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/console.css
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/console.css 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/console.css 2009-05-07 14:14:42 UTC (rev 4760)
@@ -63,8 +63,8 @@
.bpm-loading-image {
background-color:#ffffff;
- width:16pt;
- height:16pt;
+ width:16px;
+ height:16px;
}
.bpm-ProcessImage {
@@ -194,4 +194,26 @@
div.activeNode-header-link a:hover {
text-decoration:underline;
-}
\ No newline at end of file
+}
+
+.log-panel {
+ background-color: #ECF2FC;
+ border: 0px solid black;
+ margin: 0px;
+ padding:10px;
+}
+
+.log-panel .log-scroll-panel {
+ width: 100% !important;
+ height: 80px !important;
+}
+
+.log-panel .log-text-area,.log-panel BUTTON {
+ font-size: 8pt;
+ margin: 0em;
+}
+
+.log-resize-se {
+ visibility:hidden;
+}
+
Added: projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/images/icons/loading.gif
===================================================================
(Binary files differ)
Property changes on: projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/images/icons/loading.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
===================================================================
--- projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -23,8 +23,8 @@
import com.google.gwt.json.client.*;
import org.jboss.bpm.console.client.model.jbpm3.TokenReference;
+import org.jboss.bpm.console.client.util.JSONWalk;
import org.jboss.bpm.console.client.util.ConsoleLog;
-import org.jboss.bpm.console.client.util.JSONWalk;
import java.util.ArrayList;
import java.util.Date;
@@ -51,6 +51,8 @@
public static ProcessDefinitionRef parseProcessDefinition(JSONValue root)
{
+ ConsoleLog.debug("parse " + root);
+
String id = JSONWalk.on(root).next("id").asString();
Long version = JSONWalk.on(root).next("version").asLong();
String name = JSONWalk.on(root).next("name").asString();
@@ -91,12 +93,8 @@
public static List<TaskRef> parseTaskReferenceList(String json)
{
- List<TaskRef> results = new ArrayList<TaskRef>();
+ List<TaskRef> results = new ArrayList<TaskRef>();
- // {"tasks":[{"id":14,"name":"manager evaluation","isSignalling":true,
- // "isBlocking":false,"tokenId":6,"processInstanceId":4,"actor":"manager",
- // "transitionNames":["reject","approve"]}]}
-
JSONValue root = JSONParser.parse(json);
JSONArray array = JSONWalk.on(root).next("tasks").asArray();
@@ -112,8 +110,9 @@
public static TaskRef parseTaskReference(JSONObject item)
{
+ ConsoleLog.debug("parse " + item);
- long id = JSONWalk.on(item).next("id").asLong();
+ long id = JSONWalk.on(item).next("id").asLong();
String executionId = JSONWalk.on(item).next("processInstanceId").asString();
String processId = JSONWalk.on(item).next("processId").asString();
String name = JSONWalk.on(item).next("name").asString();
@@ -165,7 +164,7 @@
JSONValue jsonValue = arr.get(k);
if (jsonValue.toString().equals("null"))
{
- ConsoleLog.debug("FIXME JBPM-1828: Null value on outcomes:" + arr.toString());
+ ConsoleLog.warn("FIXME JBPM-1828: Null value on outcomes:" + arr.toString());
continue; // TODO: JBPM-1828
}
JSONString t = jsonValue.isString();
@@ -174,6 +173,23 @@
}
+ int prio = JSONWalk.on(item).next("priority").asInt();
+ ref.setPriority(prio);
+
+ JSONWalk.JSONWrapper dueDate = JSONWalk.on(item).next("dueDate");
+ if(dueDate!=null) // optional
+ {
+ Date due = dueDate.asDate();
+ ref.setDueDate(due);
+ }
+
+ JSONWalk.JSONWrapper createDate = JSONWalk.on(item).next("createDate");
+ if(createDate!=null) // optional
+ {
+ Date due = createDate.asDate();
+ ref.setDueDate(due);
+ }
+
return ref;
}
@@ -204,11 +220,7 @@
public static ProcessInstanceRef parseProcessInstance(JSONValue root)
{
ConsoleLog.debug("parse " + root);
-
- // {"id":"StateSequence/8", "definitionId":"StateSequence:1",
- // "startDate":"2009-02-19 14:36:50", "suspended":false}
-
-
+
String id = JSONWalk.on(root).next("id").asString();
String definitionId = JSONWalk.on(root).next("definitionId").asString();
Date start = JSONWalk.on(root).next("startDate").asDate();
@@ -235,6 +247,8 @@
public static TokenReference parseTokenReference(JSONObject jso)
{
+ ConsoleLog.debug("parse " + jso);
+
String rootTokenId = JSONWalk.on(jso).next("id").asString();
//String name = JSONWalk.on(jso).next("name").asString();
String nodeName = JSONWalk.on(jso).next("currentNodeName").asString();
@@ -251,7 +265,7 @@
JSONValue jsonValue = signals.get(i);
if (jsonValue.toString().equals("null"))
{
- ConsoleLog.debug("FIXME JBPM-1828: Null value on availableSignals:" + signals.toString());
+ ConsoleLog.warn("FIXME JBPM-1828: Null value on availableSignals:" + signals.toString());
continue; // TODO: JBPM-1828
}
JSONString item = jsonValue.isString();
@@ -282,7 +296,7 @@
JSONValue jsonValue = jsonArray.get(i);
if (jsonValue.toString().equals("null"))
{
- ConsoleLog.debug("FIXME JBPM-1828: Null value on string array:" + jsonArray.toString());
+ ConsoleLog.warn("FIXME JBPM-1828: Null value on string array:" + jsonArray.toString());
continue; // TODO: JBPM-1828
}
JSONString item = jsonValue.isString();
@@ -294,7 +308,8 @@
public static ServerStatus parseStatus(JSONValue json)
{
- // {"plugins":[{"type":"xyz","available":true}]}
+ ConsoleLog.debug("parse " + json);
+
ServerStatus status = new ServerStatus();
JSONArray jsonArray = JSONWalk.on(json).next("plugins").asArray();
Modified: projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/util/ConsoleLog.java
===================================================================
--- projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/util/ConsoleLog.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/util/ConsoleLog.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -33,8 +33,20 @@
*/
public class ConsoleLog
{
- private static boolean enabled = false;
+ private static boolean enabled = true; // see javadoc comments
+ public static void warn(String msg)
+ {
+ if (enabled)
+ com.allen_sauer.gwt.log.client.Log.warn(msg);
+ }
+
+ public static void info(String msg)
+ {
+ if (enabled)
+ com.allen_sauer.gwt.log.client.Log.info(msg);
+ }
+
public static void debug(String msg)
{
if (enabled)
Modified: projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/TaskRef.java
===================================================================
--- projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/TaskRef.java 2009-05-07 13:21:23 UTC (rev 4759)
+++ projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/TaskRef.java 2009-05-07 14:14:42 UTC (rev 4760)
@@ -24,6 +24,7 @@
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;
+import java.util.Date;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
@@ -51,6 +52,12 @@
private String url;
+ private Date dueDate;
+ private Date createDate;
+ private int priority;
+
+ private String description;
+
public TaskRef()
{
initOrUpdateState();
@@ -198,6 +205,46 @@
this.url = url;
}
+ public Date getDueDate()
+ {
+ return dueDate;
+ }
+
+ public void setDueDate(Date dueDate)
+ {
+ this.dueDate = dueDate;
+ }
+
+ public int getPriority()
+ {
+ return priority;
+ }
+
+ public void setPriority(int priority)
+ {
+ this.priority = priority;
+ }
+
+ public Date getCreateDate()
+ {
+ return createDate;
+ }
+
+ public void setCreateDate(Date createDate)
+ {
+ this.createDate = createDate;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
public String toString()
{
return "TaskRef{id:"+id+",state:"+currentState+"}";
16 years, 12 months
JBoss JBPM SVN: r4759 - in jbpm3/branches/jbpm-3.2.5.SP/modules/core/src: main/java/org/jbpm/configuration and 6 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-05-07 09:21:23 -0400 (Thu, 07 May 2009)
New Revision: 4759
Added:
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/SharedProcessClassLoaderFactory.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassLoadersTest.java
Removed:
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java
Modified:
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/DefaultProcessClassLoaderFactory.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoaderFactory.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/XmlUtil.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/JbpmContextTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java
Log:
[JBPM-2202] merge r4689 from trunk;
take parent class loader into account when looking up a cached process class loader
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2009-05-07 10:14:21 UTC (rev 4758)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2009-05-07 13:21:23 UTC (rev 4759)
@@ -24,10 +24,11 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
-import java.util.Stack;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -48,30 +49,31 @@
/**
* configuration of one jBPM instance.
- *
* <p>
- * During process execution, jBPM might need to use some services. A JbpmConfiguration contains the knowledge on how to
- * create those services.
+ * During process execution, jBPM might need to use some services. A JbpmConfiguration contains the
+ * knowledge on how to create those services.
* </p>
- *
* <p>
- * A JbpmConfiguration is a thread safe object and serves as a factory for {@link org.jbpm.JbpmContext}s, which means
- * one JbpmConfiguration can be used to create {@link org.jbpm.JbpmContext}s for all threads. The single
- * JbpmConfiguration can be maintained in a static member or in the JNDI tree if that is available.
+ * A JbpmConfiguration is a thread safe object and serves as a factory for
+ * {@link org.jbpm.JbpmContext}s, which means one JbpmConfiguration can be used to create
+ * {@link org.jbpm.JbpmContext}s for all threads. The single JbpmConfiguration can be maintained in
+ * a static member or in the JNDI tree if that is available.
* </p>
- *
* <p>
* A JbpmConfiguration can be obtained in following ways:
+ * </p>
* <ul>
* <li>from a resource (by default <code>jbpm.cfg.xml</code> is used):
*
* <pre>
+ *
* JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
* </pre>
*
* or
*
* <pre>
+ *
* String myXmlResource = "...";
* JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance(myXmlResource);
* </pre>
@@ -88,8 +90,8 @@
* </pre>
*
* </li>
- * <li>By specifying a custom implementation of an object factory. This can be used to specify a JbpmConfiguration in
- * other bean-style notations such as used by JBoss Microcontainer or Spring.
+ * <li>By specifying a custom implementation of an object factory. This can be used to specify a
+ * JbpmConfiguration in other bean-style notations such as used by JBoss Microcontainer or Spring.
*
* <pre>
* ObjectFactory of = new <i>MyCustomObjectFactory</i>();
@@ -99,10 +101,9 @@
*
* </li>
* </ul>
- * </p>
- *
* <p>
- * JbpmConfigurations can be configured using a spring-like XML notation (in relax ng compact notation):
+ * JbpmConfigurations can be configured using a spring-like XML notation (in relax ng compact
+ * notation):
* </p>
*
* <pre>
@@ -234,123 +235,97 @@
* </pre>
*
* </p>
- *
* <p>
* Other configuration properties
+ * </p>
* <table>
* <tr>
* <td>jbpm.files.dir</td>
- * <td></td>
+ * <td/>
* </tr>
* <tr>
* <td>jbpm.types</td>
- * <td></td>
+ * <td/>
* </tr>
* </table>
- * </p>
*/
-public class JbpmConfiguration implements Serializable
-{
+public class JbpmConfiguration implements Serializable {
private static final long serialVersionUID = 1L;
static ObjectFactory defaultObjectFactory;
- static Map instances = new HashMap();
- static ThreadLocal jbpmConfigurationsStacks = new ThreadLocal();
+ static final Map instances = new HashMap();
+ static final ThreadLocal jbpmConfigurationStacks = new StackThreadLocal();
- private ObjectFactory objectFactory;
- private ThreadLocal jbpmContextStacks = new ThreadLocal();
+ private final ObjectFactory objectFactory;
+ private final ThreadLocal jbpmContextStacks = new StackThreadLocal();
private JobExecutor jobExecutor;
+ private boolean isClosed;
- public JbpmConfiguration(ObjectFactory objectFactory)
- {
+ static class StackThreadLocal extends ThreadLocal {
+
+ protected Object initialValue() {
+ return new ArrayList();
+ }
+ }
+
+ public JbpmConfiguration(ObjectFactory objectFactory) {
this.objectFactory = objectFactory;
}
- public static JbpmConfiguration getInstance()
- {
+ public static JbpmConfiguration getInstance() {
return getInstance(null);
}
- public static JbpmConfiguration getInstance(String resource)
- {
- JbpmConfiguration instance = null;
- synchronized (instances)
- {
- if (resource == null)
- {
- resource = "jbpm.cfg.xml";
- }
+ public static JbpmConfiguration getInstance(String resource) {
+ if (resource == null) {
+ resource = "jbpm.cfg.xml";
+ }
- instance = (JbpmConfiguration)instances.get(resource);
- if (instance == null)
- {
-
- if (defaultObjectFactory != null)
- {
- log.debug("creating jbpm configuration from given default object factory '" + defaultObjectFactory + "'");
+ JbpmConfiguration instance;
+ synchronized (instances) {
+ // look for configuration in cache
+ instance = (JbpmConfiguration) instances.get(resource);
+ if (instance == null) {
+ // configuration does not exist or was evicted, construct it
+ if (defaultObjectFactory != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("creating configuration from default object factory: " + defaultObjectFactory);
+ }
instance = new JbpmConfiguration(defaultObjectFactory);
-
}
- else
- {
-
- try
- {
- log.info("using jbpm configuration resource '" + resource + "'");
- InputStream jbpmCfgXmlStream = ClassLoaderUtil.getJbpmConfigurationStream(resource);
-
- // if a custom resource is to be used, but is not found in the
- // classpath
- // log a warning (otherwise, users who want to load custom stuff
- // will be confused if the resource is not found and not loaded,
- // without
- // any notice)
- if (jbpmCfgXmlStream == null && !"jbpm.cfg.xml".equals(resource))
- {
- log.warn("jbpm configuration resource '" + resource + "' is not available");
- }
-
- ObjectFactory objectFactory = parseObjectFactory(jbpmCfgXmlStream);
- instance = createJbpmConfiguration(objectFactory);
-
+ else {
+ log.info("using configuration resource: " + resource);
+ InputStream jbpmCfgXmlStream = ClassLoaderUtil.getStream(resource, false);
+ /*
+ * if a custom resource is specified, but not found in the classpath, log a warning;
+ * otherwise, users who want to load custom stuff will not receive any feedback when their
+ * resource cannot be found
+ */
+ if (jbpmCfgXmlStream == null && !"jbpm.cfg.xml".equals(resource)) {
+ log.warn("configuration resource '" + resource + "' could not be found");
}
- catch (RuntimeException e)
- {
- throw new JbpmException("couldn't parse jbpm configuration from resource '" + resource + "'", e);
- }
+ ObjectFactory objectFactory = parseObjectFactory(jbpmCfgXmlStream);
+ instance = createJbpmConfiguration(objectFactory);
}
-
+ // put configuration in cache
instances.put(resource, instance);
}
}
-
return instance;
}
- public static boolean hasInstance(String resource)
- {
- boolean hasInstance = false;
- if (resource == null)
- {
- resource = "jbpm.cfg.xml";
- }
- if ((instances != null) && (instances.containsKey(resource)))
- {
- hasInstance = true;
- }
- return hasInstance;
+ public static boolean hasInstance(String resource) {
+ return instances.containsKey(resource != null ? resource : "jbpm.cfg.xml");
}
- protected static ObjectFactory parseObjectFactory(InputStream inputStream)
- {
+ protected static ObjectFactory parseObjectFactory(InputStream inputStream) {
log.debug("loading defaults in jbpm configuration");
ObjectFactoryParser objectFactoryParser = new ObjectFactoryParser();
ObjectFactoryImpl objectFactoryImpl = new ObjectFactoryImpl();
objectFactoryParser.parseElementsFromResource("org/jbpm/default.jbpm.cfg.xml", objectFactoryImpl);
- if (inputStream != null)
- {
+ if (inputStream != null) {
log.debug("loading specific configuration...");
objectFactoryParser.parseElementsStream(inputStream, objectFactoryImpl);
}
@@ -358,34 +333,26 @@
return objectFactoryImpl;
}
- /**
- * create an ObjectFacotory from an XML string.
- */
- public static JbpmConfiguration parseXmlString(String xml)
- {
+ public static JbpmConfiguration parseXmlString(String xml) {
log.debug("creating jbpm configuration from xml string");
InputStream inputStream = null;
- if (xml != null)
- {
+ if (xml != null) {
inputStream = new ByteArrayInputStream(xml.getBytes());
}
ObjectFactory objectFactory = parseObjectFactory(inputStream);
return createJbpmConfiguration(objectFactory);
}
- protected static JbpmConfiguration createJbpmConfiguration(ObjectFactory objectFactory)
- {
+ protected static JbpmConfiguration createJbpmConfiguration(ObjectFactory objectFactory) {
JbpmConfiguration jbpmConfiguration = new JbpmConfiguration(objectFactory);
- // now we make the bean jbpm.configuration always availble
- if (objectFactory instanceof ObjectFactoryImpl)
- {
- ObjectFactoryImpl objectFactoryImpl = (ObjectFactoryImpl)objectFactory;
+ // make the bean jbpm.configuration always available
+ if (objectFactory instanceof ObjectFactoryImpl) {
+ ObjectFactoryImpl objectFactoryImpl = (ObjectFactoryImpl) objectFactory;
ObjectInfo jbpmConfigurationInfo = new ValueInfo("jbpmConfiguration", jbpmConfiguration);
objectFactoryImpl.addObjectInfo(jbpmConfigurationInfo);
- if (getHideStaleObjectExceptions(objectFactory))
- {
+ if (getHideStaleObjectExceptions(objectFactory)) {
StaleObjectLogConfigurer.hideStaleObjectExceptions();
}
}
@@ -393,77 +360,68 @@
return jbpmConfiguration;
}
- private static boolean getHideStaleObjectExceptions(ObjectFactory objectFactory)
- {
- if (!objectFactory.hasObject("jbpm.hide.stale.object.exceptions"))
- {
- return true;
- }
+ private static boolean getHideStaleObjectExceptions(ObjectFactory objectFactory) {
+ if (!objectFactory.hasObject("jbpm.hide.stale.object.exceptions")) return true;
+
Object object = objectFactory.createObject("jbpm.hide.stale.object.exceptions");
- return object instanceof Boolean ? ((Boolean)object).booleanValue() : true;
+ return object instanceof Boolean ? ((Boolean) object).booleanValue() : true;
}
- public static JbpmConfiguration parseInputStream(InputStream inputStream)
- {
- ObjectFactory objectFactory = parseObjectFactory(inputStream);
+ public static JbpmConfiguration parseInputStream(InputStream inputStream) {
log.debug("creating jbpm configuration from input stream");
+ ObjectFactory objectFactory = parseObjectFactory(inputStream);
return createJbpmConfiguration(objectFactory);
}
- public static JbpmConfiguration parseResource(String resource)
- {
+ public static JbpmConfiguration parseResource(String resource) {
+ if (log.isDebugEnabled()) {
+ log.debug("creating jbpm configuration from resource: " + resource);
+ }
InputStream inputStream = null;
- log.debug("creating jbpm configuration from resource '" + resource + "'");
- if (resource != null)
- {
- inputStream = ClassLoaderUtil.getJbpmConfigurationStream(resource);
+ if (resource != null) {
+ inputStream = ClassLoaderUtil.getStream(resource, false);
}
ObjectFactory objectFactory = parseObjectFactory(inputStream);
return createJbpmConfiguration(objectFactory);
}
- public JbpmContext createJbpmContext()
- {
+ public JbpmContext createJbpmContext() {
return createJbpmContext(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public JbpmContext createJbpmContext(String name)
- {
- JbpmContext jbpmContext = (JbpmContext)objectFactory.createObject(name);
+ public JbpmContext createJbpmContext(String name) {
+ ensureOpen();
+
+ JbpmContext jbpmContext = (JbpmContext) objectFactory.createObject(name);
jbpmContext.jbpmConfiguration = this;
jbpmContextCreated(jbpmContext);
return jbpmContext;
}
- public ServiceFactory getServiceFactory(String serviceName)
- {
+ private void ensureOpen() {
+ if (isClosed) throw new JbpmException("configuration closed");
+ }
+
+ public ServiceFactory getServiceFactory(String serviceName) {
return getServiceFactory(serviceName, JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public ServiceFactory getServiceFactory(String serviceName, String jbpmContextName)
- {
- ServiceFactory serviceFactory = null;
+ public ServiceFactory getServiceFactory(String serviceName, String jbpmContextName) {
JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
- try
- {
- serviceFactory = jbpmContext.getServices().getServiceFactory(serviceName);
+ try {
+ return jbpmContext.getServices().getServiceFactory(serviceName);
}
- finally
- {
+ finally {
jbpmContext.close();
}
- return serviceFactory;
}
- public static ClassLoader getProcessClassLoader(ProcessDefinition processDefinition)
- {
- ProcessClassLoaderFactory factory = null;
- if (Configs.hasObject("jbpm.processClassLoader"))
- {
- factory = (ProcessClassLoaderFactory)Configs.getObject("jbpm.processClassLoader");
+ public static ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
+ ProcessClassLoaderFactory factory;
+ if (Configs.hasObject("process.class.loader.factory")) {
+ factory = (ProcessClassLoaderFactory) Configs.getObject("process.class.loader.factory");
}
- else
- {
+ else {
factory = new DefaultProcessClassLoaderFactory();
}
return factory.getProcessClassLoader(processDefinition);
@@ -472,270 +430,232 @@
/**
* gives the jbpm domain model access to configuration information via the current JbpmContext.
*/
- public abstract static class Configs
- {
+ public static class Configs {
- public static ObjectFactory getObjectFactory()
- {
+ private Configs() {
+ // hide default constructor to prevent instantiation
+ }
+
+ public static ObjectFactory getObjectFactory() {
ObjectFactory objectFactory = null;
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext != null)
- {
+ if (jbpmContext != null) {
objectFactory = jbpmContext.objectFactory;
}
- else
- {
+ else {
objectFactory = getInstance().objectFactory;
}
return objectFactory;
}
- public static void setDefaultObjectFactory(ObjectFactory objectFactory)
- {
+ public static void setDefaultObjectFactory(ObjectFactory objectFactory) {
defaultObjectFactory = objectFactory;
}
- public static boolean hasObject(String name)
- {
+ public static boolean hasObject(String name) {
ObjectFactory objectFactory = getObjectFactory();
return objectFactory.hasObject(name);
}
- public static synchronized Object getObject(String name)
- {
+ public static synchronized Object getObject(String name) {
ObjectFactory objectFactory = getObjectFactory();
return objectFactory.createObject(name);
}
- public static String getString(String name)
- {
- return (String)getObject(name);
+ public static String getString(String name) {
+ return (String) getObject(name);
}
- public static long getLong(String name)
- {
- return ((Long)getObject(name)).longValue();
+ public static long getLong(String name) {
+ return ((Long) getObject(name)).longValue();
}
- public static int getInt(String name)
- {
- return ((Integer)getObject(name)).intValue();
+ public static int getInt(String name) {
+ return ((Integer) getObject(name)).intValue();
}
- public static boolean getBoolean(String name)
- {
- return ((Boolean)getObject(name)).booleanValue();
+ public static boolean getBoolean(String name) {
+ return ((Boolean) getObject(name)).booleanValue();
}
}
- public void cleanSchema()
- {
+ public void cleanSchema() {
cleanSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public void cleanSchema(String jbpmContextName)
- {
- JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
- try
- {
- Services services = jbpmContext.getServices();
- DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory)services.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- persistenceServiceFactory.cleanSchema();
- }
- finally
- {
- jbpmContext.close();
- }
+ public void cleanSchema(String jbpmContextName) {
+ getPersistenceServiceFactory(jbpmContextName).cleanSchema();
}
- public void createSchema()
- {
+ public void createSchema() {
createSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public void createSchema(String jbpmContextName)
- {
- JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
- try
- {
- Services services = jbpmContext.getServices();
- DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory)services.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- persistenceServiceFactory.createSchema();
- }
- finally
- {
- jbpmContext.close();
- }
+ public void createSchema(String jbpmContextName) {
+ getPersistenceServiceFactory(jbpmContextName).createSchema();
}
- public void dropSchema()
- {
+ public void dropSchema() {
dropSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public void dropSchema(String jbpmContextName)
- {
- log.warn("Dropping schema: " + jbpmContextName);
- JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
- try
- {
- Services services = jbpmContext.getServices();
- DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory)services.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- persistenceServiceFactory.dropSchema();
- }
- finally
- {
- jbpmContext.close();
- }
+ public void dropSchema(String jbpmContextName) {
+ getPersistenceServiceFactory(jbpmContextName).dropSchema();
}
- public void close()
- {
- close(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
+ private DbPersistenceServiceFactory getPersistenceServiceFactory(String jbpmContextName) {
+ return (DbPersistenceServiceFactory) getServiceFactory(Services.SERVICENAME_PERSISTENCE, jbpmContextName);
}
- public void close(String jbpmContextName)
- {
- JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
- try
- {
+ public boolean isClosed() {
+ return isClosed;
+ }
- synchronized (instances)
- {
- Iterator iter = instances.values().iterator();
- while (iter.hasNext())
- {
- if (this == iter.next())
- {
- iter.remove();
- break;
- }
- }
- }
+ public void close() {
+ close(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
+ }
- if (jobExecutor != null)
- {
- jobExecutor.stop();
- }
+ public void close(String jbpmContextName) {
+ // prevent configuration from being closed more than once
+ if (isClosed) return;
+ // stop job executor
+ if (jobExecutor != null) {
+ jobExecutor.stop();
+ jobExecutor = null;
+ }
+
+ // close service factories
+ JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
+ try {
Map serviceFactories = jbpmContext.getServices().getServiceFactories();
- if (serviceFactories != null)
- {
- Iterator iter = serviceFactories.values().iterator();
- while (iter.hasNext())
- {
- ServiceFactory serviceFactory = (ServiceFactory)iter.next();
+ if (serviceFactories != null) {
+ for (Iterator i = serviceFactories.values().iterator(); i.hasNext();) {
+ ServiceFactory serviceFactory = (ServiceFactory) i.next();
serviceFactory.close();
}
}
}
- finally
- {
+ finally {
jbpmContext.close();
}
+
+ // closing service factories requires open configuration
+ isClosed = true;
+
+ // release context stack
+ jbpmContextStacks.set(null);
+
+ // remove from configuration cache
+ synchronized (instances) {
+ for (Iterator i = instances.values().iterator(); i.hasNext();) {
+ if (this == i.next()) {
+ i.remove();
+ break;
+ }
+ }
+ }
}
- static JbpmConfiguration getCurrentJbpmConfiguration()
- {
+ static JbpmConfiguration getCurrentJbpmConfiguration() {
JbpmConfiguration currentJbpmConfiguration = null;
- Stack stack = getJbpmConfigurationStack();
- if (!stack.isEmpty())
- {
- currentJbpmConfiguration = (JbpmConfiguration)stack.peek();
+ List stack = getJbpmConfigurationStack();
+ if (!stack.isEmpty()) {
+ currentJbpmConfiguration = (JbpmConfiguration) stack.get(stack.size() - 1);
}
return currentJbpmConfiguration;
}
- static synchronized Stack getJbpmConfigurationStack()
- {
- Stack stack = (Stack)jbpmConfigurationsStacks.get();
- if (stack == null)
- {
- stack = new Stack();
- jbpmConfigurationsStacks.set(stack);
+ static List getJbpmConfigurationStack() {
+ return (List) jbpmConfigurationStacks.get();
+ }
+
+ static void clearJbpmConfigurationStack() {
+ List configStack = getJbpmConfigurationStack();
+ if (configStack != null) {
+ Object[] configs = configStack.toArray();
+ for (int f = 0; f < configs.length; f++) {
+ JbpmConfiguration config = (JbpmConfiguration) configs[f];
+ List contextStack = config.getJbpmContextStack();
+ if (contextStack != null) {
+ Object[] contexts = contextStack.toArray();
+ for (int t = 0; t < contexts.length; t++) {
+ JbpmContext context = (JbpmContext) contexts[t];
+ context.close();
+ }
+ }
+ contextStack.clear();
+ }
+ configStack.clear();
}
- return stack;
}
- synchronized void pushJbpmConfiguration()
- {
- getJbpmConfigurationStack().push(this);
+ synchronized void pushJbpmConfiguration() {
+ getJbpmConfigurationStack().add(this);
}
- synchronized void popJbpmConfiguration()
- {
+ synchronized void popJbpmConfiguration() {
getJbpmConfigurationStack().remove(this);
}
- public JbpmContext getCurrentJbpmContext()
- {
+ public JbpmContext getCurrentJbpmContext() {
+ ensureOpen();
+
JbpmContext currentJbpmContext = null;
- Stack stack = getJbpmContextStack();
- if (!stack.isEmpty())
- {
- currentJbpmContext = (JbpmContext)stack.peek();
+ List stack = getJbpmContextStack();
+ if (!stack.isEmpty()) {
+ currentJbpmContext = (JbpmContext) stack.get(stack.size() - 1);
}
return currentJbpmContext;
}
- Stack getJbpmContextStack()
- {
- Stack stack = (Stack)jbpmContextStacks.get();
- if (stack == null)
- {
- stack = new Stack();
- jbpmContextStacks.set(stack);
- }
- return stack;
+ List getJbpmContextStack() {
+ return (List) jbpmContextStacks.get();
}
- void pushJbpmContext(JbpmContext jbpmContext)
- {
- getJbpmContextStack().push(jbpmContext);
+ void pushJbpmContext(JbpmContext jbpmContext) {
+ getJbpmContextStack().add(jbpmContext);
}
- void popJbpmContext(JbpmContext jbpmContext)
- {
- Stack stack = getJbpmContextStack();
- if (stack.isEmpty())
- {
- throw new JbpmException("closed JbpmContext more then once... check your try-finally's around JbpmContexts blocks");
+ void popJbpmContext(JbpmContext jbpmContext) {
+ List stack = getJbpmContextStack();
+ int size = stack.size();
+ if (size == 0) {
+ log.warn("closed JbpmContext more than once... "
+ + "check your try-finally clauses around JbpmContext blocks");
}
- JbpmContext popped = (JbpmContext)stack.pop();
- if (jbpmContext != popped)
- {
- throw new JbpmException("closed JbpmContext in different order then they were created... check your try-finally's around JbpmContexts blocks");
+ else if (jbpmContext != stack.remove(size - 1)) {
+ stack.remove(jbpmContext); // prevent context from remaining in the stack
+ log.warn("closed JbpmContext in some order that differs from creation... "
+ + "check your try-finally clauses around JbpmContext blocks");
}
}
- void jbpmContextCreated(JbpmContext jbpmContext)
- {
+ void jbpmContextCreated(JbpmContext jbpmContext) {
pushJbpmConfiguration();
pushJbpmContext(jbpmContext);
}
- void jbpmContextClosed(JbpmContext jbpmContext)
- {
- popJbpmConfiguration();
+ void jbpmContextClosed(JbpmContext jbpmContext) {
popJbpmContext(jbpmContext);
+ popJbpmConfiguration();
}
- public void startJobExecutor()
- {
+ public void startJobExecutor() {
getJobExecutor().start();
}
- public synchronized JobExecutor getJobExecutor()
- {
- if (jobExecutor == null)
- {
- try
- {
- jobExecutor = (JobExecutor)this.objectFactory.createObject("jbpm.job.executor");
+ public synchronized JobExecutor getJobExecutor() {
+ ensureOpen();
+
+ if (jobExecutor == null) {
+ Object object = objectFactory.createObject("jbpm.job.executor");
+ if (object instanceof JobExecutor) {
+ jobExecutor = (JobExecutor) object;
}
- catch (ClassCastException e)
- {
- throw new JbpmException("jbpm configuration object under key 'jbpm.job.executor' is not a " + JobExecutor.class.getName(), e);
+ else if (object != null) {
+ throw new JbpmException("configuration object 'jbpm.job.executor' is not an "
+ + JobExecutor.class.getName());
}
}
return jobExecutor;
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java 2009-05-07 10:14:21 UTC (rev 4758)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java 2009-05-07 13:21:23 UTC (rev 4759)
@@ -37,6 +37,7 @@
private static final long serialVersionUID = 1L;
+ ClassLoader classLoader = null; // lazy load it later! See below..
List objectInfos = null;
Map namedObjectInfos = null;
Map singletons = new HashMap();
@@ -160,7 +161,14 @@
// "lazy load" classloader, shouldn't be loaded too early
// because if jbpm.cfg.xml is not yet parsed, the correct class loader
// may not be initialized yet.
- return ClassLoaderUtil.loadClass(className);
+ if (classLoader==null) {
+ classLoader = ClassLoaderUtil.getClassLoader();
+ }
+ try {
+ return classLoader.loadClass(className);
+ } catch (ClassNotFoundException e) {
+ throw new JbpmException("couldn't load class '"+className+"'", e);
+ }
}
Object getRegistryKey(ObjectInfo objectInfo) {
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/DefaultProcessClassLoaderFactory.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/DefaultProcessClassLoaderFactory.java 2009-05-07 10:14:21 UTC (rev 4758)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/DefaultProcessClassLoaderFactory.java 2009-05-07 13:21:23 UTC (rev 4759)
@@ -1,7 +1,5 @@
package org.jbpm.instantiation;
-import java.io.Serializable;
-
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.util.ClassLoaderUtil;
@@ -10,12 +8,12 @@
*
* @author bernd.ruecker(a)camunda.com
*/
-public class DefaultProcessClassLoaderFactory implements ProcessClassLoaderFactory, Serializable {
-
+public class DefaultProcessClassLoaderFactory implements ProcessClassLoaderFactory {
+
private static final long serialVersionUID = 1L;
public ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
// default behavior like before https://jira.jboss.org/jira/browse/JBPM-1148
return new ProcessClassLoader(ClassLoaderUtil.getClassLoader(), processDefinition);
- }
+ }
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java 2009-05-07 10:14:21 UTC (rev 4758)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java 2009-05-07 13:21:23 UTC (rev 4759)
@@ -29,106 +29,127 @@
import java.net.URLConnection;
import java.net.URLStreamHandler;
+import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.file.def.FileDefinition;
import org.jbpm.graph.def.ProcessDefinition;
public class ProcessClassLoader extends ClassLoader {
-
- private ProcessDefinition processDefinition = null;
- public ProcessClassLoader( ClassLoader parent, ProcessDefinition processDefinition ) {
+ private ProcessDefinition processDefinition;
+ private long processDefinitionId;
+
+ public ProcessClassLoader(ClassLoader parent, ProcessDefinition processDefinition) {
super(parent);
- this.processDefinition = processDefinition;
+ // check whether the given process definition is transient
+ long id = processDefinition.getId();
+ if (id != 0) {
+ // persistent, keep id only
+ processDefinitionId = id;
+ }
+ else {
+ // transient, keep full object
+ this.processDefinition = processDefinition;
+ }
}
+ protected ProcessDefinition getProcessDefinition() {
+ return processDefinition != null ? processDefinition : JbpmContext.getCurrentJbpmContext()
+ .getGraphSession()
+ .loadProcessDefinition(processDefinitionId);
+ }
+
public URL findResource(String name) {
- URL url = null;
+ ProcessDefinition processDefinition = getProcessDefinition();
FileDefinition fileDefinition = processDefinition.getFileDefinition();
- if (fileDefinition!=null) {
- // if the name of the resources starts with a /
- if (name.startsWith("/")) {
- // then we start searching from the root of the process archive
+ if (fileDefinition != null) {
+ // we know that the leading slashes are removed in the names of the
+ // file definitions, therefore we skip the leading slashes
+ int off = 0;
+ for (int len = name.length(); off < len && name.charAt(off) == '/'; off++)
+ /* just increase offset */;
- // we know that the leading slashes are removed in the names of the
- // file definitions, therefor we skip the leading slashes
- while (name.startsWith("/")) {
- name = name.substring(1);
- }
- } else {
- // otherwise, (if the resource is relative), we look in the classes
+ // if the name of the resources is absolute (starts with one or more slashes)
+ if (off > 0) {
+ // then start searching from the root of the process archive
+ name = name.substring(off);
+ }
+ else {
+ // otherwise (if the resource is relative), look in the classes
// directory in the process archive
- name = "classes/"+name;
+ name = "classes/" + name;
}
byte[] bytes = null;
if (fileDefinition.hasFile(name)) {
bytes = fileDefinition.getBytes(name);
}
- if (bytes!=null) {
+ if (bytes != null) {
try {
- url = new URL(null, "processresource://"+processDefinition.getName()+"/classes/"+name, new BytesUrlStreamHandler(bytes));
- } catch (MalformedURLException e) {
+ return new URL(null, "processresource://"
+ + processDefinition.getName()
+ + "/classes/"
+ + name, new BytesUrlStreamHandler(bytes));
+ }
+ catch (MalformedURLException e) {
throw new JbpmException("couldn't create url", e);
}
}
}
- return url;
+ return null;
}
-
+
public static class BytesUrlStreamHandler extends URLStreamHandler {
+
byte[] bytes;
+
public BytesUrlStreamHandler(byte[] bytes) {
this.bytes = bytes;
}
+
protected URLConnection openConnection(URL u) throws IOException {
return new BytesUrlConnection(bytes, u);
}
}
public static class BytesUrlConnection extends URLConnection {
+
byte[] bytes = null;
+
public BytesUrlConnection(byte[] bytes, URL u) {
super(u);
this.bytes = bytes;
}
+
public void connect() throws IOException {
}
+
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(bytes);
}
}
- public Class findClass(String name) throws ClassNotFoundException {
- Class clazz = null;
+ public Class findClass(String className) throws ClassNotFoundException {
+ FileDefinition fileDefinition = getProcessDefinition().getFileDefinition();
+ if (fileDefinition != null) {
+ String fileName = "classes/" + className.replace('.', '/') + ".class";
+ byte[] classBytes = fileDefinition.getBytes(fileName);
- FileDefinition fileDefinition = processDefinition.getFileDefinition();
- if (fileDefinition!=null) {
- String fileName = "classes/" + name.replace( '.', '/' ) + ".class";
- byte[] classBytes;
- try {
- classBytes = fileDefinition.getBytes(fileName);
- clazz = defineClass(name, classBytes, 0, classBytes.length);
- } catch (JbpmException e) {
- clazz = null;
- }
-
- // Add the package information
- // see https://jira.jboss.org/jira/browse/JBPM-1404
- final int packageIndex = name.lastIndexOf('.');
- if (packageIndex != -1) {
- final String packageName = name.substring(0, packageIndex);
- final Package classPackage = getPackage(packageName);
- if (classPackage == null) {
- definePackage(packageName, null, null, null, null, null, null, null);
+ if (classBytes != null) {
+ // define the package before defining the class
+ // see https://jira.jboss.org/jira/browse/JBPM-1404
+ int packageIndex = className.lastIndexOf('.');
+
+ if (packageIndex != -1) {
+ String packageName = className.substring(0, packageIndex);
+
+ if (getPackage(packageName) == null) {
+ definePackage(packageName, null, null, null, processDefinition.getName(), Integer.toString(processDefinition.getVersion()), null, null);
+ }
}
+ return defineClass(className, classBytes, 0, classBytes.length);
}
}
-
- if (clazz==null) {
- throw new ClassNotFoundException("class '"+name+"' could not be found by the process classloader");
- }
-
- return clazz;
+ throw new ClassNotFoundException(className);
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoaderFactory.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoaderFactory.java 2009-05-07 10:14:21 UTC (rev 4758)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoaderFactory.java 2009-05-07 13:21:23 UTC (rev 4759)
@@ -1,21 +1,31 @@
package org.jbpm.instantiation;
+import java.io.Serializable;
+
+import org.jbpm.JbpmConfiguration;
import org.jbpm.graph.def.ProcessDefinition;
/**
- * Factory to retrieve the Process{@link ClassLoader} which is then used
- * to load delegation classes used by the process.
+ * <p>
+ * Factory to retrieve the Process {@link ClassLoader} which is then used to load delegation classes
+ * used by the process.
+ * </p>
+ * <p>
+ * Default is the build in {@link ProcessClassLoader}, which tries to load the classes from the jBPM
+ * database first.
+ * </p>
+ * <p>
+ * Can be configured by setting the property <code>jbpm.process.class.loader</code> in the
+ * configuration file to the class name of the custom class loader.
+ * </p>
+ * <p>
+ * Implementations should be serializable, as the {@link JbpmConfiguration} that references them is.
+ * </p>
*
- * Default is the build in {@link ProcessClassLoader}, which
- * tries to load the classes from the jbpm database first.
- *
- * Can be configured by setting the property <b>'jbpm.processClassLoader'</b>
- * in the jbpm.cfg.xml to the class name of the custom class loader.
- *
* @author bernd.ruecker(a)camunda.com
*/
-public interface ProcessClassLoaderFactory {
+public interface ProcessClassLoaderFactory extends Serializable {
public ClassLoader getProcessClassLoader(ProcessDefinition processDefinition);
-
+
}
\ No newline at end of file
Copied: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/SharedProcessClassLoaderFactory.java (from rev 4689, jbpm3/trunk/modules/core/src/main/java/org/jbpm/instantiation/SharedProcessClassLoaderFactory.java)
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/SharedProcessClassLoaderFactory.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/SharedProcessClassLoaderFactory.java 2009-05-07 13:21:23 UTC (rev 4759)
@@ -0,0 +1,98 @@
+/*
+ * 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.instantiation;
+
+import java.lang.ref.SoftReference;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.util.ClassLoaderUtil;
+
+/**
+ * Refined process class loader factory that maintains a cache of the class loaders it returns. The
+ * cache does not prevent class loaders from being discarded by the garbage collector.
+ *
+ * @author Alejandro Guizar
+ */
+public class SharedProcessClassLoaderFactory implements ProcessClassLoaderFactory {
+
+ private transient Map classLoaderRefs = new HashMap();
+
+ private static final long serialVersionUID = 1L;
+
+ public ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
+ // determine the key to lookup a cached class loader
+ // observe that the given process definition may be transient
+ long id = processDefinition.getId();
+ if (id == 0L) id = processDefinition.hashCode();
+ Long key = new Long(id);
+ // consider that the context class loader changes among applications
+ ClassLoader parentClassLoader = ClassLoaderUtil.getClassLoader();
+ assert parentClassLoader != null : "parent class loader is null";
+
+ synchronized (classLoaderRefs) {
+ // lookup the class loader reference
+ ClassLoader processClassLoader = getProcessClassLoader(key, parentClassLoader);
+ // the reference may not exist or may have been cleared already
+ if (processClassLoader == null) {
+ // (re-)create the class loader and the reference
+ processClassLoader = new ProcessClassLoader(parentClassLoader, processDefinition);
+ // cache the reference
+ putProcessClassLoader(key, processClassLoader);
+ }
+ return processClassLoader;
+ }
+ }
+
+ private ClassLoader getProcessClassLoader(Long processDefinitionKey, ClassLoader parentClassLoader) {
+ List referenceList = (List) classLoaderRefs.get(processDefinitionKey);
+ if (referenceList != null) {
+ for (Iterator i = referenceList.iterator(); i.hasNext();) {
+ SoftReference reference = (SoftReference) i.next();
+ ClassLoader processClassLoader = (ClassLoader) reference.get();
+ // reference may have been cleared already
+ if (processClassLoader == null) {
+ // remove cleared reference
+ i.remove();
+ }
+ // process class loader may have a different parent
+ else if (processClassLoader.getParent() == parentClassLoader) {
+ return processClassLoader;
+ }
+ }
+ }
+ return null;
+ }
+
+ private void putProcessClassLoader(Long processDefinitionKey, ClassLoader processClassLoader) {
+ List referenceList = (List) classLoaderRefs.get(processDefinitionKey);
+ if (referenceList == null) {
+ referenceList = new ArrayList();
+ classLoaderRefs.put(processDefinitionKey, referenceList);
+ }
+ referenceList.add(new SoftReference(processClassLoader));
+ }
+}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2009-05-07 10:14:21 UTC (rev 4758)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2009-05-07 13:21:23 UTC (rev 4759)
@@ -29,126 +29,132 @@
import org.jbpm.JbpmException;
/**
- * provides centralized classloader lookup.
+ * provides centralized classloader lookup.
*/
-public class ClassLoaderUtil
-{
+public class ClassLoaderUtil {
- private ClassLoaderUtil()
- {
+ private ClassLoaderUtil() {
// hide default constructor to prevent instantiation
}
- public static Class loadClass(String className)
- {
- try
- {
+ /**
+ * Bad usage of ClassLoader.loadClass() under JDK 6.
+ *
+ * @deprecated Use {@linkplain #classForName(String) classForName()} instead
+ * @see <a href="https://jira.jboss.org/jira/browse/JBPM-1976">JBPM-1976</a>
+ */
+ public static Class loadClass(String className) {
+ try {
return getClassLoader().loadClass(className);
}
- catch (ClassNotFoundException e)
- {
+ catch (ClassNotFoundException e) {
throw new JbpmException("class not found '" + className + "'", e);
}
}
- /*
- * returns the {@link ClassLoader} which is used in jbpm. Can be configured in jbpm.cfg.xml by the property <b>'jbpm.classloader'</b> <td> <li>'jbpm': (default value)
- * uses the {@link ClassLoaderUtil}.class.getClassLoader() {@link ClassLoader}. This was the only behavior available before <a
- * href="https://jira.jboss.org/jira/browse/JBPM-1148">JBPM-1148</a>.</li> <li>'context': uses the Thread.currentThread().getContextClassLoader().</li> <li>'custom':
- * means that a ClassLoader class has to be provided in the property <b>'jbpm.classloader.classname'</b></li> </td>
+ public static Class classForName(String className) {
+ try {
+ return Class.forName(className, true, getClassLoader());
+ }
+ catch (ClassNotFoundException e) {
+ throw new JbpmException("class not found '" + className + "'", e);
+ }
+ }
+
+ public static Class classForName(String className, boolean useConfiguredLoader) {
+ if (useConfiguredLoader) return classForName(className);
+
+ // try context class loader first, so that applications can override provided classes
+ try {
+ return Class.forName(className, true, Thread.currentThread().getContextClassLoader());
+ }
+ catch (ClassNotFoundException e) {
+ // try the class loader of the current class
+ try {
+ return Class.forName(className);
+ }
+ catch (ClassNotFoundException e2) {
+ // give up
+ throw new JbpmException("class not found '" + className + "'", e);
+ }
+ }
+ }
+
+ /**
+ * Returns the {@link ClassLoader} employed by jBPM to load classes referenced in the
+ * configuration. The class loader can be changed in <code>jbpm.cfg.xml</code> by setting the
+ * string property <code>jbpm.class.loader</code>. The possible values are:
+ * <ul>
+ * <li><code>jbpm</code> (default) indicates the class loader of the jBPM classes. Before <a
+ * href="https://jira.jboss.org/jira/browse/JBPM-1148">JBPM-1148</a> no other behavior was
+ * available</li>
+ * <li><code>context</code> indicates the {@linkplain Thread#getContextClassLoader() context class
+ * loader}</li>
+ * <li>any other value is interpreted as a reference to a class loader bean described in the
+ * configuration</li>
+ * </ul>
*/
- public static ClassLoader getClassLoader()
- {
- if (JbpmConfiguration.Configs.hasObject("jbpm.classLoader"))
- {
- String jbpmClassloader = JbpmConfiguration.Configs.getString("jbpm.classLoader");
+ public static ClassLoader getClassLoader() {
+ if (JbpmConfiguration.Configs.hasObject("jbpm.class.loader")) {
+ String jbpmClassLoader = JbpmConfiguration.Configs.getString("jbpm.class.loader");
- if (jbpmClassloader.equals("jbpm"))
- {
+ if (jbpmClassLoader.equals("jbpm")) {
+ // use class loader that loaded the jbpm classes
return ClassLoaderUtil.class.getClassLoader();
}
- else if (jbpmClassloader.equals("context"))
- {
+
+ if (jbpmClassLoader.equals("context")) {
+ // use the context class loader
return Thread.currentThread().getContextClassLoader();
}
- else if (jbpmClassloader.equals("custom"))
- {
- String jbpmClassloaderClassname = null;
- try
- {
- if (!JbpmConfiguration.Configs.hasObject("jbpm.customClassLoader.className"))
- {
- throw new JbpmException("'jbpm.classloader' property set to 'custom' but 'jbpm.customClassLoader.className' is empty!");
- }
- jbpmClassloaderClassname = JbpmConfiguration.Configs.getString("jbpm.customClassLoader.className");
- if (jbpmClassloaderClassname == null)
- {
- throw new JbpmException("'jbpm.classloader' property set to 'custom' but 'jbpm.customClassLoader.className' is empty!");
- }
- Class clazz = ClassLoaderUtil.class.getClassLoader().loadClass(jbpmClassloaderClassname);
- if (clazz == null)
- clazz = Thread.currentThread().getContextClassLoader().loadClass(jbpmClassloaderClassname);
-
- return (ClassLoader)clazz.newInstance();
- }
- catch (InstantiationException e)
- {
- throw new JbpmException("Error instantiating custom classloader " + jbpmClassloaderClassname, e);
- }
- catch (IllegalAccessException e)
- {
- throw new JbpmException("Error accessing custom classloader " + jbpmClassloaderClassname, e);
- }
- catch (ClassNotFoundException e)
- {
- throw new JbpmException("Custom classloader " + jbpmClassloaderClassname + " not found ", e);
- }
+ // interpret value as a reference to a class loader bean
+ Object bean = JbpmConfiguration.Configs.getObject(jbpmClassLoader);
+ if (!(bean instanceof ClassLoader)) {
+ throw new JbpmException("bean '" + jbpmClassLoader + "' is not a class loader");
}
- else
- {
- throw new JbpmException("'jbpm.classloader' property set to '" + jbpmClassloader + "' but only the values 'jbpm'/'context'/'custom' are supported!");
- }
+ return (ClassLoader) bean;
}
- else
- {
- // default behavior like before https://jira.jboss.org/jira/browse/JBPM-1148
+ else {
+ // behave like before JBPM-1148
return ClassLoaderUtil.class.getClassLoader();
}
}
- public static InputStream getStream(String resource)
- {
+ public static InputStream getStream(String resource) {
return getClassLoader().getResourceAsStream(resource);
}
- /*
- * Load jbpm configuration related resources as stream (normally jbpm.cfg.xml). This method first tries to load the resource from the {@link ClassLoaderUtil} class
- * loader, if not found it tries the context class loader. If this doesn't return any ressource the call is delegated to the class loader configured by calling
- * getClassLoader(). This is a special method because the class loader which has to be used for loading the jbpm.cfg.xml cannot be configured in the jbpm.cfg.xml
- * itself.
+ /**
+ * Load jbpm configuration related resources as stream (normally jbpm.cfg.xml). This method first
+ * tries to load the resource from the {@link ClassLoaderUtil} class loader, if not found it tries
+ * the context class loader. If this doesn't return any ressource the call is delegated to the
+ * class loader configured by calling getClassLoader(). This is a special method because the class
+ * loader which has to be used for loading the jbpm.cfg.xml cannot be configured in the
+ * jbpm.cfg.xml itself.
*/
- public static InputStream getJbpmConfigurationStream(String resource)
- {
- InputStream jbpmCfgStream = ClassLoaderUtil.class.getClassLoader().getResourceAsStream(resource);
- if (jbpmCfgStream == null)
- {
- jbpmCfgStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
+ public static InputStream getStream(String resource, boolean useConfiguredLoader) {
+ if (useConfiguredLoader) return getStream(resource);
+
+ // try context class loader first, so that applications can override provided classes
+ InputStream stream = Thread.currentThread()
+ .getContextClassLoader()
+ .getResourceAsStream(resource);
+ if (stream == null) {
+ // try the class loader of the current class
+ stream = ClassLoaderUtil.class.getClassLoader().getResourceAsStream(resource);
}
- return jbpmCfgStream;
+ return stream;
}
- public static Properties getProperties(String resource)
- {
+ public static Properties getProperties(String resource) {
Properties properties = new Properties();
- try
- {
+ try {
InputStream inStream = getStream(resource);
properties.load(inStream);
inStream.close();
}
- catch (IOException e)
- {
+ catch (IOException e) {
throw new JbpmException("couldn't load properties file '" + resource + "'", e);
}
return properties;
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/XmlUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/XmlUtil.java 2009-05-07 10:14:21 UTC (rev 4758)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/XmlUtil.java 2009-05-07 13:21:23 UTC (rev 4759)
@@ -59,20 +59,20 @@
}
/**
- * @param isJbpmConfiguration specifies if the resource should be loaded
- * with the "limited" bootstrap class loader for jbpm config.
+ * @param isJbpmConfiguration specifies if the resource should be loaded with the "limited"
+ * bootstrap class loader for jbpm config.
*/
- public static Document parseXmlResource(String resource, boolean isJbpmConfiguration) {
+ public static Document parseXmlResource(String resource, boolean isJbpmConfiguration) {
// decide which class loading mechanism to use for loading the jbpm
// configuration (see https://jira.jboss.org/jira/browse/JBPM-1148)
InputStream inputStream = null;
if (isJbpmConfiguration)
- inputStream = ClassLoaderUtil.getJbpmConfigurationStream(resource);
+ inputStream = ClassLoaderUtil.getStream(resource, false);
else
inputStream = ClassLoaderUtil.getStream(resource);
-
+
if (inputStream == null)
- throw new IllegalArgumentException("Cannot load resource: " + resource);
+ throw new IllegalArgumentException("Cannot load resource: " + resource);
InputSource inputSource = new InputSource(inputStream);
return parseXmlInputSource(inputSource);
}
@@ -80,8 +80,9 @@
public static Document parseXmlInputStream(InputStream inputStream) {
Document document = null;
try {
- document = getDocumentBuilder().parse(inputStream);
- } catch (Exception e) {
+ document = getDocumentBuilder().parse(inputStream);
+ }
+ catch (Exception e) {
throw new XmlException("couldn't parse xml", e);
}
return document;
@@ -90,14 +91,16 @@
public static Document parseXmlInputSource(InputSource inputSource) {
Document document = null;
try {
- document = getDocumentBuilder().parse(inputSource);
- } catch (Exception e) {
+ document = getDocumentBuilder().parse(inputSource);
+ }
+ catch (Exception e) {
throw new XmlException("couldn't parse xml", e);
}
return document;
}
- public static DocumentBuilder getDocumentBuilder() throws FactoryConfigurationError, ParserConfigurationException {
+ public static DocumentBuilder getDocumentBuilder() throws FactoryConfigurationError,
+ ParserConfigurationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
return factory.newDocumentBuilder();
}
@@ -109,9 +112,9 @@
public static List elements(Element element, String tagName) {
NodeList nodeList = element.getElementsByTagName(tagName);
List elements = new ArrayList(nodeList.getLength());
- for (int i=0; i<nodeList.getLength(); i++) {
+ for (int i = 0; i < nodeList.getLength(); i++) {
Node child = nodeList.item(i);
- if(child.getParentNode()==element) {
+ if (child.getParentNode() == element) {
elements.add(child);
}
}
@@ -121,7 +124,7 @@
public static Element element(Element element, String name) {
Element childElement = null;
NodeList nodeList = element.getElementsByTagName(name);
- if (nodeList.getLength()>0) {
+ if (nodeList.getLength() > 0) {
childElement = (Element) nodeList.item(0);
}
return childElement;
@@ -134,43 +137,41 @@
public static List elements(Element element) {
List elements = new ArrayList();
NodeList nodeList = element.getChildNodes();
- for (int i=0; i<nodeList.getLength(); i++) {
+ for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
- if ( (node instanceof Element)
- && (element==node.getParentNode())
- ){
+ if ((node instanceof Element) && (element == node.getParentNode())) {
elements.add(node);
}
}
return elements;
}
-
public static Element element(Element element) {
Element onlyChild = null;
List elements = elements(element);
- if (! elements.isEmpty()) {
+ if (!elements.isEmpty()) {
onlyChild = (Element) elements.get(0);
}
return onlyChild;
}
public static String toString(Element element) {
- if (element==null) return "null";
+ if (element == null) return "null";
Source source = new DOMSource(element);
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
Result result = new StreamResult(printWriter);
-
+
try {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(source, result);
- } catch (Exception e) {
- throw new XmlException("couldn't write element '"+element.getTagName()+"' to string", e);
}
-
+ catch (Exception e) {
+ throw new XmlException("couldn't write element '" + element.getTagName() + "' to string", e);
+ }
+
printWriter.close();
return stringWriter.toString();
@@ -179,7 +180,7 @@
public static String getContentText(Element element) {
StringBuffer buffer = new StringBuffer();
NodeList nodeList = element.getChildNodes();
- for (int i=0; i<nodeList.getLength(); i++) {
+ for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node instanceof CharacterData) {
CharacterData characterData = (CharacterData) node;
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2009-05-07 10:14:21 UTC (rev 4758)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2009-05-07 13:21:23 UTC (rev 4759)
@@ -33,11 +33,8 @@
<string name="resource.mail.templates" value="jbpm.mail.templates.xml" />
<!-- class loading -->
- <!--
- <string name="jbpm.classLoader" value="jbpm" />
- <string name="jbpm.customClassLoader.className" value="org.example.ClassLoader" />
- <bean name="jbpm.processClassLoader" class="org.jbpm.instantiation.DefaultProcessClassLoaderFactory" singleton="true" />
- -->
+ <string name="jbpm.class.loader" value="context" />
+ <bean name="process.class.loader.factory" class="org.jbpm.instantiation.SharedProcessClassLoaderFactory" singleton="true" />
<!-- make sure the block size matches the length in ByteArray.hbm.xml -->
<int name="jbpm.byte.block.size" value="1024" singleton="true" />
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java 2009-05-07 10:14:21 UTC (rev 4758)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java 2009-05-07 13:21:23 UTC (rev 4759)
@@ -21,36 +21,22 @@
*/
package org.jbpm;
-import java.util.HashMap;
-
+import org.hibernate.SessionFactory;
import org.jbpm.configuration.ConfigurationException;
import org.jbpm.configuration.ObjectFactory;
import org.jbpm.configuration.ObjectFactoryImpl;
import org.jbpm.configuration.ObjectFactoryParser;
-import org.jbpm.persistence.db.DbPersistenceServiceFactory;
-import org.jbpm.svc.Services;
import org.jbpm.util.XmlException;
public class JbpmConfigurationTest extends AbstractJbpmTestCase {
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
- JbpmConfiguration.instances = new HashMap();
+ JbpmConfiguration.clearJbpmConfigurationStack();
JbpmConfiguration.defaultObjectFactory = null;
- JbpmConfiguration.jbpmConfigurationsStacks = new ThreadLocal();
- JbpmContext.currentContextsStack = new ThreadLocal();
+ JbpmConfiguration.instances.clear();
}
-
- protected void tearDown() throws Exception
- {
- JbpmConfiguration.instances = new HashMap();
- JbpmConfiguration.defaultObjectFactory = null;
- JbpmConfiguration.jbpmConfigurationsStacks = new ThreadLocal();
- JbpmContext.currentContextsStack = new ThreadLocal();
- super.tearDown();
- }
-
+
public void testSingleton() {
JbpmConfiguration.defaultObjectFactory = new ObjectFactoryImpl(null, null);
JbpmConfiguration instance = JbpmConfiguration.getInstance();
@@ -61,35 +47,32 @@
}
public void testDefaultContextCreation() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='"+JbpmContext.DEFAULT_JBPM_CONTEXT_NAME+"' />" +
- "</jbpm-configuration>"
- );
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='"
+ + JbpmContext.DEFAULT_JBPM_CONTEXT_NAME
+ + "' />"
+ + "</jbpm-configuration>");
assertNotNull(jbpmConfiguration);
assertNotNull(jbpmConfiguration.createJbpmContext());
}
public void testNonExistingContext() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration />"
- );
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration />");
assertNotNull(jbpmConfiguration);
try {
jbpmConfiguration.createJbpmContext("non-existing-context");
fail("expected exception");
- } catch (ConfigurationException e) {
+ }
+ catch (ConfigurationException e) {
//OK
}
}
public void testParseXmlStringConfiguration() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='a' />" +
- " <jbpm-context name='b' />" +
- "</jbpm-configuration>"
- );
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='a' />"
+ + " <jbpm-context name='b' />"
+ + "</jbpm-configuration>");
assertNotNull(jbpmConfiguration);
JbpmContext a = jbpmConfiguration.createJbpmContext("a");
assertNotNull(a);
@@ -99,11 +82,9 @@
}
public void testNonSingletonContextCreation() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='a' />" +
- "</jbpm-configuration>"
- );
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='a' />"
+ + "</jbpm-configuration>");
assertNotNull(jbpmConfiguration);
JbpmContext a = jbpmConfiguration.createJbpmContext("a");
assertNotNull(a);
@@ -116,7 +97,8 @@
try {
JbpmConfiguration.parseXmlString("< problematic // <</> <x>M/L");
fail("expected exception");
- } catch (XmlException e) {
+ }
+ catch (XmlException e) {
// OK
}
}
@@ -132,18 +114,16 @@
// 'jbpm.cfg.xml' or the static method JbpmConfiguration.Configs.setDefaultObjectFactory
// to specify the configuration information.
- JbpmConfiguration.Configs.setDefaultObjectFactory(
- ObjectFactoryParser.parseXmlString(
- "<jbpm-configuration>" +
- " <string name='myproperty'>myvalue</string>" +
- "</jbpm-configuration>"
- )
- );
+ JbpmConfiguration.Configs.setDefaultObjectFactory(ObjectFactoryParser.parseXmlString("<jbpm-configuration>"
+ + " <string name='myproperty'>myvalue</string>"
+ + "</jbpm-configuration>"));
assertEquals("myvalue", JbpmConfiguration.Configs.getString("myproperty"));
}
public static class CustomObjectFactory implements ObjectFactory {
+
private static final long serialVersionUID = 1L;
+
public Object createObject(String name) {
Object o = null;
if ("myproperty".equals(name)) {
@@ -151,48 +131,42 @@
}
return o;
}
+
public boolean hasObject(String name) {
return "myproperty".equals(name);
}
}
public void testDomainModelConfigsWithCustomObjectFactory() {
- JbpmConfiguration.Configs.setDefaultObjectFactory(
- new CustomObjectFactory()
- );
+ JbpmConfiguration.Configs.setDefaultObjectFactory(new CustomObjectFactory());
assertEquals("mycustomfactoriedvalue", JbpmConfiguration.Configs.getString("myproperty"));
}
public void testDomainModelConfigsWithJbpmContext() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='default.jbpm.context' />" +
- " <string name='myproperty'>myvalueinacontext</string>" +
- "</jbpm-configuration>"
- );
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='default.jbpm.context' />"
+ + " <string name='myproperty'>myvalueinacontext</string>"
+ + "</jbpm-configuration>");
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
assertEquals("myvalueinacontext", JbpmConfiguration.Configs.getString("myproperty"));
- } finally {
+ }
+ finally {
jbpmContext.close();
}
}
public void testDomainModelConfigsWithNestedJbpmContext() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='default.jbpm.context' />" +
- " <string name='myproperty'>myvalueinacontext</string>" +
- "</jbpm-configuration>"
- );
- JbpmConfiguration nestedJbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='default.jbpm.context' />" +
- " <string name='myproperty'>myvalueinanestedcontext</string>" +
- "</jbpm-configuration>"
- );
-
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='default.jbpm.context' />"
+ + " <string name='myproperty'>myvalueinacontext</string>"
+ + "</jbpm-configuration>");
+ JbpmConfiguration nestedJbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='default.jbpm.context' />"
+ + " <string name='myproperty'>myvalueinanestedcontext</string>"
+ + "</jbpm-configuration>");
+
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
assertEquals("myvalueinacontext", JbpmConfiguration.Configs.getString("myproperty"));
@@ -200,12 +174,14 @@
JbpmContext nestedJbpmContext = nestedJbpmConfiguration.createJbpmContext();
try {
assertEquals("myvalueinanestedcontext", JbpmConfiguration.Configs.getString("myproperty"));
- } finally {
+ }
+ finally {
nestedJbpmContext.close();
}
-
+
assertEquals("myvalueinacontext", JbpmConfiguration.Configs.getString("myproperty"));
- } finally {
+ }
+ finally {
jbpmContext.close();
}
}
@@ -213,15 +189,15 @@
public void testJbpmConfigurationClose() {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ SessionFactory sessionFactory;
try {
- jbpmContext.getSession();
- } finally {
+ sessionFactory = jbpmContext.getSessionFactory();
+ }
+ finally {
jbpmContext.close();
}
-
jbpmConfiguration.close();
-
- DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- assertTrue(dbPersistenceServiceFactory.getSessionFactory().isClosed());
+
+ assertTrue("expected " + sessionFactory + " to be closed", sessionFactory.isClosed());
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/JbpmContextTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/JbpmContextTest.java 2009-05-07 10:14:21 UTC (rev 4758)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/JbpmContextTest.java 2009-05-07 13:21:23 UTC (rev 4759)
@@ -21,8 +21,6 @@
*/
package org.jbpm;
-import java.util.HashMap;
-
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.logging.LoggingService;
import org.jbpm.logging.log.MessageLog;
@@ -33,29 +31,17 @@
import org.jbpm.svc.save.SaveOperation;
public class JbpmContextTest extends AbstractJbpmTestCase {
-
- protected void setUp() throws Exception
- {
+
+ protected void setUp() throws Exception {
super.setUp();
- JbpmConfiguration.instances = new HashMap();
+ JbpmConfiguration.instances.clear();
JbpmConfiguration.defaultObjectFactory = null;
- JbpmContext.currentContextsStack = new ThreadLocal();
}
- protected void tearDown() throws Exception
- {
- JbpmConfiguration.instances = new HashMap();
- JbpmConfiguration.defaultObjectFactory = null;
- JbpmContext.currentContextsStack = new ThreadLocal();
- super.tearDown();
- }
-
public void testServices() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='a' />" +
- "</jbpm-configuration>"
- );
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='a' />"
+ + "</jbpm-configuration>");
assertNotNull(jbpmConfiguration);
Services s = jbpmConfiguration.createJbpmContext("a").getServices();
assertNotNull(s);
@@ -65,11 +51,9 @@
}
public void testJbpmContext() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='a' />" +
- "</jbpm-configuration>"
- );
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='a' />"
+ + "</jbpm-configuration>");
JbpmContext one = jbpmConfiguration.createJbpmContext("a");
assertNotNull(one);
JbpmContext two = jbpmConfiguration.createJbpmContext("a");
@@ -78,58 +62,57 @@
}
public static class TestServiceFactory implements ServiceFactory {
+
private static final long serialVersionUID = 1L;
+
public Service openService() {
return new TestService();
}
+
public void close() {
}
}
public static class TestService implements Service {
+
private static final long serialVersionUID = 1L;
+
public void close() {
}
}
public void testCustomService() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='a'>" +
- " <service name='test' factory='org.jbpm.JbpmContextTest$TestServiceFactory' />" +
- " </jbpm-context>" +
- "</jbpm-configuration>"
- );
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='a'>"
+ + " <service name='test' factory='org.jbpm.JbpmContextTest$TestServiceFactory' />"
+ + " </jbpm-context>"
+ + "</jbpm-configuration>");
Object service = jbpmConfiguration.createJbpmContext("a").getServices().getService("test");
assertNotNull(service);
assertEquals(TestService.class, service.getClass());
}
-
+
public void testServiceInFactoryElement() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='a'>" +
- " <service name='test'>" +
- " <factory>" +
- " <bean class='org.jbpm.JbpmContextTest$TestServiceFactory' />" +
- " </factory>" +
- " </service>" +
- " </jbpm-context>" +
- "</jbpm-configuration>"
- );
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='a'>"
+ + " <service name='test'>"
+ + " <factory>"
+ + " <bean class='org.jbpm.JbpmContextTest$TestServiceFactory' />"
+ + " </factory>"
+ + " </service>"
+ + " </jbpm-context>"
+ + "</jbpm-configuration>");
Object service = jbpmConfiguration.createJbpmContext("a").getServices().getService("test");
assertNotNull(service);
assertEquals(TestService.class, service.getClass());
}
-
+
public void testServiceCaching() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='a'>" +
- " <service name='test' factory='org.jbpm.JbpmContextTest$TestServiceFactory' />" +
- " </jbpm-context>" +
- "</jbpm-configuration>"
- );
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='a'>"
+ + " <service name='test' factory='org.jbpm.JbpmContextTest$TestServiceFactory' />"
+ + " </jbpm-context>"
+ + "</jbpm-configuration>");
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext("a");
TestService serviceOne = (TestService) jbpmContext.getServices().getService("test");
assertNotNull(serviceOne);
@@ -139,22 +122,28 @@
jbpmContext = jbpmConfiguration.createJbpmContext("a");
assertNotSame(serviceOne, jbpmContext.getServices().getService("test"));
}
-
+
public static class CustomLoggingServiceFactory implements ServiceFactory {
+
private static final long serialVersionUID = 1L;
+
public Service openService() {
return new CustomLoggingService();
}
+
public void close() {
}
}
public static class CustomLoggingService implements LoggingService {
+
private static final long serialVersionUID = 1L;
ProcessLog processLog;
int invocationCount = 0;
+
public void close() {
}
+
public void log(ProcessLog processLog) {
this.processLog = processLog;
this.invocationCount++;
@@ -162,17 +151,15 @@
}
public void testCustomLoggingService() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='a'>" +
- " <service name='logging' factory='org.jbpm.JbpmContextTest$CustomLoggingServiceFactory' />" +
- " </jbpm-context>" +
- "</jbpm-configuration>"
- );
-
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='a'>"
+ + " <service name='logging' factory='org.jbpm.JbpmContextTest$CustomLoggingServiceFactory' />"
+ + " </jbpm-context>"
+ + "</jbpm-configuration>");
+
CustomLoggingService customLoggingService = null;
MessageLog messageLog = null;
-
+
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext("a");
try {
customLoggingService = (CustomLoggingService) jbpmContext.getServices().getLoggingService();
@@ -181,70 +168,70 @@
processInstance.getLoggingInstance().addLog(messageLog);
jbpmContext.save(processInstance);
- } finally {
+ }
+ finally {
jbpmContext.close();
}
assertEquals(messageLog, customLoggingService.processLog);
assertEquals(1, customLoggingService.invocationCount);
}
-
-
+
public static class TestSaveOperation implements SaveOperation {
+
static int invocationCount = 0;
private static final long serialVersionUID = 1L;
+
public void save(ProcessInstance processInstance, JbpmContext jbpmContext) {
invocationCount++;
}
}
public void testSaveOperation() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='default.jbpm.context'>" +
- " <save-operations>" +
- " <save-operation class='org.jbpm.JbpmContextTest$TestSaveOperation' />" +
- " </save-operations>" +
- " </jbpm-context>" +
- "</jbpm-configuration>"
- );
-
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='default.jbpm.context'>"
+ + " <save-operations>"
+ + " <save-operation class='org.jbpm.JbpmContextTest$TestSaveOperation' />"
+ + " </save-operations>"
+ + " </jbpm-context>"
+ + "</jbpm-configuration>");
+
TestSaveOperation.invocationCount = 0;
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
+
try {
-
+
assertEquals(0, TestSaveOperation.invocationCount);
jbpmContext.save(new ProcessInstance());
assertEquals(1, TestSaveOperation.invocationCount);
-
- } finally {
+
+ }
+ finally {
jbpmContext.close();
}
}
public void testSaveOperationInBeanElement() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='default.jbpm.context'>" +
- " <save-operations>" +
- " <save-operation>" +
- " <bean class='org.jbpm.JbpmContextTest$TestSaveOperation' />" +
- " </save-operation>" +
- " </save-operations>" +
- " </jbpm-context>" +
- "</jbpm-configuration>"
- );
-
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <jbpm-context name='default.jbpm.context'>"
+ + " <save-operations>"
+ + " <save-operation>"
+ + " <bean class='org.jbpm.JbpmContextTest$TestSaveOperation' />"
+ + " </save-operation>"
+ + " </save-operations>"
+ + " </jbpm-context>"
+ + "</jbpm-configuration>");
+
TestSaveOperation.invocationCount = 0;
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
+
try {
-
+
assertEquals(0, TestSaveOperation.invocationCount);
jbpmContext.save(new ProcessInstance());
assertEquals(1, TestSaveOperation.invocationCount);
-
- } finally {
+
+ }
+ finally {
jbpmContext.close();
}
}
Copied: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassLoadersTest.java (from rev 4689, jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassLoadersTest.java)
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassLoadersTest.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassLoadersTest.java 2009-05-07 13:21:23 UTC (rev 4759)
@@ -0,0 +1,143 @@
+/*
+ * 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.instantiation;
+
+import org.jbpm.AbstractJbpmTestCase;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.JbpmException;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.util.ClassLoaderUtil;
+
+/**
+ * {@link ProcessClassLoaderFactory} and class loader can be configured via
+ * {@link JbpmConfiguration} / jbpm.cfg.xml. Test if that works. Introduced with
+ * https://jira.jboss.org/jira/browse/JBPM-1148
+ *
+ * @author bernd.ruecker(a)camunda.com
+ */
+public class ConfigurableClassLoadersTest extends AbstractJbpmTestCase {
+
+ private ProcessDefinition processDefinition = new ProcessDefinition();
+
+ public void testDefaultProcessClassLoaderFactory() {
+ ClassLoader processClassLoader = JbpmConfiguration.getProcessClassLoader(processDefinition);
+ assertSame(ProcessClassLoader.class, processClassLoader.getClass());
+ }
+
+ public void testCustomProcessClassLoaderFactory() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <bean name='process.class.loader.factory' class='"
+ + CustomProcessClassLoaderFactory.class.getName()
+ + "' singleton='true' />"
+ + "</jbpm-configuration>");
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+
+ ClassLoader processClassLoader = JbpmConfiguration.getProcessClassLoader(processDefinition);
+ assertSame(CustomClassLoader.class, processClassLoader.getClass());
+
+ jbpmContext.close();
+ jbpmConfiguration.close();
+ }
+
+ public static class CustomProcessClassLoaderFactory implements ProcessClassLoaderFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ public ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
+ return new CustomClassLoader();
+ }
+ }
+
+ public void testDefaultClassLoader() {
+ ClassLoader classLoader = ClassLoaderUtil.getClassLoader();
+ assertSame(ClassLoaderUtil.class.getClassLoader(), classLoader);
+ }
+
+ public void testJbpmClassLoader() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <string name='jbpm.class.loader' value='jbpm' /> "
+ + "</jbpm-configuration>");
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+
+ ClassLoader classLoader = ClassLoaderUtil.getClassLoader();
+ assertSame(ClassLoaderUtil.class.getClassLoader(), classLoader);
+
+ jbpmContext.close();
+ jbpmConfiguration.close();
+ }
+
+ public void testContextClassLoader() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <string name='jbpm.class.loader' value='context' /> "
+ + "</jbpm-configuration>");
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+
+ ClassLoader classLoader = ClassLoaderUtil.getClassLoader();
+ assertSame(Thread.currentThread().getContextClassLoader(), classLoader);
+
+ jbpmContext.close();
+ jbpmConfiguration.close();
+ }
+
+ public void testNonExistentClassLoader() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <string name='jbpm.class.loader' value='absent' /> "
+ + "</jbpm-configuration>");
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+
+ try {
+ ClassLoaderUtil.getClassLoader();
+ fail("expected " + JbpmException.class.getName());
+ }
+ catch (JbpmException ex) {
+ // fine, exception was expected
+ }
+
+ jbpmContext.close();
+ jbpmConfiguration.close();
+ }
+
+ public void testCustomClassLoader() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <string name='jbpm.class.loader' value='custom.class.loader' />"
+ + " <bean name='custom.class.loader' class='"
+ + CustomClassLoader.class.getName()
+ + "' /> "
+ + "</jbpm-configuration>");
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+
+ ClassLoader classLoader = ClassLoaderUtil.getClassLoader();
+ assertSame(CustomClassLoader.class, classLoader.getClass());
+
+ jbpmContext.close();
+ jbpmConfiguration.close();
+ }
+
+ public static class CustomClassLoader extends ClassLoader {
+
+ public CustomClassLoader() {
+ super(Thread.currentThread().getContextClassLoader());
+ }
+ }
+
+}
Deleted: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java 2009-05-07 10:14:21 UTC (rev 4758)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java 2009-05-07 13:21:23 UTC (rev 4759)
@@ -1,136 +0,0 @@
-/*
- * 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.instantiation;
-
-import org.jbpm.AbstractJbpmTestCase;
-import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmConfigurationTestHelper;
-import org.jbpm.JbpmContext;
-import org.jbpm.graph.def.ProcessDefinition;
-
-/**
- * {@link ProcessClassLoaderFactory} and class loader can be configured
- * via {@link JbpmConfiguration} / jbpm.cfg.xml. Test if that works.
- *
- * Introduced with https://jira.jboss.org/jira/browse/JBPM-1148
- *
- * @author bernd.ruecker(a)camunda.com
- */
-public class ConfigurableClassloadersTest extends AbstractJbpmTestCase {
-
- public void testDefaultBehavior() {
- JbpmConfiguration.getInstance();
- ClassLoader processClassLoader = JbpmConfiguration.getProcessClassLoader(null);
-
- assertNotNull(processClassLoader);
- assertEquals(ProcessClassLoader.class, processClassLoader.getClass());
- }
-
- public static class MyClassLoader extends ClassLoader {
- public MyClassLoader() {
- }
- public MyClassLoader(ClassLoader parent) {
- super(parent);
- }
- }
-
- public static class TestProcessClassLoaderFactory implements ProcessClassLoaderFactory {
- public ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
- return new MyClassLoader(Thread.currentThread().getContextClassLoader());
- }
- }
-
- public void testOwnProcessFactory() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context>" +
- " </jbpm-context>" +
- " <string name='jbpm.classLoader' value='jbpm' /> " +
- " <bean name='jbpm.processClassLoader' class='org.jbpm.instantiation.ConfigurableClassloadersTest$TestProcessClassLoaderFactory' singelton='true' />" +
- "</jbpm-configuration>"
- );
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
- ClassLoader processClassLoader = JbpmConfiguration.getProcessClassLoader(null);
- assertNotNull(processClassLoader);
- assertEquals(MyClassLoader.class, processClassLoader.getClass());
-
- jbpmContext.close();
- jbpmConfiguration.close();
- }
-
- public void testContextClassloaderFactory() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context>" +
- " </jbpm-context>" +
- " <string name='jbpm.classLoader' value='context' /> " +
- "</jbpm-configuration>"
- );
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
- assertNotNull(jbpmContext);
-
- jbpmContext.close();
- jbpmConfiguration.close();
- }
-
- public void testCustomClassloaderFactoryWithoutClassname() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context>" +
- " </jbpm-context>" +
- " <string name='jbpm.classLoader' value='custom' /> " +
- "</jbpm-configuration>"
- );
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- ClassLoader processClassLoader = JbpmConfiguration.getProcessClassLoader(null);
- fail("we should get an exception because custom class loader class not specified");
- }
- catch (Exception ex) {}
-
- jbpmContext.close();
- jbpmConfiguration.close();
- }
-
- public void testCustomClassloaderFactory() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context>" +
- " </jbpm-context>" +
- " <string name='jbpm.classLoader' value='custom' /> " +
- " <string name='jbpm.customClassLoader.className' value='org.jbpm.instantiation.ConfigurableClassloadersTest$MyClassLoader' />" +
- "</jbpm-configuration>"
- );
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
-
- ClassLoader processClassLoader = JbpmConfiguration.getProcessClassLoader(null);
- assertNotNull(processClassLoader);
- // not configured, must be default
- assertEquals(ProcessClassLoader.class, processClassLoader.getClass());
-
- jbpmContext.close();
- jbpmConfiguration.close();
- }
-
-}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java 2009-05-07 10:14:21 UTC (rev 4758)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java 2009-05-07 13:21:23 UTC (rev 4759)
@@ -7,16 +7,15 @@
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.instantiation.ConfigurableClassloadersTest;
+import org.jbpm.instantiation.ConfigurableClassLoadersTest;
import org.jbpm.instantiation.ProcessClassLoader;
import org.jbpm.util.ClassLoaderUtil;
/**
* Test case for ProcessClassLoader hierarchy and setting the ContextClassLoader correctly. Relates
- * to {@link ConfigurableClassloadersTest}.
+ * to {@link ConfigurableClassLoadersTest}.
*
- * @author Tom Baeyens
- * @author bernd.ruecker(a)camunda.com
+ * @author Tom Baeyens, bernd.ruecker(a)camunda.com
*/
public class ProcessClassLoaderTest extends AbstractJbpmTestCase {
@@ -26,14 +25,17 @@
super(parent);
}
+ protected synchronized Class loadClass(String name, boolean resolve)
+ throws ClassNotFoundException {
+ return super.loadClass(name, resolve);
+ }
+
+ public Class loadClass(String name) throws ClassNotFoundException {
+ return super.loadClass(name);
+ }
+
protected Class findClass(String name) throws ClassNotFoundException {
- if ("TestContextClassLoader-knows-where-to-find-ContextLoadedAction".equals(name)) {
- return getParent().loadClass(ContextLoadedAction.class.getName());
- }
- else if ("TestContextClassLoader-knows-where-to-find-ContextLoadedExceptionAction".equals(name)) {
- return getParent().loadClass(ContextLoadedExceptionAction.class.getName());
- }
- return null;
+ return super.findClass(name);
}
}
@@ -61,7 +63,7 @@
}
}
- /**
+ /*
* DOES NOT configure usage of the context classloader. So this tests the default (backwards
* compatible) behaviour. so the classloading hierarchy of DefaultLoadedAction should be
* ProcessClassloader -> jbpm-lib classloader
@@ -70,7 +72,9 @@
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ " <start-state name='start'>"
+ " <transition to='state'>"
- + " <action class='org.jbpm.jpdl.par.ProcessClassLoaderTest$DefaultLoadedAction' />"
+ + " <action class='"
+ + DefaultLoadedAction.class.getName()
+ + "' />"
+ " </transition>"
+ " </start-state>"
+ " <state name='state'>"
@@ -102,12 +106,13 @@
}
}
- /**
+ /*
* configures usage of the context classloader so the classloading hierarchy of
* ContextLoadedAction should be ProcessClassloader -> TestContextClassLoader ->
* Thread.currentContextClassLoader
*/
public void testContextClassLoader() {
+
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ " <string name='jbpm.classLoader' value='context' />"
+ "</jbpm-configuration>");
@@ -121,7 +126,9 @@
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ " <start-state name='start'>"
+ " <transition to='state'>"
- + " <action class='TestContextClassLoader-knows-where-to-find-ContextLoadedAction' />"
+ + " <action class='"
+ + ContextLoadedAction.class.getName()
+ + "' />"
+ " </transition>"
+ " </start-state>"
+ " <state name='state'>"
@@ -135,6 +142,7 @@
assertEquals(1, contextLoadedActionInvocations);
assertSame(testContextClassLoader, Thread.currentThread().getContextClassLoader());
+
}
finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
@@ -142,7 +150,7 @@
}
}
- /**
+ /*
* a third test should set the testcontextClassLoader in the test and then let the action throw an
* exception. Then it should be verified that the original classloader is still restored
* correctly. Easiest is to start from a copy of the testContextClassLoader
@@ -179,7 +187,9 @@
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ " <start-state name='start'>"
+ " <transition to='state'>"
- + " <action class='TestContextClassLoader-knows-where-to-find-ContextLoadedExceptionAction' />"
+ + " <action class='"
+ + ContextLoadedExceptionAction.class.getName()
+ + "' />"
+ " </transition>"
+ " </start-state>"
+ " <state name='state'>"
@@ -190,11 +200,13 @@
// create the process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
+
}
catch (Exception ex) {
assertEquals(1, contextLoadedActionInvocations);
assertEquals("simulate exception", ex.getMessage());
assertSame(testContextClassLoader, Thread.currentThread().getContextClassLoader());
+
}
finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
16 years, 12 months
JBoss JBPM SVN: r4758 - in jbpm4/trunk/modules: test-db/src/test/java/org/jbpm/test/history and 1 other directory.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-05-07 06:14:21 -0400 (Thu, 07 May 2009)
New Revision: 4758
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java
Log:
JBPM-2222 fixed stack overflow bug
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java 2009-05-07 09:52:13 UTC (rev 4757)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java 2009-05-07 10:14:21 UTC (rev 4758)
@@ -86,7 +86,7 @@
appendWhereClause(" hai.activityName = '"+activityName+"'", hql);
}
- return hql().toString();
+ return hql.toString();
}
protected void applyParameters(Query query) {
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java 2009-05-07 10:14:21 UTC (rev 4758)
@@ -0,0 +1,87 @@
+/*
+ * 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.history;
+
+import java.util.List;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryActivityInstance;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryActivityInstanceQeuryTest extends JbpmTestCase {
+
+ public void testSimpleQuery() {
+ deployJpdlXmlString(
+ "<process name='abc'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition to ='b' />" +
+ " </state>" +
+ " <state name='b'>" +
+ " <transition to ='c' />" +
+ " </state>" +
+ " <state name='c'>" +
+ " <transition to ='end' />" +
+ " </state>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("abc");
+ executionService.signalExecutionById(processInstance.getId());
+ executionService.signalExecutionById(processInstance.getId());
+ executionService.signalExecutionById(processInstance.getId());
+
+ processInstance = executionService.startProcessInstanceByKey("abc");
+ executionService.signalExecutionById(processInstance.getId());
+ executionService.signalExecutionById(processInstance.getId());
+
+ processInstance = executionService.startProcessInstanceByKey("abc");
+ executionService.signalExecutionById(processInstance.getId());
+
+ executionService.startProcessInstanceByKey("abc");
+
+ List<HistoryActivityInstance> histActInsts = historyService.createHistoryActivityInstanceQuery()
+ .activityName("a")
+ .list();
+
+ assertEquals(4, histActInsts.size());
+
+ histActInsts = historyService.createHistoryActivityInstanceQuery()
+ .activityName("b")
+ .list();
+
+ assertEquals(3, histActInsts.size());
+
+ histActInsts = historyService.createHistoryActivityInstanceQuery()
+ .activityName("c")
+ .list();
+
+ assertEquals(2, histActInsts.size());
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 12 months
JBoss JBPM SVN: r4757 - jbpm4/branches/idm/modules/distro/src/main/files/jboss.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-05-07 05:52:13 -0400 (Thu, 07 May 2009)
New Revision: 4757
Modified:
jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml
Log:
added identity.component property in build script
Modified: jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml
===================================================================
--- jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml 2009-05-07 09:06:35 UTC (rev 4756)
+++ jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml 2009-05-07 09:52:13 UTC (rev 4757)
@@ -11,6 +11,7 @@
<!-- DEFAULT PROPERTY VALUES -->
<property name="database" value="hsqldb" />
+ <property name="identity.component" value="jbpm-built-in" />
<property name="jbpm.version" value="4.0.0-SNAPSHOT" />
<property name="jbpm.parent.dir" value="../.." />
<property name="jbpm.home" value="${jbpm.parent.dir}/jbpm-${jbpm.version}" /> <!-- jbpm.home should not be configured. change jbpm.parent.dir instead -->
@@ -28,6 +29,7 @@
<!-- ### LOG PROPERTIES ################################################# -->
<target name="log.properties">
<echo message="database.................... ${database}" />
+ <echo message="identity.component.......... ${identity.component}" />
<echo message="jbpm.home................... ${jbpm.home}" />
<echo message="jboss.version............... ${jboss.version}" />
<echo message="jboss.filename.............. ${jboss.filename}" />
16 years, 12 months
JBoss JBPM SVN: r4756 - in projects/gwt-console/trunk: gui/war/src/main/java/org/jboss/bpm/console/client/icons and 4 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-05-07 05:06:35 -0400 (Thu, 07 May 2009)
New Revision: 4756
Added:
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/common/AbstractView.java
Modified:
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/ConsoleIconBundle.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/DefinitionListView.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/ProcessEditor.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/AbstractTaskList.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/AssignedTasksView.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/OpenTasksView.java
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/TaskEditor.java
projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/MenuSection.java
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/InfoFacade.java
Log:
Pimp up image bundle. Added editor icons
Added: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/common/AbstractView.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/common/AbstractView.java (rev 0)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/common/AbstractView.java 2009-05-07 09:06:35 UTC (rev 4756)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jboss.bpm.console.client.common;
+
+import com.mvc4g.client.ViewInterface;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.HTML;
+import org.gwt.mosaic.ui.client.layout.LayoutPanel;
+import org.jboss.bpm.console.client.LazyPanel;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public abstract class AbstractView extends LayoutPanel
+ implements ViewInterface, LazyPanel
+{
+ private AbstractImagePrototype icon;
+
+ protected AbstractView()
+ {
+ }
+
+ protected AbstractImagePrototype getIcon()
+ {
+ return icon;
+ }
+
+ protected void setIcon(AbstractImagePrototype icon)
+ {
+ this.icon = icon;
+ }
+
+ public String getIconTitle()
+ {
+ HTML html = new HTML(
+ (icon != null ? (icon.getHTML() + " ")
+ : (""))
+ + this.getTitle());
+
+ return html.toString();
+ }
+}
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/ConsoleIconBundle.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/ConsoleIconBundle.java 2009-05-07 09:03:27 UTC (rev 4755)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/icons/ConsoleIconBundle.java 2009-05-07 09:06:35 UTC (rev 4756)
@@ -27,11 +27,16 @@
public interface ConsoleIconBundle extends ImageBundle
{
/**
- * @gwt.resource processIcon.png
+ * @gwt.resource processIcon.png
*/
AbstractImagePrototype processIcon();
/**
+ * @gwt.resource play.png
+ */
+ AbstractImagePrototype instanceIcon();
+
+ /**
* Would bundle the file 'open-file-icon.gif' residing in the same package as this type.
* @gwt.resource open-file-icon.gif
@@ -45,7 +50,7 @@
*/
/**
- * @gwt.resource docIcon.png
+ * @gwt.resource toolsIcon.png
*/
AbstractImagePrototype settingsIcon();
@@ -53,4 +58,9 @@
* @gwt.resource taskIcon.png
*/
AbstractImagePrototype taskIcon();
+
+ /**
+ * @gwt.resource userIcon.png
+ */
+ AbstractImagePrototype userIcon();
}
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/DefinitionListView.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/DefinitionListView.java 2009-05-07 09:03:27 UTC (rev 4755)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/DefinitionListView.java 2009-05-07 09:06:35 UTC (rev 4756)
@@ -24,6 +24,7 @@
import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.core.client.GWT;
import com.mvc4g.client.Controller;
import com.mvc4g.client.Event;
import com.mvc4g.client.ViewInterface;
@@ -36,14 +37,15 @@
import org.gwt.mosaic.ui.client.list.DefaultListModel;
import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
import org.jboss.bpm.console.client.LazyPanel;
+import org.jboss.bpm.console.client.icons.ConsoleIconBundle;
+import org.jboss.bpm.console.client.common.AbstractView;
import java.util.List;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
-class DefinitionListView extends LayoutPanel
- implements ViewInterface, LazyPanel
+class DefinitionListView extends AbstractView
{
public final static String ID = DefinitionListView.class.getName();
@@ -58,7 +60,9 @@
public DefinitionListView()
{
super();
+ ConsoleIconBundle icons = GWT.create(ConsoleIconBundle.class);
setTitle("Process Definitions");
+ setIcon(icons.processIcon());
}
public boolean isInitialized()
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java 2009-05-07 09:03:27 UTC (rev 4755)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java 2009-05-07 09:06:35 UTC (rev 4756)
@@ -23,6 +23,7 @@
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.core.client.GWT;
import com.mvc4g.client.Controller;
import com.mvc4g.client.ViewInterface;
import com.mvc4g.client.Event;
@@ -37,14 +38,15 @@
import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
import org.jboss.bpm.console.client.model.ProcessInstanceRef;
import org.jboss.bpm.console.client.LazyPanel;
+import org.jboss.bpm.console.client.icons.ConsoleIconBundle;
+import org.jboss.bpm.console.client.common.AbstractView;
import java.util.List;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
-class InstanceListView extends LayoutPanel
- implements ViewInterface, LazyPanel
+class InstanceListView extends AbstractView
{
public final static String ID = InstanceListView.class.getName();
@@ -63,8 +65,9 @@
public InstanceListView()
{
super();
+ ConsoleIconBundle icons = GWT.create(ConsoleIconBundle.class);
setTitle("Process Instances");
-
+ setIcon(icons.instanceIcon());
}
public boolean isInitialized()
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/ProcessEditor.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/ProcessEditor.java 2009-05-07 09:03:27 UTC (rev 4755)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/ProcessEditor.java 2009-05-07 09:06:35 UTC (rev 4756)
@@ -37,6 +37,7 @@
import org.jboss.bpm.console.client.Editor;
import org.jboss.bpm.console.client.MenuSection;
import org.jboss.bpm.console.client.LazyPanel;
+import org.jboss.bpm.console.client.common.AbstractView;
import org.jboss.bpm.console.client.icons.ConsoleIconBundle;
/**
@@ -119,13 +120,13 @@
}
}
- private void registerView(String id, Widget view)
+ private void registerView(String id, AbstractView view)
{
// register view with controller
- super.controller.addView(id, (ViewInterface)view);
+ super.controller.addView(id, view);
// add to tab layout
- this.tabPanel.add(view, view.getTitle());
+ this.tabPanel.add(view, view.getIconTitle(), true);
}
private void registerAction(String name, ActionInterface action)
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/AbstractTaskList.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/AbstractTaskList.java 2009-05-07 09:03:27 UTC (rev 4755)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/AbstractTaskList.java 2009-05-07 09:06:35 UTC (rev 4756)
@@ -25,6 +25,7 @@
import org.gwt.mosaic.ui.client.list.DefaultListModel;
import org.gwt.mosaic.ui.client.ListBox;
import org.jboss.bpm.console.client.LazyPanel;
+import org.jboss.bpm.console.client.common.AbstractView;
import org.jboss.bpm.console.client.model.TaskRef;
import com.mvc4g.client.ViewInterface;
import com.mvc4g.client.Controller;
@@ -36,8 +37,7 @@
*
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
-public abstract class AbstractTaskList extends LayoutPanel
- implements ViewInterface, LazyPanel
+public abstract class AbstractTaskList extends AbstractView
{
protected Controller controller;
protected LayoutPanel taskList = null;
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/AssignedTasksView.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/AssignedTasksView.java 2009-05-07 09:03:27 UTC (rev 4755)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/AssignedTasksView.java 2009-05-07 09:06:35 UTC (rev 4756)
@@ -27,6 +27,7 @@
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Frame;
import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.core.client.GWT;
import com.mvc4g.client.Event;
import org.gwt.mosaic.ui.client.*;
import org.gwt.mosaic.ui.client.layout.BoxLayout;
@@ -34,6 +35,7 @@
import org.gwt.mosaic.ui.client.layout.LayoutPanel;
import org.gwt.mosaic.ui.client.list.DefaultListModel;
import org.jboss.bpm.console.client.ApplicationContext;
+import org.jboss.bpm.console.client.icons.ConsoleIconBundle;
import org.jboss.bpm.console.client.model.TaskRef;
import org.jboss.bpm.console.client.task.events.TaskIdentityEvent;
import org.jboss.bpm.console.client.util.WindowUtil;
@@ -56,7 +58,9 @@
{
super();
this.appContext = appContext;
+ ConsoleIconBundle icons = GWT.create(ConsoleIconBundle.class);
setTitle("Your Tasks");
+ setIcon(icons.userIcon());
}
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/OpenTasksView.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/OpenTasksView.java 2009-05-07 09:03:27 UTC (rev 4755)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/OpenTasksView.java 2009-05-07 09:06:35 UTC (rev 4756)
@@ -21,6 +21,7 @@
*/
package org.jboss.bpm.console.client.task;
+import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;
import com.mvc4g.client.Event;
@@ -32,6 +33,7 @@
import org.gwt.mosaic.ui.client.layout.BoxLayoutData;
import org.gwt.mosaic.ui.client.layout.LayoutPanel;
import org.gwt.mosaic.ui.client.list.DefaultListModel;
+import org.jboss.bpm.console.client.icons.ConsoleIconBundle;
import org.jboss.bpm.console.client.model.TaskRef;
import org.jboss.bpm.console.client.task.events.TaskIdentityEvent;
@@ -48,7 +50,9 @@
public OpenTasksView()
{
super();
+ ConsoleIconBundle icons = GWT.create(ConsoleIconBundle.class);
setTitle("Open Tasks");
+ setIcon(icons.taskIcon());
}
public void initialize()
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/TaskEditor.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/TaskEditor.java 2009-05-07 09:03:27 UTC (rev 4755)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/TaskEditor.java 2009-05-07 09:06:35 UTC (rev 4756)
@@ -21,11 +21,9 @@
*/
package org.jboss.bpm.console.client.task;
+import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.SourcesTabEvents;
import com.google.gwt.user.client.ui.TabListener;
-import com.google.gwt.user.client.ui.Widget;
-import com.google.gwt.core.client.GWT;
-import com.mvc4g.client.ViewInterface;
import com.mvc4g.client.ActionInterface;
import com.mvc4g.client.Event;
import org.gwt.mosaic.ui.client.DecoratedTabLayoutPanel;
@@ -34,8 +32,9 @@
import org.gwt.mosaic.ui.client.layout.BorderLayoutData;
import org.jboss.bpm.console.client.ApplicationContext;
import org.jboss.bpm.console.client.Editor;
-import org.jboss.bpm.console.client.MenuSection;
import org.jboss.bpm.console.client.LazyPanel;
+import org.jboss.bpm.console.client.MenuSection;
+import org.jboss.bpm.console.client.common.AbstractView;
import org.jboss.bpm.console.client.icons.ConsoleIconBundle;
/**
@@ -104,13 +103,13 @@
}
}
- private void registerView(String id, Widget view)
+ private void registerView(String id, AbstractView view)
{
// register view with controller
- super.controller.addView(id, (ViewInterface)view);
+ super.controller.addView(id, view);
// add to tab layout
- this.tabPanel.add(view, view.getTitle());
+ this.tabPanel.add(view, view.getIconTitle(), true);
}
private void registerAction(String name, ActionInterface action)
Modified: projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/MenuSection.java
===================================================================
--- projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/MenuSection.java 2009-05-07 09:03:27 UTC (rev 4755)
+++ projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/MenuSection.java 2009-05-07 09:06:35 UTC (rev 4756)
@@ -42,7 +42,7 @@
super();
this.menuTitle = new HTML(
- (icon != null ? (icon.getHTML() + " ")
+ (icon != null ? (icon.getHTML() + " ")
: (""))
+ title);
Modified: projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/InfoFacade.java
===================================================================
--- projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/InfoFacade.java 2009-05-07 09:03:27 UTC (rev 4755)
+++ projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/InfoFacade.java 2009-05-07 09:06:35 UTC (rev 4756)
@@ -44,21 +44,31 @@
private Class[] pluginInterfaces = {TaskDispatcherPlugin.class};
+ private ServerStatus status = null;
+
@GET
@Path("status")
@Produces("application/json")
public Response getServerInfo()
{
- ServerStatus status = new ServerStatus();
- for(Class type : pluginInterfaces)
+ ServerStatus status = getServerStatus();
+ return createJsonResponse(status);
+ }
+
+ private ServerStatus getServerStatus()
+ {
+ if(null==this.status) // expensive to create
{
- Object impl = PluginMgr.load(type);
- boolean isAvailable = (impl!=null);
+ this.status = new ServerStatus();
+ for(Class type : pluginInterfaces)
+ {
+ Object impl = PluginMgr.load(type);
+ boolean isAvailable = (impl!=null);
- status.getPlugins().add(new PluginInfo(type.getName(), isAvailable));
+ status.getPlugins().add(new PluginInfo(type.getName(), isAvailable));
+ }
}
-
- return createJsonResponse(status);
+ return status;
}
private Response createJsonResponse(Object wrapper)
16 years, 12 months