cancel
Showing results for 
Search instead for 
Did you mean: 

Reference to FileFolderService in jbpm Workflow Java Action

netboy1977
Champ in-the-making
Champ in-the-making
Hello all,

I want to create folders from Java action in an jbpm Workflow (Alfresco 3.4d). I am a bit confused how to do this in Java since the JS Code is quite simple and it seems to be far more difficult in Java.

How best to insert a reference to FileFolderService in a workflow Java action?

According to NodeRef cookbook you receive an instance to FileFolderService this way:


ServiceRegistry serviceRegistry = (ServiceRegistry) beanFactory.getBean(ServiceRegistry.SERVICE_REGISTRY);
     
       FileFolderService fileFolderService = serviceRegistry.getFileFolderService();

However, I see no way to get the serviceRegistry since I am implementing org.jbpm.graph.def.ActionHandler which only provides org.jbpm.graph.exe.ExecutionContext.

This is my relvant action code in the process definiton:


    <event type="node-leave">
      <action class="org.example.FileFolderCreator"/>
   </event>   

Questions:


1. Which interface to best implement to get a reference of ServiceRegistry?
2. Do I have to add/inject anything to my workflow action?
3. Is there another way to acquire this, i.e. use NodeService?

Thanks for your replies!

Dominik
1 REPLY 1

afaust
Legendary Innovator
Legendary Innovator
Hello,

for Java actions in jBPM workflows you should be extending the Alfresco-specific JBPMSpringActionHandler class which provides you with a initialiseHandler method that has a BeanFactory as a parameter. Then the example from the Cookbook will work just as in your example - the service reference obtained needs to be put into a member variable in order for the execute method to have access to it, but that is about all the extra wiring you need.

Regards
Axel