Upload
alfresco-software
View
613
Download
0
Embed Size (px)
Citation preview
Why Actions and Behaviours?!
Extend beyond content models.
Make extensions smarter. Encapsulate features.
React to changes.
Breaking it down ...!
Content Model – data structure and
constraints Behaviours – interactions, consequences
and restrictions Actions – execution
Code Example – Java Behaviour!
Bind class behaviour. Java implementation.
Execute behaviour when aspect is added. Initialise property with calculated value.
@see IdentifiableAspectPartOne.java
Code Example – Association Binding!
Bind association behaviour. Java implementation.
Make sure Identifiable aspect is always applied.
@see ApplyAspectBehaviour.java
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 hierarchies
Properties – bound to property, too granular
JavaScript Behaviours!
More accessible for developers.
Greater flexibility. Common Script API.
Spring configurable. No java code!
Code Example – JavaScript !
Add identifiable aspect to content. JavaScript implementation.
Special ‘behaviour’ object available. Spring configured.
@see onCreateChildAssociation_cmContent_cmContains.js
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”
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 @ IdentifiableAspectPartTwo.java
Code Example – Model Restrictions !
Behaviours can throw exceptions. Runtime exceptions rollback transactions. Can be used to enforce model constraints.
For example read only properties.
See @IdentifiableAspectPartThree.java
Behaviour Filter Bean!
Enable and disable behaviours from other services.
By type and/or node. Per transaction.
Enable/disable all.
See @BehaviourFilter.java
What is an Action?!
Unit of work. Executed in the repository.
Passed parameters, return value. Sync or asyn execution.
Puts the ‘do’ in API. Reusable.
Code Example - Executing An Action!
Notify author when Identifiable node is deleted.
Execute custom action from behaviour. Use action service.
@see IdentifiableAspect.java
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.
Code Example – Custom Action !
Custom Java action. Notifies author via email. Configured using Spring.
Private action, does not appear in UI.
See @DeleteNotificationActionExecuter.java