07-08-2011 06:41 PM
<serviceTask id="springTask1" name="BeanTest" activiti:expression="${taskBean.execute(contactName)}"></serviceTask>
package org.psc.bpmn.examples;
import java.util.List;
import org.activiti.engine.RuntimeService;
import org.psc.bpmn.tasks.Contact;
import org.psc.service.ContactService;
public class GetBeanTest {
public GetBeanTest() {
super();
}
private ContactService contactService;
private RuntimeService runtimeService;
public void execute(String contactName) throws Exception {
if(contactService == null){
System.out.println("Bean was null!");
}else{
System.out.println("Bean is valid!");
List<Contact> contacts= contactService.getContacts();
System.out.println("There are " + contacts.size() +" in the contact list.");
for (Contact contact : contacts) {
if(contact.getName().equalsIgnoreCase(contactName)){
System.out.println("Found the contact! " + contactName );
// How do I get the current process so I can put some new process variable into it?
// runtimeService.?????
}
}
}
}
public void setRuntimeService(RuntimeService runtimeService) {
this.runtimeService = runtimeService;
}
public void setContactService(ContactService contactService) {
this.contactService = contactService;
}
}
07-09-2011 03:16 PM
Wrapped Exception (with status template): Delegate expression ${taskBean} did not resolve to an implementation of interface org.activiti.engine.impl.pvm.delegate.ActivityBehavior nor interface org.activiti.engine.delegate.JavaDelegate
public class GetBeanTest implements JavaDelegate {
private ContactService contactService;
public GetBeanTest() {
super();
}
public String getContactName(String contactName) throws Exception {
String retVal= "unknown";
if(contactService == null){
System.out.println("Bean was null!");
}else{
System.out.println("Bean is valid!");
List<Contact> contacts= contactService.getContacts();
System.out.println("There are " + contacts.size() +" in the contact list.");
for (Contact contact : contacts) {
if(contact.getName().equalsIgnoreCase(contactName)){
System.out.println("Found the contact! " + contactName );
retVal= contact.getEmail();
}
}
}
return retVal;
}
public void setContactService(ContactService contactService) {
this.contactService = contactService;
}
@Override
public void execute(DelegateExecution execution) throws Exception {
System.out.println("+++++++++++++ in execute ++++++++++++++++");
System.out.println("Event Name: " + execution.getEventName());
System.out.println("ID: " + execution.getId());
System.out.println("Process Instance ID: " + execution.getProcessInstanceId());
Set<String> varNames= execution.getVariableNames();
for (String string : varNames) {
System.out.println("Varible Named " + string + " exists");
if(string.equalsIgnoreCase("contactName")){
String contactName= (String) execution.getVariable(string);
getContactName(contactName);
}else{
System.out.println("unable to find contact name.");
}
}
}
}
07-11-2011 08:29 AM
07-19-2011 03:59 AM
07-19-2011 10:25 AM
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.