JBoss JBPM SVN: r6121 - in projects/businesslink: src/test/java/org/jbpm/businesslink and 1 other directory.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2010-01-22 06:50:49 -0500 (Fri, 22 Jan 2010)
New Revision: 6121
Modified:
projects/businesslink/.classpath
projects/businesslink/pom.xml
projects/businesslink/src/test/java/org/jbpm/businesslink/BusinessLinkTest.java
Log:
adding persistence
Modified: projects/businesslink/.classpath
===================================================================
--- projects/businesslink/.classpath 2010-01-22 11:50:24 UTC (rev 6120)
+++ projects/businesslink/.classpath 2010-01-22 11:50:49 UTC (rev 6121)
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="src" path="src/test/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
Modified: projects/businesslink/pom.xml
===================================================================
--- projects/businesslink/pom.xml 2010-01-22 11:50:24 UTC (rev 6120)
+++ projects/businesslink/pom.xml 2010-01-22 11:50:49 UTC (rev 6121)
@@ -30,54 +30,37 @@
<properties>
<hibernate.version>3.3.1.GA</hibernate.version>
- <junit.version>3.8.2</junit.version>
- </properties>
-<!--
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <apache.ant.version>1.7.0</apache.ant.version>
- <beanshell.version>2.0b5</beanshell.version>
- <groovy.version>1.5.6</groovy.version>
- <cactus.version>1.8.1</cactus.version>
- <drools.version>5.0.1</drools.version>
- <aspectjrt.version>1.5.3</aspectjrt.version>
- <freemarker.version>2.3.15</freemarker.version>
- <gwt.console.version>1.3.0</gwt.console.version>
- <jbpm.gpd.version>4.3-SNAPSHOT</jbpm.gpd.version>
- <slf4j.version>1.5.2</slf4j.version>
<hsqldb.version>1.8.0.7</hsqldb.version>
- <jboss.identity.version>1.0.0.Beta1</jboss.identity.version>
- <jboss.j2ee.version>4.2.2.GA</jboss.j2ee.version>
- <jboss.client.version>5.0.1.GA</jboss.client.version>
- <jsr233.version>2.0.5</jsr233.version>
- <juel.version>2.1.0</juel.version>
<junit.version>3.8.2</junit.version>
- <log4j.version>1.2.14</log4j.version>
- <mail.version>1.4.1</mail.version>
- <report.engine.version>2.3.2</report.engine.version>
- <servlet-api.version>2.5</servlet-api.version>
- <signavio.jbpmeditor.version>1.1</signavio.jbpmeditor.version>
- <spring.version>2.0.8</spring.version>
- <stax.api.version>1.0.1</stax.api.version>
- <wiser.version>1.2</wiser.version>
- <woodstox.version>3.2.6</woodstox.version>
- <hsqldb.version>1.8.0.7</hsqldb.version>
- <mysql.connector.version>5.0.8</mysql.connector.version>
- <postgresql.version>8.3-603.jdbc3</postgresql.version>
- <jtds.version>1.2.2</jtds.version>
- <oracle.version>10.2.0.4</oracle.version>
- -->
+ <slf4j.version>1.5.2</slf4j.version>
+ </properties>
<dependencies>
<dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${hibernate.version}</version>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>${hsqldb.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${hibernate.version}</version>
+ </dependency>
+ <dependency> <!-- added for hibernate -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency> <!-- added for hibernate -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
</dependencies>
<scm>
Modified: projects/businesslink/src/test/java/org/jbpm/businesslink/BusinessLinkTest.java
===================================================================
--- projects/businesslink/src/test/java/org/jbpm/businesslink/BusinessLinkTest.java 2010-01-22 11:50:24 UTC (rev 6120)
+++ projects/businesslink/src/test/java/org/jbpm/businesslink/BusinessLinkTest.java 2010-01-22 11:50:49 UTC (rev 6121)
@@ -21,8 +21,9 @@
import junit.framework.TestCase;
import org.jbpm.businesslink.api.Artifact;
-import org.jbpm.businesslink.internal.BusinessLinkServiceImpl;
-import org.jbpm.businesslink.internal.file.FileRepository;
+import org.jbpm.businesslink.test.BusinessLinkConfiguration;
+import org.jbpm.businesslink.test.BusinessLinkSessionFactory;
+import org.jbpm.businesslink.test.TestBusinessLinkSession;
/**
* @author Tom Baeyens
@@ -33,36 +34,53 @@
private static String testSourcesPath = getTestSourcesPath();
+ protected static BusinessLinkSessionFactory businessLinkSessionFactory = new BusinessLinkConfiguration()
+ .hibernateCfgResource("hibernate.cfg.xml")
+ .fileRepository("test-sources", testSourcesPath)
+ .buildBusinessLinkSessionFactory();
+
+ protected TestBusinessLinkSession session;
+
public void testJavaFile() throws Exception {
- BusinessLinkServiceImpl greenLightService = new BusinessLinkServiceImpl();
- greenLightService.addRepository(new FileRepository("test-sources", testSourcesPath));
-
- List<Artifact> artifacts = greenLightService.getArtifacts("test-sources/org/jbpm/businesslink");
+ session = businessLinkSessionFactory.openSession();
+ List<Artifact> artifacts = session.getArtifacts("test-sources/org/jbpm/businesslink");
+ session.commit();
+
assertNotNull(artifacts);
assertFalse(artifacts.isEmpty());
Artifact artifact = artifacts.get(0);
+ assertEquals(".svn", artifact.getName());
+ assertEquals(Artifact.ARTIFACTTYPE_DIRECTORY, artifact.getType());
+ assertEquals("test-sources/org/jbpm/businesslink/.svn", artifact.getPath());
+
+ artifact = artifacts.get(1);
assertEquals("BusinessLinkTest.java", artifact.getName());
assertEquals(".java", artifact.getType());
assertEquals("test-sources/org/jbpm/businesslink/BusinessLinkTest.java", artifact.getPath());
- assertEquals(1, artifacts.size());
+ assertEquals(2, artifacts.size());
}
public void testDirectory() throws Exception {
- BusinessLinkServiceImpl greenLightService = new BusinessLinkServiceImpl();
- greenLightService.addRepository(new FileRepository("test-sources", testSourcesPath));
+ session = businessLinkSessionFactory.openSession();
+ List<Artifact> artifacts = session.getArtifacts("test-sources/org/jbpm");
+ session.commit();
- List<Artifact> artifacts = greenLightService.getArtifacts("test-sources/org/jbpm");
assertNotNull(artifacts);
assertFalse(artifacts.isEmpty());
Artifact artifact = artifacts.get(0);
+ assertEquals(".svn", artifact.getName());
+ assertEquals(Artifact.ARTIFACTTYPE_DIRECTORY, artifact.getType());
+ assertEquals("test-sources/org/jbpm/.svn", artifact.getPath());
+
+ artifact = artifacts.get(1);
assertEquals("businesslink", artifact.getName());
assertEquals(Artifact.ARTIFACTTYPE_DIRECTORY, artifact.getType());
assertEquals("test-sources/org/jbpm/businesslink", artifact.getPath());
- assertEquals(1, artifacts.size());
+ assertEquals(2, artifacts.size());
}
private static String getTestSourcesPath() {
14 years, 4 months
JBoss JBPM SVN: r6120 - in projects/businesslink/src: main/java/org/jbpm/businesslink/internal/svc and 3 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2010-01-22 06:50:24 -0500 (Fri, 22 Jan 2010)
New Revision: 6120
Added:
projects/businesslink/src/main/java/org/jbpm/businesslink/internal/svc/BusinessLinkSessionImpl.java
projects/businesslink/src/main/resources/
projects/businesslink/src/main/resources/jbpm.businesslink.cfg.xml
projects/businesslink/src/test/resources/
projects/businesslink/src/test/resources/hibernate.cfg.xml
projects/businesslink/src/test/resources/logging.properties
Log:
adding persistence
Added: projects/businesslink/src/main/java/org/jbpm/businesslink/internal/svc/BusinessLinkSessionImpl.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/internal/svc/BusinessLinkSessionImpl.java (rev 0)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/internal/svc/BusinessLinkSessionImpl.java 2010-01-22 11:50:24 UTC (rev 6120)
@@ -0,0 +1,78 @@
+/*
+ * 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.businesslink.internal.svc;
+
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.Session;
+import org.jbpm.businesslink.api.Artifact;
+import org.jbpm.businesslink.api.BusinessLinkSession;
+import org.jbpm.businesslink.api.Link;
+import org.jbpm.businesslink.internal.spi.Repository;
+import org.jbpm.businesslink.test.BusinessLinkSessionFactory;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BusinessLinkSessionImpl implements BusinessLinkSession {
+
+ protected Map<String, Repository> repositories;
+ protected Session session;
+
+ public BusinessLinkSessionImpl(){
+ }
+
+ public BusinessLinkSessionImpl(BusinessLinkSessionFactory businessLinkSessionFactory) {
+ this.repositories = businessLinkSessionFactory.getRepositories();
+ this.session = businessLinkSessionFactory.getSessionFactory().openSession();
+ }
+
+ public List<Artifact> getArtifacts(String directoryPath) {
+ int slashIndex = directoryPath.indexOf('/');
+ if (slashIndex==-1) {
+ throw new RuntimeException("invalid directory path: no slash: "+directoryPath);
+ }
+ String repositoryName = directoryPath.substring(0, slashIndex);
+ Repository repository = repositories.get(repositoryName);
+
+ String repoPath = directoryPath.substring(slashIndex+1);
+ return repository.getArtifacts(repoPath);
+ }
+
+
+ public Link createLink(String artifactA, String artifactB) {
+ return null;
+ }
+
+ public Link deleteLink(Link link) {
+ return null;
+ }
+
+ public List<Link> getLinks(String path) {
+ return null;
+ }
+
+ public void updateLink(Link link) {
+ }
+}
Property changes on: projects/businesslink/src/main/java/org/jbpm/businesslink/internal/svc/BusinessLinkSessionImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/businesslink/src/main/resources/jbpm.businesslink.cfg.xml
===================================================================
--- projects/businesslink/src/main/resources/jbpm.businesslink.cfg.xml (rev 0)
+++ projects/businesslink/src/main/resources/jbpm.businesslink.cfg.xml 2010-01-22 11:50:24 UTC (rev 6120)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <process-engine-context>
+
+ <object class="org.jbpm.businesslink.internal.svc.BusinessLinkServiceImpl">
+ <field name="commandService"><ref type="org.jbpm.pvm.internal.cmd.CommandService" /></field>
+ <invoke method="addRepository">
+ <arg>
+ <object class="org.jbpm.businesslink.internal.file.FileRepository">
+ <constructor>
+ <arg><string value="test-sources" /></arg>
+ <arg><string value="src/test/java" /></arg>
+ </constructor>
+ </object>
+ </arg>
+ </invoke>
+ </object>
+
+ </process-engine-context>
+
+</jbpm-configuration>
Property changes on: projects/businesslink/src/main/resources/jbpm.businesslink.cfg.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/businesslink/src/test/resources/hibernate.cfg.xml
===================================================================
--- projects/businesslink/src/test/resources/hibernate.cfg.xml (rev 0)
+++ projects/businesslink/src/test/resources/hibernate.cfg.xml 2010-01-22 11:50:24 UTC (rev 6120)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+ <property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
+ <property name="hibernate.connection.username">sa</property>
+ <property name="hibernate.connection.password"></property>
+ <property name="hibernate.hbm2ddl.auto">create-drop</property>
+ <property name="hibernate.format_sql">true</property>
+
+ </session-factory>
+</hibernate-configuration>
Property changes on: projects/businesslink/src/test/resources/hibernate.cfg.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/businesslink/src/test/resources/logging.properties
===================================================================
--- projects/businesslink/src/test/resources/logging.properties (rev 0)
+++ projects/businesslink/src/test/resources/logging.properties 2010-01-22 11:50:24 UTC (rev 6120)
@@ -0,0 +1,18 @@
+handlers= java.util.logging.ConsoleHandler
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.businesslink.internal.log.LogFormatter
+
+org.jbpm.level=FINE
+# org.jbpm.pvm.internal.tx.level=FINE
+# org.jbpm.pvm.internal.wire.level=FINE
+# org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=INFO
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+org.hibernate.cfg.HbmBinder.level=SEVERE
+org.hibernate.SQL.level=FINEST
+org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST
\ No newline at end of file
Property changes on: projects/businesslink/src/test/resources/logging.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 4 months
JBoss JBPM SVN: r6119 - in projects/businesslink/src/main/java/org/jbpm/businesslink: api and 4 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2010-01-22 06:50:00 -0500 (Fri, 22 Jan 2010)
New Revision: 6119
Added:
projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkSession.java
projects/businesslink/src/main/java/org/jbpm/businesslink/internal/log/
projects/businesslink/src/main/java/org/jbpm/businesslink/internal/log/LogFormatter.java
projects/businesslink/src/main/java/org/jbpm/businesslink/internal/svc/
projects/businesslink/src/main/java/org/jbpm/businesslink/test/
projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkConfiguration.java
projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkSessionFactory.java
projects/businesslink/src/main/java/org/jbpm/businesslink/test/TestBusinessLinkSession.java
Removed:
projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkService.java
projects/businesslink/src/main/java/org/jbpm/businesslink/internal/BusinessLinkServiceImpl.java
Modified:
projects/businesslink/src/main/java/org/jbpm/businesslink/internal/file/FileArtifact.java
Log:
adding persistence
Deleted: projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkService.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkService.java 2010-01-22 10:39:47 UTC (rev 6118)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkService.java 2010-01-22 11:50:00 UTC (rev 6119)
@@ -1,45 +0,0 @@
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jbpm.businesslink.api;
-
-import java.util.List;
-
-
-/** central service access to greenlight facilities.
- *
- * authenticated user is assumed to be accessible by the service implementation.
- *
- * @author Tom Baeyens
- */
-public interface BusinessLinkService {
-
- List<Artifact> getArtifacts(String directoryPath);
-
- List<Link> getLinks(String path);
- Link createLink(String artifactA, String artifactB);
- void updateLink(Link link);
- Link deleteLink(Link link);
-
-// List<Comment> getComments(String path);
-// void createComment(String path, String text);
-// void updateComment(Comment comment);
-// void deleteComment(Comment comment);
-//
-// Watch createWatch(String path);
-// List<Watch> getWatchers(String path);
-// void updateWatch(Watch watch);
-// void deleteWatch(Watch watch);
-}
Added: projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkSession.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkSession.java (rev 0)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkSession.java 2010-01-22 11:50:00 UTC (rev 6119)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jbpm.businesslink.api;
+
+import java.util.List;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface BusinessLinkSession {
+
+ List<Artifact> getArtifacts(String directoryPath);
+
+ List<Link> getLinks(String path);
+ Link createLink(String artifactA, String artifactB);
+ void updateLink(Link link);
+ Link deleteLink(Link link);
+
+// List<Comment> getComments(String path);
+// void createComment(String path, String text);
+// void updateComment(Comment comment);
+// void deleteComment(Comment comment);
+//
+// Watch createWatch(String path);
+// List<Watch> getWatchers(String path);
+// void updateWatch(Watch watch);
+// void deleteWatch(Watch watch);
+
+}
Property changes on: projects/businesslink/src/main/java/org/jbpm/businesslink/api/BusinessLinkSession.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: projects/businesslink/src/main/java/org/jbpm/businesslink/internal/BusinessLinkServiceImpl.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/internal/BusinessLinkServiceImpl.java 2010-01-22 10:39:47 UTC (rev 6118)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/internal/BusinessLinkServiceImpl.java 2010-01-22 11:50:00 UTC (rev 6119)
@@ -1,66 +0,0 @@
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jbpm.businesslink.internal;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.businesslink.api.Artifact;
-import org.jbpm.businesslink.api.BusinessLinkService;
-import org.jbpm.businesslink.api.Link;
-import org.jbpm.businesslink.internal.spi.Repository;
-
-
-/**
- * @author Tom Baeyens
- */
-public class BusinessLinkServiceImpl implements BusinessLinkService {
-
- Map<String, Repository> repositories = new HashMap<String, Repository>();
-
- public void addRepository(Repository repository) {
- repositories.put(repository.getName(), repository);
- }
-
- public List<Artifact> getArtifacts(String directoryPath) {
- int slashIndex = directoryPath.indexOf('/');
- if (slashIndex==-1) {
- throw new RuntimeException("invalid directory path: no slash: "+directoryPath);
- }
- String repositoryName = directoryPath.substring(0, slashIndex);
- Repository repository = repositories.get(repositoryName);
-
- String repoPath = directoryPath.substring(slashIndex+1);
- return repository.getArtifacts(repoPath);
- }
-
-
- public Link createLink(String artifactA, String artifactB) {
- return null;
- }
-
- public Link deleteLink(Link link) {
- return null;
- }
-
- public List<Link> getLinks(String path) {
- return null;
- }
-
- public void updateLink(Link link) {
- }
-}
Modified: projects/businesslink/src/main/java/org/jbpm/businesslink/internal/file/FileArtifact.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/internal/file/FileArtifact.java 2010-01-22 10:39:47 UTC (rev 6118)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/internal/file/FileArtifact.java 2010-01-22 11:50:00 UTC (rev 6119)
@@ -40,7 +40,7 @@
}
public String getPath() {
- return fileRepository.name+'/'+path;
+ return fileRepository.getName()+'/'+path;
}
public String getType() {
Added: projects/businesslink/src/main/java/org/jbpm/businesslink/internal/log/LogFormatter.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/internal/log/LogFormatter.java (rev 0)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/internal/log/LogFormatter.java 2010-01-22 11:50:00 UTC (rev 6119)
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jbpm.businesslink.internal.log;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Formatter;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+public class LogFormatter extends Formatter {
+
+ static final String NEWLINE = System.getProperty("line.separator");
+ static final DateFormat dateTimeFormat = new SimpleDateFormat("HH:mm:ss,SSS");
+ static final Map<Level, String> levels = new HashMap<Level, String>();
+ private static Map<Integer, Integer> indentations = new HashMap<Integer, Integer>();
+
+
+ static {
+ levels.put(Level.ALL, "ALL");
+ levels.put(Level.CONFIG, "CFG");
+ levels.put(Level.FINE, "FIN");
+ levels.put(Level.FINER, "FNR");
+ levels.put(Level.FINEST, "FST");
+ levels.put(Level.INFO, "INF");
+ levels.put(Level.OFF, "OFF");
+ levels.put(Level.SEVERE, "SEV");
+ levels.put(Level.WARNING, "WRN");
+ }
+
+ public String format(LogRecord logRecord) {
+ StringWriter msg = new StringWriter();
+ if (logRecord.getThrown()!=null) {
+ msg.append("### EXCEPTION ###########################################");
+ msg.append(NEWLINE);
+ }
+ msg.append(dateTimeFormat.format(new Date()));
+ msg.append(" ");
+ msg.append(levels.get(logRecord.getLevel()));
+ msg.append(" ");
+
+ int threadId = logRecord.getThreadID();
+ for (int i=0; i<getIndentation(threadId); i++) {
+ msg.append(" ");
+ }
+
+ msg.append("| [");
+
+ String loggerName = logRecord.getLoggerName();
+ int dotIndex = loggerName.lastIndexOf('.');
+ if (dotIndex!=-1) {
+ loggerName = loggerName.substring(dotIndex+1);
+ }
+ msg.append(loggerName);
+
+ msg.append("] ");
+
+ msg.append(logRecord.getMessage());
+ if (logRecord.getThrown()!=null) {
+ msg.append(NEWLINE);
+ logRecord.getThrown().printStackTrace(new PrintWriter(msg));
+ msg.append("### EXCEPTION ###########################################");
+ }
+ msg.append(NEWLINE);
+ return msg.toString();
+ }
+
+ private int getIndentation(int threadId) {
+ Integer indentation = indentations.get(threadId);
+ if (indentation==null) {
+ indentation = indentations.size();
+ indentations.put(threadId, indentation);
+ }
+ return indentation;
+ }
+
+ public static void resetIndentation() {
+ indentations = new HashMap<Integer, Integer>();
+ }
+}
Property changes on: projects/businesslink/src/main/java/org/jbpm/businesslink/internal/log/LogFormatter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkConfiguration.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkConfiguration.java (rev 0)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkConfiguration.java 2010-01-22 11:50:00 UTC (rev 6119)
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jbpm.businesslink.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.LogManager;
+
+import org.hibernate.cfg.Configuration;
+import org.jbpm.businesslink.internal.file.FileRepository;
+import org.jbpm.businesslink.internal.spi.Repository;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BusinessLinkConfiguration {
+
+ static {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ InputStream inputStream = classLoader.getResourceAsStream("logging.properties");
+ try {
+ if (inputStream != null) {
+ LogManager.getLogManager().readConfiguration(inputStream);
+
+ String redirectCommons = LogManager.getLogManager().getProperty("redirect.commons.logging");
+ if ( (redirectCommons!=null)
+ && (! redirectCommons.equalsIgnoreCase("disabled"))
+ && (! redirectCommons.equalsIgnoreCase("off"))
+ && (! redirectCommons.equalsIgnoreCase("false"))
+ ) {
+ System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger" );
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("couldn't initialize logging properly", e);
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ Map<String, Repository> repositories = new HashMap<String, Repository>();
+ Configuration hibernateConfiguration = new Configuration();
+
+ public BusinessLinkConfiguration fileRepository(String name, String rootPath) {
+ addRepository(new FileRepository(name, rootPath));
+ return this;
+ }
+
+ public BusinessLinkConfiguration hibernateCfgResource(String hibernateCfgResource) {
+ hibernateConfiguration.configure(hibernateCfgResource);
+ return this;
+ }
+
+ public BusinessLinkConfiguration hibernateMappingResource(String hibernateMappingResource) {
+ hibernateConfiguration.addResource(hibernateMappingResource);
+ return this;
+ }
+
+ public BusinessLinkSessionFactory buildBusinessLinkSessionFactory() {
+ return new BusinessLinkSessionFactory(this);
+ }
+
+ void addRepository(Repository repository) {
+ repositories.put(repository.getName(), repository);
+ }
+}
Property changes on: projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkConfiguration.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkSessionFactory.java (from rev 6111, projects/businesslink/src/main/java/org/jbpm/businesslink/internal/BusinessLinkServiceImpl.java)
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkSessionFactory.java (rev 0)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkSessionFactory.java 2010-01-22 11:50:00 UTC (rev 6119)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jbpm.businesslink.test;
+
+import java.util.Map;
+
+import org.hibernate.SessionFactory;
+import org.jbpm.businesslink.internal.spi.Repository;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BusinessLinkSessionFactory {
+
+ Map<String, Repository> repositories;
+ SessionFactory sessionFactory;
+
+ public BusinessLinkSessionFactory(BusinessLinkConfiguration businessLinkConfiguration) {
+ repositories = businessLinkConfiguration.repositories;
+ sessionFactory = businessLinkConfiguration.hibernateConfiguration.buildSessionFactory();
+ }
+
+ public TestBusinessLinkSession openSession() {
+ return new TestBusinessLinkSession(this);
+ }
+
+ public Map<String, Repository> getRepositories() {
+ return repositories;
+ }
+ public SessionFactory getSessionFactory() {
+ return sessionFactory;
+ }
+}
Property changes on: projects/businesslink/src/main/java/org/jbpm/businesslink/test/BusinessLinkSessionFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/businesslink/src/main/java/org/jbpm/businesslink/test/TestBusinessLinkSession.java
===================================================================
--- projects/businesslink/src/main/java/org/jbpm/businesslink/test/TestBusinessLinkSession.java (rev 0)
+++ projects/businesslink/src/main/java/org/jbpm/businesslink/test/TestBusinessLinkSession.java 2010-01-22 11:50:00 UTC (rev 6119)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jbpm.businesslink.test;
+
+import org.hibernate.Transaction;
+import org.jbpm.businesslink.internal.svc.BusinessLinkSessionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TestBusinessLinkSession extends BusinessLinkSessionImpl {
+
+ Transaction transaction;
+
+ public TestBusinessLinkSession(BusinessLinkSessionFactory businessLinkSessionFactory) {
+ super(businessLinkSessionFactory);
+ this.transaction = session.beginTransaction();
+ }
+
+ public void commit() {
+ // TODO put proper exception handling in place
+ transaction.commit();
+ session.close();
+ }
+
+ public void rollback() {
+ // TODO put proper exception handling in place
+ transaction.rollback();
+ session.close();
+ }
+}
Property changes on: projects/businesslink/src/main/java/org/jbpm/businesslink/test/TestBusinessLinkSession.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 4 months
JBoss JBPM SVN: r6118 - in jbpm3/branches/jbpm-3.2-soa/modules/core/src: main/java/org/jbpm/graph/node and 5 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-01-22 05:39:47 -0500 (Fri, 22 Jan 2010)
New Revision: 6118
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Action.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/DbSubProcessResolver.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/JpdlException.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/Problem.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/scheduler/def/CancelTimerAction.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/scheduler/def/CreateTimerAction.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/scheduler/exe/SchedulerTest.java
Log:
JBPM-2678: clean up parse error reporting
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Action.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Action.java 2010-01-22 10:38:03 UTC (rev 6117)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Action.java 2010-01-22 10:39:47 UTC (rev 6118)
@@ -85,8 +85,8 @@
actionDelegation.read(actionElement, jpdlReader);
}
else {
- jpdlReader.addWarning("action does not have class nor ref-name attribute "
- + actionElement.asXML());
+ jpdlReader.addWarning("action does not have class nor ref-name attribute: "
+ + actionElement.getPath());
}
String acceptPropagatedEvents = actionElement.attributeValue("accept-propagated-events");
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/DbSubProcessResolver.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/DbSubProcessResolver.java 2010-01-22 10:38:03 UTC (rev 6117)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/DbSubProcessResolver.java 2010-01-22 10:39:47 UTC (rev 6118)
@@ -2,6 +2,7 @@
import org.dom4j.Element;
import org.jbpm.JbpmContext;
+import org.jbpm.db.GraphSession;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.jpdl.JpdlException;
@@ -10,43 +11,41 @@
private static final long serialVersionUID = 1L;
public ProcessDefinition findSubProcess(Element subProcessElement) {
- ProcessDefinition subProcessDefinition = null;
- String subProcessName = subProcessElement.attributeValue("name");
- String subProcessVersion = subProcessElement.attributeValue("version");
-
- // if this parsing is done in the context of a process deployment, there is
- // a database connection to look up the subprocess.
- // when there is no jbpmSession, the definition will be left null... the
- // testcase can set it as appropriate.
+ // if this parsing is done in the context of a process deployment,
+ // there is a database connection to look up the subprocess.
+ // when there is no jbpmSession, the definition will be left null...
+ // the test case can set it as appropriate.
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
if (jbpmContext != null) {
-
+ GraphSession graphSession = jbpmContext.getGraphSession();
+
// now, we must be able to find the sub-process
- if (subProcessName != null) {
-
- // if the name and the version are specified
- if (subProcessVersion != null) {
-
- try {
- int version = Integer.parseInt(subProcessVersion);
- // select that exact process definition as the subprocess definition
- subProcessDefinition = jbpmContext.getGraphSession().findProcessDefinition(subProcessName, version);
+ String subProcessName = subProcessElement.attributeValue("name");
+ if (subProcessName == null) {
+ throw new JpdlException("subprocess name is not specified: "
+ + subProcessElement.getPath());
+ }
- } catch (NumberFormatException e) {
- throw new JpdlException("version in process-state was not a number: " + subProcessElement.asXML());
- }
-
- } else { // if only the name is specified
- // select the latest version of that process as the subprocess
- // definition
- subProcessDefinition = jbpmContext.getGraphSession().findLatestProcessDefinition(subProcessName);
- }
- } else {
- throw new JpdlException("no sub-process name specfied in process-state: " + subProcessElement.asXML());
+ // if only the name is specified,
+ String subProcessVersion = subProcessElement.attributeValue("version");
+ if (subProcessVersion == null) {
+ // select the latest version of the subprocess definition
+ return graphSession.findLatestProcessDefinition(subProcessName);
}
+
+ // if the name and the version are specified
+ try {
+ // select the exact version of the subprocess definition
+ int version = Integer.parseInt(subProcessVersion);
+ return graphSession.findProcessDefinition(subProcessName, version);
+ }
+ catch (NumberFormatException e) {
+ throw new JpdlException("subprocess version is invalid: "
+ + subProcessElement.getPath());
+ }
}
- return subProcessDefinition;
+ return null;
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java 2010-01-22 10:38:03 UTC (rev 6117)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java 2010-01-22 10:39:47 UTC (rev 6118)
@@ -83,7 +83,8 @@
processDefinition = jpdlReader.getProcessDefinition();
className = delegateElement.attributeValue("class");
if (className == null) {
- jpdlReader.addWarning("no class specified in " + delegateElement.asXML());
+ jpdlReader.addWarning("no class specified in delegation: "
+ + delegateElement.getPath());
}
configType = delegateElement.attributeValue("config-type");
@@ -92,8 +93,8 @@
StringWriter stringWriter = new StringWriter();
// when parsing, it could be to store the config in the database,
// so we want to make the configuration compact
- XMLWriter xmlWriter = new XMLWriter(stringWriter,
- OutputFormat.createCompactFormat());
+ XMLWriter xmlWriter =
+ new XMLWriter(stringWriter, OutputFormat.createCompactFormat());
for (Iterator iter = delegateElement.content().iterator(); iter.hasNext();) {
Object node = iter.next();
xmlWriter.write(node);
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/JpdlException.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/JpdlException.java 2010-01-22 10:38:03 UTC (rev 6117)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/JpdlException.java 2010-01-22 10:39:47 UTC (rev 6118)
@@ -21,26 +21,30 @@
*/
package org.jbpm.jpdl;
-import java.util.*;
+import java.util.Collections;
+import java.util.List;
import org.jbpm.jpdl.xml.Problem;
public class JpdlException extends RuntimeException {
private static final long serialVersionUID = 1L;
-
- protected List problems = null;
-
+
+ protected List problems;
+
public JpdlException(List problems) {
super(problems.toString());
this.problems = problems;
}
+
public JpdlException(String msg) {
this(Collections.singletonList(new Problem(Problem.LEVEL_ERROR, msg)));
}
- public JpdlException(String msg, Throwable e ) {
+
+ public JpdlException(String msg, Throwable e) {
this(Collections.singletonList(new Problem(Problem.LEVEL_ERROR, msg, e)));
}
+
public List getProblems() {
return problems;
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java 2010-01-22 10:38:03 UTC (rev 6117)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java 2010-01-22 10:39:47 UTC (rev 6118)
@@ -29,12 +29,14 @@
import java.util.List;
import java.util.Set;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
+import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
@@ -56,52 +58,71 @@
private static final long serialVersionUID = 1L;
- static SAXParserFactory saxParserFactory = createSaxParserFactory();
+ private static SAXParserFactory saxParserFactory = createSaxParserFactory();
private static Set schemaResources = getDefaultSchemaResources();
private static Object schemaSource;
- public static Document parse(InputSource inputSource, ProblemListener problemListener) throws Exception {
- Document document = null;
- SAXReader saxReader = createSaxReader(problemListener);
- document = saxReader.read(inputSource);
- return document;
+ public static Document parse(InputSource inputSource,
+ ProblemListener problemListener) throws DocumentException {
+ try {
+ SAXReader saxReader = createSaxReader(problemListener);
+ return saxReader.read(inputSource);
+ }
+ catch (SAXException e) {
+ throw new DocumentException("failed to create sax reader", e);
+ }
}
- public static SAXReader createSaxReader(ProblemListener problemListener) throws Exception {
+ public static SAXReader createSaxReader(ProblemListener problemListener)
+ throws SAXException {
XMLReader xmlReader = createXmlReader();
SAXReader saxReader = new SAXReader(xmlReader);
saxReader.setErrorHandler(new JpdlErrorHandler(problemListener));
return saxReader;
}
-
- public static XMLReader createXmlReader() throws Exception {
- SAXParser saxParser = saxParserFactory.newSAXParser();
- XMLReader xmlReader = saxParser.getXMLReader();
-
+
+ public static XMLReader createXmlReader() throws SAXException {
+ SAXParser saxParser;
try {
- saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
- } catch (SAXException e){
- log.warn("couldn't set schema language property", e);
+ saxParser = saxParserFactory.newSAXParser();
}
+ catch (ParserConfigurationException e) {
+ // validating, namespace-aware sax parsr should be available
+ throw new AssertionError(e);
+ }
try {
- saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", getSchemaSource());
- } catch (SAXException e){
- log.warn("couldn't set schema source property", e);
+ saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
+ "http://www.w3.org/2001/XMLSchema");
}
+ catch (SAXException e) {
+ log.warn("failed to set schema language to xml schema", e);
+ }
+ Object schemaSource = getSchemaSource();
try {
- xmlReader.setFeature("http://apache.org/xml/features/validation/dynamic", true);
- } catch (SAXException e){
- log.warn("couldn't set dynamic validation feature", e);
+ saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",
+ schemaSource);
}
+ catch (SAXException e) {
+ log.warn("failed to set schema source to " + schemaSource, e);
+ }
+
+ XMLReader xmlReader = saxParser.getXMLReader();
+ try {
+ xmlReader.setFeature("http://apache.org/xml/features/validation/dynamic",
+ true);
+ }
+ catch (SAXException e) {
+ log.warn("failed to enable dynamic validation", e);
+ }
return xmlReader;
}
- private static Object getSchemaSource() {
+ private synchronized static Object getSchemaSource() {
if (schemaSource == null) {
ClassLoader classLoader = ClassLoaderUtil.getClassLoader();
- List schemaLocations = new ArrayList(schemaResources.size());
+ List schemaLocations = new ArrayList(schemaResources.size());
for (Iterator i = schemaResources.iterator(); i.hasNext();) {
String schemaResource = (String) i.next();
URL schemaURL = classLoader.getResource(schemaResource);
@@ -111,7 +132,8 @@
schemaLocations.add(schemaLocation);
}
}
- schemaSource = schemaLocations.toArray(new String[schemaLocations.size()]);
+ schemaSource =
+ schemaLocations.toArray(new String[schemaLocations.size()]);
}
return schemaSource;
}
@@ -146,8 +168,8 @@
problemListener.addProblem(problem);
}
}
-
- public static void addSchemaResource(String resource) {
+
+ public synchronized static void addSchemaResource(String resource) {
schemaResources.add(resource);
schemaSource = null;
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java 2010-01-22 10:38:03 UTC (rev 6117)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java 2010-01-22 10:39:47 UTC (rev 6118)
@@ -28,13 +28,16 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.StringTokenizer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
+import org.dom4j.DocumentException;
import org.dom4j.Element;
+import org.xml.sax.InputSource;
+
import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmException;
import org.jbpm.context.def.VariableAccess;
import org.jbpm.graph.action.ActionTypes;
import org.jbpm.graph.def.Action;
@@ -57,22 +60,21 @@
import org.jbpm.taskmgmt.def.Task;
import org.jbpm.taskmgmt.def.TaskController;
import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
-import org.xml.sax.InputSource;
public class JpdlXmlReader implements ProblemListener {
-
+
private static final long serialVersionUID = 1L;
- protected InputSource inputSource = null;
+ protected InputSource inputSource;
protected List problems = new ArrayList();
- protected ProblemListener problemListener = null;
- protected ProcessDefinition processDefinition = null;
- protected String initialNodeName = null;
- protected Collection unresolvedTransitionDestinations = null;
- protected Collection unresolvedActionReferences = null;
+ protected ProblemListener problemListener;
+ protected ProcessDefinition processDefinition;
+ protected String initialNodeName;
+ protected Collection unresolvedTransitionDestinations = new ArrayList();
+ protected Collection unresolvedActionReferences = new ArrayList();
/**
- * the parsed process definition as DOM tree (available after readProcessDefinition)
+ * process definition as DOM tree, available after readProcessDefinition
*/
protected Document document;
@@ -82,24 +84,23 @@
public JpdlXmlReader(InputSource inputSource) {
this.inputSource = inputSource;
}
-
+
public JpdlXmlReader(InputSource inputSource, ProblemListener problemListener) {
this.inputSource = inputSource;
this.problemListener = problemListener;
}
-
+
public JpdlXmlReader(Reader reader) {
this(new InputSource(reader));
}
public void close() throws IOException {
InputStream byteStream = inputSource.getByteStream();
- if (byteStream != null)
+ if (byteStream != null)
byteStream.close();
else {
Reader charStream = inputSource.getCharacterStream();
- if (charStream != null)
- charStream.close();
+ if (charStream != null) charStream.close();
}
document = null;
}
@@ -110,21 +111,18 @@
public void addProblem(Problem problem) {
problems.add(problem);
- if (problemListener!=null) problemListener.addProblem(problem);
+ if (problemListener != null) problemListener.addProblem(problem);
}
-
+
public void addError(String description) {
- log.error("invalid process xml: "+description);
addProblem(new Problem(Problem.LEVEL_ERROR, description));
}
public void addError(String description, Throwable exception) {
- log.error("invalid process xml: "+description, exception);
addProblem(new Problem(Problem.LEVEL_ERROR, description, exception));
}
public void addWarning(String description) {
- log.warn("process xml warning: "+description);
addProblem(new Problem(Problem.LEVEL_WARNING, description));
}
@@ -133,23 +131,21 @@
processDefinition = ProcessDefinition.createNewProcessDefinition();
// initialize lists
- problems = new ArrayList();
- unresolvedTransitionDestinations = new ArrayList();
- unresolvedActionReferences = new ArrayList();
-
+ problems.clear();
+ unresolvedTransitionDestinations.clear();
+ unresolvedActionReferences.clear();
+
try {
// parse the document into a dom tree
document = JpdlParser.parse(inputSource, this);
Element root = document.getRootElement();
-
+
// read the process name
parseProcessDefinitionAttributes(root);
-
- // get the process description
+
+ // get the process description
String description = root.elementTextTrim("description");
- if (description!=null) {
- processDefinition.setDescription(description);
- }
+ if (description != null) processDefinition.setDescription(description);
// first pass: read most content
readSwimlanes(root);
@@ -164,23 +160,14 @@
resolveActionReferences();
verifySwimlaneAssignments();
- } catch (Exception e) {
- log.error("couldn't parse process definition", e);
- addProblem(new Problem(Problem.LEVEL_ERROR, "couldn't parse process definition", e));
- }
-
- if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR)) {
- throw new JpdlException(problems);
- }
-
- if (problems!=null) {
- Iterator iter = problems.iterator();
- while (iter.hasNext()) {
- Problem problem = (Problem) iter.next();
- log.warn("process parse warning: "+problem.getDescription());
+ if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR)) {
+ throw new JpdlException(problems);
}
}
-
+ catch (DocumentException e) {
+ throw new JpdlException("failed to parse process document", e);
+ }
+
return processDefinition;
}
@@ -188,37 +175,37 @@
processDefinition.setName(root.attributeValue("name"));
initialNodeName = root.attributeValue("initial");
}
-
+
protected void readSwimlanes(Element processDefinitionElement) {
- Iterator iter = processDefinitionElement.elementIterator("swimlane");
- TaskMgmtDefinition taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
- while (iter.hasNext()) {
+ TaskMgmtDefinition taskMgmtDefinition =
+ processDefinition.getTaskMgmtDefinition();
+ for (Iterator iter = processDefinitionElement.elementIterator("swimlane"); iter.hasNext();) {
Element swimlaneElement = (Element) iter.next();
String swimlaneName = swimlaneElement.attributeValue("name");
- if (swimlaneName==null) {
+ if (swimlaneName == null) {
addWarning("there's a swimlane without a name");
- } else {
+ }
+ else {
Swimlane swimlane = new Swimlane(swimlaneName);
Element assignmentElement = swimlaneElement.element("assignment");
- if (assignmentElement!=null) {
-
- if ( (assignmentElement.attribute("actor-id")!=null)
- || (assignmentElement.attribute("pooled-actors")!=null)
- ) {
+ if (assignmentElement != null) {
+ if (assignmentElement.attribute("actor-id") != null
+ || assignmentElement.attribute("pooled-actors") != null) {
swimlane.setActorIdExpression(assignmentElement.attributeValue("actor-id"));
swimlane.setPooledActorsExpression(assignmentElement.attributeValue("pooled-actors"));
-
- } else {
- Delegation assignmentDelegation = readAssignmentDelegation(assignmentElement);
+ }
+ else {
+ Delegation assignmentDelegation =
+ readAssignmentDelegation(assignmentElement);
swimlane.setAssignmentDelegation(assignmentDelegation);
}
- } else {
+ }
+ else {
Task startTask = taskMgmtDefinition.getStartTask();
- if ( (startTask==null)
- || (startTask.getSwimlane()!=swimlane)
- ) {
- addWarning("swimlane '"+swimlaneName+"' does not have an assignment");
+ if (startTask == null || startTask.getSwimlane() != swimlane) {
+ addWarning("swimlane '" + swimlaneName
+ + "' does not have an assignment");
}
}
taskMgmtDefinition.addSwimlane(swimlane);
@@ -227,178 +214,175 @@
}
public void readNodes(Element element, NodeCollection nodeCollection) {
- Iterator nodeElementIter = element.elementIterator();
- while (nodeElementIter.hasNext()) {
- Element nodeElement = (Element) nodeElementIter.next();
+ for (Iterator iter = element.elementIterator(); iter.hasNext();) {
+ Element nodeElement = (Element) iter.next();
String nodeName = nodeElement.getName();
// get the node type
Class nodeType = NodeTypes.getNodeType(nodeName);
- if (nodeType!=null) {
-
- Node node = null;
+ if (nodeType != null) {
try {
- // create a new instance
- node = (Node) nodeType.newInstance();
- } catch (Exception e) {
- log.error("couldn't instantiate node '"+nodeName+"', of type '"+nodeType.getName()+"'", e);
+ // instantiate the node
+ Node node = (Node) nodeType.newInstance();
+ node.setProcessDefinition(processDefinition);
+
+ // check for duplicate start-states
+ if (node instanceof StartState
+ && processDefinition.getStartState() != null) {
+ addError("max one start-state allowed in a process");
+ }
+ else {
+ // read the common node parts of the element
+ readNode(nodeElement, node, nodeCollection);
+
+ // let node parse its special configuration
+ node.read(nodeElement, this);
+ }
}
-
- node.setProcessDefinition(processDefinition);
-
- // check for duplicate start-states
- if ( (node instanceof StartState)
- && (processDefinition.getStartState()!=null)
- ) {
- addError("max one start-state allowed in a process");
-
- } else {
- // read the common node parts of the element
- readNode(nodeElement, node, nodeCollection);
-
- // if the node is parsable
- // (meaning: if the node has special configuration to parse, other then the
- // common node data)
- node.read(nodeElement, this);
+ catch (InstantiationException e) {
+ throw new JbpmException("could not instantiate " + nodeType, e);
}
+ catch (IllegalAccessException e) {
+ throw new JbpmException("illegal access to " + nodeType, e);
+ }
}
}
}
public void readTasks(Element element, TaskNode taskNode) {
List elements = element.elements("task");
- TaskMgmtDefinition tmd = (TaskMgmtDefinition) processDefinition.getDefinition(TaskMgmtDefinition.class);
- if (elements.size()>0) {
- if (tmd==null) {
+ TaskMgmtDefinition tmd =
+ (TaskMgmtDefinition) processDefinition.getDefinition(TaskMgmtDefinition.class);
+ if (elements.size() > 0) {
+ if (tmd == null) {
tmd = new TaskMgmtDefinition();
}
processDefinition.addDefinition(tmd);
-
- Iterator iter = elements.iterator();
- while (iter.hasNext()) {
+
+ for (Iterator iter = elements.iterator(); iter.hasNext();) {
Element taskElement = (Element) iter.next();
readTask(taskElement, tmd, taskNode);
}
}
}
- public Task readTask(Element taskElement, TaskMgmtDefinition taskMgmtDefinition, TaskNode taskNode) {
+ public Task readTask(Element taskElement,
+ TaskMgmtDefinition taskMgmtDefinition, TaskNode taskNode) {
Task task = new Task();
task.setProcessDefinition(processDefinition);
-
+
// get the task name
String name = taskElement.attributeValue("name");
- if (name!=null) {
+ if (name != null) {
task.setName(name);
taskMgmtDefinition.addTask(task);
- } else if (taskNode!=null) {
+ }
+ else if (taskNode != null) {
task.setName(taskNode.getName());
taskMgmtDefinition.addTask(task);
}
-
- // get the task description
+
+ // get the task description
String description = taskElement.elementTextTrim("description");
- if (description!=null) {
+ if (description != null) {
task.setDescription(description);
- } else {
+ }
+ else {
task.setDescription(taskElement.attributeValue("description"));
}
-
- // get the condition
+
+ // get the condition
String condition = taskElement.elementTextTrim("condition");
- if (condition!=null) {
+ if (condition != null) {
task.setCondition(condition);
- } else {
+ }
+ else {
task.setCondition(taskElement.attributeValue("condition"));
}
-
+
// parse common subelements
readTaskTimers(taskElement, task);
readEvents(taskElement, task);
readExceptionHandlers(taskElement, task);
- // duedate and priority
+ // duedate
String duedateText = taskElement.attributeValue("duedate");
- if (duedateText==null) {
+ if (duedateText == null) {
duedateText = taskElement.attributeValue("dueDate");
}
task.setDueDate(duedateText);
+ // priority
String priorityText = taskElement.attributeValue("priority");
- if (priorityText!=null) {
+ if (priorityText != null) {
task.setPriority(Task.parsePriority(priorityText));
}
-
+
// if this task is in the context of a taskNode, associate them
- if (taskNode!=null) {
- taskNode.addTask(task);
- }
+ if (taskNode != null) taskNode.addTask(task);
// blocking
String blockingText = taskElement.attributeValue("blocking");
- if (blockingText!=null) {
- if ( ("true".equalsIgnoreCase(blockingText))
- || ("yes".equalsIgnoreCase(blockingText))
- || ("on".equalsIgnoreCase(blockingText)) ) {
- task.setBlocking(true);
- }
+ if (blockingText != null
+ && ("true".equalsIgnoreCase(blockingText)
+ || "yes".equalsIgnoreCase(blockingText) || "on".equalsIgnoreCase(blockingText))) {
+ task.setBlocking(true);
}
-
+
// signalling
String signallingText = taskElement.attributeValue("signalling");
- if (signallingText!=null) {
- if ( ("false".equalsIgnoreCase(signallingText))
- || ("no".equalsIgnoreCase(signallingText))
- || ("off".equalsIgnoreCase(signallingText)) ) {
- task.setSignalling(false);
- }
+ if (signallingText != null
+ && ("false".equalsIgnoreCase(signallingText)
+ || "no".equalsIgnoreCase(signallingText) || "off".equalsIgnoreCase(signallingText))) {
+ task.setSignalling(false);
}
-
+
// assignment
String swimlaneName = taskElement.attributeValue("swimlane");
Element assignmentElement = taskElement.element("assignment");
// if there is a swimlane attribute specified
- if (swimlaneName!=null) {
+ if (swimlaneName != null) {
Swimlane swimlane = taskMgmtDefinition.getSwimlane(swimlaneName);
- if (swimlane==null) {
- addWarning("task references unknown swimlane '"+swimlaneName+"':"+taskElement.asXML());
- } else {
+ if (swimlane == null) {
+ addWarning("task references unknown swimlane: "
+ + taskElement.getPath());
+ }
+ else {
task.setSwimlane(swimlane);
}
-
+ }
// else if there is a direct assignment specified
- } else if (assignmentElement!=null) {
- if ( (assignmentElement.attribute("actor-id")!=null)
- || (assignmentElement.attribute("pooled-actors")!=null)
- ) {
+ else if (assignmentElement != null) {
+ if (assignmentElement.attribute("actor-id") != null
+ || assignmentElement.attribute("pooled-actors") != null) {
task.setActorIdExpression(assignmentElement.attributeValue("actor-id"));
task.setPooledActorsExpression(assignmentElement.attributeValue("pooled-actors"));
-
- } else {
- Delegation assignmentDelegation = readAssignmentDelegation(assignmentElement);
+ }
+ else {
+ Delegation assignmentDelegation =
+ readAssignmentDelegation(assignmentElement);
task.setAssignmentDelegation(assignmentDelegation);
}
-
+ }
// if no assignment or swimlane is specified
- } else {
- // the user has to manage assignment manually, so we better inform him/her.
- log.info("process xml information: no swimlane or assignment specified for task '"+taskElement.asXML()+"'");
+ else {
+ // user has to manage assignment manually, so better inform him/her
+ addProblem(new Problem(Problem.LEVEL_INFO,
+ "no assignment specified for task: " + taskElement.getPath()));
}
// notify
String notificationsText = taskElement.attributeValue("notify");
- if ( notificationsText!=null
- && ("true".equalsIgnoreCase(notificationsText)
- || "on".equalsIgnoreCase(notificationsText)
- || "yes".equalsIgnoreCase(notificationsText)
- )
- ) {
+ if (notificationsText != null
+ && ("true".equalsIgnoreCase(notificationsText)
+ || "on".equalsIgnoreCase(notificationsText) || "yes".equalsIgnoreCase(notificationsText))) {
String notificationEvent = Event.EVENTTYPE_TASK_ASSIGN;
Event event = task.getEvent(notificationEvent);
- if (event==null) {
+ if (event == null) {
event = new Event(notificationEvent);
task.addEvent(event);
}
- Delegation delegation = createMailDelegation(notificationEvent, null, null, null, null);
+ Delegation delegation =
+ createMailDelegation(notificationEvent, null, null, null, null);
Action action = new Action(delegation);
action.setProcessDefinition(processDefinition);
action.setName(task.getName());
@@ -407,10 +391,10 @@
// task controller
Element taskControllerElement = taskElement.element("controller");
- if (taskControllerElement!=null) {
+ if (taskControllerElement != null) {
task.setTaskController(readTaskController(taskControllerElement));
}
-
+
return task;
}
@@ -419,107 +403,109 @@
String expression = assignmentElement.attributeValue("expression");
String actorId = assignmentElement.attributeValue("actor-id");
String pooledActors = assignmentElement.attributeValue("pooled-actors");
-
- if (expression!=null){
+
+ if (expression != null) {
assignmentDelegation.setProcessDefinition(processDefinition);
assignmentDelegation.setClassName("org.jbpm.identity.assignment.ExpressionAssignmentHandler");
- assignmentDelegation.setConfiguration("<expression>"+expression+"</expression>");
-
- } else if ( (actorId!=null)
- || (pooledActors!=null)
- ) {
+ assignmentDelegation.setConfiguration("<expression>" + expression
+ + "</expression>");
+ }
+ else if (actorId != null || pooledActors != null) {
assignmentDelegation.setProcessDefinition(processDefinition);
assignmentDelegation.setClassName("org.jbpm.taskmgmt.assignment.ActorAssignmentHandler");
String configuration = "";
- if (actorId!=null) {
- configuration += "<actorId>"+actorId+"</actorId>";
+ if (actorId != null) {
+ configuration += "<actorId>" + actorId + "</actorId>";
}
- if (pooledActors!=null) {
- configuration += "<pooledActors>"+pooledActors+"</pooledActors>";
+ if (pooledActors != null) {
+ configuration += "<pooledActors>" + pooledActors + "</pooledActors>";
}
assignmentDelegation.setConfiguration(configuration);
-
- } else {
+ }
+ else {
assignmentDelegation = new Delegation();
assignmentDelegation.read(assignmentElement, this);
}
-
+
return assignmentDelegation;
}
protected TaskController readTaskController(Element taskControllerElement) {
TaskController taskController = new TaskController();
- if (taskControllerElement.attributeValue("class")!=null) {
+ if (taskControllerElement.attributeValue("class") != null) {
Delegation taskControllerDelegation = new Delegation();
taskControllerDelegation.read(taskControllerElement, this);
taskController.setTaskControllerDelegation(taskControllerDelegation);
- } else {
+ }
+ else {
List variableAccesses = readVariableAccesses(taskControllerElement);
taskController.setVariableAccesses(variableAccesses);
}
return taskController;
}
-
+
public List readVariableAccesses(Element element) {
List variableAccesses = new ArrayList();
- Iterator iter = element.elementIterator("variable");
- while (iter.hasNext()) {
+ for (Iterator iter = element.elementIterator("variable"); iter.hasNext();) {
Element variableElement = (Element) iter.next();
-
+
String variableName = variableElement.attributeValue("name");
- if (variableName==null) {
- addProblem(new Problem(Problem.LEVEL_WARNING, "the name attribute of a variable element is required: "+variableElement.asXML()));
+ if (variableName == null) {
+ addWarning("variable name not specified: "
+ + variableElement.getPath());
}
String access = variableElement.attributeValue("access", "read,write");
String mappedName = variableElement.attributeValue("mapped-name");
-
+
variableAccesses.add(new VariableAccess(variableName, access, mappedName));
}
return variableAccesses;
}
public void readStartStateTask(Element startTaskElement, StartState startState) {
- TaskMgmtDefinition taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
+ TaskMgmtDefinition taskMgmtDefinition =
+ processDefinition.getTaskMgmtDefinition();
Task startTask = readTask(startTaskElement, taskMgmtDefinition, null);
startTask.setStartState(startState);
- if (startTask.getName()==null) {
+ if (startTask.getName() == null) {
startTask.setName(startState.getName());
}
taskMgmtDefinition.setStartTask(startTask);
}
- public void readNode(Element nodeElement, Node node, NodeCollection nodeCollection) {
+ public void readNode(Element nodeElement, Node node,
+ NodeCollection nodeCollection) {
- // first put the node in its collection. this is done so that the
- // setName later on will be able to differentiate between nodes contained in
+ // first put the node in its collection. this is done so that the
+ // setName later on will be able to differentiate between nodes contained in
// processDefinitions and nodes contained in superstates
nodeCollection.addNode(node);
// get the node name
String name = nodeElement.attributeValue("name");
- if (name!=null) {
+ if (name != null) {
node.setName(name);
// check if this is the initial node
- if ( (initialNodeName!=null)
- && (initialNodeName.equals(node.getFullyQualifiedName()))
- ) {
+ if (initialNodeName != null
+ && initialNodeName.equals(node.getFullyQualifiedName())) {
processDefinition.setStartState(node);
}
}
- // get the node description
+ // get the node description
String description = nodeElement.elementTextTrim("description");
- if (description!=null) {
+ if (description != null) {
node.setDescription(description);
}
String asyncText = nodeElement.attributeValue("async");
if ("true".equalsIgnoreCase(asyncText)) {
node.setAsync(true);
- } else if ("exclusive".equalsIgnoreCase(asyncText)) {
+ }
+ else if ("exclusive".equalsIgnoreCase(asyncText)) {
node.setAsync(true);
node.setAsyncExclusive(true);
}
@@ -534,8 +520,7 @@
}
protected void readNodeTimers(Element nodeElement, Node node) {
- Iterator iter = nodeElement.elementIterator("timer");
- while (iter.hasNext()) {
+ for (Iterator iter = nodeElement.elementIterator("timer"); iter.hasNext();) {
Element timerElement = (Element) iter.next();
readNodeTimer(timerElement, node);
}
@@ -544,29 +529,27 @@
protected void readNodeTimer(Element timerElement, Node node) {
String name = timerElement.attributeValue("name", node.getName());
if (name == null) name = generateTimerName();
-
+
CreateTimerAction createTimerAction = new CreateTimerAction();
createTimerAction.read(timerElement, this);
createTimerAction.setTimerName(name);
createTimerAction.setTimerAction(readSingleAction(timerElement));
addAction(node, Event.EVENTTYPE_NODE_ENTER, createTimerAction);
-
+
CancelTimerAction cancelTimerAction = new CancelTimerAction();
cancelTimerAction.setTimerName(name);
addAction(node, Event.EVENTTYPE_NODE_LEAVE, cancelTimerAction);
}
private String generateTimerName() {
- return "timer-" + (timerNumber++);
+ return "timer-" + (timerNumber++);
}
protected void readTaskTimers(Element taskElement, Task task) {
- Iterator iter = taskElement.elementIterator();
- while (iter.hasNext()) {
+ for (Iterator iter = taskElement.elementIterator(); iter.hasNext();) {
Element element = (Element) iter.next();
- if ( ("timer".equals(element.getName()))
- || ("reminder".equals(element.getName()))
- ) {
+ String elementName = element.getName();
+ if ("timer".equals(elementName) || "reminder".equals(elementName)) {
readTaskTimer(element, task);
}
}
@@ -574,7 +557,7 @@
protected void readTaskTimer(Element timerElement, Task task) {
String name = timerElement.attributeValue("name", task.getName());
- if (name==null) name = generateTimerName();
+ if (name == null) name = generateTimerName();
CreateTimerAction createTimerAction = new CreateTimerAction();
createTimerAction.read(timerElement, this);
@@ -582,8 +565,10 @@
Action action = null;
if ("timer".equals(timerElement.getName())) {
action = readSingleAction(timerElement);
- } else {
- Delegation delegation = createMailDelegation("task-reminder", null, null, null, null);
+ }
+ else {
+ Delegation delegation =
+ createMailDelegation("task-reminder", null, null, null, null);
action = new Action(delegation);
}
createTimerAction.setTimerAction(action);
@@ -593,29 +578,28 @@
Collection cancelEventTypes = new ArrayList();
String cancelEventTypeText = timerElement.attributeValue("cancel-event");
- if (cancelEventTypeText!=null) {
+ if (cancelEventTypeText != null) {
// cancel-event is a comma separated list of events
StringTokenizer tokenizer = new StringTokenizer(cancelEventTypeText, ",");
while (tokenizer.hasMoreTokens()) {
cancelEventTypes.add(tokenizer.nextToken().trim());
}
- } else {
+ }
+ else {
// set the default
cancelEventTypes.add(Event.EVENTTYPE_TASK_END);
}
-
- Iterator iter = cancelEventTypes.iterator();
- while (iter.hasNext()) {
+
+ for (Iterator iter = cancelEventTypes.iterator(); iter.hasNext();) {
String cancelEventType = (String) iter.next();
CancelTimerAction cancelTimerAction = new CancelTimerAction();
cancelTimerAction.setTimerName(name);
addAction(task, cancelEventType, cancelTimerAction);
}
}
-
+
protected void readEvents(Element parentElement, GraphElement graphElement) {
- Iterator iter = parentElement.elementIterator("event");
- while (iter.hasNext()) {
+ for (Iterator iter = parentElement.elementIterator("event"); iter.hasNext();) {
Element eventElement = (Element) iter.next();
String eventType = eventElement.attributeValue("type");
if (!graphElement.hasEvent(eventType)) {
@@ -625,17 +609,15 @@
}
}
- public void readActions(Element eventElement, GraphElement graphElement, String eventType) {
+ public void readActions(Element eventElement, GraphElement graphElement,
+ String eventType) {
// for all the elements in the event element
- Iterator nodeElementIter = eventElement.elementIterator();
- while (nodeElementIter.hasNext()) {
- Element actionElement = (Element) nodeElementIter.next();
+ for (Iterator iter = eventElement.elementIterator(); iter.hasNext();) {
+ Element actionElement = (Element) iter.next();
String actionName = actionElement.getName();
if (ActionTypes.hasActionName(actionName)) {
Action action = createAction(actionElement);
- if ( (graphElement!=null)
- && (eventType!=null)
- ) {
+ if (graphElement != null && eventType != null) {
// add the action to the event
addAction(graphElement, eventType, action);
}
@@ -643,69 +625,69 @@
}
}
- protected void addAction(GraphElement graphElement, String eventType, Action action) {
+ protected void addAction(GraphElement graphElement, String eventType,
+ Action action) {
Event event = graphElement.getEvent(eventType);
- if (event==null) {
- event = new Event(eventType);
+ if (event == null) {
+ event = new Event(eventType);
graphElement.addEvent(event);
}
event.addAction(action);
}
-
+
public Action readSingleAction(Element nodeElement) {
- Action action = null;
// search for the first action element in the node
- Iterator iter = nodeElement.elementIterator();
- while (iter.hasNext() && (action==null)) {
+ for (Iterator iter = nodeElement.elementIterator(); iter.hasNext();) {
Element candidate = (Element) iter.next();
if (ActionTypes.hasActionName(candidate.getName())) {
// parse the action and assign it to this node
- action = createAction(candidate);
+ return createAction(candidate);
}
}
- return action;
+ return null;
}
public Action createAction(Element actionElement) {
- // create a new instance of the action
- Action action = null;
String actionName = actionElement.getName();
Class actionType = ActionTypes.getActionType(actionName);
try {
- action = (Action) actionType.newInstance();
- } catch (Exception e) {
- log.error("couldn't instantiate action '"+actionName+"', of type '"+actionType.getName()+"'", e);
+ // instantiate action
+ Action action = (Action) actionType.newInstance();
+ // read the common node parts of the action
+ readAction(actionElement, action);
+ return action;
}
-
- // read the common node parts of the action
- readAction(actionElement, action);
-
- return action;
+ catch (InstantiationException e) {
+ throw new JbpmException("failed to instantiate " + actionType, e);
+ }
+ catch (IllegalAccessException e) {
+ throw new JbpmException("illegal access to " + actionType, e);
+ }
}
public void readAction(Element element, Action action) {
// if a name is specified for this action
String actionName = element.attributeValue("name");
- if (actionName!=null) {
+ if (actionName != null) {
action.setName(actionName);
- // add the action to the named process action repository
+ // add the action to the named process action repository
processDefinition.addAction(action);
}
- // if the action is parsable
- // (meaning: if the action has special configuration to parse, other then the common node data)
+ // let action parse its special configuration
action.read(element, this);
}
- protected void readExceptionHandlers(Element graphElementElement, GraphElement graphElement) {
- Iterator iter = graphElementElement.elementIterator("exception-handler");
- while (iter.hasNext()) {
+ protected void readExceptionHandlers(Element graphDomElement,
+ GraphElement graphElement) {
+ for (Iterator iter = graphDomElement.elementIterator("exception-handler"); iter.hasNext();) {
Element exceptionHandlerElement = (Element) iter.next();
readExceptionHandler(exceptionHandlerElement, graphElement);
}
}
- protected void readExceptionHandler(Element exceptionHandlerElement, GraphElement graphElement) {
+ protected void readExceptionHandler(Element exceptionHandlerElement,
+ GraphElement graphElement) {
// create the exception handler
ExceptionHandler exceptionHandler = new ExceptionHandler();
exceptionHandler.setExceptionClassName(exceptionHandlerElement.attributeValue("exception-class"));
@@ -713,8 +695,7 @@
graphElement.addExceptionHandler(exceptionHandler);
// read the actions in the body of the exception-handler element
- Iterator iter = exceptionHandlerElement.elementIterator();
- while (iter.hasNext()) {
+ for (Iterator iter = exceptionHandlerElement.elementIterator(); iter.hasNext();) {
Element childElement = (Element) iter.next();
if (ActionTypes.hasActionName(childElement.getName())) {
Action action = createAction(childElement);
@@ -724,14 +705,13 @@
}
// transition destinations are parsed in a second pass //////////////////////
-
+
public void addUnresolvedTransitionDestination(Element nodeElement, Node node) {
- unresolvedTransitionDestinations.add(new Object[]{nodeElement, node});
+ unresolvedTransitionDestinations.add(new Object[] { nodeElement, node });
}
public void resolveTransitionDestinations() {
- Iterator iter = unresolvedTransitionDestinations.iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = unresolvedTransitionDestinations.iterator(); iter.hasNext();) {
Object[] unresolvedTransition = (Object[]) iter.next();
Element nodeElement = (Element) unresolvedTransition[0];
Node node = (Node) unresolvedTransition[1];
@@ -740,8 +720,7 @@
}
public void resolveTransitionDestinations(List transitionElements, Node node) {
- Iterator iter = transitionElements.iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = transitionElements.iterator(); iter.hasNext();) {
Element transitionElement = (Element) iter.next();
resolveTransitionDestination(transitionElement, node);
}
@@ -749,11 +728,13 @@
/**
* creates the transition object and configures it by the read attributes
+ *
* @return the created <code>org.jbpm.graph.def.Transition</code> object
- * (useful, if you want to override this method
- * to read additional configuration properties)
+ * (useful, if you want to override this method to read additional
+ * configuration properties)
*/
- public Transition resolveTransitionDestination(Element transitionElement, Node node) {
+ public Transition resolveTransitionDestination(Element transitionElement,
+ Node node) {
Transition transition = new Transition();
transition.setProcessDefinition(processDefinition);
@@ -761,14 +742,12 @@
transition.setDescription(transitionElement.elementTextTrim("description"));
String condition = transitionElement.attributeValue("condition");
- if (condition==null) {
+ if (condition == null) {
Element conditionElement = transitionElement.element("condition");
- if (conditionElement!=null) {
+ if (conditionElement != null) {
condition = conditionElement.getTextTrim();
// for backwards compatibility
- if ( (condition==null)
- || (condition.length()==0)
- ) {
+ if (condition == null || condition.length() == 0) {
condition = conditionElement.attributeValue("expression");
}
}
@@ -780,41 +759,44 @@
// set destinationNode of the transition
String toName = transitionElement.attributeValue("to");
- if (toName==null) {
- addWarning("node '"+node.getFullyQualifiedName()+"' has a transition without a 'to'-attribute to specify its destinationNode");
- } else {
- Node to = ((NodeCollection)node.getParent()).findNode(toName);
- if (to==null) {
- addWarning("transition to='"+toName+"' on node '"+node.getFullyQualifiedName()+"' cannot be resolved");
- } else {
+ if (toName == null) {
+ addWarning("node '" + node.getFullyQualifiedName()
+ + "' has a transition without a 'to'-attribute");
+ }
+ else {
+ Node to = ((NodeCollection) node.getParent()).findNode(toName);
+ if (to == null) {
+ addWarning("transition to='" + toName + "' on node '"
+ + node.getFullyQualifiedName() + "' cannot be resolved");
+ }
+ else {
to.addArrivingTransition(transition);
}
}
-
+
// read the actions
readActions(transitionElement, transition, Event.EVENTTYPE_TRANSITION);
-
readExceptionHandlers(transitionElement, transition);
-
return transition;
}
-
+
// action references are parsed in a second pass ////////////////////////////
public void addUnresolvedActionReference(Element actionElement, Action action) {
- unresolvedActionReferences.add(new Object[]{actionElement, action});
+ unresolvedActionReferences.add(new Object[] { actionElement, action });
}
public void resolveActionReferences() {
- Iterator iter = unresolvedActionReferences.iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = unresolvedActionReferences.iterator(); iter.hasNext();) {
Object[] unresolvedActionReference = (Object[]) iter.next();
Element actionElement = (Element) unresolvedActionReference[0];
Action action = (Action) unresolvedActionReference[1];
String referencedActionName = actionElement.attributeValue("ref-name");
- Action referencedAction = processDefinition.getAction(referencedActionName);
- if (referencedAction==null) {
- addWarning("couldn't resolve action reference in "+actionElement.asXML());
+ Action referencedAction =
+ processDefinition.getAction(referencedActionName);
+ if (referencedAction == null) {
+ addWarning("referenced action not found: "
+ + actionElement.getPath());
}
action.setReferencedAction(referencedAction);
}
@@ -822,21 +804,22 @@
// verify swimlane assignments in second pass ///////////////////////////////
public void verifySwimlaneAssignments() {
- TaskMgmtDefinition taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
- if ( (taskMgmtDefinition!=null)
- && (taskMgmtDefinition.getSwimlanes()!=null)
- ) {
- Iterator iter = taskMgmtDefinition.getSwimlanes().values().iterator();
- while (iter.hasNext()) {
+ TaskMgmtDefinition taskMgmtDefinition =
+ processDefinition.getTaskMgmtDefinition();
+ Map swimlanes;
+ if (taskMgmtDefinition != null
+ && (swimlanes = taskMgmtDefinition.getSwimlanes()) != null) {
+ for (Iterator iter = swimlanes.values().iterator(); iter.hasNext();) {
Swimlane swimlane = (Swimlane) iter.next();
-
+
Task startTask = taskMgmtDefinition.getStartTask();
- Swimlane startTaskSwimlane = (startTask!=null ? startTask.getSwimlane() : null);
-
- if ( (swimlane.getAssignmentDelegation()==null)
- && (swimlane!=startTaskSwimlane)
- ) {
- addWarning("swimlane '"+swimlane.getName()+"' does not have an assignment");
+ Swimlane startTaskSwimlane =
+ startTask != null ? startTask.getSwimlane() : null;
+
+ if (swimlane.getAssignmentDelegation() == null
+ && swimlane != startTaskSwimlane) {
+ addWarning("swimlane '" + swimlane.getName()
+ + "' does not have an assignment");
}
}
}
@@ -844,33 +827,30 @@
// mail delegations /////////////////////////////////////////////////////////
- public Delegation createMailDelegation(String template,
- String actors,
- String to,
- String subject,
- String text) {
+ public Delegation createMailDelegation(String template, String actors,
+ String to, String subject, String text) {
StringBuffer config = new StringBuffer();
- if (template!=null) {
+ if (template != null) {
config.append("<template>");
config.append(template);
config.append("</template>");
}
- if (actors!=null) {
+ if (actors != null) {
config.append("<actors>");
config.append(actors);
config.append("</actors>");
}
- if (to!=null) {
+ if (to != null) {
config.append("<to>");
config.append(to);
config.append("</to>");
}
- if (subject!=null) {
+ if (subject != null) {
config.append("<subject>");
config.append(subject);
config.append("</subject>");
}
- if (text!=null) {
+ if (text != null) {
config.append("<text>");
config.append(text);
config.append("</text>");
@@ -878,8 +858,10 @@
String mailClassName = Mail.class.getName();
if (JbpmConfiguration.Configs.hasObject("jbpm.mail.class.name")) {
- mailClassName = JbpmConfiguration.Configs.getString("jbpm.mail.class.name");
- } else if (JbpmConfiguration.Configs.hasObject("mail.class.name")) {
+ mailClassName =
+ JbpmConfiguration.Configs.getString("jbpm.mail.class.name");
+ }
+ else if (JbpmConfiguration.Configs.hasObject("mail.class.name")) {
mailClassName = JbpmConfiguration.Configs.getString("mail.class.name");
}
@@ -891,14 +873,12 @@
public String getProperty(String property, Element element) {
String value = element.attributeValue(property);
- if (value==null) {
+ if (value == null) {
Element propertyElement = element.element(property);
- if (propertyElement!=null) {
+ if (propertyElement != null) {
value = propertyElement.getText();
}
}
return value;
}
-
- private static final Log log = LogFactory.getLog(JpdlXmlReader.class);
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/Problem.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/Problem.java 2010-01-22 10:38:03 UTC (rev 6117)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/xml/Problem.java 2010-01-22 10:39:47 UTC (rev 6118)
@@ -26,19 +26,25 @@
import java.util.Iterator;
public class Problem implements Serializable {
-
+
private static final long serialVersionUID = 1L;
-
+
public static final int LEVEL_FATAL = 1;
public static final int LEVEL_ERROR = 2;
public static final int LEVEL_WARNING = 3;
public static final int LEVEL_INFO = 4;
static String getTypeDescription(int level) {
- if (level==LEVEL_FATAL) return "FATAL";
- if (level==LEVEL_ERROR) return "ERROR";
- if (level==LEVEL_WARNING) return "WARNING";
- if (level==LEVEL_INFO) return "INFO";
+ switch (level) {
+ case LEVEL_FATAL:
+ return "FATAL";
+ case LEVEL_ERROR:
+ return "ERROR";
+ case LEVEL_WARNING:
+ return "WARNING";
+ case LEVEL_INFO:
+ return "INFO";
+ }
return null;
}
@@ -48,7 +54,7 @@
protected String folder;
protected Integer line;
protected Throwable exception;
-
+
public Problem(int level, String description) {
this.level = level;
this.description = description;
@@ -59,24 +65,23 @@
this.description = description;
this.exception = exception;
}
-
+
public String toString() {
StringBuffer buffer = new StringBuffer();
- buffer.append("["+getTypeDescription(level)+"]");
- if (description!=null) buffer.append(" "+description);
- if (resource!=null) buffer.append(" at "+resource);
- if (line!=null) buffer.append(" line "+line);
- if (folder!=null) buffer.append(" in "+folder);
+ buffer.append('[').append(getTypeDescription(level)).append(']');
+ if (description != null) buffer.append(' ').append(description);
+ if (resource != null) {
+ buffer.append(" (").append(resource);
+ if (line != null) buffer.append(':').append(line);
+ buffer.append(')');
+ }
return buffer.toString();
}
-
+
public static boolean containsProblemsOfLevel(Collection c, int level) {
- Iterator iter = c.iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = c.iterator(); iter.hasNext();) {
Problem problem = (Problem) iter.next();
- if (problem.level <= level) {
- return true;
- }
+ if (problem.level <= level) return true;
}
return false;
}
@@ -84,33 +89,43 @@
public String getDescription() {
return description;
}
+
public void setDescription(String description) {
this.description = description;
}
+
public Throwable getException() {
return exception;
}
+
public void setException(Throwable exception) {
this.exception = exception;
}
+
public String getFolder() {
return folder;
}
+
public void setFolder(String folder) {
this.folder = folder;
}
+
public Integer getLine() {
return line;
}
+
public void setLine(Integer line) {
this.line = line;
}
+
public String getResource() {
return resource;
}
+
public void setResource(String resource) {
this.resource = resource;
}
+
public int getLevel() {
return level;
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/scheduler/def/CancelTimerAction.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/scheduler/def/CancelTimerAction.java 2010-01-22 10:38:03 UTC (rev 6117)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/scheduler/def/CancelTimerAction.java 2010-01-22 10:39:47 UTC (rev 6118)
@@ -22,33 +22,36 @@
package org.jbpm.scheduler.def;
import org.dom4j.Element;
+
import org.jbpm.graph.def.Action;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.jpdl.xml.JpdlXmlReader;
import org.jbpm.scheduler.SchedulerService;
-import org.jbpm.svc.Services;
public class CancelTimerAction extends Action {
private static final long serialVersionUID = 1L;
-
- String timerName = null;
-
+
+ String timerName;
+
public void read(Element actionElement, JpdlXmlReader jpdlReader) {
timerName = actionElement.attributeValue("name");
- if (timerName==null) {
- jpdlReader.addWarning("no 'name' specified in CancelTimerAction '"+actionElement.asXML()+"'");
+ if (timerName == null) {
+ jpdlReader.addWarning("timer name not specified on cancel timer: "
+ + actionElement.getPath());
}
}
public void execute(ExecutionContext executionContext) throws Exception {
- SchedulerService schedulerService = (SchedulerService) Services.getCurrentService(Services.SERVICENAME_SCHEDULER);
+ SchedulerService schedulerService =
+ executionContext.getJbpmContext().getServices().getSchedulerService();
schedulerService.deleteTimersByName(timerName, executionContext.getToken());
}
-
+
public String getTimerName() {
return timerName;
}
+
public void setTimerName(String timerName) {
this.timerName = timerName;
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/scheduler/def/CreateTimerAction.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/scheduler/def/CreateTimerAction.java 2010-01-22 10:38:03 UTC (rev 6117)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/scheduler/def/CreateTimerAction.java 2010-01-22 10:39:47 UTC (rev 6118)
@@ -25,6 +25,7 @@
import java.util.Date;
import org.dom4j.Element;
+
import org.jbpm.JbpmException;
import org.jbpm.calendar.BusinessCalendar;
import org.jbpm.calendar.Duration;
@@ -35,15 +36,13 @@
import org.jbpm.job.Timer;
import org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator;
import org.jbpm.jpdl.xml.JpdlXmlReader;
-import org.jbpm.jpdl.xml.Problem;
import org.jbpm.scheduler.SchedulerService;
-import org.jbpm.svc.Services;
import org.jbpm.util.Clock;
public class CreateTimerAction extends Action {
private static final long serialVersionUID = 1L;
- static final BusinessCalendar businessCalendar = new BusinessCalendar();
+ static final BusinessCalendar businessCalendar = new BusinessCalendar();
String timerName;
String dueDate;
@@ -56,68 +55,78 @@
timerAction = jpdlReader.readSingleAction(actionElement);
dueDate = actionElement.attributeValue("duedate");
- if (dueDate==null) {
- jpdlReader.addWarning("no duedate specified in create timer action '"+actionElement+"'");
+ if (dueDate == null) {
+ jpdlReader.addWarning("due date not specified on create timer: "
+ + actionElement.getPath());
}
repeat = actionElement.attributeValue("repeat");
- if ( "true".equalsIgnoreCase(repeat)
- || "yes".equalsIgnoreCase(repeat) ) {
+ if ("true".equalsIgnoreCase(repeat) || "yes".equalsIgnoreCase(repeat)) {
repeat = dueDate;
}
transitionName = actionElement.attributeValue("transition");
-
- if ( (transitionName!=null)
- && (repeat!=null)
- ) {
+
+ if (transitionName != null && repeat != null) {
repeat = null;
- jpdlReader.addProblem(new Problem(Problem.LEVEL_WARNING, "ignoring repeat on timer with transition "+actionElement.asXML()));
+ jpdlReader.addWarning("ignoring repeat on create timer with transition: "
+ + actionElement.getPath());
}
}
public void execute(ExecutionContext executionContext) throws Exception {
Timer timer = createTimer(executionContext);
- SchedulerService schedulerService = (SchedulerService) Services.getCurrentService(Services.SERVICENAME_SCHEDULER);
+ SchedulerService schedulerService =
+ executionContext.getJbpmContext().getServices().getSchedulerService();
schedulerService.createTimer(timer);
}
protected Timer createTimer(ExecutionContext executionContext) {
- Date baseDate = null;
- Date dueDateDate = null;
- Duration duration;
- String durationString = null;
- String durationSeparator = null;
Timer timer = new Timer(executionContext.getToken());
timer.setName(timerName);
timer.setRepeat(repeat);
- if (dueDate!=null) {
- if (dueDate.startsWith("#")) {
- String baseDateEL = dueDate.substring(0,dueDate.indexOf("}")+1);
- Object o = JbpmExpressionEvaluator.evaluate(baseDateEL, executionContext);
- if (o instanceof Date) {
- baseDate = (Date) o;
- } else {
- if (o instanceof Calendar) {
- baseDate = ((Calendar) o).getTime();
- } else {
- throw new JbpmException("Invalid basedate type: " + baseDateEL + " is of type " + o.getClass().getName() +". Only Date and Calendar are supported");
- }
+
+ if (dueDate != null) {
+ Date dueDateDate;
+ if (dueDate.startsWith("#{")) {
+ int braceIndex = dueDate.indexOf("}");
+ if (braceIndex == -1) {
+ throw new JbpmException("invalid due date, closing brace missing: "
+ + dueDate);
}
- int endOfELIndex = dueDate.indexOf("}");
- if (endOfELIndex < (dueDate.length() -1) ) {
- durationSeparator = dueDate.substring(endOfELIndex+1).trim().substring(0,1);
- if ( !(durationSeparator.equals("+") || durationSeparator.equals("-") ) ){
- throw new JbpmException("Invalid duedate, + or - missing after EL");
+
+ String baseDateEL = dueDate.substring(0, braceIndex + 1);
+ Object result =
+ JbpmExpressionEvaluator.evaluate(baseDateEL, executionContext);
+
+ Date baseDate;
+ if (result instanceof Date) {
+ baseDate = (Date) result;
+ }
+ else if (result instanceof Calendar) {
+ baseDate = ((Calendar) result).getTime();
+ }
+ else {
+ throw new JbpmException("invalid base date type: "
+ + result.getClass().getName());
+ }
+
+ String durationString = dueDate.substring(braceIndex + 1).trim();
+ if (durationString.length() > 0) {
+ char durationSeparator = durationString.charAt(0);
+ if (durationSeparator != '+' && durationSeparator != '-') {
+ throw new JbpmException("invalid due date, + or - missing: "
+ + dueDate);
}
- durationString = dueDate.substring(endOfELIndex+1).trim();
+ durationString = dueDate.substring(braceIndex + 1).trim();
+ dueDateDate =
+ businessCalendar.add(baseDate, new Duration(durationString));
}
- } else {
- durationString = dueDate;
+ else {
+ dueDateDate = baseDate;
+ }
}
- if (baseDate != null && (durationString == null || durationString.length() == 0)) {
- dueDateDate = baseDate;
- } else {
- duration = new Duration(durationString);
- dueDateDate = businessCalendar.add( (baseDate != null) ? baseDate : Clock.getCurrentTime(), duration );
+ else {
+ dueDateDate =
+ businessCalendar.add(Clock.getCurrentTime(), new Duration(dueDate));
}
timer.setDueDate(dueDateDate);
}
@@ -125,51 +134,60 @@
timer.setTransitionName(transitionName);
timer.setGraphElement(executionContext.getEventSource());
timer.setTaskInstance(executionContext.getTaskInstance());
-
+
// if this action was executed for a graph element
- if ( (getEvent()!=null)
- && (getEvent().getGraphElement()!=null)
- ) {
- GraphElement graphElement = getEvent().getGraphElement();
+ Event event = getEvent();
+ GraphElement graphElement;
+ if (event != null && (graphElement = event.getGraphElement()) != null) {
try {
executionContext.setTimer(timer);
// fire the create timer event on the same graph element
graphElement.fireEvent(Event.EVENTTYPE_TIMER_CREATE, executionContext);
- } finally {
+ }
+ finally {
executionContext.setTimer(null);
}
}
-
+
return timer;
}
-
+
public String getDueDate() {
return dueDate;
}
+
public void setDueDate(String dueDateDuration) {
this.dueDate = dueDateDuration;
}
+
public String getRepeat() {
return repeat;
}
+
public void setRepeat(String repeatDuration) {
this.repeat = repeatDuration;
}
+
public String getTransitionName() {
return transitionName;
}
+
public void setTransitionName(String transitionName) {
this.transitionName = transitionName;
}
+
public String getTimerName() {
return timerName;
}
+
public void setTimerName(String timerName) {
this.timerName = timerName;
}
+
public Action getTimerAction() {
return timerAction;
}
+
public void setTimerAction(Action timerAction) {
this.timerAction = timerAction;
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/scheduler/exe/SchedulerTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/scheduler/exe/SchedulerTest.java 2010-01-22 10:38:03 UTC (rev 6117)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/scheduler/exe/SchedulerTest.java 2010-01-22 10:39:47 UTC (rev 6118)
@@ -655,8 +655,7 @@
processInstance.signal();
}
catch (JbpmException je) {
- assertEquals("Invalid basedate type: #{dateOfPension} is of type java.lang.String. "
- + "Only Date and Calendar are supported", je.getMessage());
+ assert je.getMessage().indexOf("invalid base date") != -1 : je;
}
finally {
jbpmContext.close();
@@ -670,8 +669,7 @@
processInstance.signal();
}
catch (JbpmException je) {
- assertEquals("Invalid basedate type: #{dateOfPension} is of type java.lang.String. "
- + "Only Date and Calendar are supported", je.getMessage());
+ assert je.getMessage().indexOf("invalid base date") != -1 : je;
}
finally {
jbpmContext.close();
14 years, 4 months
JBoss JBPM SVN: r6117 - in projects/jsf-console/branches/jsf-console-3.3.1.SP: gpd-deployer/src/main/java/org/jbpm/web and 1 other directory.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-01-22 05:38:03 -0500 (Fri, 22 Jan 2010)
New Revision: 6117
Modified:
projects/jsf-console/branches/jsf-console-3.3.1.SP/gpd-deployer/src/main/java/org/jbpm/web/ProcessUploadServlet.java
projects/jsf-console/branches/jsf-console-3.3.1.SP/pom.xml
Log:
SOA-1586: avoid printing and sending back stack traces after deploying invalid process definition
Modified: projects/jsf-console/branches/jsf-console-3.3.1.SP/gpd-deployer/src/main/java/org/jbpm/web/ProcessUploadServlet.java
===================================================================
--- projects/jsf-console/branches/jsf-console-3.3.1.SP/gpd-deployer/src/main/java/org/jbpm/web/ProcessUploadServlet.java 2010-01-21 21:40:24 UTC (rev 6116)
+++ projects/jsf-console/branches/jsf-console-3.3.1.SP/gpd-deployer/src/main/java/org/jbpm/web/ProcessUploadServlet.java 2010-01-22 10:38:03 UTC (rev 6117)
@@ -25,6 +25,7 @@
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.MalformedURLException;
+import java.util.List;
import java.util.zip.ZipInputStream;
import javax.servlet.ServletException;
@@ -41,6 +42,9 @@
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.jpdl.JpdlException;
+import org.jbpm.jpdl.xml.Problem;
+import org.jbpm.util.IoUtil;
public class ProcessUploadServlet extends javax.servlet.http.HttpServlet {
@@ -74,6 +78,15 @@
ProcessDefinition processDefinition = parseProcessArchive(processStream);
deployProcessDefinition(processDefinition, response);
}
+ catch (JpdlException e) {
+ List problems = e.getProblems();
+ StringBuffer message = new StringBuffer();
+ for (int i = 0, n = problems.size(); i < n; i++) {
+ Problem problem = (Problem) problems.get(i);
+ message.append(problem).append(IoUtil.lineSeparator);
+ }
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, message.toString());
+ }
finally {
jbpmContext.close();
}
Modified: projects/jsf-console/branches/jsf-console-3.3.1.SP/pom.xml
===================================================================
--- projects/jsf-console/branches/jsf-console-3.3.1.SP/pom.xml 2010-01-21 21:40:24 UTC (rev 6116)
+++ projects/jsf-console/branches/jsf-console-3.3.1.SP/pom.xml 2010-01-22 10:38:03 UTC (rev 6117)
@@ -43,7 +43,7 @@
<jbpm.version>3.2.8</jbpm.version>
<jboss.gravel.version>1.0.0.GA</jboss.gravel.version>
<junit.version>3.8.1</junit.version>
- <sun.facelets.version>1.1.15.B1</sun.facelets.version>
+ <sun.facelets.version>1.1.15</sun.facelets.version>
</properties>
<!-- DependencyManagement -->
14 years, 4 months
JBoss JBPM SVN: r6116 - in jbpm4/trunk/modules/jpdl/src: main/java/org/jbpm/jpdl/internal/xml and 1 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-01-21 16:40:24 -0500 (Thu, 21 Jan 2010)
New Revision: 6116
Added:
jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ActivityParsingTest.java
jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlParseTestCase.java
Log:
JBPM-2560: incorporate patch and test case
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2010-01-21 14:27:19 UTC (rev 6115)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2010-01-21 21:40:24 UTC (rev 6116)
@@ -28,7 +28,7 @@
import org.jbpm.api.JbpmException;
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.model.Transition;
-import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cal.BusinessCalendar;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.events.TaskActivityStart;
@@ -50,8 +50,6 @@
private static final long serialVersionUID = 1L;
- private static final Log log = Log.getLog(TaskActivity.class.getName());
-
protected TaskDefinitionImpl taskDefinition;
public void execute(ActivityExecution execution) {
@@ -76,7 +74,13 @@
task.setDescription(taskDefinition.getDescription());
task.setPriority(taskDefinition.getPriority());
task.setFormResourceName(taskDefinition.getFormResourceName());
-
+
+ // calculate the due date of the task based on the due date duration
+ if (taskDefinition.getDueDateDuration() != null) {
+ BusinessCalendar businessCalendar = EnvironmentImpl.getFromCurrent(BusinessCalendar.class);
+ task.setDuedate(businessCalendar.add(task.getCreateTime(), taskDefinition.getDueDateDuration()));
+ }
+
// save task so that TaskDbSession.findTaskByExecution works for assign event listeners
dbSession.save(task);
@@ -159,28 +163,14 @@
// Likely a programmatic error.
throw new JbpmException("No transition named '" + signalName + "' was found.");
}
-
}
if (transition!=null) {
execution.take(transition);
}
-
}
}
- /**
- * Checks if the given collection of transitions are all named or not.
- */
- private boolean allTransitionsNamed(Collection<Transition> transitions) {
- for (Transition transition : transitions) {
- if (transition.getName() == null) {
- return false;
- }
- }
- return true;
- }
-
public TaskDefinitionImpl getTaskDefinition() {
return taskDefinition;
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2010-01-21 14:27:19 UTC (rev 6115)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2010-01-21 21:40:24 UTC (rev 6116)
@@ -526,7 +526,15 @@
String form = XmlUtil.attribute(element, "form");
taskDefinition.setFormResourceName(form);
-
+
+ String duedate = XmlUtil.attribute(element, "duedate");
+ taskDefinition.setDueDateDuration(duedate);
+
+ Integer priority = XmlUtil.attributeInteger(element, "priority", false, parse);
+ if (priority != null) {
+ taskDefinition.setPriority(priority);
+ }
+
ProcessDefinitionImpl processDefinition = parse.contextStackFind(ProcessDefinitionImpl.class);
if (processDefinition.getTaskDefinition(taskName)!=null) {
parse.addProblem("duplicate task name "+taskName, element);
Modified: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ActivityParsingTest.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ActivityParsingTest.java 2010-01-21 14:27:19 UTC (rev 6115)
+++ jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ActivityParsingTest.java 2010-01-21 21:40:24 UTC (rev 6116)
@@ -31,7 +31,7 @@
*/
public class ActivityParsingTest extends JpdlParseTestCase {
- public void testInvalidActivityeName() {
+ public void testInvalidActivityName() {
List<Problem> problems = parseProblems(
"<process name='p'>" +
" <state name='invalid / activityname' />" +
Modified: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlParseTestCase.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlParseTestCase.java 2010-01-21 14:27:19 UTC (rev 6115)
+++ jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlParseTestCase.java 2010-01-21 21:40:24 UTC (rev 6116)
@@ -25,11 +25,9 @@
import org.jbpm.jpdl.internal.xml.JpdlParser;
import org.jbpm.pvm.internal.client.ClientProcessDefinition;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
import org.jbpm.pvm.internal.xml.Problem;
import org.jbpm.test.BaseJbpmTestCase;
-
/**
* @author Tom Baeyens
*/
@@ -52,17 +50,17 @@
public ClientProcessDefinition parse(String xmlString) {
JpdlParser jpdlParser = new JpdlParser();
- List<ProcessDefinitionImpl> processDefinitions = (List<ProcessDefinitionImpl>) jpdlParser.createParse()
+ Object documentObject = jpdlParser.createParse()
.setString(xmlString)
.execute()
.checkErrors("process definition xml string")
.getDocumentObject();
- if ( (processDefinitions==null)
- || (processDefinitions.isEmpty())
- ) {
- return null;
+ if (documentObject instanceof List<?>) {
+ List<?> processDefinitions = (List<?>) documentObject;
+ if (!processDefinitions.isEmpty())
+ return (ClientProcessDefinition) processDefinitions.get(0);
}
- return processDefinitions.get(0);
+ return null;
}
}
Added: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java 2010-01-21 21:40:24 UTC (rev 6116)
@@ -0,0 +1,43 @@
+package org.jbpm.jpdl.parsing;
+
+import org.jbpm.api.activity.ActivityBehaviour;
+import org.jbpm.api.model.Activity;
+import org.jbpm.jpdl.internal.activity.TaskActivity;
+import org.jbpm.pvm.internal.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
+
+public class TaskParsingTest extends JpdlParseTestCase {
+
+ public static final String PROCESS = "<process name='Test Task Parsing'>"
+ + " <start>"
+ + " <transition to='t1' />"
+ + " </start>"
+ + " <task name='t1' duedate='1 day' priority='3' form='aForm'>"
+ + " <description>first task</description>"
+ + " <transition to='end' />"
+ + " </task>"
+ + " <end name='end' />"
+ + "</process>";
+
+ public void testTaskParse() {
+ ClientProcessDefinition definition = parse(PROCESS);
+
+ Activity activity = definition.findActivity("t1");
+ assert activity instanceof ActivityImpl : activity.getClass();
+ ActivityImpl activityImpl = (ActivityImpl) activity;
+
+ ActivityBehaviour behaviour = activityImpl.getActivityBehaviour();
+ assert behaviour instanceof TaskActivity : behaviour.getClass();
+
+ TaskActivity taskActivity = (TaskActivity) behaviour;
+ TaskDefinitionImpl taskDefinition = taskActivity.getTaskDefinition();
+
+ // check for properties not previously parsed
+ assertEquals("first task", taskDefinition.getDescription());
+ assertEquals(3, taskDefinition.getPriority());
+ assertEquals("aForm", taskDefinition.getFormResourceName());
+ assertEquals("1 day", taskDefinition.getDueDateDuration());
+ }
+
+}
Property changes on: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
14 years, 4 months
JBoss JBPM SVN: r6115 - in jbpm4/trunk/modules: devguide/src/main/docbook/en/modules and 4 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2010-01-21 09:27:19 -0500 (Thu, 21 Jan 2010)
New Revision: 6115
Added:
jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.intermediate.timer.png
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml
Modified:
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
Log:
JBPM-2727: documented intermediate catch timer event
Added: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.intermediate.timer.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.intermediate.timer.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2010-01-21 12:06:28 UTC (rev 6114)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2010-01-21 14:27:19 UTC (rev 6115)
@@ -1212,6 +1212,141 @@
</section> <!-- End of basic constructs section -->
+ <section id="advancedConstructs">
+
+ <title>Advanced constructs</title>
+
+ <section id="intermediateEvents">
+
+ <title>Intermediate events</title>
+
+ <para>
+ An intermediate event is used to model something that happens during a process (ie. after
+ the process has started and before it is ended). Intermediate events are visualized as
+ a circle with a double border, with an icon indicating the event type within the circle.
+ </para>
+
+ <para>
+ There are several intermediate event types, such as a timer event, signal event, escalation
+ event, etc. Intermediate events can be either throwing or catching:
+ <itemizedlist>
+ <listitem>
+ <emphasis role="bold">Throwing: </emphasis>when an execution arrives in the event, it
+ immediately fires a certain trigger (a signal, an error, etc.). Throwing events can
+ be graphically recognized by the icon that is filled in with black.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Catching: </emphasis>when an execution arrives in the event,
+ it will wait for a certain trigger to happen (an error, a timer, etc.). Catching events
+ can be graphically recognized by the icon that is not filled with black (ie. white inside).
+ </listitem>
+ </itemizedlist>
+ </para>
+
+ </section> <!-- end of intermediate events -->
+
+ <section id="intermediateCatchTimer">
+
+ <title>Intermediate catch event: Timer </title>
+
+ <para>
+ An intermediate timer event is used to represent a <emphasis role="bold">delay</emphasis>
+ in the process. Straightfoward use cases are for example polling of data, executing
+ heavy logic only at night when nobody is working, etc.
+ </para>
+
+ <para>
+ Note that an intermediate timer only can be used as a catch event (throwing a timer event
+ makes no sense). The following diagram shows how the intermediate timer event is visualized.
+ <mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.intermediate.timer.png"/></imageobject></mediaobject>
+ Defining an intermediate timer event is done in XML as follows:
+ <programlisting>
+<intermediateCatchEvent id="myTimer" name="Wait for an hour">
+ <timerEventDefinition>
+ <timeCycle>1 hour</timeCycle>
+ </timerEventDefinition>
+</intermediateCatchEvent>
+ </programlisting>
+ There are two ways to specify the delay, using either a <emphasis role="bold">timeCycle
+ or a timeDate</emphasis>. In the example above, a timeCycle is used.
+ </para>
+
+ <para>
+ Following delay definitions are possible.
+ <itemizedlist>
+ <listitem>
+ <emphasis role="bold">timeDate: </emphasis>specifies a fixed date when the timer will
+ fire and the process continues. The default format of the date specification is
+ "dd/MM/yyyy hh:mm:ss". This can engine-wide be changed by setting the
+ <emphasis role="bold">jbpm.duedatetime.format</emphasis> property in the configuration.
+ <programlisting>
+<intermediateCatchEvent id="myTimer" >
+ <timerEventDefinition>
+ <emphasis role="bold"><timeDate>10/10/2099 00:00:00</timeDate></emphasis>
+ </timerEventDefinition>
+</intermediateCatchEvent>
+ </programlisting>
+ </listitem>
+ <listitem>
+ <emphasis role="bold">timeCycle: </emphasis>specifies a delay duration relative to the
+ time when the execution enters the timer event. Two possible definitions are possible
+
+ <para>
+ <emphasis role="bold">Duration expression: </emphasis>
+ <programlisting>
+quantity [business] {second | seconds | minute | minutes |
+ hour | hours | day | days | week |
+ weeks | month | months | year | years}
+ </programlisting>
+ This is completely similar to a timer duration definition in JPDL. Note that the
+ BPMN2 intermediate timer event also understands "business time". This
+ allows for example to define a "business day" as an interval from
+ 9am to 5pm. Timers that are started at 4pm with a duration of 2 hours, will fire
+ at 10am the next business day. Please refer to the JPDL userguide for more details
+ on how this business calendar can be customized.
+ <programlisting>
+<intermediateCatchEvent id="intermediateTimer" >
+ <timerEventDefinition>
+ <emphasis role="bold"><timeCycle>5 hours</timeCycle></emphasis>
+ </timerEventDefinition>
+</intermediateCatchEvent>
+ </programlisting>
+ </para>
+ <para>
+ <emphasis role="bold">Cron expression: </emphasis>altough duration expressions cover
+ already a great deal of delay definitions, sometimes they are not easy to use. When
+ for example the process should be delayed until Friday night 23pm such that the
+ processes can be executed in the weekend, duration expressions are hard to use
+ (you need something like "#{calculated_value} seconds", where you need
+ to calculate the value first).
+ </para>
+ <para>
+ <ulink url="http://en.wikipedia.org/wiki/CRON_expression">Cron expressions</ulink>
+ allow to define delays in a way many people know (since cron expressions
+ are used to define scheduled task on Unix machines). Note that a cron expression
+ typically is used to define repetion. In this context however, the
+ <emphasis role="bold">first point in time where the cron expression is satisfied</emphasis>
+ is used to set the due date of the timer event (so no repetition). The following example
+ shows how an intermediate timer event can be specified to continue the process
+ the next friday night at 23pm.
+ <programlisting>
+<intermediateCatchEvent id="intermediateTimer" >
+ <timerEventDefinition>
+ <emphasis role="bold"><timeCycle>0 0 23 ? * FRI</timeCycle></emphasis>
+ </timerEventDefinition>
+</intermediateCatchEvent>
+ </programlisting>
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+
+ </section> <!-- end of intermediate catch event -->
+
+ </section> <!-- End of advanced constructs -->
+
+
+
<section id="completeExample">
<title>Complete example (including console task forms)</title>
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java 2010-01-21 14:27:19 UTC (rev 6115)
@@ -0,0 +1,65 @@
+/*
+ * 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.examples.bpmn.event.timer;
+
+import java.util.Date;
+
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ *
+ * @author Joram Barrez
+ */
+public class IntermediateTimerTest extends JbpmTestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ NewDeployment deployment = repositoryService.createDeployment();
+ deployment.addResourceFromClasspath("org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml");
+ registerDeployment(deployment.deploy());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Clock.setCurrentTime(null);
+ }
+
+ public void testIntermediateTimerWithDuration() {
+ Clock.setCurrentTime(new Date(0));
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("intermediateTimerCatch");
+ Job timerJob = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+ assertEquals(timerJob.getDuedate().getTime(), new Date(60 * 60 *1000).getTime());
+
+ managementService.executeJob(timerJob.getId());
+ assertProcessInstanceEnded(processInstance);
+ }
+
+}
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml 2010-01-21 14:27:19 UTC (rev 6115)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 ../../../../../../../../../../bpmn/src/main/resources/BPMN20.xsd"
+ xmlns="http://schema.omg.org/spec/BPMN/2.0" typeLanguage="http://www.w3.org/2001/XMLSchema"
+ expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://jbpm.org/example/bpmn2/intermediateTimerCatch">
+
+ <process id="intermediateTimerCatch" name="Bpmn 2.0 example intermediate timer catch event">
+
+ <startEvent id="theStart" />
+
+ <sequenceFlow id="flow1" sourceRef="theStart" targetRef="myTimer" />
+
+ <intermediateCatchEvent id="myTimer" name="Wait for an hour">
+ <timerEventDefinition>
+ <timeCycle xsi:type="tFormalExpression">1 hour</timeCycle>
+ </timerEventDefinition>
+ </intermediateCatchEvent>
+
+ <sequenceFlow id="flow2" sourceRef="myTimer" targetRef="theEnd" />
+
+ <endEvent id="theEnd" />
+
+ </process>
+</definitions>
14 years, 4 months
JBoss JBPM SVN: r6114 - jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2010-01-21 07:06:28 -0500 (Thu, 21 Jan 2010)
New Revision: 6114
Modified:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java
Log:
Fix for Hudson
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java 2010-01-21 11:56:54 UTC (rev 6113)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java 2010-01-21 12:06:28 UTC (rev 6114)
@@ -110,7 +110,22 @@
" </process>" +
"</definitions>";
+ private static final String TIMER_CATCH_WITH_CRON_EXPRESSION_2 =
+ "<definitions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
+ " <process id='timeDateProcess'>" +
+ " <startEvent id='theStart' />" +
+ " <sequenceFlow id='flow1' sourceRef='theStart' targetRef='intermediateTimer' />" +
+ " <intermediateCatchEvent id='intermediateTimer' >" +
+ " <timerEventDefinition>" +
+ " <timeCycle>0 0 23 ? * FRI</timeCycle>" + // Every friday at 23:00
+ " </timerEventDefinition>" +
+ " </intermediateCatchEvent>" +
+ " <sequenceFlow id='flow2' sourceRef='intermediateTimer' targetRef='theEnd' />" +
+ " <endEvent id='theEnd' />" +
+ " </process>" +
+ "</definitions>";
+
@Override
protected void tearDown() throws Exception {
super.tearDown();
@@ -159,28 +174,42 @@
CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
Job timerJob = managementService.createJobQuery().processInstanceId(pi.getId()).uniqueResult();
- Date expectedDueDate = getDate(10, Calendar.OCTOBER, 2099);
+ Date expectedDueDate = getDateAtMidnight(10, Calendar.OCTOBER, 2099);
assertEquals(expectedDueDate.getTime(), timerJob.getDuedate().getTime());
managementService.executeJob(timerJob.getId());
assertProcessInstanceEnded(pi);
}
- public void testCronExpression() throws InterruptedException {
+ public void testCronExpression() {
deployBpmn2XmlString(TIMER_CATCH_WITH_CRON_EXPRESSION);
- Clock.setCurrentTime(new Date(61000)); // Start on 61 seconds
+ Clock.setCurrentTime(getDate(20, Calendar.JANUARY, 2010, 0, 1, 1)); // Start on 61 seconds
ProcessInstance pi = executionService.startProcessInstanceByKey("timeDateProcess");
CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
Job timerJob = managementService.createJobQuery().processInstanceId(pi.getId()).uniqueResult();
- assertEquals(120000, timerJob.getDuedate().getTime());
+ assertEquals(getDate(20, Calendar.JANUARY, 2010, 0, 2, 0).getTime(), timerJob.getDuedate().getTime());
managementService.executeJob(timerJob.getId());
assertProcessInstanceEnded(pi);
}
- private Date getDate(int day, int month, int year) {
+ public void testCronExpression2() {
+ deployBpmn2XmlString(TIMER_CATCH_WITH_CRON_EXPRESSION_2);
+ Clock.setCurrentTime(getDateAtMidnight(21, Calendar.JANUARY, 2010)); // 21/01/2009 is a Thursday
+
+ ProcessInstance pi = executionService.startProcessInstanceByKey("timeDateProcess");
+ CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
+
+ Job timerJob = managementService.createJobQuery().processInstanceId(pi.getId()).uniqueResult();
+ assertEquals(getDate(22, Calendar.JANUARY, 2010, 23, 0, 0).getTime(), timerJob.getDuedate().getTime());
+
+ managementService.executeJob(timerJob.getId());
+ assertProcessInstanceEnded(pi);
+ }
+
+ private Date getDateAtMidnight(int day, int month, int year) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, day);
cal.set(Calendar.MONTH, month);
@@ -191,6 +220,18 @@
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
+
+ private Date getDate(int day, int month, int year, int hour, int minute, int second) {
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.DAY_OF_MONTH, day);
+ cal.set(Calendar.MONTH, month);
+ cal.set(Calendar.YEAR, year);
+ cal.set(Calendar.HOUR_OF_DAY, hour);
+ cal.set(Calendar.MINUTE, minute);
+ cal.set(Calendar.SECOND, second);
+ cal.set(Calendar.MILLISECOND, 0);
+ return cal.getTime();
+ }
}
14 years, 4 months
JBoss JBPM SVN: r6113 - jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2010-01-21 06:56:54 -0500 (Thu, 21 Jan 2010)
New Revision: 6113
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java
Log:
Fix for Hudson
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java 2010-01-21 09:17:34 UTC (rev 6112)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java 2010-01-21 11:56:54 UTC (rev 6113)
@@ -13,6 +13,8 @@
import java.util.TimeZone;
import java.util.TreeSet;
+import org.jbpm.pvm.internal.util.Clock;
+
/**
* Provides a parser and evaluator for unix-like cron expressions. Cron
* expressions provide the ability to specify complex time combinations such as
@@ -1031,8 +1033,10 @@
protected Date getTimeAfter(Date afterTime) {
- Calendar cl = Calendar.getInstance(getTimeZone());
-
+ //Calendar cl = Calendar.getInstance(getTimeZone());
+ Calendar cl = Calendar.getInstance();
+ cl.setTime(Clock.getCurrentTime());
+
// move ahead one second, since we're computing the time *after* the
// given time
afterTime = new Date(afterTime.getTime() + 1000);
14 years, 4 months
JBoss JBPM SVN: r6112 - in jbpm4/trunk/modules: test-db and 1 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2010-01-21 04:17:34 -0500 (Thu, 21 Jan 2010)
New Revision: 6112
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendarImpl.java
jbpm4/trunk/modules/test-db/pom.xml
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java
Log:
Fix for Hudson
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendarImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendarImpl.java 2010-01-21 09:12:26 UTC (rev 6111)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendarImpl.java 2010-01-21 09:17:34 UTC (rev 6112)
@@ -28,6 +28,7 @@
import java.util.TimeZone;
import org.jbpm.api.JbpmException;
+import org.jbpm.pvm.internal.util.Clock;
/**
* a calendar that knows about business hours.
@@ -85,7 +86,7 @@
Date end = null;
long millis = convertToMillis(duration);
end = new Date(date.getTime()-millis);
- if (end.before(new Date())) {
+ if (end.before(Clock.getCurrentTime())) {
throw new JbpmException("Duedate "+ end+ " in the past");
}
return end;
Modified: jbpm4/trunk/modules/test-db/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-db/pom.xml 2010-01-21 09:12:26 UTC (rev 6111)
+++ jbpm4/trunk/modules/test-db/pom.xml 2010-01-21 09:17:34 UTC (rev 6112)
@@ -105,8 +105,7 @@
<trimStackTrace>false</trimStackTrace>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<excludes>
- <exclude>org/jbpm/bpmn/UserTaskTest.java</exclude>
- <exclude>org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java</exclude>
+
</excludes>
</configuration>
</plugin>
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java 2010-01-21 09:12:26 UTC (rev 6111)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java 2010-01-21 09:17:34 UTC (rev 6112)
@@ -166,9 +166,9 @@
assertProcessInstanceEnded(pi);
}
- public void testCronExpression() {
+ public void testCronExpression() throws InterruptedException {
deployBpmn2XmlString(TIMER_CATCH_WITH_CRON_EXPRESSION);
- Clock.setCurrentTime(new Date(61000)); // Start on 35 seconds
+ Clock.setCurrentTime(new Date(61000)); // Start on 61 seconds
ProcessInstance pi = executionService.startProcessInstanceByKey("timeDateProcess");
CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
14 years, 4 months