PLAT-10 Actions & Behaviors


Published on

Learn how to leverage Alfresco’s action services to perform repeatable operations on our content. Understand Alfresco’s built-in actions and discover how you can encapsulate your business logic in your own custom actions should you need to. We then examine the various forms of callbacks and hook-points available to the developer in the form of behaviors and give some examples of how these can be used to enforce custom business logic and model consistency

Published in: Technology, Education
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

PLAT-10 Actions & Behaviors

  1. 1. Actions and Behaviors! Roy Wetherall – Founding Engineer - @rwetherall!
  2. 2. Agenda! 1.  Breaking it Down! 2.  Behaviours! 3.  Actions! 4.  Demo! 5.  Questions!
  3. 3. Breaking It Down!
  4. 4. Why Actions and Behaviours?! Extend beyond content models. Make extensions smarter. Encapsulate features. React to changes.
  5. 5. Sum of the Parts ...! Content Model + Behaviours + Actions = Smart Repository Extension
  6. 6. Breaking it down ...! Content Model – data structure and constraints Behaviours – interactions, consequences and restrictions Actions – execution
  7. 7. Behaviours !
  8. 8. Architecture!
  9. 9. Binding Behaviours!
  10. 10. Different Types Of Bindings! Service – called every time Class – most common, bound to type or aspect Association – bound to association, useful for adding smarts to custom hierarchiesProperties – bound to property, too granular
  11. 11. Code Example – Java Behaviour! Bind class behaviour. Java implementation. Execute behaviour when aspect is added.e.g. Initialise property with calculated value. @see
  12. 12. Notification Frequencies! Every Time First Event Transaction Commit
  13. 13. JavaScript Behaviours! More accessible for developers. Greater flexibility. Common Script API. Spring configurable. No Java code!
  14. 14. Code Example – JavaScript ! Add identifiable aspect to content. JavaScript implementation. Special ‘behaviour’ object available. Spring configured.@see onCreateChildAssociation_cmContent_cmContains.js
  15. 15. Common uses for behaviours ... !! Built in “rules”. Service call-back extension points. Calculated properties. Complex constraints. Auto-casting. A model with behaviour is a “Smart Model”.
  16. 16. Code Example – Copy Service Callback! Define custom behaviour copy. Ensures id is not duplicated. New id defined on copy. Technique can be used to prevent aspects being copied all. See
  17. 17. Code Example – Model Restrictions ! Behaviours can throw exceptions.Runtime exceptions rollback transactions.Can be used to enforce model constraints (e.g. read only properties). See
  18. 18. Behaviour Filter Bean!Enable and disable behaviours from other services. By type and/or node. Per transaction. Enable/disable all. See
  19. 19. Actions !
  20. 20. What is an Action?! Unit of work. Executed in the repository. Passed parameters, return value. Sync or async execution. Puts the ‘do’ in API. Reusable. Alfresco implementation of the GoF “Command” pattern
  21. 21. Architecture!
  22. 22. Anatomy of an Action!
  23. 23. Code Example - Executing An Action! Notify author when Identifiable node is deleted. Execute custom action from behaviour. Use action service. @see
  24. 24. Custom Actions! Extend built-in actions. Implemented in Java or JavaScript. Available in Share UI. Executable as rules. Custom conditions implemented in the same way. Convenient way to execute asynchronous work.
  25. 25. Code Example – Custom Action ! Custom Java action. Notifies author via email. Configured using Spring. Private action, does not appear in UI.See
  26. 26. Putting It All Together
(or a quick demo in Share 4.0)!
  27. 27. Questions?!