summaryrefslogtreecommitdiff
path: root/calamus-engine/src/main/java/io/trygvis
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2014-04-21 09:01:00 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2014-04-21 09:01:00 +0200
commitfd681e2c6663652be02a31f7b40da4cd283ab37e (patch)
tree83cf23c1cc1f9320f2464e355d33d7abce3249e8 /calamus-engine/src/main/java/io/trygvis
parentd38810a179a6f669ea0d3e7588f2aabed762deff (diff)
downloadcalamus-fd681e2c6663652be02a31f7b40da4cd283ab37e.tar.gz
calamus-fd681e2c6663652be02a31f7b40da4cd283ab37e.tar.bz2
calamus-fd681e2c6663652be02a31f7b40da4cd283ab37e.tar.xz
calamus-fd681e2c6663652be02a31f7b40da4cd283ab37e.zip
wip
Diffstat (limited to 'calamus-engine/src/main/java/io/trygvis')
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/CalamusDbConfig.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/CalamusDbConfig.java)20
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/CalamusJbpm.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpm.java)16
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/CalamusJbpmConfig.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpmConfig.java)23
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/JenkinsBuildResultMessageListener.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/JenkinsBuildResultMessageListener.java)8
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/Main.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/Main.java)6
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/MqClient.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/MqClient.java)8
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/NexusNewArtifactMessageListener.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/NexusNewArtifactMessageListener.java)19
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/RestartAppWorkItemHandler.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/RestartAppWorkItemHandler.java)2
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/UpgradeAppWorkItemHandler.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/UpgradeAppWorkItemHandler.java)2
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/AbstractEntity.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/domain/AbstractEntity.java)2
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/AppInstance.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/service/AppInstance.java)2
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/AppService.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/service/AppService.java)2
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/Artifact.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/domain/Artifact.java)4
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/Process.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/domain/Process.java)17
-rw-r--r--calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/ProcessTrigger.java (renamed from calamus-engine/src/main/java/io/trygvis/engine/domain/ProcessTrigger.java)6
15 files changed, 80 insertions, 57 deletions
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/CalamusDbConfig.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/CalamusDbConfig.java
index 39772c8..ad0e5a9 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/CalamusDbConfig.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/CalamusDbConfig.java
@@ -1,4 +1,4 @@
-package io.trygvis.engine;
+package io.trygvis.calamus.engine;
import bitronix.tm.BitronixTransactionManager;
import bitronix.tm.TransactionManagerServices;
@@ -7,17 +7,10 @@ import com.googlecode.flyway.core.Flyway;
import com.googlecode.flyway.core.api.MigrationInfo;
import com.googlecode.flyway.core.api.MigrationInfoService;
import org.jbpm.process.audit.JPAAuditLogService;
-import org.kie.api.io.Resource;
-import org.kie.api.io.ResourceType;
-import org.kie.api.runtime.manager.RuntimeEnvironment;
-import org.kie.internal.io.ResourceFactory;
-import org.kie.spring.factorybeans.RuntimeEnvironmentFactoryBean;
-import org.kie.spring.factorybeans.RuntimeManagerFactoryBean;
import org.slf4j.Logger;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
-import org.springframework.context.annotation.Lazy;
import org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy;
import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
@@ -29,8 +22,6 @@ import org.springframework.transaction.support.TransactionTemplate;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
import static java.lang.String.format;
import static org.slf4j.LoggerFactory.getLogger;
@@ -44,20 +35,23 @@ public class CalamusDbConfig {
private final Logger log = getLogger(getClass());
@Bean
- public DataSource dataSource() {
+ public PoolingDataSource innerDataSource() {
PoolingDataSource ds = new PoolingDataSource();
ds.setUniqueName("jdbc/jbpm-ds");
ds.setClassName(bitronix.tm.resource.jdbc.lrc.LrcXADataSource.class.getCanonicalName());
- ds.setMaxPoolSize(3);
+ ds.setMaxPoolSize(10);
ds.setAllowLocalTransactions(true);
ds.getDriverProperties().put("user", "jbpm");
ds.getDriverProperties().put("password", "jbpm");
ds.getDriverProperties().put("url", "jdbc:postgresql://localhost/jbpm");
ds.getDriverProperties().put("driverClassName", org.postgresql.Driver.class.getCanonicalName());
ds.init();
+ return ds;
+ }
+ @Bean
+ public DataSource dataSource(PoolingDataSource ds) {
return new TransactionAwareDataSourceProxy(new LazyConnectionDataSourceProxy(ds));
-// return ds;
}
public static class DbMigrations {
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpm.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/CalamusJbpm.java
index 5b0e8ec..af6f489 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpm.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/CalamusJbpm.java
@@ -1,7 +1,10 @@
-package io.trygvis.engine;
+package io.trygvis.calamus.engine;
+import org.kie.api.runtime.KieSession;
+import org.kie.api.runtime.manager.RuntimeEngine;
+import org.kie.api.runtime.manager.RuntimeManager;
import org.kie.api.runtime.process.ProcessInstance;
-import org.kie.internal.runtime.StatefulKnowledgeSession;
+import org.kie.internal.runtime.manager.context.ProcessInstanceIdContext;
import org.slf4j.Logger;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.transaction.support.TransactionTemplate;
@@ -17,7 +20,7 @@ public class CalamusJbpm {
private final EntityManagerFactory emf;
- private final StatefulKnowledgeSession session;
+ private final KieSession session;
public static enum CalamusProcess {
DEPLOY("io.trygvis.bpm.Deploy");
@@ -47,7 +50,10 @@ public class CalamusJbpm {
transactionTemplate = spring.getBean(TransactionTemplate.class);
emf = spring.getBean(EntityManagerFactory.class);
- session = null;
+
+ RuntimeManager runtimeManager = spring.getBean(RuntimeManager.class);
+ RuntimeEngine engine = runtimeManager.getRuntimeEngine(ProcessInstanceIdContext.get());
+ session = engine.getKieSession();
// session = JPAKnowledgeService.newStatefulKnowledgeSession(kieBase, null, env);
// session.addEventListener(AuditLoggerFactory.newJPAInstance(env));
@@ -64,7 +70,7 @@ public class CalamusJbpm {
return emf;
}
- public StatefulKnowledgeSession getSession() {
+ public KieSession getSession() {
return session;
}
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpmConfig.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/CalamusJbpmConfig.java
index 98ba550..edfda28 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/CalamusJbpmConfig.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/CalamusJbpmConfig.java
@@ -1,9 +1,10 @@
-package io.trygvis.engine;
+package io.trygvis.calamus.engine;
import org.jbpm.process.audit.JPAAuditLogService;
import org.kie.api.io.Resource;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.manager.RuntimeEnvironment;
+import org.kie.api.runtime.manager.RuntimeManager;
import org.kie.internal.io.ResourceFactory;
import org.kie.spring.factorybeans.RuntimeEnvironmentFactoryBean;
import org.kie.spring.factorybeans.RuntimeManagerFactoryBean;
@@ -39,8 +40,10 @@ public class CalamusJbpmConfig {
x.setType("DEFAULT");
Map<Resource, ResourceType> assets = new HashMap<>();
- assets.put(ResourceFactory.newClassPathResource("/Deploy.bpmn2"), ResourceType.BPMN2);
+ System.out.println("getClass().getClassLoader() = " + getClass().getClassLoader());
+ assets.put(ResourceFactory.newClassPathResource("Deploy.bpmn2", getClass()), ResourceType.BPMN2);
x.setAssets(assets);
+// x.setClassLoader(getClass().getClassLoader());
x.setEntityManagerFactory(entityManagerFactory);
x.setTransactionManager(platformTransactionManager);
@@ -48,13 +51,15 @@ public class CalamusJbpmConfig {
return x;
}
-// @Bean
-// public RuntimeManagerFactoryBean runtimeManagerFactoryBean(RuntimeEnvironment runtimeEnvironment) {
-// RuntimeManagerFactoryBean x = new RuntimeManagerFactoryBean();
-// x.setIdentifier("spring-rm");
-// x.setRuntimeEnvironment(runtimeEnvironment);
-// return x;
-// }
+ @Bean
+ @Lazy
+ public RuntimeManager runtimeManagerFactoryBean(RuntimeEnvironment runtimeEnvironment) throws Exception {
+ RuntimeManagerFactoryBean x = new RuntimeManagerFactoryBean();
+ x.setIdentifier("spring-rm");
+ x.setRuntimeEnvironment(runtimeEnvironment);
+ x.afterPropertiesSet();
+ return (RuntimeManager) x.getObject();
+ }
@Bean
public JPAAuditLogService jpaAuditLogService(EntityManagerFactory entityManagerFactory) {
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/JenkinsBuildResultMessageListener.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/JenkinsBuildResultMessageListener.java
index 08b5e5b..39ac6e3 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/JenkinsBuildResultMessageListener.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/JenkinsBuildResultMessageListener.java
@@ -1,6 +1,6 @@
-package io.trygvis.engine;
+package io.trygvis.calamus.engine;
-import org.kie.internal.runtime.StatefulKnowledgeSession;
+import org.kie.api.runtime.KieSession;
import org.slf4j.Logger;
import javax.jms.JMSException;
@@ -17,9 +17,9 @@ import static org.slf4j.LoggerFactory.getLogger;
public class JenkinsBuildResultMessageListener implements MessageListener {
private final Logger log = getLogger(getClass());
- private StatefulKnowledgeSession session;
+ private KieSession session;
- public JenkinsBuildResultMessageListener(StatefulKnowledgeSession session) {
+ public JenkinsBuildResultMessageListener(KieSession session) {
this.session = session;
}
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/Main.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/Main.java
index c5916e0..daa4886 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/Main.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/Main.java
@@ -1,6 +1,6 @@
-package io.trygvis.engine;
+package io.trygvis.calamus.engine;
-import org.kie.internal.runtime.StatefulKnowledgeSession;
+import org.kie.api.runtime.KieSession;
public class Main {
public static void main(String[] args) throws Exception {
@@ -9,7 +9,7 @@ public class Main {
String brokerUrl = "tcp://localhost:61616";
- StatefulKnowledgeSession session = calamus.getSession();
+ KieSession session = calamus.getSession();
// EntityManager entityManager = calamus.getEntityManagerFactory().createEntityManager();
// EntityTransaction transaction = entityManager.getTransaction();
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/MqClient.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/MqClient.java
index 91eec37..0cb33ad 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/MqClient.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/MqClient.java
@@ -1,19 +1,13 @@
-package io.trygvis.engine;
+package io.trygvis.calamus.engine;
import org.apache.activemq.ActiveMQConnectionFactory;
-import org.kie.internal.runtime.StatefulKnowledgeSession;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
-import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Session;
-import javax.jms.TextMessage;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.Properties;
import static java.lang.Integer.parseInt;
import static javax.jms.Session.AUTO_ACKNOWLEDGE;
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/NexusNewArtifactMessageListener.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/NexusNewArtifactMessageListener.java
index 0813c27..ab111d7 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/NexusNewArtifactMessageListener.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/NexusNewArtifactMessageListener.java
@@ -1,9 +1,9 @@
-package io.trygvis.engine;
+package io.trygvis.calamus.engine;
-import io.trygvis.engine.domain.Artifact;
-import io.trygvis.engine.domain.Process;
-import io.trygvis.engine.domain.ProcessTrigger;
-import org.kie.internal.runtime.StatefulKnowledgeSession;
+import io.trygvis.calamus.engine.domain.Artifact;
+import io.trygvis.calamus.engine.domain.Process;
+import io.trygvis.calamus.engine.domain.ProcessTrigger;
+import org.kie.api.runtime.KieSession;
import org.slf4j.Logger;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
@@ -19,8 +19,10 @@ import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import java.io.IOException;
import java.io.StringReader;
+import java.util.Map;
import java.util.Properties;
+import static java.util.Collections.singletonMap;
import static org.slf4j.LoggerFactory.getLogger;
public class NexusNewArtifactMessageListener implements MessageListener {
@@ -28,9 +30,9 @@ public class NexusNewArtifactMessageListener implements MessageListener {
private final TransactionTemplate transactionTemplate;
private final EntityManagerFactory entityManagerFactory;
- private final StatefulKnowledgeSession session;
+ private final KieSession session;
- public NexusNewArtifactMessageListener(TransactionTemplate transactionTemplate, EntityManagerFactory entityManagerFactory, StatefulKnowledgeSession session) {
+ public NexusNewArtifactMessageListener(TransactionTemplate transactionTemplate, EntityManagerFactory entityManagerFactory, KieSession session) {
this.transactionTemplate = transactionTemplate;
this.entityManagerFactory = entityManagerFactory;
this.session = session;
@@ -93,6 +95,9 @@ public class NexusNewArtifactMessageListener implements MessageListener {
System.out.println("trigger.getMvel() = " + trigger.getMvel());
boolean match = trigger.matches(artifact);
System.out.println("match = " + match);
+
+ Map<String, Object> parameters = singletonMap("artifact", artifact);
+ session.startProcess(process.getJbpmProcessId(), parameters);
}
}
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/RestartAppWorkItemHandler.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/RestartAppWorkItemHandler.java
index 98733c7..0706cf1 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/RestartAppWorkItemHandler.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/RestartAppWorkItemHandler.java
@@ -1,4 +1,4 @@
-package io.trygvis.engine;
+package io.trygvis.calamus.engine;
import org.kie.api.runtime.process.WorkItem;
import org.kie.api.runtime.process.WorkItemHandler;
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/UpgradeAppWorkItemHandler.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/UpgradeAppWorkItemHandler.java
index 6202d6b..32da945 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/UpgradeAppWorkItemHandler.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/UpgradeAppWorkItemHandler.java
@@ -1,4 +1,4 @@
-package io.trygvis.engine;
+package io.trygvis.calamus.engine;
import org.kie.api.runtime.process.WorkItem;
import org.kie.api.runtime.process.WorkItemHandler;
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/domain/AbstractEntity.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/AbstractEntity.java
index e8b1faa..655b1cc 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/domain/AbstractEntity.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/AbstractEntity.java
@@ -1,4 +1,4 @@
-package io.trygvis.engine.domain;
+package io.trygvis.calamus.engine.domain;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/service/AppInstance.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/AppInstance.java
index 0badb8c..aa2ea14 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/service/AppInstance.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/AppInstance.java
@@ -1,4 +1,4 @@
-package io.trygvis.engine.service;
+package io.trygvis.calamus.engine.domain;
public class AppInstance {
private String name;
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/service/AppService.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/AppService.java
index 3ccde2b..da606a4 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/service/AppService.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/AppService.java
@@ -1,4 +1,4 @@
-package io.trygvis.engine.service;
+package io.trygvis.calamus.engine.domain;
public class AppService {
public void installApp(AppInstance instance) {
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/domain/Artifact.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/Artifact.java
index 8e01d92..34631ab 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/domain/Artifact.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/Artifact.java
@@ -1,10 +1,10 @@
-package io.trygvis.engine.domain;
+package io.trygvis.calamus.engine.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
import java.util.Optional;
-import static io.trygvis.engine.domain.Artifact.Level.UNTESTED;
+import static io.trygvis.calamus.engine.domain.Artifact.Level.UNTESTED;
import static java.util.Optional.ofNullable;
@Entity
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/domain/Process.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/Process.java
index ccd96cf..c1f0b49 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/domain/Process.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/Process.java
@@ -1,4 +1,4 @@
-package io.trygvis.engine.domain;
+package io.trygvis.calamus.engine.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -12,6 +12,9 @@ public class Process extends AbstractEntity {
@Column(length = 100, nullable = false)
private String name;
+ @Column(length = 100, nullable = false)
+ private String jbpmProcessId;
+
@OneToMany(mappedBy = "process")
private List<ProcessTrigger> processTriggers = new ArrayList<>();
@@ -19,7 +22,19 @@ public class Process extends AbstractEntity {
return name;
}
+ public String getJbpmProcessId() {
+ return jbpmProcessId;
+ }
+
public List<ProcessTrigger> getProcessTriggers() {
return processTriggers;
}
+
+ @Override
+ public String toString() {
+ return "Process{" +
+ "name='" + name + '\'' +
+ ", jbpmProcessId='" + jbpmProcessId + '\'' +
+ "} " + super.toString();
+ }
}
diff --git a/calamus-engine/src/main/java/io/trygvis/engine/domain/ProcessTrigger.java b/calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/ProcessTrigger.java
index 00b1603..b26f6ca 100644
--- a/calamus-engine/src/main/java/io/trygvis/engine/domain/ProcessTrigger.java
+++ b/calamus-engine/src/main/java/io/trygvis/calamus/engine/domain/ProcessTrigger.java
@@ -1,4 +1,4 @@
-package io.trygvis.engine.domain;
+package io.trygvis.calamus.engine.domain;
import org.mvel2.MVEL;
import org.mvel2.ParserContext;
@@ -21,6 +21,10 @@ public class ProcessTrigger extends AbstractEntity {
transient Serializable expression;
+ public Process getProcess() {
+ return process;
+ }
+
public String getMvel() {
return mvel;
}