Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Develop Fast Deploy Faster - APS Scripting - Alfresco DevCon 2019

Find out the advantage of APS scripting using its graphical interface and how that reduces your development lifecycle. Pros and cons of this approach versus the more traditional JAR file deployment.

  • Login to see the comments

  • Be the first to like this

Develop Fast Deploy Faster - APS Scripting - Alfresco DevCon 2019

  1. 1. Develop Fast, Deploy Faster Advantages of APS Scripting Miguel Sanchez miguel-sanchez-galan msgalan@gmail.com howToBrothers.com
  2. 2. Learn. Connect. Collaborate. Agenda • App Designer • Custom Code • APS Scripting • Spring Beans • Environment Properties • REST Calls
  3. 3. Development is all about TIME
  4. 4. Learn. Connect. Collaborate. Development is all about TIME Time traveling is just too dangerous
  5. 5. App Designer
  6. 6. Learn. Connect. Collaborate. App Designer Time traveling is just too dangerous
  7. 7. Learn. Connect. Collaborate. App Designer Drag & Drop Configuration Custom Code
  8. 8. Custom Code
  9. 9. Learn. Connect. Collaborate. Custom Code Backend • Execution Listeners • Task Listeners • Script Tasks • Service Tasks
  10. 10. Learn. Connect. Collaborate. Custom Code Script Backed vs Java BackedWhich one to choose?
  11. 11. Script vs Java
  12. 12. Learn. Connect. Collaborate. Script vs Java Implement Changes DeployTest
  13. 13. Learn. Connect. Collaborate. Script vs Java - Deployment Life Cycle IDE Update App Model Publish App Restart Place on Classpath actitivi-app Generate Java Backed ~ couple of minutes Script Backed ~ few seconds
  14. 14. Learn. Connect. Collaborate. Script vs Java Update App Model Publish App Java Backed Reuse code Debug Unit Test Active Process Instances Script Backed Reuse code Debug Unit Test Active Process Instances
  15. 15. Learn. Connect. Collaborate. Script vs Java – Which one to choose Time required to implement the solution Complexity of the solution ScriptJava
  16. 16. APS Scripting
  17. 17. Learn. Connect. Collaborate. APS Scripting Enable scripts Set properties validator.editor.bpmn.disable.scripttask=false validator.editor.bpmn.disable.scripttask.groovy=false File: activiti-app.properties Location: activiti-appWEB-INFclassesMETA-INFactiviti-app Let’s make it work
  18. 18. Learn. Connect. Collaborate. APS Scripting Enable scripts Uncomment the language you want to use File: whitelisted-scripts.conf Location: activiti-appWEB-INFclassesactiviti Let’s make it work
  19. 19. Learn. Connect. Collaborate. APS Scripting – Update Active Processes • SetProcessDefinitionVersionCmd(processDefinitionId, processDefinitionVersion)); • dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
  20. 20. Script Listeners
  21. 21. Learn. Connect. Collaborate. Script Execution Listener Class: org.activiti.engine.impl.bpmn.listener.ScriptExecutionListener Object available: execution Events: start, end, take
  22. 22. Learn. Connect. Collaborate. Script Task Listener Class: org.activiti.engine.impl.bpmn.listener.ScriptTaskListener Object available: task Events: create, assignment, complete, delete
  23. 23. Learn. Connect. Collaborate. Secure Script Listeners File: activiti-app.properties Location: activiti-appWEB-INFclassesMETA-INFactiviti-app
  24. 24. Learn. Connect. Collaborate. Secure Script Listeners Execution Listener Class: org.activiti.scripting.secure.listener.SecureJavascriptExecutionListener Task Listener Class: org.activiti.scripting.secure.listener.SecureJavascriptTaskListener The future is now safe
  25. 25. Script Task
  26. 26. Learn. Connect. Collaborate. Script Task Object available: execution
  27. 27. Learn. Connect. Collaborate. Script Tasks – Reuse Code
  28. 28. Learn. Connect. Collaborate. Script Task - Reuse Code
  29. 29. Spring Beans
  30. 30. Learn. Connect. Collaborate. Default Spring Beans • userInfoBean • emailBean • documentMergeBean • auditLogBean
  31. 31. Learn. Connect. Collaborate. Custom Spring Beans • Create a bean Package: com.activiti.extension.bean • Deploy the JAR file generated Location: activiti-appWEB-INFlib • Add your bean name to File: beans-whitelist.conf Location: activiti-appWEB-INFclassesactiviti Custom Beans, Cool!
  32. 32. Environment Variables
  33. 33. Learn. Connect. Collaborate. Environment Properties package com.activiti.extension.bean; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import org.springframework.beans.factory.annotation.Autowired; @Component public class EnvironmentProperties { @Autowired private Environment env; public String get(String key) { return env.getProperty(key); } }
  34. 34. Learn. Connect. Collaborate. Environment Properties
  35. 35. Logging
  36. 36. Learn. Connect. Collaborate. Logging File: log4j.properties Location: activiti-appWEB-INFclasses We need to go back to know what happened
  37. 37. Learn. Connect. Collaborate. Logging
  38. 38. REST Calls
  39. 39. Learn. Connect. Collaborate. REST Calls
  40. 40. Learn. Connect. Collaborate. REST Calls – Basic Authentication
  41. 41. Learn. Connect. Collaborate. Rest Calls – External Authentication
  42. 42. Learn. Connect. Collaborate. Custom REST API HTTP client Java REST API Script
  43. 43. Learn. Connect. Collaborate. Custom REST API - Example User sets the values on the app form and completes the task Script task calls the ACS API to create the folder structure
  44. 44. Learn. Connect. Collaborate. Custom REST API - Example
  45. 45. Learn. Connect. Collaborate. Custom REST API - Example • execution.getVariable(“numberofyears") • acsApi.createFolder(parentNodeId, “name")
  46. 46. Learn. Connect. Collaborate. Custom REST API - Example
  47. 47. Learn. Connect. Collaborate. Final Thoughts
  48. 48. Learn. Connect. Collaborate. Q & A HowToBrothers.com

×