02-13-2013 02:26 AM
<serviceTask id="servicetask2" name="ServiceTask" activiti:class="com.ptvag.activiti.task.ImpactServiceTask" activiti:extensionId="com.ptvag.activiti.task.ImpactServiceTaskUi"></serviceTask>
<serviceTask id="servicetask2" name="ServiceTask" activiti:delegateExpression="${serviceCall}" activiti:extensionId="com.ptvag.activiti.task.ImpactServiceTaskUi"></serviceTask>
package com.foo.activiti.task;
import org.activiti.designer.integration.servicetask.AbstractCustomServiceTask;
import org.activiti.designer.integration.servicetask.PropertyType;
import org.activiti.designer.integration.servicetask.annotation.Help;
import org.activiti.designer.integration.servicetask.annotation.Property;
import org.activiti.designer.integration.servicetask.annotation.Runtime;
@Runtime(delegationClass = "com.foo.activiti.task.ServiceTask")
public class ImpactServiceTaskUi extends AbstractCustomServiceTask {
private static final String HELP_JMX_LONG = "Name of the JMX worker queue.";
@Property(type = PropertyType.TEXT, displayName = "JMX Queue", defaultValue = "jmx example queue")
@Help(displayHelpShort = "JMX Queue", displayHelpLong = HELP_JMX_LONG)
private String jmxQueue;
/*
* (non-Javadoc)
*
* @see
* org.activiti.designer.integration.servicetask.AbstractCustomServiceTask
* #contributeToPaletteDrawer()
*/
@Override
public String contributeToPaletteDrawer() {
return "Foo";
}
@Override
public String getName() {
return "ServiceTask";
}
/*
* (non-Javadoc)
*
* @see
* org.activiti.designer.integration.servicetask.AbstractCustomServiceTask
* #getSmallIconPath()
*/
@Override
public String getSmallIconPath() {
return "icons/icon.png";
}
}
package com.foo.activiti.task;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.activiti.engine.impl.bpmn.behavior.TaskActivityBehavior;
import org.activiti.engine.impl.el.Expression;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
public class ServiceTask extends TaskActivityBehavior {
@Autowired
private JmsTemplate jmsTemplate;
/**
* Class logger.
*/
private static final Logger LOG = Logger.getLogger(ServiceTask.class);
public Expression jmxQueue;
@Override
public void execute(ActivityExecution execution)
{
LOG.info("Executing proceess with id " + execution.getProcessInstanceId());
String executionId = execution.getId();
String processInstanceId = execution.getProcessInstanceId();
StringBuilder textMessage = new StringBuilder();
textMessage.append("ProcessInstanceId=");
textMessage.append(processInstanceId).append("\n");
textMessage.append("ExecutionId=");
textMessage.append(executionId).append("\n");
final String textMessageString = textMessage.toString();
MessageCreator message = new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException
{
TextMessage message = session.createTextMessage(textMessageString);
return message;
}
};
jmsTemplate.send(jmxQueue.getExpressionText(), message);
}
@Override
public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception
{
leave(execution);
}
}
02-13-2013 02:43 PM
@Runtime(delegationClass = "com.foo.activiti.task.ServiceTask")
@Runtime(delegationExpression = "${myBeanExpression.method(execution)}")
02-14-2013 03:42 AM
02-14-2013 04:01 AM
02-14-2013 04:59 AM
02-14-2013 06:57 AM
02-14-2013 09:17 AM
02-14-2013 10:18 AM
03-03-2013 02:47 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.