added README; minor fixes

This commit is contained in:
Brian Long 2023-04-05 16:19:44 -04:00
parent 5728b2a92b
commit b116adeaa9
4 changed files with 40 additions and 16 deletions

33
README.md Normal file
View File

@ -0,0 +1,33 @@
# 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`](https://bitbucket.org/inteligr8/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.

View File

@ -1,16 +0,0 @@
package com.inteligr8.alfresco.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface BehaviorBean {
String defaultType() default "sys:base";
String defaultAssocType() default "";
}

View File

@ -88,6 +88,9 @@ public class MqAsyncService extends AbstractLifecycleBean implements AsyncServic
@Value("${inteligr8.async.mq.enabled}")
protected boolean enabled;
@Value("${inteligr8.async.mq.worker}")
protected boolean workerEnabled;
@Value("${inteligr8.async.mq.url:#{null}}")
protected String url;
@ -153,6 +156,9 @@ public class MqAsyncService extends AbstractLifecycleBean implements AsyncServic
this.factory = pool;
if (!this.workerEnabled)
return;
JobKey jobKey = new JobKey("behaviour-async", "inteligr8-annotations");
JobDetailImpl jobDetail = new JobDetailImpl();

View File

@ -2,6 +2,7 @@
inteligr8.annotations.aspectj.scanPackages=com.inteligr8.alfresco.annotations
inteligr8.async.mq.enabled=false
inteligr8.async.mq.worker=true
inteligr8.async.mq.url=${messaging.broker.url}
inteligr8.async.mq.username=${messaging.broker.username}
inteligr8.async.mq.password=${messaging.broker.password}