Skip to content

Instantly share code, notes, and snippets.

@trevershick
Created July 2, 2011 20:06
Show Gist options
  • Save trevershick/1061594 to your computer and use it in GitHub Desktop.
Save trevershick/1061594 to your computer and use it in GitHub Desktop.
Fixes a deployment but in Activiti 3.3-3.6 whereby the deployer looks at the 'oldest' instead of the 'latest' deployment and compares the bar 'to be deployed'.
package com.railinc.activiti.sso;
import java.util.List;
import org.activiti.engine.impl.persistence.entity.DeploymentEntity;
import org.activiti.engine.repository.Deployment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RailincDeploymentManager extends
org.activiti.engine.impl.persistence.entity.DeploymentManager {
private final Logger log = LoggerFactory.getLogger(RailincDeploymentManager.class);
/**
* fix a bug with the standard DeploymentManager. It sorts the deployments ascending and
* pulls the first deployment. it should sort descending.
*/
@Override
public DeploymentEntity findLatestDeploymentByName(String deploymentName) {
List<Deployment> list = getDbSqlSession().createDeploymentQuery().deploymentName(deploymentName).orderByDeploymenTime().desc().listPage(0, 1);
DeploymentEntity deployment = null;
if (list!=null && !list.isEmpty()) {
deployment = (DeploymentEntity) list.get(0);
}
if (log.isInfoEnabled()) {
if (deployment == null) {
log.info("Returning null from findLatestDeploymentByName");
} else {
log.info(String.format("Returning (%s,%s,%s) from findLatestDeploymentByName",
deployment.getId(),
deployment.getName(),
String.valueOf(deployment.getDeploymentTime())));
}
}
return deployment;
}
}
package com.railinc.activiti.sso;
import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;
import org.activiti.engine.impl.persistence.entity.DeploymentManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RailincDeploymentManagerFactory implements SessionFactory {
private final Logger log = LoggerFactory.getLogger(RailincDeploymentManagerFactory.class);
@Override
public Class<?> getSessionType() {
return DeploymentManager.class;
}
@Override
public Session openSession() {
if (log.isDebugEnabled()) {
log.debug("Returning new RailincDeploymentManager from openSession()");
}
return new RailincDeploymentManager();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<bean id="ssoProxy" class="com.railinc.loa.core.service.SSOProxy"/>
<bean id="repositoryService" factory-bean="processEngine"
factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine"
factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine"
factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine"
factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine"
factory-method="getManagementService" />
<bean id="identityService" factory-bean="processEngine"
factory-method="getIdentityService" />
<bean id="formService" factory-bean="processEngine"
factory-method="getFormService" />
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="true" />
<property name="deploymentResources"
value="classpath:activiti/LOA.bpmn20.xml" />
<property name="customSessionFactories">
<list>
<bean class="com.railinc.activiti.sso.RailincGroupManagerFactory"
p:userClient-ref="userClient"
p:modulesClient-ref="modulesClient"/>
<bean class="com.railinc.activiti.sso.RailincUserManagerFactory"
p:userClient-ref="userClient"/>
<bean class="com.railinc.activiti.sso.RailincDeploymentManagerFactory" />
</list>
</property>
</bean>
<bean id="userClient" class="com.railinc.sso.services.impl.UserClientImpl"
p:ssoServiesHost="${ssoServicesHost}"/>
<bean id="modulesClient" class="com.railinc.sso.services.impl.ModulesClientImpl"
p:ssoServiesHost="${ssoServicesHost}"/>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean"
p:processEngineConfiguration-ref="processEngineConfiguration" />
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment