JBoss JBPM SVN: r5489 - in jbpm4/branches/tbaeyens/modules/pvm/src/main: java/org/jbpm/pvm/internal/wire/descriptor and 1 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-08-18 10:05:46 -0400 (Tue, 18 Aug 2009)
New Revision: 5489
Modified:
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CommandServiceDescriptor.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/resources/jbpm.tx.cmd.cfg.xml
Log:
fixed command based interceptor stack
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java 2009-08-18 10:34:02 UTC (rev 5488)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java 2009-08-18 14:05:46 UTC (rev 5489)
@@ -42,8 +42,8 @@
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.cmd.CommandService;
import org.jbpm.pvm.internal.env.Context;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.JbpmConfigurationParser;
import org.jbpm.pvm.internal.env.PvmEnvironment;
import org.jbpm.pvm.internal.env.UserProvidedEnvironmentObject;
@@ -53,9 +53,6 @@
import org.jbpm.pvm.internal.stream.StreamInput;
import org.jbpm.pvm.internal.stream.StringStreamInput;
import org.jbpm.pvm.internal.stream.UrlStreamInput;
-import org.jbpm.pvm.internal.svc.DefaultCommandService;
-import org.jbpm.pvm.internal.svc.EnvironmentInterceptor;
-import org.jbpm.pvm.internal.tx.StandardTransactionInterceptor;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireDefinition;
import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
@@ -102,6 +99,8 @@
protected ThreadLocal<List<UserProvidedEnvironmentObject>> userProvidedEnvironmentObjectsThreadLocal = new ThreadLocal<List<UserProvidedEnvironmentObject>>();
protected ThreadLocal<String> authenticatedUserIdThreadLocal = new ThreadLocal<String>();
+ protected CommandService userCommandService = null;
+
public JbpmConfiguration() {
super((Configuration)null);
}
@@ -130,6 +129,7 @@
}
}
}
+ userCommandService = (CommandService) processEngineWireContext.get("user.command.service");
return this;
}
@@ -320,20 +320,10 @@
environmentObjects.add(userProvidedEnvironmentObject);
}
- EnvironmentInterceptor environmentInterceptor = new EnvironmentInterceptor();
- StandardTransactionInterceptor standardTransactionInterceptor = new StandardTransactionInterceptor();
- DefaultCommandService defaultCommandService = new DefaultCommandService();
-
- {
- environmentInterceptor.setNext(standardTransactionInterceptor);
- environmentInterceptor.setEnvironmentFactory(this);
- standardTransactionInterceptor.setNext(defaultCommandService);
- }
-
public <T> T execute(Command<T> command) {
EnvironmentImpl environment = openEnvironment();
try {
- return environmentInterceptor.execute(command);
+ return userCommandService.execute(command);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CommandServiceDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CommandServiceDescriptor.java 2009-08-18 10:34:02 UTC (rev 5488)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CommandServiceDescriptor.java 2009-08-18 14:05:46 UTC (rev 5489)
@@ -54,7 +54,7 @@
}
public Class< ? > getType(WireDefinition wireDefinition) {
- return CommandService.class;
+ return (name==null ? CommandService.class : null);
}
public void addInterceptorDescriptor(Descriptor descriptor) {
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/resources/jbpm.tx.cmd.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/resources/jbpm.tx.cmd.cfg.xml 2009-08-18 10:34:02 UTC (rev 5488)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/resources/jbpm.tx.cmd.cfg.xml 2009-08-18 14:05:46 UTC (rev 5489)
@@ -3,6 +3,11 @@
<jbpm-configuration>
<process-engine-context>
+ <command-service name="user.command.service">
+ <retry-interceptor />
+ <environment-interceptor />
+ <standard-transaction-interceptor />
+ </command-service>
<command-service />
</process-engine-context>
16 years, 8 months
JBoss JBPM SVN: r5488 - in jbpm4/branches/tbaeyens/modules: pvm/src/main/resources and 3 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-08-18 06:34:02 -0400 (Tue, 18 Aug 2009)
New Revision: 5488
Modified:
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/resources/jbpm.tx.cmd.cfg.xml
jbpm4/branches/tbaeyens/modules/test-cfg/src/test/java/org/jbpm/test/hibernatelongid/HibernateLongIdTest.java
jbpm4/branches/tbaeyens/modules/test-cfg/src/test/resources/logging.properties
jbpm4/branches/tbaeyens/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml
Log:
fixed command based interceptor stack
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java 2009-08-18 10:20:35 UTC (rev 5487)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java 2009-08-18 10:34:02 UTC (rev 5488)
@@ -33,6 +33,7 @@
import org.jbpm.api.ExecutionService;
import org.jbpm.api.HistoryService;
import org.jbpm.api.IdentityService;
+import org.jbpm.api.JbpmException;
import org.jbpm.api.ManagementService;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.RepositoryService;
@@ -52,6 +53,9 @@
import org.jbpm.pvm.internal.stream.StreamInput;
import org.jbpm.pvm.internal.stream.StringStreamInput;
import org.jbpm.pvm.internal.stream.UrlStreamInput;
+import org.jbpm.pvm.internal.svc.DefaultCommandService;
+import org.jbpm.pvm.internal.svc.EnvironmentInterceptor;
+import org.jbpm.pvm.internal.tx.StandardTransactionInterceptor;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireDefinition;
import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
@@ -316,10 +320,24 @@
environmentObjects.add(userProvidedEnvironmentObject);
}
+ EnvironmentInterceptor environmentInterceptor = new EnvironmentInterceptor();
+ StandardTransactionInterceptor standardTransactionInterceptor = new StandardTransactionInterceptor();
+ DefaultCommandService defaultCommandService = new DefaultCommandService();
+
+ {
+ environmentInterceptor.setNext(standardTransactionInterceptor);
+ environmentInterceptor.setEnvironmentFactory(this);
+ standardTransactionInterceptor.setNext(defaultCommandService);
+ }
+
public <T> T execute(Command<T> command) {
EnvironmentImpl environment = openEnvironment();
try {
- return get(CommandService.class).execute(command);
+ return environmentInterceptor.execute(command);
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JbpmException(e.getMessage(), e);
} finally {
environment.close();
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/resources/jbpm.tx.cmd.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/resources/jbpm.tx.cmd.cfg.xml 2009-08-18 10:20:35 UTC (rev 5487)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/resources/jbpm.tx.cmd.cfg.xml 2009-08-18 10:34:02 UTC (rev 5488)
@@ -3,9 +3,7 @@
<jbpm-configuration>
<process-engine-context>
- <command-service>
- <standard-transaction-interceptor />
- </command-service>
+ <command-service />
</process-engine-context>
<transaction-context>
Modified: jbpm4/branches/tbaeyens/modules/test-cfg/src/test/java/org/jbpm/test/hibernatelongid/HibernateLongIdTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-cfg/src/test/java/org/jbpm/test/hibernatelongid/HibernateLongIdTest.java 2009-08-18 10:20:35 UTC (rev 5487)
+++ jbpm4/branches/tbaeyens/modules/test-cfg/src/test/java/org/jbpm/test/hibernatelongid/HibernateLongIdTest.java 2009-08-18 10:34:02 UTC (rev 5488)
@@ -38,7 +38,7 @@
/**
- * @author Tom Baeyens
+ * @authorX Tom Baeyens
*/
public class HibernateLongIdTest extends JbpmCustomCfgTestCase {
Modified: jbpm4/branches/tbaeyens/modules/test-cfg/src/test/resources/logging.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-cfg/src/test/resources/logging.properties 2009-08-18 10:20:35 UTC (rev 5487)
+++ jbpm4/branches/tbaeyens/modules/test-cfg/src/test/resources/logging.properties 2009-08-18 10:34:02 UTC (rev 5488)
@@ -1,10 +1,12 @@
handlers= java.util.logging.ConsoleHandler
redirect.commons.logging = enabled
-java.util.logging.ConsoleHandler.level = FINE
+java.util.logging.ConsoleHandler.level = FINEST
java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
org.jbpm.level=FINE
+org.jbpm.pvm.internal.tx.level=FINEST
+# org.jbpm.pvm.internal.wire.level=FINEST
# org.jbpm.pvm.internal.tx.level=FINE
# org.jbpm.pvm.internal.wire.level=FINE
# org.jbpm.pvm.internal.util.level=FINE
Modified: jbpm4/branches/tbaeyens/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml 2009-08-18 10:20:35 UTC (rev 5487)
+++ jbpm4/branches/tbaeyens/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml 2009-08-18 10:34:02 UTC (rev 5488)
@@ -2,7 +2,6 @@
<jbpm-configuration>
- <import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<import resource="jbpm.tx.cmd.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
16 years, 8 months
JBoss JBPM SVN: r5487 - jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-08-18 06:20:35 -0400 (Tue, 18 Aug 2009)
New Revision: 5487
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java
Log:
remove unused imports
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java 2009-08-18 09:54:01 UTC (rev 5486)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java 2009-08-18 10:20:35 UTC (rev 5487)
@@ -23,9 +23,6 @@
import java.io.IOException;
import java.io.InputStream;
-import java.sql.PreparedStatement;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
16 years, 8 months
JBoss JBPM SVN: r5486 - in jbpm3/branches/jbpm-3.2-soa/modules: core/src/main/java/org/jbpm/db and 11 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-08-18 05:54:01 -0400 (Tue, 18 Aug 2009)
New Revision: 5486
Added:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedStringType.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedTextType.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/SybaseTextType.java
Removed:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.sybase.hbm.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.sybase.hbm.xml
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.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/job/executor/JobExecutorThread.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.mapping.sybase.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.db2.hbm.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.hbm.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.sybase.hbm.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.hbm.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.hbm.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/graph/log/ActionLogDbTest.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2375/JBPM2375Test.java
jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
Log:
[JBPM-2488] jBPM exception logging can block execution of all processes
cap length of stack traces
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -21,12 +21,13 @@
*/
package org.jbpm;
-import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jbpm.util.ClassUtil;
+
public abstract class AbstractJbpmTestCase extends TestCase {
private static Log log = LogFactory.getLog(AbstractJbpmTestCase.class);
@@ -44,21 +45,10 @@
}
protected String getShortName() {
- String shortName = getClass().getName();
- return shortName.substring(shortName.lastIndexOf('.') + 1) + "." + getName();
+ return ClassUtil.getSimpleName(getClass()) + '.' + getName();
}
protected String getLongName() {
- return getClass().getName() + "." + getName();
+ return getClass().getName() + '.' + getName();
}
-
- protected void runTest() throws Throwable {
- try {
- super.runTest();
- }
- catch (AssertionFailedError e) {
- log.error("ASSERTION FAILURE: " + e.getMessage());
- throw e;
- }
- }
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -64,6 +64,17 @@
beginSessionTransaction();
}
+ protected void runTest() throws Throwable {
+ try {
+ super.runTest();
+ }
+ catch (Exception e) {
+ // prevent unsafe use of the session after an exception occurs
+ jbpmContext.setRollbackOnly();
+ throw e;
+ }
+ }
+
protected void tearDown() throws Exception {
commitAndCloseSession();
ensureCleanDatabase();
@@ -84,14 +95,8 @@
Long count = (Long) entry.getValue();
if (count.intValue() != 0) {
hasLeftOvers = true;
- System.err.println("FIXME: " +
- getClass().getName() +
- "." +
- getName() +
- " left " +
- count +
- " records in " +
- entry.getKey());
+ System.err.println("FIXME: " + getClass().getName() + "." + getName() + " left "
+ + count + " records in " + entry.getKey());
}
}
@@ -201,7 +206,8 @@
}
if (currentCount < previousCount) {
- waitPeriod = currentCount * (currentTime - previousTime) / (previousCount - currentCount);
+ waitPeriod = currentCount * (currentTime - previousTime)
+ / (previousCount - currentCount);
if (waitPeriod < 500) waitPeriod = 500;
}
else {
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -23,7 +23,9 @@
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
+import java.sql.PreparedStatement;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -42,8 +44,10 @@
// prevent instantiation
}
- /** maps SessionFactory's to Configurations.
- * by default, configuration lookup will be enabled */
+ /**
+ * maps SessionFactory's to Configurations.<br>
+ * by default, configuration lookup will be enabled
+ */
static Map configurations = new HashMap();
public static void clearConfigurationsCache() {
@@ -58,7 +62,8 @@
return createSessionFactory(cfgXmlResource, null, true);
}
- public static SessionFactory createSessionFactory(String cfgXmlResource, String propertiesResource) {
+ public static SessionFactory createSessionFactory(String cfgXmlResource,
+ String propertiesResource) {
return createSessionFactory(cfgXmlResource, propertiesResource, true);
}
@@ -77,23 +82,24 @@
return sessionFactory;
}
- public static Configuration createConfiguration(String cfgXmlResource, String propertiesResource) {
+ public static Configuration createConfiguration(String cfgXmlResource,
+ String propertiesResource) {
Configuration configuration = new Configuration();
// if a special hibernate configuration xml file is specified,
if (cfgXmlResource != null) {
// use the configured file name
- URL cfgURL = Thread.currentThread().getContextClassLoader().getResource(cfgXmlResource);
- log.debug("creating hibernate configuration resource '" + cfgURL + "'");
+ log.debug("using hibernate configuration resource: " + cfgXmlResource);
configuration.configure(cfgXmlResource);
- } else {
- log.debug("using default hibernate configuration resource (hibernate.cfg.xml)");
+ }
+ else {
+ log.debug("using default hibernate configuration resource: hibernate.cfg.xml");
configuration.configure();
}
// if the properties are specified in a separate file
if (propertiesResource != null) {
- log.debug("using hibernate properties from resource '" + propertiesResource + "'");
+ log.debug("using hibernate properties resource: " + propertiesResource);
// load the properties
Properties properties = loadPropertiesFromResource(propertiesResource);
if (!properties.isEmpty()) {
@@ -114,27 +120,21 @@
}
public static boolean createSchemaExportScript(SessionFactory sessionFactory) {
- boolean script = false;
String showSql = getConfiguration(sessionFactory).getProperty("hibernate.show_sql");
- if ("true".equalsIgnoreCase(showSql)) {
- script = true;
- }
- return script;
+ return "true".equalsIgnoreCase(showSql);
}
public static void clearHibernateCache(SessionFactory sessionFactory) {
sessionFactory.evictQueries();
Map classMetadata = sessionFactory.getAllClassMetadata();
- Iterator iter = classMetadata.keySet().iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = classMetadata.keySet().iterator(); iter.hasNext();) {
String entityName = (String) iter.next();
sessionFactory.evictEntity(entityName);
}
Map collectionMetadata = sessionFactory.getAllCollectionMetadata();
- iter = collectionMetadata.keySet().iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = collectionMetadata.keySet().iterator(); iter.hasNext();) {
String collectionName = (String) iter.next();
sessionFactory.evictCollection(collectionName);
}
@@ -146,12 +146,14 @@
if (inputStream != null) {
try {
properties.load(inputStream);
- } catch (IOException e) {
- log.warn("couldn't load hibernate properties from resource '" + resource + "'", e);
}
- } else {
- log.warn("hibernate properties resource '" + resource + "' not found");
+ catch (IOException e) {
+ log.warn("could not load hibernate properties from resource: " + resource, e);
+ }
}
+ else {
+ log.warn("hibernate properties resource not found: " + resource);
+ }
return properties;
}
Added: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedStringType.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedStringType.java (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedStringType.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -0,0 +1,55 @@
+/*
+ * 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.db.hibernate;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Properties;
+
+import org.hibernate.type.StringType;
+import org.hibernate.usertype.ParameterizedType;
+
+/**
+ * Mapping between SQL {@link Types#VARCHAR varchar} and Java {@link String} that truncates
+ * parameter values to column size.
+ *
+ * @author Alejandro Guizar
+ */
+public class LimitedStringType extends StringType implements ParameterizedType {
+
+ private int limit;
+
+ private static final long serialVersionUID = 1L;
+
+ public void set(PreparedStatement st, Object value, int index) throws SQLException {
+ String text = (String) value;
+ if (text.length() > limit) text = text.substring(0, limit);
+
+ st.setString(index, text);
+ }
+
+ public void setParameterValues(Properties parameters) {
+ limit = Integer.parseInt(parameters.getProperty("limit"));
+ }
+
+}
Added: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedTextType.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedTextType.java (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedTextType.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -0,0 +1,56 @@
+/*
+ * 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.db.hibernate;
+
+import java.io.StringReader;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Properties;
+
+import org.hibernate.type.TextType;
+import org.hibernate.usertype.ParameterizedType;
+
+/**
+ * Mapping between SQL {@link Types#CLOB clob} and Java {@link String} that truncates parameter
+ * values to column size.
+ *
+ * @author Alejandro Guizar
+ */
+public class LimitedTextType extends TextType implements ParameterizedType {
+
+ private int limit;
+
+ private static final long serialVersionUID = 1L;
+
+ public void set(PreparedStatement st, Object value, int index) throws SQLException {
+ String text = (String) value;
+ if (text.length() > limit) text = text.substring(0, limit);
+
+ st.setCharacterStream(index, new StringReader(text), text.length());
+ }
+
+ public void setParameterValues(Properties parameters) {
+ limit = Integer.parseInt(parameters.getProperty("limit"));
+ }
+
+}
Copied: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/SybaseTextType.java (from rev 5163, jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java)
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/SybaseTextType.java (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/SybaseTextType.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -0,0 +1,245 @@
+/*
+ * 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.db.hibernate;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Serializable;
+import java.io.StringReader;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+import org.hibernate.usertype.EnhancedUserType;
+import org.hibernate.util.EqualsHelper;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Replacement for {@link org.hibernate.type.TextType} made to work around a <em>feature</em> in the
+ * jConnect driver when setting a text parameter to <code>null</code>. Specifically, the call:
+ *
+ * <pre>
+ * PreparedStatement st;
+ * st.setNull(index, Types.CLOB);
+ * </pre>
+ *
+ * throws an SQLException with SQL state "JZ0SL" and reason "Unsupported SQL type".
+ *
+ * @see <a href="https://jira.jboss.org/jira/browse/JBPM-1818">JBPM-1818</a>
+ * @author Alejandro Guizar
+ */
+public class SybaseTextType implements EnhancedUserType, Serializable {
+
+ private transient Log log;
+ private static final boolean IS_VALUE_TRACING_ENABLED =
+ LogFactory.getLog(StringHelper.qualifier(Type.class.getName())).isTraceEnabled();
+
+ private static final long serialVersionUID = 1L;
+
+ private Log log() {
+ if (log == null) {
+ log = LogFactory.getLog(getClass());
+ }
+ return log;
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException {
+ return cached != null ? deepCopy(cached) : null;
+ }
+
+ public Object deepCopy(Object value) throws HibernateException {
+ return value;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException {
+ return value != null ? (Serializable) deepCopy(value) : null;
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException {
+ return EqualsHelper.equals(x, y);
+ }
+
+ public int hashCode(Object x) throws HibernateException {
+ return x.hashCode();
+ }
+
+ public boolean isMutable() {
+ return false;
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException,
+ SQLException {
+ return nullSafeGet(rs, names[0]);
+ }
+
+ public Object nullSafeGet(ResultSet rs, String name) throws HibernateException, SQLException {
+ try {
+ Object value = get(rs, name);
+ if (value == null) {
+ if (IS_VALUE_TRACING_ENABLED) {
+ log().trace("returning null as column: " + name);
+ }
+ return null;
+ }
+ else {
+ if (IS_VALUE_TRACING_ENABLED) {
+ log().trace("returning '" + toString(value) + "' as column: " + name);
+ }
+ return value;
+ }
+ }
+ catch (RuntimeException re) {
+ log().info("could not read column value from result set: " + name + "; " + re.getMessage());
+ throw re;
+ }
+ catch (SQLException se) {
+ log().info("could not read column value from result set: " + name + "; " + se.getMessage());
+ throw se;
+ }
+ }
+
+ public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
+ // retrieve the value of the designated column in the current row of the
+ // result set as a character reader
+ Reader charReader = rs.getCharacterStream(name);
+
+ // if the corresponding SQL value is NULL, the reader we got is NULL as well
+ if (charReader == null || rs.wasNull()) return null;
+
+ // Fetch Reader content up to the end - and put characters in a StringBuffer
+ StringBuffer sbuf = new StringBuffer();
+ try {
+ char[] cbuf = new char[1024];
+ for (int amountRead; (amountRead = charReader.read(cbuf)) != -1;) {
+ sbuf.append(cbuf, 0, amountRead);
+ }
+ }
+ catch (IOException ioe) {
+ throw new HibernateException("IOException occurred reading text", ioe);
+ }
+ finally {
+ try {
+ charReader.close();
+ }
+ catch (IOException e) {
+ throw new HibernateException("IOException occurred closing stream", e);
+ }
+ }
+
+ // Return StringBuffer content as a large String
+ return sbuf.toString();
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException,
+ SQLException {
+ try {
+ if (value == null) {
+ if (IS_VALUE_TRACING_ENABLED) {
+ log().trace("binding null to parameter: " + index);
+ }
+
+ setNull(st, index);
+ }
+ else {
+ if (IS_VALUE_TRACING_ENABLED) {
+ log().trace("binding '" + toString(value) + "' to parameter: " + index);
+ }
+
+ set(st, value, index);
+ }
+ }
+ catch (RuntimeException re) {
+ log().info("could not bind value '" +
+ nullSafeToString(value) +
+ "' to parameter: " +
+ index +
+ "; " +
+ re.getMessage());
+ throw re;
+ }
+ catch (SQLException se) {
+ log().info("could not bind value '" +
+ nullSafeToString(value) +
+ "' to parameter: " +
+ index +
+ "; " +
+ se.getMessage());
+ throw se;
+ }
+ }
+
+ public void set(PreparedStatement st, Object value, int index) throws HibernateException,
+ SQLException {
+ String str = (String) value;
+ st.setCharacterStream(index, new StringReader(str), str.length());
+ }
+
+ public void setNull(PreparedStatement st, int index) throws HibernateException, SQLException {
+ // JBPM-1818: workaround for SQL state JZ0SL: "Unsupported SQL type" with jConnect
+ st.setCharacterStream(index, null, 0);
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws HibernateException {
+ return original;
+ }
+
+ public Class returnedClass() {
+ return String.class;
+ }
+
+ public int[] sqlTypes() {
+ return new int[] { sqlType() };
+ }
+
+ public int sqlType() {
+ return Types.CLOB;
+ }
+
+ public String objectToSQLString(Object value) {
+ return '\'' + (String) value + '\'';
+ }
+
+ public Object fromXMLString(String xml) {
+ return xml != null && xml.length() > 0 ? fromStringValue(xml) : null;
+ }
+
+ public String toXMLString(Object value) {
+ return toString(value);
+ }
+
+ public String nullSafeToString(Object value) throws HibernateException {
+ return value != null ? toString(value) : null;
+ }
+
+ public String toString(Object value) {
+ return (String) value;
+ }
+
+ public Object fromStringValue(String xml) {
+ return xml;
+ }
+}
Deleted: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -1,245 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.db.hibernate;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Serializable;
-import java.io.StringReader;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-import org.hibernate.usertype.EnhancedUserType;
-import org.hibernate.util.EqualsHelper;
-import org.hibernate.util.StringHelper;
-
-/**
- * Replacement for {@link org.hibernate.type.TextType} made to work around a <em>feature</em> in the
- * jConnect driver when setting a text parameter to <code>null</code>. Specifically, the call:
- *
- * <pre>
- * PreparedStatement st;
- * st.setNull(index, Types.CLOB);
- * </pre>
- *
- * throws an SQLException with SQL state "JZ0SL" and reason "Unsupported SQL type".
- *
- * @see <a href="https://jira.jboss.org/jira/browse/JBPM-1818">JBPM-1818</a>
- * @author Alejandro Guizar
- */
-public class TextType implements EnhancedUserType, Serializable {
-
- private transient Log log;
- private static final boolean IS_VALUE_TRACING_ENABLED =
- LogFactory.getLog(StringHelper.qualifier(Type.class.getName())).isTraceEnabled();
-
- private static final long serialVersionUID = 1L;
-
- private Log log() {
- if (log == null) {
- log = LogFactory.getLog(getClass());
- }
- return log;
- }
-
- public Object assemble(Serializable cached, Object owner) throws HibernateException {
- return cached != null ? deepCopy(cached) : null;
- }
-
- public Object deepCopy(Object value) throws HibernateException {
- return value;
- }
-
- public Serializable disassemble(Object value) throws HibernateException {
- return value != null ? (Serializable) deepCopy(value) : null;
- }
-
- public boolean equals(Object x, Object y) throws HibernateException {
- return EqualsHelper.equals(x, y);
- }
-
- public int hashCode(Object x) throws HibernateException {
- return x.hashCode();
- }
-
- public boolean isMutable() {
- return false;
- }
-
- public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException,
- SQLException {
- return nullSafeGet(rs, names[0]);
- }
-
- public Object nullSafeGet(ResultSet rs, String name) throws HibernateException, SQLException {
- try {
- Object value = get(rs, name);
- if (value == null) {
- if (IS_VALUE_TRACING_ENABLED) {
- log().trace("returning null as column: " + name);
- }
- return null;
- }
- else {
- if (IS_VALUE_TRACING_ENABLED) {
- log().trace("returning '" + toString(value) + "' as column: " + name);
- }
- return value;
- }
- }
- catch (RuntimeException re) {
- log().info("could not read column value from result set: " + name + "; " + re.getMessage());
- throw re;
- }
- catch (SQLException se) {
- log().info("could not read column value from result set: " + name + "; " + se.getMessage());
- throw se;
- }
- }
-
- public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
- // retrieve the value of the designated column in the current row of the
- // result set as a character reader
- Reader charReader = rs.getCharacterStream(name);
-
- // if the corresponding SQL value is NULL, the reader we got is NULL as well
- if (charReader == null || rs.wasNull()) return null;
-
- // Fetch Reader content up to the end - and put characters in a StringBuffer
- StringBuffer sbuf = new StringBuffer();
- try {
- char[] cbuf = new char[1024];
- for (int amountRead; (amountRead = charReader.read(cbuf)) != -1;) {
- sbuf.append(cbuf, 0, amountRead);
- }
- }
- catch (IOException ioe) {
- throw new HibernateException("IOException occurred reading text", ioe);
- }
- finally {
- try {
- charReader.close();
- }
- catch (IOException e) {
- throw new HibernateException("IOException occurred closing stream", e);
- }
- }
-
- // Return StringBuffer content as a large String
- return sbuf.toString();
- }
-
- public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException,
- SQLException {
- try {
- if (value == null) {
- if (IS_VALUE_TRACING_ENABLED) {
- log().trace("binding null to parameter: " + index);
- }
-
- setNull(st, index);
- }
- else {
- if (IS_VALUE_TRACING_ENABLED) {
- log().trace("binding '" + toString(value) + "' to parameter: " + index);
- }
-
- set(st, value, index);
- }
- }
- catch (RuntimeException re) {
- log().info("could not bind value '" +
- nullSafeToString(value) +
- "' to parameter: " +
- index +
- "; " +
- re.getMessage());
- throw re;
- }
- catch (SQLException se) {
- log().info("could not bind value '" +
- nullSafeToString(value) +
- "' to parameter: " +
- index +
- "; " +
- se.getMessage());
- throw se;
- }
- }
-
- public void set(PreparedStatement st, Object value, int index) throws HibernateException,
- SQLException {
- String str = (String) value;
- st.setCharacterStream(index, new StringReader(str), str.length());
- }
-
- public void setNull(PreparedStatement st, int index) throws HibernateException, SQLException {
- // JBPM-1818: workaround for SQL state JZ0SL: "Unsupported SQL type" with jConnect
- st.setCharacterStream(index, null, 0);
- }
-
- public Object replace(Object original, Object target, Object owner) throws HibernateException {
- return original;
- }
-
- public Class returnedClass() {
- return String.class;
- }
-
- public int[] sqlTypes() {
- return new int[] { sqlType() };
- }
-
- public int sqlType() {
- return Types.CLOB;
- }
-
- public String objectToSQLString(Object value) {
- return '\'' + (String) value + '\'';
- }
-
- public Object fromXMLString(String xml) {
- return xml != null && xml.length() > 0 ? fromStringValue(xml) : null;
- }
-
- public String toXMLString(Object value) {
- return toString(value);
- }
-
- public String nullSafeToString(Object value) throws HibernateException {
- return value != null ? toString(value) : null;
- }
-
- public String toString(Object value) {
- return (String) value;
- }
-
- public Object fromStringValue(String xml) {
- return xml;
- }
-}
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 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -60,12 +60,12 @@
return instantiators;
}
- long id = 0;
- protected String className = null;
- protected String configuration = null;
- protected String configType = null;
- protected ProcessDefinition processDefinition = null;
- transient Object instance = null;
+ long id;
+ protected String className;
+ protected String configuration;
+ protected String configType;
+ protected ProcessDefinition processDefinition;
+ transient Object instance;
public Delegation() {
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -43,8 +43,8 @@
* @deprecated use {@link #JobExecutorThread(String, JobExecutor)} instead
*/
public JobExecutorThread(String name, JobExecutor jobExecutor,
- JbpmConfiguration jbpmConfiguration, int idleInterval, int maxIdleInterval, long maxLockTime,
- int maxHistory) {
+ JbpmConfiguration jbpmConfiguration, int idleInterval, int maxIdleInterval,
+ long maxLockTime, int maxHistory) {
super(name);
this.jobExecutor = jobExecutor;
this.jbpmConfiguration = jbpmConfiguration;
@@ -82,18 +82,18 @@
}
}
catch (InterruptedException ie) {
- log.debug("delay after exception got interrupted", ie);
+ log.debug(getName() + " got interrupted: " + e.getMessage());
}
- // after an exception, the current idle interval is doubled to prevent
- // continuous exception generation when e.g. the db is unreachable
- currentIdleInterval <<= 1;
+ // after an exception, double the current idle interval to prevent
+ // continuous exception throwing while an anomalous condition prevails
+ currentIdleInterval *= 2;
if (currentIdleInterval > maxIdleInterval || currentIdleInterval < 0) {
currentIdleInterval = maxIdleInterval;
}
}
}
catch (InterruptedException e) {
- log.info(getName() + " got interrupted");
+ log.debug(getName() + " got interrupted: " + e.getMessage());
}
}
log.info(getName() + " leaves cyberspace");
@@ -182,7 +182,7 @@
job.setRetries(job.getRetries() - 1);
}
else {
- // allowing a transaction to proceed after a persistence exception is unsafe
+ // prevent unsafe use of the session after an exception occurs
jbpmContext.setRollbackOnly();
}
}
@@ -204,8 +204,8 @@
catch (RuntimeException e) {
if (!DbPersistenceService.isLockingException(e)) throw e;
// if this is a locking exception, keep it quiet
- StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error("failed to complete job " +
- job);
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error("failed to complete job "
+ + job);
}
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.mapping.sybase.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.mapping.sybase.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.mapping.sybase.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -97,7 +97,7 @@
<mapping resource="org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml"/>
<!-- job mapping files -->
- <mapping resource="org/jbpm/job/Job.sybase.hbm.xml"/>
+ <mapping resource="org/jbpm/job/Job.hbm.xml"/>
<mapping resource="org/jbpm/job/Timer.hbm.xml"/>
<mapping resource="org/jbpm/job/ExecuteNodeJob.hbm.xml"/>
<mapping resource="org/jbpm/job/ExecuteActionJob.hbm.xml"/>
@@ -113,7 +113,7 @@
<mapping resource="org/jbpm/logging/log/ProcessLog.hbm.xml"/>
<mapping resource="org/jbpm/logging/log/MessageLog.hbm.xml"/>
<mapping resource="org/jbpm/logging/log/CompositeLog.hbm.xml"/>
- <mapping resource="org/jbpm/graph/log/ActionLog.sybase.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ActionLog.hbm.xml"/>
<mapping resource="org/jbpm/graph/log/NodeLog.hbm.xml"/>
<mapping resource="org/jbpm/graph/log/ProcessInstanceCreateLog.hbm.xml"/>
<mapping resource="org/jbpm/graph/log/ProcessInstanceEndLog.hbm.xml"/>
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.db2.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.db2.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.db2.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -4,5 +4,8 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
- <typedef name="longstring" class="org.hibernate.type.TextType" />
+ <typedef name="longstring" class="org.hibernate.type.TextType"/>
+ <typedef name="ltdstring" class="org.jbpm.db.hibernate.LimitedTextType">
+ <param name="limit">4000</param>
+ </typedef>
</hibernate-mapping>
\ No newline at end of file
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -4,5 +4,8 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
- <typedef name="longstring" class="org.hibernate.type.StringType" />
+ <typedef name="longstring" class="org.hibernate.type.StringType"/>
+ <typedef name="ltdstring" class="org.jbpm.db.hibernate.LimitedStringType">
+ <param name="limit">4000</param>
+ </typedef>
</hibernate-mapping>
\ No newline at end of file
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.sybase.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.sybase.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.sybase.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -5,5 +5,5 @@
<hibernate-mapping>
<typedef name="longstring" class="org.hibernate.type.StringType" />
- <typedef name="text" class="org.jbpm.db.hibernate.TextType" />
+ <typedef name="ltdstring" class="org.jbpm.db.hibernate.SybaseTextType" />
</hibernate-mapping>
\ No newline at end of file
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -63,7 +63,6 @@
<field name="nbrOfThreads"><int value="1" /></field>
<field name="idleInterval"><int value="5000" /></field>
<field name="maxIdleInterval"><int value="3600000" /></field> <!-- 1 hour -->
- <field name="historyMaxSize"><int value="20" /></field>
<field name="maxLockTime"><int value="600000" /></field> <!-- 10 minutes -->
<field name="lockMonitorInterval"><int value="60000" /></field> <!-- 1 minute -->
<field name="lockBufferTime"><int value="5000" /></field> <!-- 5 seconds -->
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -10,7 +10,7 @@
extends="org.jbpm.logging.log.CompositeLog"
discriminator-value="A">
- <property name="exception" column="EXCEPTION_" type="longstring" length="4000"/>
+ <property name="exception" column="EXCEPTION_" type="ltdstring" length="4000"/>
<many-to-one name="action"
column="ACTION_"
Deleted: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.sybase.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.sybase.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.sybase.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -1,21 +0,0 @@
-<?xml version="1.0"?>
-
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping auto-import="false" default-access="field">
-
- <subclass name="org.jbpm.graph.log.ActionLog"
- extends="org.jbpm.logging.log.CompositeLog"
- discriminator-value="A">
-
- <property name="exception" column="EXCEPTION_" type="text" length="4000"/>
-
- <many-to-one name="action"
- column="ACTION_"
- foreign-key="FK_LOG_ACTION"
- index="IDX_LOG_ACTION" />
- </subclass>
-
-</hibernate-mapping>
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -35,7 +35,7 @@
<property name="isExclusive" column="ISEXCLUSIVE_" />
<property name="lockOwner" column="LOCKOWNER_" />
<property name="lockTime" column="LOCKTIME_" />
- <property name="exception" column="EXCEPTION_" type="longstring" length="4000" />
+ <property name="exception" column="EXCEPTION_" type="ltdstring" length="4000" />
<property name="retries" column="RETRIES_" />
</class>
Deleted: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.sybase.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.sybase.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.sybase.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -1,43 +0,0 @@
-<?xml version="1.0"?>
-
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping auto-import="false" default-access="field">
-
- <class name="org.jbpm.job.Job" table="JBPM_JOB" discriminator-value="J">
- <id name="id" column="ID_">
- <generator class="native" />
- </id>
- <discriminator type="char" column="CLASS_" />
- <version name="version" column="VERSION_" />
-
- <property name="dueDate" column="DUEDATE_" type="timestamp" />
-
- <many-to-one name="processInstance"
- column="PROCESSINSTANCE_"
- cascade="lock"
- foreign-key="FK_JOB_PRINST"
- index="IDX_JOB_PRINST" />
- <many-to-one name="token"
- column="TOKEN_"
- cascade="lock"
- foreign-key="FK_JOB_TOKEN"
- index="IDX_JOB_TOKEN" />
- <many-to-one name="taskInstance"
- column="TASKINSTANCE_"
- cascade="lock"
- foreign-key="FK_JOB_TSKINST"
- index="IDX_JOB_TSKINST" />
-
- <property name="isSuspended" column="ISSUSPENDED_" />
- <property name="isExclusive" column="ISEXCLUSIVE_" />
- <property name="lockOwner" column="LOCKOWNER_" />
- <property name="lockTime" column="LOCKTIME_" />
- <property name="exception" column="EXCEPTION_" type="text" length="4000" />
- <property name="retries" column="RETRIES_" />
-
- </class>
-
-</hibernate-mapping>
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/graph/log/ActionLogDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/graph/log/ActionLogDbTest.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/graph/log/ActionLogDbTest.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -24,49 +24,60 @@
import java.io.PrintWriter;
import java.io.StringWriter;
+import org.hibernate.type.Type;
+
import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.db.hibernate.LimitedStringType;
+import org.jbpm.db.hibernate.LimitedTextType;
import org.jbpm.graph.def.Action;
-public class ActionLogDbTest extends AbstractDbTestCase
-{
- public void testActionLog()
- {
+public class ActionLogDbTest extends AbstractDbTestCase {
+
+ public void testActionLog() {
Action action = new Action();
session.save(action);
-
+
ActionLog actionLog = new ActionLog(action);
- actionLog = (ActionLog)saveAndReload(actionLog);
+ actionLog = (ActionLog) saveAndReload(actionLog);
assertNotNull(actionLog.getAction());
-
+
session.delete(actionLog);
session.delete(action);
}
- public void testActionExceptionLog()
- {
- RuntimeException rte = getRuntimeException();
- StringWriter stwr = new StringWriter();
- PrintWriter prwr = new PrintWriter(stwr);
- rte.printStackTrace(prwr);
-
+ public void testActionExceptionLog() {
+ RuntimeException exception = createExceptionChain(null, 0);
+
ActionLog actionLog = new ActionLog();
- actionLog.setException(rte);
- actionLog = (ActionLog)saveAndReload(actionLog);
-
- String rteStr = actionLog.getException();
- assertNotNull("Exception not null", rteStr);
- assertEquals("Exception string", stwr.toString().length(), rteStr.length());
-
+ actionLog.setException(exception);
+ actionLog = (ActionLog) saveAndReload(actionLog);
+
+ String exceptionString = actionLog.getException();
+ assertNotNull("log exception is null", exceptionString);
+
+ int expectedLength = 4000;
+ if (!isLimitEnforced()) {
+ StringWriter exceptionWriter = new StringWriter();
+ exception.printStackTrace(new PrintWriter(exceptionWriter));
+ expectedLength = exceptionWriter.getBuffer().length();
+ assert expectedLength > 4000 : expectedLength;
+ }
+
+ int actualLength = exceptionString.length();
+ assert actualLength == expectedLength : actualLength;
+
session.delete(actionLog);
}
- private RuntimeException getRuntimeException()
- {
- RuntimeException rte = new RuntimeException("level 0");
- for (int level = 0; level < 10; level++)
- {
- rte = new RuntimeException("level " + level, rte);
- }
- return rte;
+ private boolean isLimitEnforced() {
+ Type propertyType = session.getSessionFactory()
+ .getClassMetadata(ActionLog.class)
+ .getPropertyType("exception");
+ return propertyType instanceof LimitedStringType || propertyType instanceof LimitedTextType;
}
+
+ private RuntimeException createExceptionChain(RuntimeException cause, int level) {
+ return level == 100 ? cause : createExceptionChain(level % 10 == 0 ? new RuntimeException(
+ "level " + level, cause) : cause, level + 1);
+ }
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2375/JBPM2375Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2375/JBPM2375Test.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2375/JBPM2375Test.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -28,7 +28,7 @@
" <transition to='state1' name='to_state1'/>" +
" </start-state>" +
" <state name='state1'>" +
- " <timer name='moveToDefaultEndAfter1second' duedate='1 second' transition='to_state2'/>" +
+ " <timer name='moveToNextStateAfter1second' duedate='1 second' transition='to_state2'/>" +
" <transition to='state2' name='to_state2'/>" +
" </state>" +
" <state name='state2'>" +
@@ -46,7 +46,7 @@
protected void setUp() throws Exception {
super.setUp();
- jbpmConfiguration.getJobExecutor().setLockMonitorInterval(TEST_TIMEOUT / 2);
+ jbpmConfiguration.getJobExecutor().setLockMonitorInterval(TEST_TIMEOUT / 6);
processDefinition = ProcessDefinition.parseXmlString(PROCESS_DEFINITION);
jbpmContext.deployProcessDefinition(processDefinition);
Modified: jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -87,7 +87,7 @@
job.setException(memoryWriter.toString());
}
else {
- // allowing a transaction to proceed after a persistence exception is unsafe
+ // prevent unsafe use of the session after an exception occurs
throw e instanceof RuntimeException ? (RuntimeException) e :
new JbpmException("failed to execute " + job, e);
}
16 years, 8 months
JBoss JBPM SVN: r5485 - jbpm4/trunk/modules/userguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: camunda
Date: 2009-08-18 04:17:27 -0400 (Tue, 18 Aug 2009)
New Revision: 5485
Modified:
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-DeployingBusinessArchives.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Services.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml
Log:
small fixes of errors by my colleague
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml 2009-08-18 02:20:19 UTC (rev 5484)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml 2009-08-18 08:17:27 UTC (rev 5485)
@@ -110,7 +110,7 @@
directly, is possible, but not supported.
</para>
- <para>As you already saw one example in the demo setup, the distribution a couple of ant
+ <para>As you already saw one example in the demo setup, the distribution contains a couple of ant
scripts:
</para>
<itemizedlist>
@@ -147,7 +147,7 @@
<section id="librarydependenciesandconfigurationfiles">
<title>Library dependencies and configuration files</title>
<para>We provide support for installations of jBPM through our automatic ant
- scripts. Those scripts will be put the right libs and the right configuration
+ scripts. Those scripts will put the right libs and the right configuration
files in the right location for you. If you want to create your own installation of
jBPM in your application, see the developers guide for more information.
</para>
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-DeployingBusinessArchives.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-DeployingBusinessArchives.xml 2009-08-18 02:20:19 UTC (rev 5484)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-DeployingBusinessArchives.xml 2009-08-18 08:17:27 UTC (rev 5485)
@@ -1,155 +1,155 @@
-<chapter id="deployingbusinessarchives">
- <title>Deploying business archives</title>
-
- <para>A business archive is a collection of files
- assembled in a jar formatted file. The files in
- a business archive can be jPDL process files, forms,
- process image and other process resources.
- </para>
-
- <section id="deployingprocessfilesandprocessresources">
- <title>Deploying process files and process resources</title>
-
- <para>Process files and process resources have to be
- deployed in the process repository which is stored in
- the database.
- </para>
-
- <para>There is a jBPM ant task to deploy business archives
- (<literal>org.jbpm.pvm.internal.ant.JbpmDeployTask</literal>)
- The <literal>JbpmDeployTask</literal> can deploy individual
- process files and business archives. They are deployed
- directly to the database over a JDBC connection. So it is a
- requirement that the database is up and running before you can
- deploy processes.
- </para>
-
- <para>An example of creating and deploying a business
- archive can be found in the examples directory of the
- distribution. Let's look at the relevant parts. First a path is
- declared that includes the jbpm.jar and all its dependencies.
- </para>
-
- <programlisting><path id="jbpm.libs.incl.dependencies">
- <pathelement location="${jbpm.home}/examples/target/classes" />
- <fileset dir="${jbpm.home}">
- <include name="jbpm.jar" />
- </fileset>
- <fileset dir="${jbpm.home}/lib" />
-</path></programlisting>
-
- <para>The JDBC driver jar(s) for your database should also be included
- in the path. MySql, Postgresql and hsqldb are in the distribution. But
- the oracle driver you have to download separately from the oracle site since
- we're not allowed to redistribute that file.
- </para>
-
- <para>When a business archive is deployed, jBPM scans for all the files
- with the <literal>.jpdl.xml</literal> extension in the business archive.
- All those files will be parsed as jPDL processes and made available to the
- runtime engine. All other resources in the business archive will also
- be stored as resources in that deployment and made accessible through
- <literal>InputStream getResourceAsStream(long deploymentDbid, String resourceName);</literal>
- in class <literal>RepositoryService</literal>
- </para>
-
- <para>For creating a business archives, the <literal>jar</literal> task
- can be used.
- </para>
-
- <programlisting><jar destfile="${jbpm.home}/examples/target/examples.bar">
- <fileset dir="${jbpm.home}/examples/src">
- <include name="**/*.jpdl.xml" />
- ...
- </fileset>
- </jar></programlisting>
-
- <para>Before the jbpm-deploy task can be used it need to be declared like this:</para>
-
- <programlisting><taskdef name="jbpm-deploy"
- classname="org.jbpm.pvm.internal.ant.JbpmDeployTask"
- classpathref="jbpm.libs.incl.dependencies" /></programlisting>
-
- <para>Then the ant task can be used like this</para>
-
- <programlisting>
- <jbpm-deploy file="${jbpm.home}/examples/target/examples.bar" /></programlisting>
-
- <table><title><literal>jbpm-deploy</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>file</literal></entry>
- <entry>file</entry>
- <entry></entry>
- <entry>optional</entry>
- <entry>A file to be deployed. Files ending with <literal>.xml</literal> will be deployed
- as process files. Files ending with <literal>ar</literal> like .bar or .jar
- will be deployed as business archives.
- </entry>
- </row>
- <row>
- <entry><literal>cfg</literal></entry>
- <entry>file</entry>
- <entry>jbpm.cfg.xml</entry>
- <entry>optional</entry>
- <entry>Points to the jbpm configuration file that has to be on the classpath in which
- the <literal>jbpm-deploy</literal> task was defined.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table><title><literal>jbpm-deploy</literal> elements:</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Element</entry>
- <entry>Multiplicity</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>fileset</literal></entry>
- <entry>0..*</entry>
- <entry>files to be deployed expressed as a plain ant fileset.
- Files ending with <literal>.xml</literal> will be deployed
- as process files. Files ending with <literal>ar</literal> like .bar or .jar
- will be deployed as business archives.</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- </section>
-
- <section id="deployingclasses">
- <title>Deploying classes</title>
- <para>jBPM 4 does not yet have a process classloading mechanism as in jBPM 3.
- </para>
- <para>All the classes that are referred to
- in your process files, either directly or indirectly, need to be made available
- on the classpath of your jBPM installation.
- </para>
- <para>In case of the examples, an examples.jar file is created with
- all the classes and it is put in the <literal>lib</literal> directory of the JBoss
- server configuration.</para>
- <para>If you want process classloading so that user defined classes can be deployed
- in and loaded from the business archive, vote for it in
- <ulink url="https://jira.jboss.org/jira/browse/JBPM-2200">JIRA issue JBPM-2200</ulink>.
- We'll prioritize this depending on the number of votes and on the use cases that
- you can add as a comment in which you explain why you need it.
- </para>
- </section>
-
-</chapter>
+<chapter id="deployingbusinessarchives">
+ <title>Deploying business archives</title>
+
+ <para>A business archive is a collection of files
+ assembled in a jar formatted file. The files in
+ a business archive can be jPDL process files, forms,
+ process image and other process resources.
+ </para>
+
+ <section id="deployingprocessfilesandprocessresources">
+ <title>Deploying process files and process resources</title>
+
+ <para>Process files and process resources have to be
+ deployed in the process repository which is stored in
+ the database.
+ </para>
+
+ <para>There is a jBPM ant task to deploy business archives
+ (<literal>org.jbpm.pvm.internal.ant.JbpmDeployTask</literal>)
+ The <literal>JbpmDeployTask</literal> can deploy individual
+ process files and business archives. They are deployed
+ directly to the database over a JDBC connection. So it is a
+ requirement that the database is up and running before you can
+ deploy processes.
+ </para>
+
+ <para>An example of creating and deploying a business
+ archive can be found in the ant build script (build.xml) in the examples directory of the
+ distribution. Let's look at the relevant parts. First a path is
+ declared that includes the jbpm.jar and all its dependencies.
+ </para>
+
+ <programlisting><path id="jbpm.libs.incl.dependencies">
+ <pathelement location="${jbpm.home}/examples/target/classes" />
+ <fileset dir="${jbpm.home}">
+ <include name="jbpm.jar" />
+ </fileset>
+ <fileset dir="${jbpm.home}/lib" />
+</path></programlisting>
+
+ <para>The JDBC driver jar(s) for your database should also be included
+ in the path. MySQL, PostgreSQL and HSQLDB are in the distribution. But
+ the oracle driver you have to download separately from the oracle site since
+ we're not allowed to redistribute that file.
+ </para>
+
+ <para>When a business archive is deployed, jBPM scans for all the files
+ with the <literal>.jpdl.xml</literal> extension in the business archive.
+ All those files will be parsed as jPDL processes and made available to the
+ runtime engine. All other resources in the business archive will also
+ be stored as resources in that deployment and made accessible through
+ <literal>InputStream getResourceAsStream(long deploymentDbid, String resourceName);</literal>
+ in class <literal>RepositoryService</literal>
+ </para>
+
+ <para>For creating a business archives, the <literal>jar</literal> task
+ can be used.
+ </para>
+
+ <programlisting><jar destfile="${jbpm.home}/examples/target/examples.bar">
+ <fileset dir="${jbpm.home}/examples/src">
+ <include name="**/*.jpdl.xml" />
+ ...
+ </fileset>
+ </jar></programlisting>
+
+ <para>Before the jbpm-deploy task can be used it need to be declared like this:</para>
+
+ <programlisting><taskdef name="jbpm-deploy"
+ classname="org.jbpm.pvm.internal.ant.JbpmDeployTask"
+ classpathref="jbpm.libs.incl.dependencies" /></programlisting>
+
+ <para>Then the ant task can be used like this</para>
+
+ <programlisting>
+ <jbpm-deploy file="${jbpm.home}/examples/target/examples.bar" /></programlisting>
+
+ <table><title><literal>jbpm-deploy</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>file</literal></entry>
+ <entry>file</entry>
+ <entry></entry>
+ <entry>optional</entry>
+ <entry>A file to be deployed. Files ending with <literal>.xml</literal> will be deployed
+ as process files. Files ending with <literal>ar</literal> like .bar or .jar
+ will be deployed as business archives.
+ </entry>
+ </row>
+ <row>
+ <entry><literal>cfg</literal></entry>
+ <entry>file</entry>
+ <entry>jbpm.cfg.xml</entry>
+ <entry>optional</entry>
+ <entry>Points to the jbpm configuration file that has to be on the classpath in which
+ the <literal>jbpm-deploy</literal> task was defined.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table><title><literal>jbpm-deploy</literal> elements:</title>
+ <tgroup cols="3" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Element</entry>
+ <entry>Multiplicity</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>fileset</literal></entry>
+ <entry>0..*</entry>
+ <entry>files to be deployed expressed as a plain ant fileset.
+ Files ending with <literal>.xml</literal> will be deployed
+ as process files. Files ending with <literal>ar</literal> like .bar or .jar
+ will be deployed as business archives.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ </section>
+
+ <section id="deployingclasses">
+ <title>Deploying classes</title>
+ <para>jBPM 4 does not yet have a process classloading mechanism as in jBPM 3.
+ </para>
+ <para>All the classes that are referred to
+ in your process files, either directly or indirectly, need to be made available
+ on the classpath of your jBPM installation.
+ </para>
+ <para>In case of the examples, an examples.jar file is created with
+ all the classes and it is put in the <literal>lib</literal> directory of the JBoss
+ server configuration.</para>
+ <para>If you want process classloading so that user defined classes can be deployed
+ in and loaded from the business archive, vote for it in
+ <ulink url="https://jira.jboss.org/jira/browse/JBPM-2200">JIRA issue JBPM-2200</ulink>.
+ We'll prioritize this depending on the number of votes and on the use cases that
+ you can add as a comment in which you explain why you need it.
+ </para>
+ </section>
+
+</chapter>
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Services.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Services.xml 2009-08-18 02:20:19 UTC (rev 5484)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Services.xml 2009-08-18 08:17:27 UTC (rev 5485)
@@ -1,426 +1,426 @@
-<chapter id="services">
- <title>Services</title>
-
- <section id="processdefinitionprocessinstanceandexecutions">
- <title>Process definition, process instance and executions</title>
- <para>A process definition is description of the steps in a procedure.
- For example, an insurance company could have a <literal>loan</literal>
- process definition that describes the steps of how the company deals
- with loan requests.
- </para>
- <figure id="loan.process.definition.example">
- <title>The loan process definition example</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/loan.process.definition.png"/></imageobject></mediaobject>
- </figure>
- <para>One process instance represents one particular run of a process definition.
- For example, the loan request of John Doe last Friday to finance his new boat
- is represented in one process instance of the loan process definition.
- </para>
- <para>A process instance contains all the runtime state. The
- most prominent property is the pointer that keeps track of the current activity.
- </para>
- <figure id="loan.process.instance.example">
- <title>The loan process instance example</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/loan.process.instance.png"/></imageobject></mediaobject>
- </figure>
- <para>Suppose that wiring the money and archiving can be done in parallel.
- Then the main process instance will have two child executions to keep
- track of the state like this:
- </para>
- <figure id="loan.executions.example">
- <title>The loan executions example</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/loan.executions.png"/></imageobject></mediaobject>
- </figure>
- <para>More general, a process instance is the root of a tree of executions.
- When a new process instance is started, the process instance is in fact the root
- execution scope. Only leaf executions can be active.
- </para>
- <para>The motivation to work with a tree structure like this is that
- this conceptually remains simple in the case where there is only one path
- of execution. The services API doesn't need to make a functional difference
- between process instances and executions. Therefore, the API has only
- one Execution type to refer to both <literal>ProcessInstance</literal>s and
- <literal>Execution</literal>s.
- </para>
- </section>
-
- <section id="processengine">
- <title>ProcessEngine</title>
- <para>Interacting with jBPM occurs through services.
- The service interfaces can be obtained from the <literal>ProcessEngine</literal>
- which is build from a <literal>Configuration</literal>.
- </para>
- <para>A <literal>ProcessEngine</literal> is thread safe and can be stored in a
- static member field or even better in JNDI or some other central location.
- One <literal>ProcessEngine</literal> object can be used by all requests and
- threads in an application. Here's how you can obtain a <literal>ProcessEngine</literal>
- </para>
-
- <para>The code snippets in this section and the next section about process
- deployments are taken from example
- <literal>org.jbpm.examples.services.ServicesTest</literal>
- </para>
-
- <programlisting>ProcessEngine processEngine = new Configuration()
- .buildProcessEngine();</programlisting>
-
- <para>The previous code snippet shows how to build a <literal>ProcessEngine</literal>
- from the default configuration file <literal>jbpm.cfg.xml</literal> which is
- expected in the root of the classpath. If you want to specify another
- resource location, use the <literal>setResource</literal> method like this:
- </para>
-
- <programlisting>ProcessEngine processEngine = new Configuration()
- .setResource("my-own-configuration-file.xml")
- .buildProcessEngine();</programlisting>
-
- <para>There are other <literal>setXxxx</literal> methods that allow to specify
- the configuration content as an <literal>InputStream</literal>, an
- <literal>xmlString</literal>, <literal>InputSource</literal>,
- <literal>URL</literal> or <literal>File</literal>.
- </para>
-
- <para>From a <literal>ProcessEngine</literal> the following services
- can be obtained:
- </para>
-
- <programlisting><emphasis role="bold">RepositoryService</emphasis> repositoryService = processEngine.getRepositoryService();
-<emphasis role="bold">ExecutionService</emphasis> executionService = processEngine.getExecutionService();
-<emphasis role="bold">TaskService</emphasis> taskService = processEngine.getTaskService();
-<emphasis role="bold">HistoryService</emphasis> historyService = processEngine.getHistoryService();
-<emphasis role="bold">ManagementService</emphasis> managementService = processEngine.getManagementService();</programlisting>
-
- <para>Process engine objects defined in the configuration can also be retrieved by
- type (<literal>processEngine.get(Class<T>)</literal>)
- or by name (<literal>processEngine.get(String)</literal>)</para>
-
- </section>
-
- <section id="deployingaprocess">
- <title>Deploying a process</title>
- <para>The <literal>RepositoryService</literal> groups all methods to manage
- the repository of deployments. In this first example, we'll deploy one process
- resource from the classpath with the <literal>RepositoryService</literal>:
- </para>
- <programlisting>long deploymentDbid = repositoryService.createDeployment()
- .addResourceFromClasspath("org/jbpm/examples/services/Order.jpdl.xml")
- .deploy();</programlisting>
- <para>Analogue to the <literal>addResourceFromClasspath</literal> method above,
- the source of the processes definitions XML can be picked up from a file, url, string,
- input stream or zip input stream.
- </para>
- <para>Each deployment is composed of a set of named resources. The content
- of each resource is a byte array. jPDL process files are recognized by their extension
- <literal>.jpdl.xml</literal>. Other resource types are task forms and java classes.
- </para>
- <para>A deployment works with a set of named resources and can potentially contain
- multiple process descriptions and multiple other artifact types. The jPDL deployer
- will recognise process files based on the <literal>.jpdl.xml</literal>
- extension automatically.
- </para>
- <para>During deployment, an <literal>id</literal> is assigned to the process
- definitions. The <literal>id</literal> will have format
- <literal>{key}-{version}</literal> with a dash between key and version
- </para>
- <para>If <literal>key</literal> is not provided, it is generated automatically
- based on the name. All non alpha numeric characters in the name will be replaced
- by underscores to generate the key.
- </para>
- <para>The same <literal>name</literal> can only be associated to one
- <literal>key</literal> and vice verca.
- </para>
- <para>If <literal>version</literal> is not provided, a <literal>version</literal>
- will be automatically be assigned. For version
- assignment, the versions of all deployed process definitions with the same name will
- be taken into account. The assigned <literal>version</literal> will be one higher
- then the highest <literal>version</literal> number of deployed process definitions
- with the same <literal>key</literal>. If no process definitions with a similar
- <literal>key</literal> have been deployed, version number 1 is assigned.
- </para>
- <para>In this first example, we'll supply a name and nothing else.</para>
- <programlisting><process name="Insurance claim">
-...
-</process></programlisting>
- <para>Let's assume that this is the first time that this process gets deployed.
- Then it will get the following properties:
- </para>
- <table><title>Process properties without key</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Property</entry>
- <entry>Value</entry>
- <entry>Source</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>name</literal></entry>
- <entry>Insurance claim</entry>
- <entry>process xml</entry>
- </row>
- <row>
- <entry><literal>key</literal></entry>
- <entry>Insurance_claim</entry>
- <entry>generated</entry>
- </row>
- <row>
- <entry><literal>version</literal></entry>
- <entry>1</entry>
- <entry>generated</entry>
- </row>
- <row>
- <entry><literal>id</literal></entry>
- <entry>Insurance_claim:1</entry>
- <entry>generated</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>And as a second example, we'll show how you can get shorter ids by
- specifying a process key:</para>
- <programlisting><process name="Insurance claim" key="ICL">
-...
-</process></programlisting>
- <para>Then the process definition properties look like this:</para>
- <table><title>Process properties with key</title>
- <tgroup cols="2" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Property</entry>
- <entry>Value</entry>
- <entry>Source</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>name</literal></entry>
- <entry>Insurance claim</entry>
- <entry>process xml</entry>
- </row>
- <row>
- <entry><literal>key</literal></entry>
- <entry>ICL</entry>
- <entry>process xml</entry>
- </row>
- <row>
- <entry><literal>version</literal></entry>
- <entry>1</entry>
- <entry>generated</entry>
- </row>
- <row>
- <entry><literal>id</literal></entry>
- <entry>ICL:1</entry>
- <entry>generated</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
-
- <section id="undeployingdeployments">
- <title>Undeploying deployments</title>
- <para>TODO</para>
- </section>
-
- <section id="deletingadeployment">
- <title>Deleting a deployment</title>
- <para>Deleting a deployment will remove it from the DB.</para>
- <programlisting>repositoryService.deleteDeployment(deploymentDbid);</programlisting>
- <para>That method will throw an exception when there are still active
- process executions for process definitions in that deployment.
- </para>
- <para>If you want to cascade deletion of a deployment to all
- the process instances of all the process definitions, use
- <literal>deleteDeploymentCascade</literal>.
- </para>
- </section>
-
- <section id="startinganewprocessinstance">
- <title>Starting a new process instance</title>
-
- <section id="inlatest">
- <title>In latest</title>
- <para>Simplest and most common way to start a new process instance for a process
- definition is like this:
- </para>
- <programlisting>ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL");</programlisting>
- <para>In this case, the service method will first look up the latest version of
- the processes with key <literal>ICL</literal>. Then a new
- process instance is started in that latest process definition.
- </para>
- <para>When a new version of the insurance claim process
- is deployed, all invocations of <literal>startProcessInstanceByKey</literal>
- will automatically switch to the newly deployed version.
- </para>
- </section>
-
- <section id="specificprocessversion">
- <title>Specific process version</title>
- <para>If instead you want to start a new process instance in a very
- specific version, you can use the id of the process definition like this:
- </para>
- <programlisting>ProcessInstance processInstance =
- executionService.startProcessInstanceById("ICL-1");</programlisting>
- </section>
-
- <section id="withakey">
- <title>With a key</title>
- <para>A new process instance can optionally be given a key. A key is
- a user defined reference to the execution. A key must be unique within the
- scope of all versions of a process definition. Typically it is easy
- to find such a key in the domain of the business process. For example, an
- order id or an insurance claim number.
- </para>
- <programlisting>ProcessInstance processInstance =
- executionService.startProcessInstanceByKey("ICL", "CL92837");</programlisting>
- <para>The key is used to create the id of the process instance.
- The format used is <literal>{process-key}.{execution-id}</literal>.
- With a dot between process-key and execution-id.
- So execution created in the previous code snippet will have id
- <literal>ICL.CL92837</literal>.
- </para>
- <para>If no user defined key is provided, the DB primary key is taken
- as the key. In that case, the id can be retrieved like this:
- <programlisting>ProcessInstance processInstance =
- executionService.startProcessInstanceByKey("ICL");
-String pid = processInstance.getId();</programlisting>
- </para>
- <para>We recommend the use of a user defined keys. Typically in your application
- code, you'll have the key available. By providing a user defined key, you can
- then compose the id of the execution, rather then performing a query based
- on the process variables.
- </para>
- </section>
-
- <section id="withvariables">
- <title>With variables</title>
- <para>A map of named parameter objects can be provided when starting a
- new process instance. These parameters will be set as variables on the process
- instance between creation and start of the process instance.
- </para>
- <programlisting>Map<String,Object> variables = new HashMap<String,Object>();
-variables.put("customer", "John Doe");
-variables.put("type", "Accident");
-variables.put("amount", new Float(763.74));
-
-ProcessInstance processInstance =
- executionService.startProcessInstanceByKey("ICL", variables);</programlisting>
- </section>
- </section>
-
- <section id="singallingawaitingexecution">
- <title>Signalling a waiting execution</title>
- <para>When using a <literal>state</literal> activity, the execution (or process instance)
- will wait when it arrives in the state, waiting for a signal (aka external trigger).
- Methods <literal>signalExecution</literal> can be used for that. Executions are
- referenced by an execution id (String).
- </para>
- <para>In some cases, the execution that arrives in a state will be the process instance
- itself. But that is not always the case. In case of timers or concurrency, a process
- is the root execution of a tree of executions. So you have to make sure that you signal
- the right path of execution.
- </para>
- <para>The preferred way to capture the right execution is by associating an event listener to
- the state activity like this:
- </para>
- <programlisting><state name="wait">
- <on event="start">
- <event-listener class="org.jbpm.examples.StartExternalWork" />
- </on>
- ...
-</state></programlisting>
- <para>In event listener <literal>StartExternalWork</literal> you can kick off what needs to
- be done externally. In that event listener you can also obtain the exact execution id
- with <literal>execution.getId()</literal>. It's that executionId that you'll need to provide
- the signal later on when the external work is done:
- </para>
- <programlisting>executionService.signalExecutionById(executionId);</programlisting>
- <para>There is an alternatively (less preferrable) way to obtain the executionId
- when the execution arrives in the <literal>state</literal> activity.
- It's only possible to obtain the execution id this way if you know after which jBPM
- API call the execution will have entered the <literal>state</literal> activity:
- </para>
- <programlisting>// assume that we know that after the next call
-// the process instance will arrive in <literal>state</literal> external work
-
-ProcessInstance processInstance =
- executionService.startProcessInstanceById(processDefinitionId);
-// or ProcessInstance processInstance =
-// executionService.signalProcessInstanceById(executionId);
-
-Execution execution = processInstance.findActiveExecutionIn("external work");
-String executionId = execution.getId();</programlisting>
- </section>
-
- <section id="taskservice">
- <title>TaskService</title>
- <para>The primary purpose of the TaskService is to provide access to
- task lists. The code sample will show how to get the task list for
- the user with id <literal>johndoe</literal>.
- </para>
- <programlisting>List<Task> taskList = taskService.findPersonalTasks("johndoe");</programlisting>
- <para>Typically tasks are associated with a form and displayed in some user
- interface. The form needs to be able to read and write data related to the task.
- </para>
- <programlisting>long taskDbid = task.getDbid();
-
-Set<String> variableNames = taskService.getVariableNames(taskDbid);
-variables = taskService.getVariables(taskDbid, variableNames);
-
-variables = new HashMap<String, Object>();
-variables.put("category", "small");
-variables.put("lires", 923874893);
-taskService.setVariables(taskDbid, variables);</programlisting>
- <para>and complete tasks</para>
- <programlisting>taskService.completeTask(taskDbid);</programlisting>
- <para>Tasks can also be offered to a set of candidates. Candidates can be
- users or groups. Users can take tasks for which they are a candidate. Taking
- a task means that this user will be set as the assignee. After that, other users
- will be blocked from taking the task.
- </para>
- <para>People should not work on
- a task unless they are assigned to that task. The user interface displays
- forms and allow users to complete tasks if they are assigned to it.
- For unassigned tasks for which the user is a candidate, the only action that
- should be exposed is 'take'.
- </para>
- <para>More on tasks in <xref linkend="task" /> </para>
- </section>
-
- <section id="historyservice">
- <title>HistoryService</title>
- <para>During runtime execution of process instances, events are generated. And from
- those events, history information on both running and completed process executions are
- collected in the history tables. The <literal>HistoryService</literal> provides
- access to that information.
- </para>
- <para>Querying for all process instances for a specific process definition can be
- done like this:</para>
- <programlisting>List<HistoryProcessInstance> historyProcessInstances = historyService
- .createHistoryProcessInstanceQuery()
- .processDefinitionId("ICL-1")
- .orderAsc(HistoryProcessInstanceQuery.PROPERTY_STARTTIME)
- .list();</programlisting>
- <para>Also individual activity executions are stored in the history information as
- <literal>HistoryActivityInstance</literal>s.
- </para>
- <programlisting>List<HistoryActivityInstance> histActInsts = historyService
- .createHistoryActivityInstanceQuery()
- .processDefinitionId("ICL-1")
- .activityName("a")
- .list();</programlisting>
- <para>Convenience methods <literal>avgDurationPerActivity</literal> and
- <literal>choiceDistribution</literal> are also available. See javadocs for more
- information on those methods.
- </para>
- </section>
-
- <section id="managementservice">
- <title>ManagementService</title>
- <para>The management service is mostly used to manage the jobs. See javadocs for
- more information. This functionality is also exposed through the console.
- </para>
- </section>
-
-</chapter>
\ No newline at end of file
+<chapter id="services">
+ <title>Services</title>
+
+ <section id="processdefinitionprocessinstanceandexecutions">
+ <title>Process definition, process instance and executions</title>
+ <para>A process definition is description of the steps in a procedure.
+ For example, an insurance company could have a <literal>loan</literal>
+ process definition that describes the steps of how the company deals
+ with loan requests.
+ </para>
+ <figure id="loan.process.definition.example">
+ <title>The loan process definition example</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/loan.process.definition.png"/></imageobject></mediaobject>
+ </figure>
+ <para>One process instance represents one particular run of a process definition.
+ For example, the loan request of John Doe last Friday to finance his new boat
+ is represented in one process instance of the loan process definition.
+ </para>
+ <para>A process instance contains all the runtime state. The
+ most prominent property is the pointer that keeps track of the current activity.
+ </para>
+ <figure id="loan.process.instance.example">
+ <title>The loan process instance example</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/loan.process.instance.png"/></imageobject></mediaobject>
+ </figure>
+ <para>Suppose that wiring the money and archiving can be done in parallel.
+ Then the main process instance will have two child executions to keep
+ track of the state like this:
+ </para>
+ <figure id="loan.executions.example">
+ <title>The loan executions example</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/loan.executions.png"/></imageobject></mediaobject>
+ </figure>
+ <para>More general, a process instance is the root of a tree of executions.
+ When a new process instance is started, the process instance is in fact the root
+ execution scope. Only leaf executions can be active.
+ </para>
+ <para>The motivation to work with a tree structure like this is that
+ this conceptually remains simple in the case where there is only one path
+ of execution. The services API doesn't need to make a functional difference
+ between process instances and executions. Therefore, the API has only
+ one Execution type to refer to both <literal>ProcessInstance</literal>s and
+ <literal>Execution</literal>s.
+ </para>
+ </section>
+
+ <section id="processengine">
+ <title>ProcessEngine</title>
+ <para>Interacting with jBPM occurs through services.
+ The service interfaces can be obtained from the <literal>ProcessEngine</literal>
+ which is build from a <literal>Configuration</literal>.
+ </para>
+ <para>A <literal>ProcessEngine</literal> is thread safe and can be stored in a
+ static member field or even better in JNDI or some other central location.
+ One <literal>ProcessEngine</literal> object can be used by all requests and
+ threads in an application. Here's how you can obtain a <literal>ProcessEngine</literal>
+ </para>
+
+ <para>The code snippets in this section and the next section about process
+ deployments are taken from example
+ <literal>org.jbpm.examples.services.ServicesTest</literal>
+ </para>
+
+ <programlisting>ProcessEngine processEngine = new Configuration()
+ .buildProcessEngine();</programlisting>
+
+ <para>The previous code snippet shows how to build a <literal>ProcessEngine</literal>
+ from the default configuration file <literal>jbpm.cfg.xml</literal> which is
+ expected in the root of the classpath. If you want to specify another
+ resource location, use the <literal>setResource</literal> method like this:
+ </para>
+
+ <programlisting>ProcessEngine processEngine = new Configuration()
+ .setResource("my-own-configuration-file.xml")
+ .buildProcessEngine();</programlisting>
+
+ <para>There are other <literal>setXxxx</literal> methods that allow to specify
+ the configuration content as an <literal>InputStream</literal>, an
+ <literal>xmlString</literal>, <literal>InputSource</literal>,
+ <literal>URL</literal> or <literal>File</literal>.
+ </para>
+
+ <para>From a <literal>ProcessEngine</literal> the following services
+ can be obtained:
+ </para>
+
+ <programlisting><emphasis role="bold">RepositoryService</emphasis> repositoryService = processEngine.getRepositoryService();
+<emphasis role="bold">ExecutionService</emphasis> executionService = processEngine.getExecutionService();
+<emphasis role="bold">TaskService</emphasis> taskService = processEngine.getTaskService();
+<emphasis role="bold">HistoryService</emphasis> historyService = processEngine.getHistoryService();
+<emphasis role="bold">ManagementService</emphasis> managementService = processEngine.getManagementService();</programlisting>
+
+ <para>Process engine objects defined in the configuration can also be retrieved by
+ type (<literal>processEngine.get(Class<T>)</literal>)
+ or by name (<literal>processEngine.get(String)</literal>)</para>
+
+ </section>
+
+ <section id="deployingaprocess">
+ <title>Deploying a process</title>
+ <para>The <literal>RepositoryService</literal> groups all methods to manage
+ the repository of deployments. In this first example, we'll deploy one process
+ resource from the classpath with the <literal>RepositoryService</literal>:
+ </para>
+ <programlisting>long deploymentId = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/services/Order.jpdl.xml")
+ .deploy();</programlisting>
+ <para>Analogue to the <literal>addResourceFromClasspath</literal> method above,
+ the source of the processes definitions XML can be picked up from a file, url, string,
+ input stream or zip input stream.
+ </para>
+ <para>Each deployment is composed of a set of named resources. The content
+ of each resource is a byte array. jPDL process files are recognized by their extension
+ <literal>.jpdl.xml</literal>. Other resource types are task forms and java classes.
+ </para>
+ <para>A deployment works with a set of named resources and can potentially contain
+ multiple process descriptions and multiple other artifact types. The jPDL deployer
+ will recognise process files based on the <literal>.jpdl.xml</literal>
+ extension automatically.
+ </para>
+ <para>During deployment, an <literal>id</literal> is assigned to the process
+ definitions. The <literal>id</literal> will have format
+ <literal>{key}-{version}</literal> with a dash between key and version
+ </para>
+ <para>If <literal>key</literal> is not provided, it is generated automatically
+ based on the name. All non alpha numeric characters in the name will be replaced
+ by underscores to generate the key.
+ </para>
+ <para>The same <literal>name</literal> can only be associated to one
+ <literal>key</literal> and vice versa.
+ </para>
+ <para>If <literal>version</literal> is not provided, a <literal>version</literal>
+ will be automatically be assigned. For version
+ assignment, the versions of all deployed process definitions with the same name will
+ be taken into account. The assigned <literal>version</literal> will be one higher
+ then the highest <literal>version</literal> number of deployed process definitions
+ with the same <literal>key</literal>. If no process definitions with a similar
+ <literal>key</literal> have been deployed, version number 1 is assigned.
+ </para>
+ <para>In this first example, we'll supply a name and nothing else.</para>
+ <programlisting><process name="Insurance claim">
+...
+</process></programlisting>
+ <para>Let's assume that this is the first time that this process gets deployed.
+ Then it will get the following properties:
+ </para>
+ <table><title>Process properties without key</title>
+ <tgroup cols="3" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Property</entry>
+ <entry>Value</entry>
+ <entry>Source</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>name</literal></entry>
+ <entry>Insurance claim</entry>
+ <entry>process xml</entry>
+ </row>
+ <row>
+ <entry><literal>key</literal></entry>
+ <entry>Insurance_claim</entry>
+ <entry>generated</entry>
+ </row>
+ <row>
+ <entry><literal>version</literal></entry>
+ <entry>1</entry>
+ <entry>generated</entry>
+ </row>
+ <row>
+ <entry><literal>id</literal></entry>
+ <entry>Insurance_claim-1</entry>
+ <entry>generated</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>And as a second example, we'll show how you can get shorter ids by
+ specifying a process key:</para>
+ <programlisting><process name="Insurance claim" key="ICL">
+...
+</process></programlisting>
+ <para>Then the process definition properties look like this:</para>
+ <table><title>Process properties with key</title>
+ <tgroup cols="2" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Property</entry>
+ <entry>Value</entry>
+ <entry>Source</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>name</literal></entry>
+ <entry>Insurance claim</entry>
+ <entry>process xml</entry>
+ </row>
+ <row>
+ <entry><literal>key</literal></entry>
+ <entry>ICL</entry>
+ <entry>process xml</entry>
+ </row>
+ <row>
+ <entry><literal>version</literal></entry>
+ <entry>1</entry>
+ <entry>generated</entry>
+ </row>
+ <row>
+ <entry><literal>id</literal></entry>
+ <entry>ICL-1</entry>
+ <entry>generated</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+
+ <section id="undeployingdeployments">
+ <title>Undeploying deployments</title>
+ <para>TODO</para>
+ </section>
+
+ <section id="deletingadeployment">
+ <title>Deleting a deployment</title>
+ <para>Deleting a deployment will remove it from the DB.</para>
+ <programlisting>repositoryService.deleteDeployment(deploymentId);</programlisting>
+ <para>That method will throw an exception when there are still active
+ process executions for process definitions in that deployment.
+ </para>
+ <para>If you want to cascade deletion of a deployment to all
+ the process instances of all the process definitions, use
+ <literal>deleteDeploymentCascade</literal>.
+ </para>
+ </section>
+
+ <section id="startinganewprocessinstance">
+ <title>Starting a new process instance</title>
+
+ <section id="inlatest">
+ <title>In latest</title>
+ <para>Simplest and most common way to start a new process instance for a process
+ definition is like this:
+ </para>
+ <programlisting>ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL");</programlisting>
+ <para>In this case, the service method will first look up the latest version of
+ the processes with key <literal>ICL</literal>. Then a new
+ process instance is started in that latest process definition.
+ </para>
+ <para>When a new version of the insurance claim process
+ is deployed, all invocations of <literal>startProcessInstanceByKey</literal>
+ will automatically switch to the newly deployed version.
+ </para>
+ </section>
+
+ <section id="specificprocessversion">
+ <title>Specific process version</title>
+ <para>If instead you want to start a new process instance in a very
+ specific version, you can use the id of the process definition like this:
+ </para>
+ <programlisting>ProcessInstance processInstance =
+ executionService.startProcessInstanceById("ICL-1");</programlisting>
+ </section>
+
+ <section id="withakey">
+ <title>With a key</title>
+ <para>A new process instance can optionally be given a key. A key is
+ a user defined reference to the execution. A key must be unique within the
+ scope of all versions of a process definition. Typically it is easy
+ to find such a key in the domain of the business process. For example, an
+ order id or an insurance claim number.
+ </para>
+ <programlisting>ProcessInstance processInstance =
+ executionService.startProcessInstanceByKey("ICL", "CL92837");</programlisting>
+ <para>The key is used to create the id of the process instance.
+ The format used is <literal>{process-key}.{execution-id}</literal>.
+ With a dot between process-key and execution-id.
+ So execution created in the previous code snippet will have id
+ <literal>ICL.CL92837</literal>.
+ </para>
+ <para>If no user defined key is provided, the DB primary key is taken
+ as the key. In that case, the id can be retrieved like this:
+ <programlisting>ProcessInstance processInstance =
+ executionService.startProcessInstanceByKey("ICL");
+String pid = processInstance.getId();</programlisting>
+ </para>
+ <para>We recommend the use of a user defined keys. Typically in your application
+ code, you'll have the key available. By providing a user defined key, you can
+ then compose the id of the execution, rather then performing a query based
+ on the process variables.
+ </para>
+ </section>
+
+ <section id="withvariables">
+ <title>With variables</title>
+ <para>A map of named parameter objects can be provided when starting a
+ new process instance. These parameters will be set as variables on the process
+ instance between creation and start of the process instance.
+ </para>
+ <programlisting>Map<String,Object> variables = new HashMap<String,Object>();
+variables.put("customer", "John Doe");
+variables.put("type", "Accident");
+variables.put("amount", new Float(763.74));
+
+ProcessInstance processInstance =
+ executionService.startProcessInstanceByKey("ICL", variables);</programlisting>
+ </section>
+ </section>
+
+ <section id="singallingawaitingexecution">
+ <title>Signalling a waiting execution</title>
+ <para>When using a <literal>state</literal> activity, the execution (or process instance)
+ will wait when it arrives in the state, waiting for a signal (aka external trigger).
+ Methods <literal>signalExecution</literal> can be used for that. Executions are
+ referenced by an execution id (String).
+ </para>
+ <para>In some cases, the execution that arrives in a state will be the process instance
+ itself. But that is not always the case. In case of timers or concurrency, a process
+ is the root execution of a tree of executions. So you have to make sure that you signal
+ the right path of execution.
+ </para>
+ <para>The preferred way to capture the right execution is by associating an event listener to
+ the state activity like this:
+ </para>
+ <programlisting><state name="wait">
+ <on event="start">
+ <event-listener class="org.jbpm.examples.StartExternalWork" />
+ </on>
+ ...
+</state></programlisting>
+ <para>In event listener <literal>StartExternalWork</literal> you can kick off what needs to
+ be done externally. In that event listener you can also obtain the exact execution id
+ with <literal>execution.getId()</literal>. It's that executionId that you'll need to provide
+ the signal later on when the external work is done:
+ </para>
+ <programlisting>executionService.signalExecutionById(executionId);</programlisting>
+ <para>There is an alternatively (less preferrable) way to obtain the executionId
+ when the execution arrives in the <literal>state</literal> activity.
+ It's only possible to obtain the execution id this way if you know after which jBPM
+ API call the execution will have entered the <literal>state</literal> activity:
+ </para>
+ <programlisting>// assume that we know that after the next call
+// the process instance will arrive in <literal>state</literal> external work
+
+ProcessInstance processInstance =
+ executionService.startProcessInstanceById(processDefinitionId);
+// or ProcessInstance processInstance =
+// executionService.signalProcessInstanceById(executionId);
+
+Execution execution = processInstance.findActiveExecutionIn("external work");
+String executionId = execution.getId();</programlisting>
+ </section>
+
+ <section id="taskservice">
+ <title>TaskService</title>
+ <para>The primary purpose of the TaskService is to provide access to
+ task lists. The code sample will show how to get the task list for
+ the user with id <literal>johndoe</literal>.
+ </para>
+ <programlisting>List<Task> taskList = taskService.findPersonalTasks("johndoe");</programlisting>
+ <para>Typically tasks are associated with a form and displayed in some user
+ interface. The form needs to be able to read and write data related to the task.
+ </para>
+ <programlisting>long taskId = task.getId();
+
+Set<String> variableNames = taskService.getVariableNames(taskId);
+variables = taskService.getVariables(taskId, variableNames);
+
+variables = new HashMap<String, Object>();
+variables.put("category", "small");
+variables.put("lires", 923874893);
+taskService.setVariables(taskId, variables);</programlisting>
+ <para>and complete tasks</para>
+ <programlisting>taskService.completeTask(taskId);</programlisting>
+ <para>Tasks can also be offered to a set of candidates. Candidates can be
+ users or groups. Users can take tasks for which they are a candidate. Taking
+ a task means that this user will be set as the assignee. After that, other users
+ will be blocked from taking the task.
+ </para>
+ <para>People should not work on
+ a task unless they are assigned to that task. The user interface should display
+ forms and allow users to complete tasks if they are assigned to it.
+ For unassigned tasks for which the user is a candidate, the only action that
+ should be exposed is 'take'.
+ </para>
+ <para>More on tasks in <xref linkend="task" /> </para>
+ </section>
+
+ <section id="historyservice">
+ <title>HistoryService</title>
+ <para>During runtime execution of process instances, events are generated. And from
+ those events, history information on both running and completed process executions are
+ collected in the history tables. The <literal>HistoryService</literal> provides
+ access to that information.
+ </para>
+ <para>Querying for all process instances for a specific process definition can be
+ done like this:</para>
+ <programlisting>List<HistoryProcessInstance> historyProcessInstances = historyService
+ .createHistoryProcessInstanceQuery()
+ .processDefinitionId("ICL-1")
+ .orderAsc(HistoryProcessInstanceQuery.PROPERTY_STARTTIME)
+ .list();</programlisting>
+ <para>Also individual activity executions are stored in the history information as
+ <literal>HistoryActivityInstance</literal>s.
+ </para>
+ <programlisting>List<HistoryActivityInstance> histActInsts = historyService
+ .createHistoryActivityInstanceQuery()
+ .processDefinitionId("ICL-1")
+ .activityName("a")
+ .list();</programlisting>
+ <para>Convenience methods <literal>avgDurationPerActivity</literal> and
+ <literal>choiceDistribution</literal> are also available. See javadocs for more
+ information on those methods.
+ </para>
+ </section>
+
+ <section id="managementservice">
+ <title>ManagementService</title>
+ <para>The management service is mostly used to manage the jobs. See javadocs for
+ more information. This functionality is also exposed through the console.
+ </para>
+ </section>
+
+</chapter>
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml 2009-08-18 02:20:19 UTC (rev 5484)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml 2009-08-18 08:17:27 UTC (rev 5485)
@@ -247,7 +247,7 @@
<para>Let's start a new process instance for this process definition:</para>
<programlisting>ProcessInstance processInstance = executionService
.startProcessInstanceByKey("StateChoice");</programlisting>
- <para>Now, the execution is arrived in the <literal>wait for response</literal>.
+ <para>Now, the execution has arrived in the <literal>wait for response</literal>.
The execution will wait there until an external trigger is given. In case
a <literal>state</literal> has multiple outgoing transitions, the signalName given
in the external trigger will be matched against the name of the outgoing transition
16 years, 8 months
JBoss JBPM SVN: r5484 - in jbpm3/branches/jbpm-3.2-soa/modules/core/src: test/java/org/jbpm/taskmgmt/exe and 1 other directory.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-08-17 22:20:19 -0400 (Mon, 17 Aug 2009)
New Revision: 5484
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskVariablesDbTest.java
Log:
test task variable query
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java 2009-08-18 02:06:38 UTC (rev 5483)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java 2009-08-18 02:20:19 UTC (rev 5484)
@@ -335,8 +335,8 @@
}
/**
- * cancels this task. This task intance will be marked as cancelled and as ended. But cancellation
- * doesn't influence singalling and continuation of process execution.
+ * cancels this task. This task instance will be marked as cancelled and as ended. But cancellation
+ * doesn't influence signalling and continuation of process execution.
*/
public void cancel() {
markAsCancelled();
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskVariablesDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskVariablesDbTest.java 2009-08-18 02:06:38 UTC (rev 5483)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskVariablesDbTest.java 2009-08-18 02:20:19 UTC (rev 5484)
@@ -24,10 +24,17 @@
import java.util.HashMap;
import java.util.Map;
+import org.hibernate.Hibernate;
+import org.hibernate.criterion.Restrictions;
+
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.node.TaskNode;
+import org.jbpm.taskmgmt.def.Task;
public class TaskVariablesDbTest extends AbstractDbTestCase {
@@ -39,8 +46,8 @@
newTransaction();
try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
- TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createTaskInstance(
- processInstance.getRootToken());
+ TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
+ .createTaskInstance(processInstance.getRootToken());
taskInstance.setVariable("key", "value");
taskInstance = saveAndReload(taskInstance);
@@ -336,4 +343,66 @@
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
+
+ public void testTaskVariableQuery() {
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='task-variable-query'>"
+ + " <start-state>"
+ + " <transition to='t' />"
+ + " </start-state>"
+ + " <task-node name='t' create-tasks='no'>"
+ + " <event type='node-enter'>"
+ + " <action class='"
+ + CreateTasksAction.class.getName()
+ + "'/>"
+ + " </event>"
+ + " <task name='vartask'>"
+ + " <assignment actor-id='me' />"
+ + " </task>"
+ + " </task-node>"
+ + "</process-definition>");
+ jbpmContext.deployProcessDefinition(processDefinition);
+
+ newTransaction();
+ try {
+ ProcessInstance processInstance = new ProcessInstance(processDefinition);
+ processInstance.signal();
+
+ newTransaction();
+ assertEquals(5, jbpmContext.getTaskList("me").size());
+
+ newTransaction();
+ TaskInstance task = getTask("index", 3, "me");
+ assertEquals(3, ((Long) task.getVariable("index")).longValue());
+ }
+ finally {
+ graphSession.deleteProcessDefinition(processDefinition.getId());
+ }
+ }
+
+ private TaskInstance getTask(String variableName, long variableValue, String actorId) {
+ return (TaskInstance) jbpmContext.getSession()
+ .createCriteria(TaskInstance.class)
+ .add(Restrictions.eq("actorId", actorId))
+ .createCriteria("variableInstances")
+ .add(Restrictions.eq("name", variableName))
+ .add(Restrictions.sqlRestriction("{alias}.LONGVALUE_ = ?", new Long(variableValue), Hibernate.LONG))
+ .uniqueResult();
+ }
+
+ public static final class CreateTasksAction implements ActionHandler {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ExecutionContext executionContext) throws Exception {
+ TaskNode taskNode = (TaskNode) executionContext.getNode();
+ Task task = taskNode.getTask("vartask");
+ TaskMgmtInstance taskMgmtInstance = executionContext.getTaskMgmtInstance();
+
+ for (int index = 0; index < 5; index++) {
+ TaskInstance ti = taskMgmtInstance.createTaskInstance(task, executionContext);
+ ti.setVariableLocally("index", new Long(index));
+ }
+ }
+
+ }
}
16 years, 8 months
JBoss JBPM SVN: r5483 - jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-08-17 22:06:38 -0400 (Mon, 17 Aug 2009)
New Revision: 5483
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/log4j.xml
Log:
take out org.hibernate.connection log category, no longer useful
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/log4j.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/log4j.xml 2009-08-18 02:05:22 UTC (rev 5482)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/log4j.xml 2009-08-18 02:06:38 UTC (rev 5483)
@@ -40,9 +40,11 @@
<priority value="DEBUG" />
</category>
+ <!--
<category name="org.hibernate.connection">
<priority value="TRACE" />
</category>
+ -->
<!-- ======================= -->
<!-- Setup the Root category -->
16 years, 8 months
JBoss JBPM SVN: r5482 - jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2094.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-08-17 22:05:22 -0400 (Mon, 17 Aug 2009)
New Revision: 5482
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2094/processdefinition.xml
Log:
[JBPM-2094] set async='exclusive' in join node
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2094/processdefinition.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2094/processdefinition.xml 2009-08-15 03:29:25 UTC (rev 5481)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2094/processdefinition.xml 2009-08-18 02:05:22 UTC (rev 5482)
@@ -83,7 +83,7 @@
<transition name="" to="join1"/>
</node>
- <join name="join1">
+ <join name="join1" async="exclusive">
<transition to="Shipment Notice"/>
</join>
16 years, 8 months
JBoss JBPM SVN: r5481 - in jbpm4/trunk/modules/db: scripts and 1 other directory.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-08-14 23:29:25 -0400 (Fri, 14 Aug 2009)
New Revision: 5481
Modified:
jbpm4/trunk/modules/db/pom.xml
jbpm4/trunk/modules/db/scripts/antrun-schema.xml
jbpm4/trunk/modules/db/scripts/antrun-upgrade.xml
Log:
[JBPM-1995] build script to calculate jBPM DB differences
generate schema update script and diff between schema creation scripts
Modified: jbpm4/trunk/modules/db/pom.xml
===================================================================
--- jbpm4/trunk/modules/db/pom.xml 2009-08-14 10:04:17 UTC (rev 5480)
+++ jbpm4/trunk/modules/db/pom.xml 2009-08-15 03:29:25 UTC (rev 5481)
@@ -71,7 +71,7 @@
<goal>run</goal>
</goals>
<configuration>
- <tasks>
+ <tasks>
<property name="project.output.dir" value="${project.build.outputDirectory}"/>
<property name="previous.version.dir" value="${previous.version.directory}"/>
<ant antfile="scripts/antrun-upgrade.xml" target="upgrade-schema" inheritRefs="yes"/>
@@ -84,7 +84,7 @@
</build>
<properties>
- <previous.version.directory>${project.build.directory}/previous</previous.version.directory>
+ <previous.version.directory>${project.build.directory}/${jbpm.previous.version}</previous.version.directory>
</properties>
</profile>
</profiles>
Modified: jbpm4/trunk/modules/db/scripts/antrun-schema.xml
===================================================================
--- jbpm4/trunk/modules/db/scripts/antrun-schema.xml 2009-08-14 10:04:17 UTC (rev 5480)
+++ jbpm4/trunk/modules/db/scripts/antrun-schema.xml 2009-08-15 03:29:25 UTC (rev 5481)
@@ -10,57 +10,59 @@
<project>
- <!-- ================================================================== -->
- <!-- jBPM Database schema -->
- <!-- ================================================================== -->
+ <!-- ================================================================== -->
+ <!-- jBPM Database schema -->
+ <!-- ================================================================== -->
- <target name="create-schema">
- <taskdef name="schemaexport"
- classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
- classpathref="maven.compile.classpath" />
+ <target name="create-schema">
+ <taskdef name="schemaexport"
+ classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
+ classpathref="maven.compile.classpath" />
- <!-- HsqlDB -->
- <create-ddl db="hsqldb"/>
+ <mkdir dir="${project.output.dir}" />
- <!-- MySQL -->
- <create-ddl db="mysql"/>
- <!--TODO: https://jira.jboss.org/jira/browse/JBPM-2071 -->
- <replace file="${project.output.dir}/jbpm.mysql.create.sql" token="BLOB_VALUE_ blob" value="BLOB_VALUE_ longblob" />
+ <!-- HsqlDB -->
+ <create-ddl db="hsqldb" />
- <!-- Oracle -->
- <create-ddl db="oracle"/>
+ <!-- MySQL -->
+ <create-ddl db="mysql" />
+ <!--TODO: https://jira.jboss.org/jira/browse/JBPM-2071 -->
+ <replace file="${project.output.dir}/jbpm.mysql.create.sql"
+ token="BLOB_VALUE_ blob"
+ value="BLOB_VALUE_ longblob" />
- <!-- PostgreSQL -->
- <create-ddl db="postgresql"/>
+ <!-- Oracle -->
+ <create-ddl db="oracle" />
- </target>
+ <!-- PostgreSQL -->
+ <create-ddl db="postgresql" />
- <!--
- ============================================
- Macro defs, no need to change anything below
- ============================================
- -->
+ </target>
- <macrodef name="create-ddl">
- <attribute name="db"/>
+ <!-- ============================================ -->
+ <!-- Macro definitions -->
+ <!-- ============================================ -->
- <sequential>
- <echo>=====================</echo>
- <echo>Create DDL @{db}</echo>
-
- <schemaexport output="${project.output.dir}/jbpm.(a){db}.create.sql"
- create="yes" drop="no"
- config="src/main/config/(a){db}.hibernate.cfg.xml"
- text="yes" delimiter=";"
- quiet="yes"/>
- <schemaexport output="${project.output.dir}/jbpm.(a){db}.drop.sql"
- create="no" drop="yes"
- config="src/main/config/(a){db}.hibernate.cfg.xml"
- text="yes" delimiter=";"
- quiet="yes"/>
+ <macrodef name="create-ddl">
+ <attribute name="db" />
- <echo>=====================</echo>
- </sequential>
- </macrodef>
+ <sequential>
+ <echo>=====================</echo>
+ <echo>Create DDL @{db}</echo>
+ <schemaexport output="${project.output.dir}/jbpm.(a){db}.create.sql"
+ create="yes" drop="no"
+ config="src/main/config/(a){db}.hibernate.cfg.xml"
+ text="yes" delimiter=";"
+ quiet="yes" />
+ <schemaexport output="${project.output.dir}/jbpm.(a){db}.drop.sql"
+ create="no" drop="yes"
+ config="src/main/config/(a){db}.hibernate.cfg.xml"
+ text="yes" delimiter=";"
+ quiet="yes" />
+
+ <echo>=====================</echo>
+ </sequential>
+ </macrodef>
+
</project>
Modified: jbpm4/trunk/modules/db/scripts/antrun-upgrade.xml
===================================================================
--- jbpm4/trunk/modules/db/scripts/antrun-upgrade.xml 2009-08-14 10:04:17 UTC (rev 5480)
+++ jbpm4/trunk/modules/db/scripts/antrun-upgrade.xml 2009-08-15 03:29:25 UTC (rev 5481)
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
-
<!-- ============================================ -->
<!-- jBPM database schema -->
<!-- ============================================ -->
@@ -9,21 +8,37 @@
<taskdef name="schemaupdate"
classname="org.hibernate.tool.hbm2ddl.SchemaUpdateTask"
classpathref="maven.compile.classpath" />
- <taskdef name="schemaexport"
- classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
- classpathref="maven.compile.classpath"/>
+ <taskdef name="schemaexport"
+ classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
+ classpathref="maven.compile.classpath" />
- <!-- HSQLDB -->
- <upgrade-ddl db="hsqldb"/>
+ <!-- HSQLDB -->
+ <java classname="org.hsqldb.Server"
+ classpathref="maven.compile.classpath"
+ fork="yes" spawn="yes">
+ <arg value="-port" />
+ <arg value="1701" />
+ <arg value="-database.0" />
+ <arg value="${previous.version.dir}/jbpmdb" />
+ </java>
+ <upgrade-ddl db="hsqldb" />
+ <sql url="${hsqldb.hibernate.connection.url}"
+ driver="${hsqldb.hibernate.connection.driver_class}"
+ classpathref="maven.compile.classpath"
+ userid="${hsqldb.hibernate.connection.username}"
+ password="${hsqldb.hibernate.connection.password}"
+ autocommit="yes">
+ SHUTDOWN
+ </sql>
- <!-- MySQL -->
- <upgrade-ddl db="mysql"/>
+ <!-- MySQL -->
+ <upgrade-ddl db="mysql" />
- <!-- Oracle -->
- <upgrade-ddl db="oracle"/>
+ <!-- PostgreSQL -->
+ <upgrade-ddl db="postgresql" />
- <!-- PostgreSQL -->
- <upgrade-ddl db="postgresql"/>
+ <!-- Oracle -->
+ <upgrade-ddl db="oracle" />
</target>
<!-- ============================================ -->
@@ -37,31 +52,40 @@
<echo>=====================</echo>
<echo>Upgrade DDL @{db}</echo>
- <property file="${user.home}/.jbpm4/jdbc/(a){db}.properties" prefix="@{db}"/>
- <echo>driver... ${(a){db}.jdbc.driver}</echo>
- <echo>url...... ${(a){db}.jdbc.url}</echo>
- <echo>username. ${(a){db}.jdbc.username}</echo>
- <echo>password. ${(a){db}.jdbc.password}</echo>
+ <!-- calculate the difference beetween the previous and the current create schemas -->
+ <exec command="diff" osfamily="unix" output="${previous.version.dir}/jbpm.(a){db}.create.diff">
+ <arg value="-u" />
+ <arg file="${previous.version.dir}/jbpm.(a){db}.create.sql" />
+ <arg file="${project.output.dir}/jbpm.(a){db}.create.sql" />
+ </exec>
+
+ <property name="@{db}.hibernate.cfg" value="src/main/config/(a){db}.hibernate.cfg.xml" />
+ <property name="@{db}.hibernate.properties"
+ value="${user.home}/.jbpm4/jdbc/(a){db}.properties" />
+ <property file="${(a){db}.hibernate.properties}" prefix="@{db}" />
+ <echo>driver... ${(a){db}.hibernate.connection.driver_class}</echo>
+ <echo>url...... ${(a){db}.hibernate.connection.url}</echo>
+ <echo>username. ${(a){db}.hibernate.connection.username}</echo>
+ <echo>password. ${(a){db}.hibernate.connection.password}</echo>
+
<!-- drop current schema if exists -->
- <sql src="${project.output.dir}/jbpm.(a){db}.drop.sql" url="${(a){db}.jdbc.url}"
- driver="${(a){db}.jdbc.driver}" classpathref="maven.compile.classpath"
- userid="${(a){db}.jdbc.username}" password="${(a){db}.jdbc.password}"
- autocommit="yes" onerror="continue"/>
+ <schemaexport output="${project.output.dir}/jbpm.(a){db}.drop.sql"
+ config="${(a){db}.hibernate.cfg}"
+ properties="${(a){db}.hibernate.properties}"
+ drop="yes" quiet="yes" />
<!-- create previous version schema -->
- <sql src="${previous.version.dir}/jbpm.(a){db}.create.sql" url="${(a){db}.jdbc.url}"
- driver="${(a){db}.jdbc.driver}" classpathref="maven.compile.classpath"
- userid="${(a){db}.jdbc.username}" password="${(a){db}.jdbc.password}"
- autocommit="yes"/>
+ <sql src="${previous.version.dir}/jbpm.(a){db}.create.sql"
+ url="${(a){db}.hibernate.connection.url}"
+ driver="${(a){db}.hibernate.connection.driver_class}"
+ classpathref="maven.compile.classpath"
+ userid="${(a){db}.hibernate.connection.username}"
+ password="${(a){db}.hibernate.connection.password}"
+ autocommit="yes" continue="yes" />
<!-- generate schema upgrade script -->
- <schemaupdate outputFile="${project.build.dir}/jbpm.(a){db}.update.sql"
- config="src/main/config/(a){db}.hibernate.cfg.xml"
- properties="${user.home}/.jbpm4/(a){db}.properties"
- text="yes" delimiter=";"/>
- <!-- drop previous version schema -->
- <sql src="${previous.version.dir}/jbpm.(a){db}.drop.sql" url="${(a){db}.jdbc.url}"
- driver="${(a){db}.jdbc.driver}" classpathref="maven.compile.classpath"
- userid="${(a){db}.jdbc.username}" password="${(a){db}.jdbc.password}"
- autocommit="yes"/>
+ <schemaupdate outputFile="${previous.version.dir}/jbpm.(a){db}.update.sql"
+ config="${(a){db}.hibernate.cfg}"
+ properties="${(a){db}.hibernate.properties}"
+ delimiter=";" />
<echo>=====================</echo>
</sequential>
16 years, 8 months
JBoss JBPM SVN: r5480 - in projects/jopr-integration/trunk: src/main/java/org and 6 other directories.
by do-not-reply@jboss.org
Author: jim.ma
Date: 2009-08-14 06:04:17 -0400 (Fri, 14 Aug 2009)
New Revision: 5480
Added:
projects/jopr-integration/trunk/src/main/java/org/rhq/
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ExceptionJobDiscoveryComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/InstanceJobDiscoveryComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/JobComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/MessageDiscoveryComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDefComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDefDiscoveryComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDeploymentComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDeploymentDiscoveryComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineDiscoveryComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessInstanceComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessInstanceDiscoveryComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/TimerDiscoveryComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/JBPMEngineConnection.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/JBPMEngineConnector.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/LocalJBPMEngineConnector.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/RemoteJBPMEngineConnector.java
Removed:
projects/jopr-integration/trunk/src/main/java/org/jbosson/plugins/jbpm/
Modified:
projects/jopr-integration/trunk/pom.xml
projects/jopr-integration/trunk/src/main/resources/META-INF/rhq-plugin.xml
Log:
Initial commit for local jopr plugin (embeded jopr);it provides the functions to mintor the processEngine, deployment, process definition,process instance and jobs
Modified: projects/jopr-integration/trunk/pom.xml
===================================================================
--- projects/jopr-integration/trunk/pom.xml 2009-08-14 05:01:17 UTC (rev 5479)
+++ projects/jopr-integration/trunk/pom.xml 2009-08-14 10:04:17 UTC (rev 5480)
@@ -1,229 +1,332 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.jboss.on</groupId>
- <artifactId>jon-parent</artifactId>
- <version>2.1.2.GA</version>
- </parent>
+ <parent>
+ <groupId>org.jboss.on</groupId>
+ <!--
+ Bypass the jopr-plugins-parent which can not have children. It must
+ build after the plugins in order to execute integration tests on
+ them.
+ -->
+ <artifactId>jopr-modules-parent</artifactId>
+ <version>2.3.0-SNAPSHOT</version>
+ </parent>
- <groupId>org.jboss.on</groupId>
- <artifactId>jopr-jbpm-plugin</artifactId>
- <packaging>jar</packaging>
+ <groupId>org.jboss.on</groupId>
+ <artifactId>jopr-jbpm4-plugin</artifactId>
+ <packaging>jar</packaging>
- <name>Jopr jbpm Plugin</name>
- <description>A plugin for managing jbpm</description>
+ <name>Jopr jbpm4 Plugin</name>
+ <description>A plugin for managing jbpm</description>
- <scm>
- <connection>scm:svn:https://svn.jboss.org/repos/jbpm/projects/jopr-integration</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbpm/projects/jopr-integration</developerConnection>
- </scm>
+ <scm>
+ <connection>
+ scm:svn:https://svn.jboss.org/repos/jbpm/projects/jopr-integration
+ </connection>
+ <developerConnection>
+ scm:svn:https://svn.jboss.org/repos/jbpm/projects/jopr-integration
+ </developerConnection>
+ </scm>
- <properties>
- <scm.module.path>.</scm.module.path>
- </properties>
+ <properties>
+ <scm.module.path>.</scm.module.path>
+ </properties>
- <dependencies>
- <dependency>
- <groupId>org.jboss.on</groupId>
- <artifactId>rhq-jbossas-plugin</artifactId>
- <version>2.1.2.GA</version>
- <scope>provided</scope>
- </dependency>
-
- <!--enable copy the dependecies to the package, it does not need this dependency -->
- <dependency>
- <groupId>org.jbpm.jbpm3</groupId>
- <artifactId>jbpm-jpdl</artifactId>
- <version>3.2.5.GA</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.on</groupId>
+ <artifactId>jopr-jboss-as-5-plugin</artifactId>
+ <version>2.3.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-jmx-plugin</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-pvm</artifactId>
+ <version>4.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-jpdl</artifactId>
+ <version>4.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin
+ </artifactId>
+ <version>2.0</version>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.outputDirectory}/lib
+ </outputDirectory>
+ <includeScope>runtime</includeScope>
+ <excludeGroupIds>
+ </excludeGroupIds>
+ <excludeArtifactIds>
+
+ </excludeArtifactIds>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin
+ </artifactId>
+ <version>2.3</version>
+ <executions>
+ <execution>
+ <id>copy-resources2</id>
+ <phase>test</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.outputDirectory}/lib
+ </outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources/META-INF
+ </directory>
+ <includes>
+ <include>jbpm.*.xml</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <profiles>
+ <profile>
+ <id>integration-tests</id>
+ <activation>
+ <property>
+ <name>maven.test.skip</name>
+ <value>!true</value>
+ </property>
+ </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.0</version>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>process-resources</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
- <includeScope>runtime</includeScope>
- <excludeGroupIds>org.apache.jackrabbit</excludeGroupIds>
- <excludeArtifactIds>xml-apis,xercesImpl,tm-extractors,poi,pdfbox,nekohtml,lucene-core,junit,jta,i18nlog,hibernate,derby,ehcache</excludeArtifactIds>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <profiles>
- <profile>
- <id>integration-tests</id>
- <activation>
- <property>
- <name>maven.test.skip</name>
- <value>!true</value>
- </property>
- </activation>
+ <build>
+ <plugins>
- <build>
- <plugins>
- <!-- Integration testing voodoo to load and test this plugin with its plugin dependencies -->
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>pre-integration-test</phase>
- <configuration>
- <tasks>
- <echo>Setting up plugin dependencies for ${project.artifactId}-${project.version}.jar...</echo>
- <property name="settings.localRepository" location="${user.home}/.m2/repository" />
- <mkdir dir="target/itest" />
- <mkdir dir="target/itest/plugins" />
- <mkdir dir="target/itest/lib" />
- <copy toDir="target/itest/plugins" flatten="true">
- <fileset dir="${settings.localRepository}/">
- <include name="org/rhq/rhq-platform-plugin/${rhq.version}/rhq-platform-plugin-${rhq.version}.jar" />
- <include name="org/rhq/rhq-jmx-plugin/${rhq.version}/rhq-jmx-plugin-${rhq.version}.jar" />
- <include name="org/jboss/on/rhq-tomcat-plugin/${project.version}/rhq-tomcat-plugin-${project.version}.jar" />
- <include name="org/jboss/on/rhq-jbossas-plugin/${project.version}/rhq-jbossas-plugin-${project.version}.jar" />
- </fileset>
- <fileset dir="${project.build.directory}">
- <include name="${project.artifactId}-${project.version}.jar" />
- </fileset>
- </copy>
- <unzip dest="target/itest/lib">
- <fileset dir="${settings.localRepository}/org/hyperic/sigar-dist/${sigar.version}" includes="*.zip" />
- <patternset>
- <include name="**/lib/sigar.jar" />
- <include name="**/lib/bcel*.jar" />
- <include name="**/lib/*.so" />
- <include name="**/lib/*.sl" />
- <include name="**/lib/*.dll" />
- <include name="**/lib/*.dylib" />
- </patternset>
- </unzip>
- <move todir="target/itest/lib" flatten="true">
- <fileset dir="target/itest/lib">
- <include name="**/lib/*" />
- </fileset>
- </move>
- <delete dir="target/itest/lib/hyperic-sigar-${sigar.version}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
+ <!--
+ Integration testing voodoo to load and test this plugin with its
+ plugin dependencies
+ -->
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>pre-integration-test</phase>
+ <configuration>
+ <tasks>
+ <echo>Setting up plugin dependencies for
+ ${project.artifactId}-${project.version}.jar...</echo>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository" />
+ <mkdir dir="target/itest" />
+ <mkdir dir="target/itest/plugins" />
+ <mkdir dir="target/itest/lib" />
+ <copy toDir="target/itest/plugins" flatten="true">
+ <fileset dir="${settings.localRepository}/">
+ <include
+ name="org/rhq/rhq-platform-plugin/${rhq.version}/rhq-platform-plugin-${rhq.version}.jar" />
+ <include
+ name="org/rhq/rhq-jmx-plugin/${rhq.version}/rhq-jmx-plugin-${rhq.version}.jar" />
+ <include
+ name="org/jboss/on/jopr-tomcat-plugin/${project.version}/jopr-tomcat-plugin-${project.version}.jar" />
+ <include
+ name="org/jboss/on/jopr-jboss-as-plugin/${project.version}/jopr-jboss-as-plugin-${project.version}.jar" />
+ </fileset>
+ <fileset dir="${project.build.directory}">
+ <include name="${project.artifactId}-${project.version}.jar" />
+ </fileset>
+ </copy>
+ <unzip dest="target/itest/lib">
+ <fileset
+ dir="${settings.localRepository}/org/hyperic/sigar-dist/${sigar.version}"
+ includes="*.zip" />
+ <patternset>
+ <include name="**/lib/sigar.jar" />
+ <include name="**/lib/bcel*.jar" />
+ <include name="**/lib/*.so" />
+ <include name="**/lib/*.sl" />
+ <include name="**/lib/*.dll" />
+ <include name="**/lib/*.dylib" />
+ </patternset>
+ </unzip>
+ <move todir="target/itest/lib" flatten="true">
+ <fileset dir="target/itest/lib">
+ <include name="**/lib/*" />
+ </fileset>
+ </move>
+ <delete dir="target/itest/lib/hyperic-sigar-${sigar.version}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- <executions>
- <execution>
- <id>surefire-it</id>
- <phase>integration-test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <skip>${maven.test.skip}</skip>
- <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
- <useSystemClassLoader>false</useSystemClassLoader>
- <argLine>-Dorg.hyperic.sigar.path=${basedir}/target/itest/lib</argLine>
- <!--<argLine>-Dorg.hyperic.sigar.path=${basedir}/target/itest/lib -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>-->
- <systemProperties>
- <property>
- <name>project.artifactId</name>
- <value>${project.artifactId}</value>
- </property>
- <property>
- <name>project.version</name>
- <value>${project.version}</value>
- </property>
- </systemProperties>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin
+ </artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <excludedGroups>${rhq.testng.excludedGroups}
+ </excludedGroups>
+ <useSystemClassLoader>false</useSystemClassLoader>
+ <argLine>-Dorg.hyperic.sigar.path=${basedir}/target/itest/lib
+ </argLine>
+ <!--
+ <argLine>-Dorg.hyperic.sigar.path=${basedir}/target/itest/lib
+ -Xdebug -Xnoagent -Djava.compiler=NONE
+ -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>
+ -->
+ <systemProperties>
+ <property>
+ <name>project.artifactId</name>
+ <value>${project.artifactId}</value>
+ </property>
+ <property>
+ <name>project.version</name>
+ <value>${project.version}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
- </plugins>
- </build>
- </profile>
+ </plugins>
+ </build>
+ </profile>
- <profile>
- <id>dev</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <properties>
- <rhq.rootDir>../../..</rhq.rootDir>
- <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins</rhq.deploymentDir>
- </properties>
+ <profile>
+ <id>dev</id>
- <build>
- <plugins>
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}
+ </rhq.containerDir>
+ <rhq.deploymentDir>
+ ${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins
+ </rhq.deploymentDir>
+ </properties>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
- <executions>
+ <build>
+ <plugins>
- <execution>
- <id>deploy</id>
- <phase>compile</phase>
- <configuration>
- <tasks>
- <mkdir dir="${rhq.deploymentDir}" />
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating ${deployment.file}...</echo>
- <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
- <execution>
- <id>undeploy</id>
- <phase>clean</phase>
- <configuration>
- <tasks>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Deleting ${deployment.file}...</echo>
- <delete file="${deployment.file}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file"
+ location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
- </executions>
- </plugin>
+ <execution>
+ <id>deploy-jar-meta-inf</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file"
+ location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating META-INF dir in ${deployment.file}...
+ </echo>
+ <unjar
+ src="${project.build.directory}/${project.build.finalName}.jar"
+ dest="${project.build.outputDirectory}">
+ <patternset>
+ <include name="META-INF/**" />
+ </patternset>
+ </unjar>
+ <jar destfile="${deployment.file}"
+ manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
+ update="true">
+ </jar>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
- </plugins>
- </build>
- </profile>
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file"
+ location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
- </profiles>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+
</project>
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ExceptionJobDiscoveryComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ExceptionJobDiscoveryComponent.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ExceptionJobDiscoveryComponent.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.api.job.Job;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbpm4.connector.JBPMEngineConnection;
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public class ExceptionJobDiscoveryComponent implements ResourceDiscoveryComponent<ProcessEngineComponent> {
+ private final Log log = LogFactory.getLog(this.getClass());
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ProcessEngineComponent> context) {
+ Set<DiscoveredResourceDetails> jbpmDefs = new java.util.HashSet<DiscoveredResourceDetails>();
+ JBPMEngineConnection jbpmConnection = context.getParentResourceComponent().getJBPMConnection();
+ List<Job> jobs = jbpmConnection.queryJob(false, false, true, null);
+ log.debug("Discovering " + jobs.size() + " exceptional jobs....");
+ for (Job job : jobs) {
+ DiscoveredResourceDetails details = new DiscoveredResourceDetails(context.getResourceType(), String.valueOf(job.getId()), job.getId(), null, job.getId(), null, null);
+ jbpmDefs.add(details);
+ }
+ return jbpmDefs;
+ }
+}
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/InstanceJobDiscoveryComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/InstanceJobDiscoveryComponent.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/InstanceJobDiscoveryComponent.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.api.job.Job;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbpm4.connector.JBPMEngineConnection;
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public class InstanceJobDiscoveryComponent implements ResourceDiscoveryComponent<ProcessInstanceComponent> {
+ private final Log log = LogFactory.getLog(this.getClass());
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ProcessInstanceComponent> context) {
+ Set<DiscoveredResourceDetails> jbpmDefs = new java.util.HashSet<DiscoveredResourceDetails>();
+ ProcessInstanceComponent jbpmInstance = context.getParentResourceComponent();
+ JBPMEngineConnection jbpmConnection = jbpmInstance.getJBPMConnection();
+ List<Job> jobs = jbpmConnection.queryJob(false, true, false, context.getParentResourceContext().getResourceKey());
+ log.debug("Discovering " + jobs.size() + " instance jobs....");
+ for (Job job : jobs) {
+ DiscoveredResourceDetails details = new DiscoveredResourceDetails(context.getResourceType(), String.valueOf(job.getId()), job.getId(), null, job.getId(), null, null);
+ jbpmDefs.add(details);
+ }
+ return jbpmDefs;
+ }
+
+}
\ No newline at end of file
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/JobComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/JobComponent.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/JobComponent.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4;
+
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.api.job.Job;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.plugins.jbpm4.connector.JBPMEngineConnection;
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public class JobComponent implements ResourceComponent , MeasurementFacet {
+ private ResourceContext resourceContext;
+ private Log log = LogFactory.getLog(this.getClass());
+ private Job job = null;
+ private JBPMEngineConnection jbpmConnection = null;
+ public void start(ResourceContext resourceContext) {
+ this.resourceContext = resourceContext;
+ if (resourceContext.getParentResourceComponent() instanceof ProcessEngineComponent) {
+ jbpmConnection = ((ProcessEngineComponent)resourceContext.getParentResourceComponent()).getJBPMConnection();
+ }
+
+ if (resourceContext.getParentResourceComponent() instanceof ProcessInstanceComponent) {
+ jbpmConnection = ((ProcessInstanceComponent)resourceContext.getParentResourceComponent()).getJBPMConnection();
+ }
+
+ job = jbpmConnection.getJob(resourceContext.getResourceKey());
+ }
+
+ public void stop() {
+ }
+
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) {
+ for (MeasurementScheduleRequest request : metrics) {
+
+ if (request.getName().equals("id")) {
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(job.getId()));
+ report.addData(value);
+ }
+
+ if (request.getName().equals("duedate")) {
+ MeasurementDataTrait value = new MeasurementDataTrait(request,String.valueOf(job.getDueDate() == null ? "--" : job.getDueDate()));
+ report.addData(value);
+ }
+
+ if (request.getName().equals("lockExpirationTime")) {
+ MeasurementDataTrait value = new MeasurementDataTrait(request,String.valueOf(job.getLockExpirationTime() == null ? "--" : job.getLockExpirationTime()));
+ report.addData(value);
+ }
+ if (request.getName().equals("lockOwner")) {
+ MeasurementDataTrait value = new MeasurementDataTrait(request,String.valueOf(job.getLockOwner() == null ? "--" : job.getLockOwner()));
+ report.addData(value);
+ }
+ if (request.getName().equals("isExclusive")) {
+ MeasurementDataTrait value = new MeasurementDataTrait(request,String.valueOf(job.isExclusive()));
+ report.addData(value);
+ }
+
+ if (request.getName().equals("exception")) {
+ MeasurementDataTrait value = new MeasurementDataTrait(request, job.getException() == null ? "" : job.getException());
+ report.addData(value);
+ }
+
+ }
+
+ }
+
+
+ public AvailabilityType getAvailability() {
+ if (job.getException() == null) {
+ return AvailabilityType.UP;
+ }
+ return AvailabilityType.DOWN;
+ }
+
+
+
+}
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/MessageDiscoveryComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/MessageDiscoveryComponent.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/MessageDiscoveryComponent.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.api.job.Job;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbpm4.connector.JBPMEngineConnection;
+
+public class MessageDiscoveryComponent implements ResourceDiscoveryComponent<ProcessEngineComponent> {
+ private final Log log = LogFactory.getLog(this.getClass());
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ProcessEngineComponent> context) {
+ Set<DiscoveredResourceDetails> jbpmDefs = new java.util.HashSet<DiscoveredResourceDetails>();
+ JBPMEngineConnection jbpmConnection = context.getParentResourceComponent().getJBPMConnection();
+ List<Job> jobs = jbpmConnection.queryJob(false, true, false, null);
+ log.debug("Discovering " + jobs.size() + " messeage jobs....");
+ for (Job job : jobs) {
+ DiscoveredResourceDetails details = new DiscoveredResourceDetails(context.getResourceType(), String.valueOf(job.getId()), job.getId(), null, job.getId(), null, null);
+ jbpmDefs.add(details);
+ }
+ return jbpmDefs;
+ }
+}
+
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDefComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDefComponent.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDefComponent.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4;
+
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.plugins.jbpm4.connector.JBPMEngineConnection;
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public class ProcessDefComponent implements ResourceComponent<ProcessEngineComponent> , MeasurementFacet, CreateChildResourceFacet {
+ private ResourceContext<ProcessEngineComponent> resourceContext;
+ private Log log = LogFactory.getLog(this.getClass());
+ ProcessDefinition processDef = null;
+ private JBPMEngineConnection jbpmConnection = null;
+ public void start(ResourceContext<ProcessEngineComponent> resourceContext) {
+ this.resourceContext = resourceContext;
+ jbpmConnection = resourceContext.getParentResourceComponent().getJBPMConnection();
+ processDef = jbpmConnection.getProcessDefById(resourceContext.getResourceKey());
+ }
+
+ public void stop() {
+ }
+
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) {
+ for (MeasurementScheduleRequest request : metrics) {
+ if (request.getName().equals("version")) {
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(processDef.getVersion()));
+ report.addData(value);
+ }
+ if (request.getName().equals("id")) {
+
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(processDef.getId()));
+ report.addData(value);
+ }
+
+ if (request.getName().equals("description")) {
+ MeasurementDataTrait value = new MeasurementDataTrait(request,processDef.getDescription());
+ report.addData(value);
+ }
+
+ }
+
+ }
+
+
+ public AvailabilityType getAvailability() {
+ ProcessDefinition processDef = jbpmConnection.getProcessDefById(resourceContext.getResourceKey());
+ if (processDef != null) {
+ return AvailabilityType.UP;
+ }
+ return AvailabilityType.DOWN;
+ }
+
+ public JBPMEngineConnection getJBPMConnection() {
+ return resourceContext.getParentResourceComponent().getJBPMConnection();
+ }
+
+ //---------------CreateChildResourceFacet implementation -----------------//
+ public CreateResourceReport createResource(CreateResourceReport report) {
+ String resourceTypeName = report.getResourceType().getName();
+ report.setResourceKey(resourceTypeName);
+ report.setResourceName(resourceTypeName);
+ ProcessInstance instance = jbpmConnection.startProcessInstance(this.resourceContext.getResourceKey());
+ if (instance == null) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage("Failed to start process instance");
+ } else {
+ report.setStatus(CreateResourceStatus.SUCCESS);
+ }
+ return report;
+ }
+
+
+
+}
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDefDiscoveryComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDefDiscoveryComponent.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDefDiscoveryComponent.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4;
+
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.api.ProcessDefinition;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbpm4.connector.JBPMEngineConnection;
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public class ProcessDefDiscoveryComponent implements ResourceDiscoveryComponent<ProcessEngineComponent> {
+ private final Log log = LogFactory.getLog(this.getClass());
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ProcessEngineComponent> context) {
+ Set<DiscoveredResourceDetails> jbpmDefs = new java.util.HashSet<DiscoveredResourceDetails>();
+ JBPMEngineConnection jbpmConnection = context.getParentResourceComponent().getJBPMConnection();
+ List<ProcessDefinition> defList = (List<ProcessDefinition>)jbpmConnection.getProcessDefs();
+ log.debug("Discovering " + defList.size() + " process definition....");
+ for (ProcessDefinition def : defList) {
+ DiscoveredResourceDetails details = new DiscoveredResourceDetails(context.getResourceType(), String.valueOf(def.getId()), def.getId(), String.valueOf(def.getVersion()), def.getId(), null, null);
+ jbpmDefs.add(details);
+ }
+ return jbpmDefs;
+ }
+}
\ No newline at end of file
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDeploymentComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDeploymentComponent.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDeploymentComponent.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4;
+
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.api.Deployment;
+import org.rhq.core.domain.content.PackageDetailsKey;
+import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.transfer.ContentResponseResult;
+import org.rhq.core.domain.content.transfer.DeployPackageStep;
+import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
+import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.content.ContentFacet;
+import org.rhq.core.pluginapi.content.ContentServices;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.plugins.jbpm4.connector.JBPMEngineConnection;
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public class ProcessDeploymentComponent implements ResourceComponent<ProcessEngineComponent> , MeasurementFacet, ContentFacet{
+ private ResourceContext<ProcessEngineComponent> resourceContext;
+ private Log log = LogFactory.getLog(this.getClass());
+ private Deployment deployment = null;
+ private JBPMEngineConnection jbpmConnection = null;
+ public void start(ResourceContext<ProcessEngineComponent> resourceContext) {
+ this.resourceContext = resourceContext;
+ jbpmConnection = resourceContext.getParentResourceComponent().getJBPMConnection();
+ deployment = jbpmConnection.getDeployment(resourceContext.getResourceKey());
+ }
+
+ public void stop() {
+ }
+
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) {
+ for (MeasurementScheduleRequest request : metrics) {
+
+ if (request.getName().equals("id")) {
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(deployment.getId()));
+ report.addData(value);
+ }
+ if (request.getName().equals("name")) {
+
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(deployment.getName()));
+ report.addData(value);
+ }
+
+ if (request.getName().equals("timestamp")) {
+ MeasurementDataTrait value = new MeasurementDataTrait(request,String.valueOf(deployment.getTimestamp()));
+ report.addData(value);
+ }
+
+ if (request.getName().equals("state")) {
+ MeasurementDataTrait value = new MeasurementDataTrait(request,String.valueOf(deployment.getState()));
+ report.addData(value);
+ }
+
+ }
+
+ }
+
+ public AvailabilityType getAvailability() {
+ Deployment deployment = jbpmConnection.getDeployment(resourceContext.getResourceKey());
+ if (deployment != null) {
+ return AvailabilityType.UP;
+ }
+ return AvailabilityType.DOWN;
+ }
+
+
+ // ------------ ContentFacet implementation -------------
+
+ public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
+ return null;
+ }
+
+ public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType packageType) {
+
+ String fileName = deployment.getName();
+ PackageDetailsKey key = new PackageDetailsKey(fileName, "1.0", "Process Deployments", "noarch");
+ ResourcePackageDetails packageDetails = new ResourcePackageDetails(key);
+ packageDetails.setFileName(fileName);
+ packageDetails.setLocation(fileName);
+ packageDetails.setFileCreatedDate(null); // TODO: get created date via SIGAR
+ Set<ResourcePackageDetails> packages = new HashSet<ResourcePackageDetails>();
+ packages.add(packageDetails);
+
+ return packages;
+ }
+
+
+
+ public RemovePackagesResponse removePackages(Set<ResourcePackageDetails> packages) {
+ throw new UnsupportedOperationException("Cannot remove the package backing an EAR/WAR resource.");
+ }
+
+ public List<DeployPackageStep> generateInstallationSteps(ResourcePackageDetails packageDetails) {
+ // Intentional - there are no steps involved in installing an EAR or WAR.
+ return null;
+ }
+
+ public DeployPackagesResponse deployPackages(Set<ResourcePackageDetails> packages, ContentServices contentServices) {
+ //TODO: enable deploy it
+ DeployPackagesResponse response = new DeployPackagesResponse(ContentResponseResult.FAILURE);
+ response .setOverallRequestErrorMessage("Unsupported jbpm deployment update");
+ return response;
+ }
+
+
+
+
+
+}
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDeploymentDiscoveryComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDeploymentDiscoveryComponent.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessDeploymentDiscoveryComponent.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.api.Deployment;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbpm4.connector.JBPMEngineConnection;
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public class ProcessDeploymentDiscoveryComponent implements ResourceDiscoveryComponent<ProcessEngineComponent> {
+ private final Log log = LogFactory.getLog(this.getClass());
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ProcessEngineComponent> context) {
+ Set<DiscoveredResourceDetails> jbpmDefs = new java.util.HashSet<DiscoveredResourceDetails>();
+ JBPMEngineConnection jbpmConnection = context.getParentResourceComponent().getJBPMConnection();
+ List<Deployment> deploymentList = (List<Deployment>)jbpmConnection.getDeployments();
+ log.debug("Discovering " + deploymentList.size() + " jbpm development ....");
+ for (Deployment deployment : deploymentList) {
+ DiscoveredResourceDetails details = new DiscoveredResourceDetails(context.getResourceType(), String.valueOf(deployment.getId()), deployment.getName(), String.valueOf(deployment.getTimestamp()), deployment.getName(), null, null);
+ jbpmDefs.add(details);
+ }
+ return jbpmDefs;
+ }
+}
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineComponent.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineComponent.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,176 @@
+package org.rhq.plugins.jbpm4;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.util.Set;
+
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.content.PackageDetailsKey;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.pluginapi.content.ContentContext;
+import org.rhq.core.pluginapi.content.ContentServices;
+import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
+import org.rhq.plugins.jbpm4.connector.JBPMEngineConnection;
+import org.rhq.plugins.jbpm4.connector.JBPMEngineConnector;
+import org.rhq.plugins.jbpm4.connector.LocalJBPMEngineConnector;
+import org.rhq.plugins.jbpm4.connector.RemoteJBPMEngineConnector;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+
+public class ProcessEngineComponent extends MBeanResourceComponent implements CreateChildResourceFacet{
+ private static final String NAMING_URL = "namingURL";
+ private static final String PRINCIPAL = "principal";
+ private static final String CREDENTIALS = "credentials";
+ private static final String RESOURCE_TYPE_JBPM_DEVELOPMENT ="Process Developments";
+
+ private ContentContext contentContext = null;
+ private ResourceContext resourceContext = null;
+ private JBPMEngineConnection jbpmConnection = null;
+ private JBPMEngineConnector processEngineConnector = null;
+ public void start(ResourceContext context) {
+ super.start(context);
+ resourceContext = context;
+ if (runningEmbedded()) {
+ processEngineConnector = new LocalJBPMEngineConnector();
+ }else {
+ Configuration pluginConfiguration = getAS5ServerPluginConfiguration();
+ String namingURL = pluginConfiguration.getSimpleValue(NAMING_URL, null);
+ //validateNamingURL(namingURL);
+ String principal = pluginConfiguration.getSimpleValue(PRINCIPAL, null);
+ String credentials = pluginConfiguration.getSimpleValue(CREDENTIALS,null);
+ processEngineConnector = new RemoteJBPMEngineConnector(namingURL, principal, credentials);
+ }
+ jbpmConnection = processEngineConnector.connect();
+ }
+
+ @Override
+ public AvailabilityType getAvailability() {
+ AvailabilityType av = super.getAvailability();
+ return av;
+ }
+
+ /* implement the DeleteResourceFacet */
+ public void deleteResource() throws Exception {
+ //TODO: implement it
+ }
+
+ public void getValues(MeasurementReport report, Set requests) {
+ super.getValues(report, requests);
+ Set<MeasurementScheduleRequest> metricRequests = (Set<MeasurementScheduleRequest>)requests;
+ for (MeasurementScheduleRequest request : metricRequests) {
+ if (request.getName().equals("deployedProcessNumber")) {
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(this.jbpmConnection.getProcessDefs().size()));
+ report.addData(value);
+ }
+ if (request.getName().equals("processInstancNumber")) {
+
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(this.jbpmConnection.getAllProcessInstance().size()));
+ report.addData(value);
+ }
+
+ if (request.getName().equals("jobsNumber")) {
+
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(this.jbpmConnection.queryJob(false, false, false, null).size()));
+ report.addData(value);
+ }
+
+ if (request.getName().equals("exceptionalJobsNumber")) {
+
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(this.jbpmConnection.queryJob(false, false, true, null).size()));
+ report.addData(value);
+ }
+ }
+
+ }
+
+
+ public CreateResourceReport createResource(CreateResourceReport report) {
+ String resourceTypeName = report.getResourceType().getName();
+ try {
+ if (resourceTypeName.equals(RESOURCE_TYPE_JBPM_DEVELOPMENT)) {
+ jbpmProcessCreate(report);
+ } else {
+ throw new UnsupportedOperationException("Unknown Resource type: " + resourceTypeName);
+ }
+ } catch (Exception e) {
+ report.setErrorMessage(e.getMessage());
+ report.setException(e);
+ }
+ return report;
+ }
+
+ public void jbpmProcessCreate(CreateResourceReport report) {
+ ResourcePackageDetails details = report.getPackageDetails();
+ PackageDetailsKey key = details.getKey();
+ String resourceTypeName = report.getResourceType().getName();
+ String archiveName = key.getName();
+
+ report.setResourceName(archiveName);
+ report.setResourceKey(archiveName);
+
+ int lastPeriod = archiveName.lastIndexOf(".");
+ String extension = archiveName.substring(lastPeriod + 1);
+
+ if (!archiveName.endsWith("xml") && !archiveName.endsWith("ar") && lastPeriod > -1) {
+ report.setErrorMessage("unsupported extension: "+ archiveName +" Only .xml files and .*ar archives are supported");
+ report.setStatus(CreateResourceStatus.FAILURE);
+ return;
+ }
+
+
+ File tempDir = resourceContext.getTemporaryDirectory();
+ File archiveFile = new File(archiveName);
+ String filename = archiveFile.getName();
+ File tempFile = new File(tempDir.getAbsolutePath(), filename);
+ try {
+ OutputStream osForTempDir = new BufferedOutputStream(
+ new FileOutputStream(tempFile));
+
+ ContentContext contentContext = resourceContext.getContentContext();
+ ContentServices contentServices = contentContext.getContentServices();
+ contentServices.downloadPackageBitsForChildResource(contentContext,
+ resourceTypeName, key, osForTempDir);
+
+ osForTempDir.close();
+ this.jbpmConnection.deployProcess(tempFile);
+ report.setStatus(CreateResourceStatus.SUCCESS);
+ } catch (Exception e) {
+ report.setErrorMessage("Failed to deploy [" + archiveName + "]");
+ report.setException(e);
+ report.setStatus(CreateResourceStatus.FAILURE);
+ }
+ }
+
+
+ public JBPMEngineConnection getJBPMConnection() {
+ return this.jbpmConnection;
+ }
+
+ public boolean runningEmbedded() {
+ Configuration pluginConfiguration = this.getAS5ServerPluginConfiguration();
+ String namingUrl = pluginConfiguration.getSimpleValue(NAMING_URL, null);
+ return namingUrl == null;
+ }
+
+ private Configuration getAS5ServerPluginConfiguration() {
+ ApplicationServerComponent as5Server = (ApplicationServerComponent)resourceContext.getParentResourceComponent();
+ Configuration pluginConfiguration = as5Server.getResourceContext().getPluginConfiguration();
+ return pluginConfiguration;
+ }
+
+
+}
\ No newline at end of file
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineDiscoveryComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineDiscoveryComponent.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineDiscoveryComponent.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.ClassLoaderFacet;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
+import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
+
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public class ProcessEngineDiscoveryComponent extends MBeanResourceDiscoveryComponent implements ClassLoaderFacet {
+ private static final String SERVER_HOME_DIR = "serverHomeDir";
+ private static final String HOME_DIR="homeDir";
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext)
+ {
+ Set<DiscoveredResourceDetails> resources = new HashSet<DiscoveredResourceDetails>();
+ resources = super.discoverResources(discoveryContext);
+ log.trace("Discovered " + resources.size() + " " + discoveryContext.getResourceType() + " Resources.");
+ return resources;
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public List<URL> getAdditionalClasspathUrls(ResourceDiscoveryContext context, DiscoveredResourceDetails details) throws Exception {
+ Configuration pluginConfig = context.getParentResourceContext().getPluginConfiguration();
+ String serverHome = pluginConfig.getSimple(SERVER_HOME_DIR).getStringValue();
+
+ List<URL> clientJars = new ArrayList<URL>();
+ //TODO:Review it and removed the jars not needed
+ String[] jarFileNames = { "lib/jbpm.jar",
+ "deploy/jbpm/jbpm-service.sar/freemarker.jar",
+ "deploy/jbpm/jbpm-service.sar/jbpm-spi.jar",
+ "deploy/jbpm/jbpm-service.sar/juel.jar",
+ "deploy/jbpm/jbpm-service.sar/juel-engine.jar",
+ "deploy/jbpm/jbpm-service.sar/juel-impl.jar",
+ "deploy/jbpm/jbpm-service.sar/livetribe-jsr223.jar",
+ };
+ for (String jarFileName : jarFileNames) {
+ File clientJar = new File(serverHome, jarFileName);
+ if (!clientJar.exists()) {
+ throw new FileNotFoundException("Cannot find [" + clientJar + "]");
+ }
+ if (!clientJar.canRead()) {
+ throw new IOException("Cannot read [" + clientJar + "]");
+ }
+ clientJars.add(clientJar.toURI().toURL());
+ }
+
+
+ //This is for remote JNDI connection
+ //TODO: review it to see what can be removed
+ String homeDir = pluginConfig.getSimple(HOME_DIR).getStringValue();
+
+ String[] jbossJarFiles = { "client/jbossall-client.jar",
+ "common/lib/jboss-security-aspects.jar",
+ "lib/jboss-managed.jar",
+ "lib/jboss-metatype.jar",
+ "lib/jboss-dependency.jar",
+ "lib/jboss-kernel.jar"
+ };
+ for (String jarFileName : jbossJarFiles) {
+ File clientJar = new File(homeDir, jarFileName);
+ if (!clientJar.exists()) {
+ throw new FileNotFoundException("Cannot find [" + clientJar + "]");
+ }
+ if (!clientJar.canRead()) {
+ throw new IOException("Cannot read [" + clientJar + "]");
+ }
+ clientJars.add(clientJar.toURI().toURL());
+ }
+
+
+
+ return clientJars;
+ }
+
+}
\ No newline at end of file
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessInstanceComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessInstanceComponent.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessInstanceComponent.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4;
+
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.plugins.jbpm4.connector.JBPMEngineConnection;
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public class ProcessInstanceComponent implements ResourceComponent<ProcessDefComponent>, MeasurementFacet, DeleteResourceFacet {
+ private Log log = LogFactory.getLog(this.getClass());
+ private JBPMEngineConnection jbpmConnection = null;
+ private ProcessInstance instance = null;
+ private String instanceId;
+ public void start(ResourceContext<ProcessDefComponent> resourceContext) {
+ instanceId = resourceContext.getResourceKey();
+ jbpmConnection = resourceContext.getParentResourceComponent().getJBPMConnection();
+ instance = jbpmConnection.getProcessInstance(instanceId);
+
+ }
+
+ public void stop() {
+ }
+
+ public AvailabilityType getAvailability() {
+ if (instance.getState().equals(Execution.STATE_ENDED)) {
+ return AvailabilityType.DOWN;
+ }
+ return AvailabilityType.UP;
+ }
+
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) {
+ for (MeasurementScheduleRequest request : metrics) {
+ if (request.getName().equals("id")) {
+
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(instance.getId()));
+ report.addData(value);
+ }
+
+ if (request.getName().equals("key")) {
+
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(instance.getKey() == null ? "--" : instance.getKey()));
+ report.addData(value);
+ }
+
+ if (request.getName().equals("name")) {
+
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(instance.getName() == null ? "--" : instance.getName()));
+ report.addData(value);
+ }
+
+ if (request.getName().equals("priority")) {
+
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(instance.getPriority()));
+ report.addData(value);
+ }
+
+ if (request.getName().equals("definitionId")) {
+
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(instance.getProcessDefinitionId()));
+ report.addData(value);
+ }
+
+
+ if (request.getName().equals("status")) {
+ MeasurementDataTrait value = new MeasurementDataTrait(request,
+ String.valueOf(instance.getState()));
+ report.addData(value);
+ }
+ }
+ }
+
+ public JBPMEngineConnection getJBPMConnection() {
+ return this.jbpmConnection;
+ }
+
+ /* implement the DeleteResourceFacet */
+ public void deleteResource() throws Exception {
+ this.jbpmConnection.deleteProcessInstance(instanceId);
+ }
+}
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessInstanceDiscoveryComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessInstanceDiscoveryComponent.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessInstanceDiscoveryComponent.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4;
+
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.api.ProcessInstance;
+
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public class ProcessInstanceDiscoveryComponent implements ResourceDiscoveryComponent<ProcessDefComponent> {
+ public Set<DiscoveredResourceDetails> discoverResources(
+ ResourceDiscoveryContext<ProcessDefComponent> context) {
+
+ Set<DiscoveredResourceDetails> jbpmDefs = new java.util.HashSet<DiscoveredResourceDetails>();
+ ProcessDefComponent defComponent = context.getParentResourceComponent();
+ List<ProcessInstance> instances = defComponent.getJBPMConnection().getProcessInstances(context.getParentResourceContext().getResourceKey());
+ for (ProcessInstance instance: instances) {
+ DiscoveredResourceDetails details = new DiscoveredResourceDetails(context.getResourceType(), String.valueOf(instance.getId()), instance.getId(), null, instance.getId(), null, null);
+ jbpmDefs.add(details);
+ }
+ return jbpmDefs;
+ }
+
+}
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/TimerDiscoveryComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/TimerDiscoveryComponent.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/TimerDiscoveryComponent.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.api.job.Job;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbpm4.connector.JBPMEngineConnection;
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public class TimerDiscoveryComponent implements ResourceDiscoveryComponent<ProcessEngineComponent> {
+ private final Log log = LogFactory.getLog(this.getClass());
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ProcessEngineComponent> context) {
+ Set<DiscoveredResourceDetails> jbpmDefs = new java.util.HashSet<DiscoveredResourceDetails>();
+ JBPMEngineConnection jbpmConnection = context.getParentResourceComponent().getJBPMConnection();
+ List<Job> jobs = jbpmConnection.queryJob(true, false, false, null);
+ log.debug("Discovering " + jobs.size() + " messeage jobs....");
+ for (Job job : jobs) {
+ DiscoveredResourceDetails details = new DiscoveredResourceDetails(context.getResourceType(), String.valueOf(job.getId()), job.getId(), null, job.getId(), null, null);
+ jbpmDefs.add(details);
+ }
+ return jbpmDefs;
+ }
+}
\ No newline at end of file
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/JBPMEngineConnection.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/JBPMEngineConnection.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/JBPMEngineConnection.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4.connector;
+
+import java.io.File;
+import java.util.List;
+
+import org.jbpm.api.Deployment;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public interface JBPMEngineConnection {
+ List<ProcessDefinition> getProcessDefs();
+ ProcessDefinition getProcessDefById(String id);
+ String deployProcess(File processFile) throws Exception;
+ List<ProcessInstance> getAllProcessInstance();
+ List<ProcessInstance> getProcessInstances(String defId);
+ ProcessInstance getProcessInstance(String instanceId);
+ void deleteProcessInstance(String instanceId);
+ ProcessInstance startProcessInstance(String defId);
+ List<Deployment> getDeployments();
+ Deployment getDeployment(String deploymentId);
+ public List<Job> queryJob(boolean timerOnly , boolean messageOnly, boolean exception, String processInstanceId);
+ Job getJob(String jobId);
+}
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/JBPMEngineConnector.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/JBPMEngineConnector.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/JBPMEngineConnector.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4.connector;
+
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public interface JBPMEngineConnector {
+ JBPMEngineConnection connect();
+ boolean isConnected();
+ void disconnect();
+}
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/LocalJBPMEngineConnector.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/LocalJBPMEngineConnector.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/LocalJBPMEngineConnector.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,166 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4.connector;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.net.URL;
+import java.util.List;
+import java.util.zip.ZipInputStream;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.api.Deployment;
+import org.jbpm.api.JobQuery;
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessEngine;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public class LocalJBPMEngineConnector implements JBPMEngineConnector, JBPMEngineConnection {
+ private final Log log = LogFactory.getLog(this.getClass());
+ private final String PROCESSENGINE__JNDI_NAME = "java:/ProcessEngine";
+ private InitialContext initialContext = null;
+ private ProcessEngine processEngine = null;
+ public JBPMEngineConnection connect() {
+ log.debug("Connecting to local ProcessEngine...");
+ try {
+ initialContext = new InitialContext(null);
+ processEngine = (ProcessEngine)initialContext.lookup(this.PROCESSENGINE__JNDI_NAME);
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to create JNDI InitialContext.", e);
+ }
+ return this;
+ }
+
+ public void disconnect(){
+
+ }
+
+ public List<ProcessDefinition> getProcessDefs() {
+ List<ProcessDefinition> defs = processEngine.getRepositoryService().createProcessDefinitionQuery().list();
+ return defs;
+ }
+
+ public ProcessDefinition getProcessDefById(String id) {
+ return processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionId(id).uniqueResult();
+ }
+
+ public List<ProcessInstance> getAllProcessInstance() {
+ return processEngine.getExecutionService().createProcessInstanceQuery().list();
+ }
+
+ public List<Deployment> getDeployments() {
+ return processEngine.getRepositoryService().createDeploymentQuery().list();
+ }
+
+ public Deployment getDeployment(String deploymentId) {
+
+ return processEngine.getRepositoryService().createDeploymentQuery().deploymentDbid(Long.valueOf(deploymentId)).uniqueResult();
+
+ }
+
+ public List<Job> queryJob(boolean timerOnly , boolean messageOnly, boolean exception, String processInstanceId) {
+ JobQuery jobQuery = processEngine.getManagementService().createJobQuery();
+ if (processInstanceId != null) {
+ jobQuery.processInstanceId(processInstanceId);
+ }
+
+ if (exception) {
+ jobQuery.exception(true);
+ }
+
+ if (timerOnly) {
+ jobQuery = jobQuery.timers();
+ } else if (messageOnly) {
+ jobQuery = jobQuery.messages();
+ }
+ return jobQuery.list();
+ }
+
+ public Job getJob(String jobId) {
+ //TODO: there is proper API to query the job by jobId.Ask Joram to add it...
+ List<Job> jobs = processEngine.getManagementService().createJobQuery().list();
+ for (Job job : jobs) {
+ if (job.getId().equals(jobId)) {
+ return job;
+ }
+ }
+ return null;
+ }
+
+
+
+
+ public String deployProcess(URL url) {
+ return processEngine.getRepositoryService().createDeployment().addResourceFromUrl(url).deploy();
+ }
+
+ public boolean isConnected() {
+ return processEngine == null;
+ }
+
+ public String deployProcess(File processFile) throws Exception {
+ NewDeployment deployment = this.processEngine.getRepositoryService().createDeployment();
+ deployment.setName(processFile.getName());
+ deployment.setTimestamp(System.currentTimeMillis());
+ if (processFile.getName().endsWith(".xml")) {
+ log.debug("deploying process file " + processFile.getName());
+ deployment.addResourceFromFile(processFile);
+
+ } else if (processFile.getName().endsWith("ar")) {
+ log.debug("deploying business archive " + processFile.getName());
+ FileInputStream fileInputStream;
+ try {
+ fileInputStream = new FileInputStream(processFile);
+ } catch (FileNotFoundException e) {
+ throw e;
+ }
+ ZipInputStream zipInputStream = new ZipInputStream(fileInputStream);
+ deployment.addResourcesFromZipInputStream(zipInputStream);
+ }
+ return deployment.deploy();
+ }
+
+ public List<ProcessInstance> getProcessInstances(String defId) {
+ return processEngine.getExecutionService().createProcessInstanceQuery().processDefinitionId(defId).list();
+ }
+ public ProcessInstance getProcessInstance(String instanceId) {
+ return processEngine.getExecutionService().createProcessInstanceQuery().processInstanceId(instanceId).uniqueResult();
+ }
+
+ public void deleteProcessInstance(String instanceId) {
+ processEngine.getExecutionService().deleteProcessInstance(instanceId);
+ }
+ public ProcessInstance startProcessInstance(String defId) {
+ return processEngine.getExecutionService().startProcessInstanceById(defId);
+ }
+
+}
Added: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/RemoteJBPMEngineConnector.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/RemoteJBPMEngineConnector.java (rev 0)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/RemoteJBPMEngineConnector.java 2009-08-14 10:04:17 UTC (rev 5480)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.rhq.plugins.jbpm4.connector;
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+/**
+ * @author ema(a)redhat.com
+ *
+ */
+public class RemoteJBPMEngineConnector implements JBPMEngineConnector {
+
+ private static final String NAMING_CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory";
+ private static final String JNP_TIMEOUT_JNP_INIT_PROP = "jnp.timeout";
+ private static final String JNP_SOTIMEOUT_JNP_INIT_PROP = "jnp.sotimeout";
+ private static final String JNP_DISABLE_DISCOVERY_JNP_INIT_PROP = "jnp.disableDiscovery";
+ private static final int JNP_TIMEOUT = 60 * 1000; // 60 seconds
+ private static final int JNP_SO_TIMEOUT = 60 * 1000; // 60 seconds
+ private static final boolean JNP_DISABLE_DISCOVERY = true;
+
+ //TODO: ProcessEngine can not be serialized. What is the instead ?
+ private final String XXX__JNDI_NAME = "ProcessEngine";
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ private String providerURL;
+ private String principal;
+ private String credentials;
+ private InitialContext initialContext;
+
+ public RemoteJBPMEngineConnector(String providerURL, String principal, String credentials) {
+ this.providerURL = providerURL;
+ this.principal = principal;
+ this.credentials = credentials;
+ }
+
+ public JBPMEngineConnection connect() {
+ Properties env = new Properties();
+ env.setProperty(Context.PROVIDER_URL, providerURL);
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY, NAMING_CONTEXT_FACTORY);
+ env.setProperty(JNP_TIMEOUT_JNP_INIT_PROP, String.valueOf(JNP_TIMEOUT));
+ env.setProperty(JNP_SOTIMEOUT_JNP_INIT_PROP, String.valueOf(JNP_SO_TIMEOUT));
+ env.setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP, String.valueOf(JNP_DISABLE_DISCOVERY));
+ env.setProperty(Context.SECURITY_CREDENTIALS, this.credentials);
+ env.setProperty(Context.SECURITY_PRINCIPAL, this.principal);
+ /*ProcessEngine processEngine = null;
+ log.debug("Connecting to ProcessEngine via remote JNDI using env [" + env + "]...");
+ try {
+ initialContext = new InitialContext(env);
+ processEngine = (ProcessEngine)initialContext.lookup(this.PROCESSENGINE__JNDI_NAME);
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to create JNDI InitialContext.", e);
+ }*/
+ return null;
+ }
+
+ public void disconnect() {
+
+ }
+
+ public boolean isConnected() {
+ return false;
+ }
+}
+
Modified: projects/jopr-integration/trunk/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- projects/jopr-integration/trunk/src/main/resources/META-INF/rhq-plugin.xml 2009-08-14 05:01:17 UTC (rev 5479)
+++ projects/jopr-integration/trunk/src/main/resources/META-INF/rhq-plugin.xml 2009-08-14 10:04:17 UTC (rev 5480)
@@ -1,122 +1,188 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<plugin name="JBPM-Plugin" displayName="JBPM-Plugin"
- package="org.jbosson.plugins.jbpm"
- description="Provides monitoring of JBoss JBPM" version="2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<plugin name="JBPM4-Plugin" displayName="JBPM4-Plugin"
+ package="org.rhq.plugins.jbpm4" description="Provides monitoring of JBoss JBPM"
+ version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin" xmlns:c="urn:xmlns:rhq-configuration">
<depends plugin="JMX" />
- <depends plugin="JBossAS" useClasses="true" />
- <service name="JBPM Service"
- discovery="org.jbosson.plugins.jbpm.JbpmServiceDiscoveryComponent"
- class="org.jbosson.plugins.jbpm.JbpmServiceComponent"
- description="JBPM Service" singleton="true">
+ <depends plugin="JBossAS5" useClasses="true" />
+ <service name="JBPM4 Engine"
+ discovery="ProcessEngineDiscoveryComponent"
+ class="ProcessEngineComponent"
+ description="JBPM4" singleton="true">
<runs-inside>
<parent-resource-type name="JBossAS Server"
- plugin="JBossAS" />
+ plugin="JBossAS5" />
</runs-inside>
+ <subcategories>
+ <subcategory name="Jobs"
+ description="The jbos without exception">
+ </subcategory>
+ </subcategories>
<plugin-configuration>
- <c:simple-property name="objectName" readOnly="true"
- default="jboss.esb:service=JbpmService" />
- <c:simple-property name="nameTemplate"
- default="JBPM Service" />
+ <c:simple-property name="objectName" readOnly="true" default="org.jbpm:service=ServerConfig" />
+ <c:simple-property name="nameTemplate" default="JBPM4 Engine"/>
<c:simple-property name="DescriptionTemplate"
- default="JBoss Service." />
- <!--c:simple-property name="additionalClassPathEntries" default="/x1/jbossON/jbpm-lib/*.jar"/-->
+ default="JBPM4 Engine"/>
</plugin-configuration>
- <operation name="start" displayName="Start JBPM Service"
- description="Start the JBPM Service" />
- <operation name="stop" displayName="Stop JBPM Service"
- description="Stop the JBPM Service" />
- <metric property="Name" displayName="Service Name"
- dataType="trait" displayType="summary" defaultOn="true"
- description="JBPM ServiceName" />
- <metric property="StateString" displayName="jbpm State String"
- dataType="trait" displayType="summary" defaultOn="true"
- description="Current state of JBPM Service" />
- <metric property="State" displayName="jbpm State"
- dataType="trait" displayType="summary" defaultOn="true"
- description="Numeric value of the state of the jbpm service" />
- <help>
- <![CDATA[
- JBoss JBPM Service
- ]]>
- </help>
+
+ <metric property="deployedProcessNumber" dataType="measurement" displayType="summary" defaultOn="true"
+ description="Deployed process number" />
+ <metric property="processInstancNumber" dataType="measurement" displayType="summary" defaultOn="true"
+ description="Process instances number includes started and suspended" />
- <service name="Process Definitions"
- discovery="org.jbosson.plugins.jbpm.JbpmProcessDefDiscoveryComponent"
- class="org.jbosson.plugins.jbpm.JbpmProcessDefComponent"
- creationDataType="content"
- createDeletePolicy="both"
- description="JBPM Process Definitions">
-
-
- <metric property="version" displayName="Version"
- dataType="trait" displayType="summary" defaultOn="true"
+ <metric property="jobsNumber" dataType="measurement" displayType="summary" defaultOn="true"
+ description="the number of normal jobs" />
+ <metric property="exceptionalJobsNumber" dataType="measurement" displayType="summary" defaultOn="true"
+ description="the number of exceptional jobs" />
+
+
+ <service name="Timer"
+ discovery="TimerDiscoveryComponent"
+ class="JobComponent"
+ subCategory="Jobs"
+ description="JBPM timers jobs">
+ <metric property="id" displayName="id" dataType="trait" displayType="summary" defaultOn="true"
+ description="job id" />
+ <metric property="duedate" displayName="duedate" dataType="trait" displayType="summary" defaultOn="true"
+ description="job duedate" />
+ <metric property="lockExpirationTime" displayName="lockExpirationTime" dataType="trait" displayType="summary" defaultOn="true"
+ description="job lockExpirationTime" />
+ <metric property="lockOwner" displayName="lockOwner" dataType="trait" displayType="summary" defaultOn="true"
+ description="job lockOwner" />
+ <metric property="isExclusive" displayName="isExclusive" dataType="trait" displayType="summary" defaultOn="true"
+ description="job isExclusive" />
+ <metric property="exception" displayName="exception" dataType="trait" displayType="summary" defaultOn="true"
+ description="job exception" />
+ </service>
+
+ <service name="Message"
+ discovery="MessageDiscoveryComponent"
+ class="JobComponent"
+ subCategory="Jobs"
+ description="JBPM message jobs">
+ <metric property="id" displayName="id" dataType="trait" displayType="summary" defaultOn="true"
+ description="job id" />
+ <metric property="duedate" displayName="duedate" dataType="trait" displayType="summary" defaultOn="true"
+ description="job duedate" />
+ <metric property="lockExpirationTime" displayName="lockExpirationTime" dataType="trait" displayType="summary" defaultOn="true"
+ description="job lockExpirationTime" />
+ <metric property="lockOwner" displayName="lockOwner" dataType="trait" displayType="summary" defaultOn="true"
+ description="job lockOwner" />
+ <metric property="isExclusive" displayName="isExclusive" dataType="trait" displayType="summary" defaultOn="true"
+ description="job isExclusive" />
+ <metric property="exception" displayName="exception" dataType="trait" displayType="summary" defaultOn="true"
+ description="job exception" />
+ </service>
+
+ <service name="Exceptional Jobs"
+ discovery="ExceptionJobDiscoveryComponent"
+ class="JobComponent"
+ subCategory="Jobs"
+ description="JBPM exceptional jobs">
+ <metric property="id" displayName="id" dataType="trait" displayType="summary" defaultOn="true"
+ description="job id" />
+ <metric property="duedate" displayName="duedate" dataType="trait" displayType="summary" defaultOn="true"
+ description="job duedate" />
+ <metric property="lockExpirationTime" displayName="lockExpirationTime" dataType="trait" displayType="summary" defaultOn="true"
+ description="job lockExpirationTime" />
+ <metric property="lockOwner" displayName="lockOwner" dataType="trait" displayType="summary" defaultOn="true"
+ description="job lockOwner" />
+ <metric property="isExclusive" displayName="isExclusive" dataType="trait" displayType="summary" defaultOn="true"
+ description="job isExclusive" />
+ <metric property="exception" displayName="exception" dataType="trait" displayType="summary" defaultOn="true"
+ description="job exception" />
+ </service>
+
+
+
+
+
+ <service name="Process Deployments"
+ discovery="ProcessDeploymentDiscoveryComponent"
+ class="ProcessDeploymentComponent"
+ createDeletePolicy="create-only"
+ creationDataType="content"
+ description="JBPM Process Deployment">
+ <metric property="id" displayName="id" dataType="trait" displayType="summary" defaultOn="true"
+ description="deployment id" />
+ <metric property="name" displayName="name" dataType="trait" displayType="summary" defaultOn="true"
+ description="deployment name" />
+ <metric property="timestamp" displayName="timestamp" dataType="trait" displayType="summary" defaultOn="true"
+ description="deployment timestamp" />
+ <metric property="state" displayName="state" dataType="trait" displayType="summary" defaultOn="true"
+ description="deployment state" />
+
+ <content name="file" displayName="jBPM Process File"
+ category="deployable" isCreationType="true">
+ </content>
+ </service>
+ <service name="Process Definitions"
+ discovery="ProcessDefDiscoveryComponent"
+ class="ProcessDefComponent"
+ description="JBPM Process Definitions">
+ <metric property="version" displayName="version" dataType="trait" displayType="summary" defaultOn="true"
description="Process definition version" />
- <metric property="id" displayName="Id" dataType="trait"
- displayType="summary" defaultOn="true"
+ <metric property="id" displayName="id" dataType="trait" displayType="summary" defaultOn="true"
description="Process definition id" />
- <content name="file" displayName="jBPM Process"
- category="deployable" isCreationType="true">
- <configuration>
- <c:group name="deployment"
- displayName="Deployment Options">
- <c:simple-property name="deployZipped"
- displayName="Deploy Zipped" type="boolean" default="false"
- required="true"
- description="Indicates jBPM process artifacts either par file or xml file" />
- </c:group>
- </configuration>
- </content>
- <service name="Process Instances"
- discovery="org.jbosson.plugins.jbpm.JbpmInstanceDiscoveryComponent"
- class="org.jbosson.plugins.jbpm.JbpmInstanceComponent"
+ <metric property="description" displayName="description" dataType="trait" displayType="summary" defaultOn="true"
+ description="Process definition id" />
+
+ <service name="Process Instances"
+ discovery="ProcessInstanceDiscoveryComponent"
+ class="ProcessInstanceComponent"
createDeletePolicy="both"
creationDataType="configuration"
- description="Process Instances">
+ description="Process Instance">
-
- <operation name="suspend" displayName="suspend"
- description="Suspend this process instance"/>
-
- <operation name="resume" displayName="resume"
- description="Resume this process instance"/>
-
- <operation name="end" displayName="end"
- description="End this process instance"/>
-
- <metric property="version" displayName="Version"
+ <metric property="id" displayName="id"
dataType="trait" displayType="summary" defaultOn="true"
- description="Process Instance version" />
+ description="Process instance id" />
- <metric property="id" displayName="Id" dataType="trait"
+ <metric property="key" displayName="key" dataType="trait"
displayType="summary" defaultOn="true"
- description="Process Instance Id" />
+ description="Process instance key" />
- <metric property="start" displayName="StartData"
+ <metric property="name" displayName="name"
dataType="trait" displayType="summary" defaultOn="true"
- description="Process Instance StartData" />
+ description="Process instance name" />
- <metric property="status" displayName="Status"
+ <metric property="priority" displayName="priority"
dataType="trait" displayType="summary" defaultOn="true"
- description="Process Instance Satus" />
+ description="Process instance priority" />
- <metric property="end" displayName="EndData"
+ <metric property="definitionId" displayName="definitionId"
dataType="trait" displayType="summary" defaultOn="true"
- description="Process Instance EndData" />
-
- <help>
- <![CDATA[
- JBoss Process Instances
- ]]>
- </help>
-
-
+ description="Process definition id" />
+
+ <metric property="status" displayName="status"
+ dataType="trait" displayType="summary" defaultOn="true"
+ description="Process instance status" />
+ <resource-configuration>
+ <c:simple-property name="start instance" displayName="startInstance" type="boolean" required="true"
+ default="true">
+ </c:simple-property>
+ </resource-configuration>
+ <service name="Jobs"
+ discovery="InstanceJobDiscoveryComponent"
+ class="JobComponent"
+ description="JBPM jobs">
+ <metric property="id" displayName="id" dataType="trait" displayType="summary" defaultOn="true"
+ description="job id" />
+ <metric property="duedate" displayName="duedate" dataType="trait" displayType="summary" defaultOn="true"
+ description="job duedate" />
+ <metric property="lockExpirationTime" displayName="lockExpirationTime" dataType="trait" displayType="summary" defaultOn="true"
+ description="job lockExpirationTime" />
+ <metric property="lockOwner" displayName="lockOwner" dataType="trait" displayType="summary" defaultOn="true"
+ description="job lockOwner" />
+ <metric property="isExclusive" displayName="isExclusive" dataType="trait" displayType="summary" defaultOn="true"
+ description="job isExclusive" />
+ <metric property="exception" displayName="exception" dataType="trait" displayType="summary" defaultOn="true"
+ description="job exception" />
+ </service>
</service>
-
- </service>
+ </service>
</service>
</plugin>
16 years, 8 months