Wie bekomme ich die aktuelle Activiti ProcessInstance in SpringBean?

Ich versuche einen workflow arbeiten mit Activiti 5.5 mit einer Feder gesteuerter Prozess-engine, und ich habe einige Schwierigkeiten.

Ich habe einen ServiceTask in meinem workflow, der aufgelöst wird, zu einer Spring Managed bean. Es sieht wie folgt aus:

<serviceTask id="springTask1" name="BeanTest" activiti:delegateExpression="${taskBean}"></serviceTask>

Bin ich nicht starten den Prozess über den code, der Prozess wird entweder gestartet, über die activti-rest-api oder eine form. Wie bekomme ich den Kontext, in dem diese Aufgabe ausgeführt wird, aus dem inneren der Bohne, so dass ich möglicherweise in der Lage sein, eine Prozess-variable, könnte verwiesen werden, die in einer späteren Aufgabe, wie eine E-Mail. Ich habe versucht, an den Frühling Beispiele, die kommen mit Activiti 5.5 und ich sehe nicht, wie mein Beispiel ist jede anders als die Beispiele. Ich bin der Umsetzung der JavaDelegate interface das gleiche, was der Frühling Beispiel zeigt.

Hier ist mein code:

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.");
        }
    }
}

}

Hier ist der Frühling config (boring parts left out für die Kürze):

<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  </bean>

<!--Dao Beans -->
<bean id="contactDao" class="org.psc.database.dao.jpa.ContactDaoImpl"/>

<!--  Service Beans -->

  <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="contactService" class="org.psc.service.impl.ContactServiceImpl">
    <property name="contactDao" ref="contactDao"/>
</bean>

<bean id="contact" class="org.psc.bpmn.tasks.Contact"/>
<bean id="taskBean" class="org.psc.bpmn.examples.GetBeanTest">
        <property name="contactService" ref="contactService"/>
</bean>

Wenn ich den worflow, bekomme ich eine Fehlermeldung:

06090000 Gewickelt Ausnahme (mit status-template): Delegieren Ausdruck ${taskBean} konnte nicht beheben, die eine Implementierung der Schnittstelle org.activiti.Motor.impl.pvm.delegieren.ActivityBehavior noch die Schnittstelle org.activiti.Motor.delegieren.JavaDelegate

Jede/Alle Antworten dankbar!
Vielen Dank im Voraus.

InformationsquelleAutor Griff | 2011-07-09

Schreibe einen Kommentar