3.4 KiB
Generic Annotations Module for Alfresco Content Services
This module provides several annotations that help a developer create modules for Alfresco Content Services.
Design
AspectJ
This module relies on AspectJ. It uses it so that code can be wrapped around methods and parameters where annotations are used. This is known as the Aspect-Oriented Programming (AOP) model. The inclusion of AspectJ in ACS is not trivial, but it is mostly handled by the aspectj-platform-module
project. See that project for details.
When including the
aspectj-platform-module
AMP, remember to add the-javaagent:...
argument in the JEE web container.
Annotations
Annotation | Purpose |
---|---|
@Authorized |
Wraps the method in the Alfresco API AuthenticationUtil.runAs() . It only does this if the authorized user should be changed. Use the annotation value field or the Authorizable interface. Using neither will authorize the non-authorized as the system user. |
@AuthorizedAsSystem |
Wraps the method in the Alfresco API AuthenticationUtil.runAsSystem() . It only does this if the authorized user is not already the system user. |
@Transactional |
Wraps the method in the Alfresco API RetryingTransactionHelper.doInTransaction() . It only does this per the normal expectation of @Transactional . This is the Spring Framework annotation being made usable by this library. |
@TransactionalRetryable |
If @Transactional deems a new transaction is needed, this allows for the overridding of retrying parameters. Without this annotation, all transactions are still retried with default parameters. |
@Asynchronous |
Redirects calls to the method to put a message in MQ for asynchronous queuing and execution. The message is then discovered by this or another clustered instance and executed asynchronously in a separate transaction. |
@IfNodeExists |
Skips the method if a node parameter does not exist. This includes child, source, and target nodes of associations, but not parent nodes. This may be applied to specific parameters or the whole method (all node parameters). |
@IfNodeOfType |
Skips the method if a node parameter is not of the configured type. This includes child, source, and target nodes of associations, but not parent nodes. This may be applied to specific parameters or the whole method (all node parameters). Use the annotation type field or the NodeTypeConstrainable interface. |
@IfNodeHasAspect |
Skips the method if a node parameter does not have the configured aspect. This includes child, source, and target nodes of associations, but not parent nodes. This may be applied to specific parameters or the whole method (all node parameters). Use the annotation aspect field or the NodeAspectConstrainable interface. |
@IfChildAssociationIsPrimary |
Skips the method if a child association parameter is not considered primary. This may be applied to specific parameters or the whole method (all node parameters). |
Install
Install this as any other ACS Platform module. It is of the JAR type, so it just needs to be in the same classpath as the application.
In addition, make sure to follow the instructions for installing aspectj-platform-module
, specifically the javaagent
argument.