Skip to content
Daniel Gradecak edited this page Oct 8, 2018 · 1 revision

Alfresco @MVC AOP Enables a couple of useful annotations on the Alfresco Repository side.

Alfresco retrying transaction or runAs features tend to introduce quite a lot of boilerplate code, this library allows to avoid that.

@AlfrescoAuthentication

used on a service method to indicate what type of authentication is allowed, same usage as in the webscript decriptor user. Four possibilities are NONE, GUEST, USER, ADMIN as defined in the AuthenticationType enum. Defaults to USER

@AlfrescoRunAs

allows with a simple annotation to use the runas mechanism of alfresco. The value has to be a static string with the username.

@AlfrescoTransaction

this one uses the RetryingTansaction in order to avoid to write all lines for a RetryingTransactionCallback, Params: readOnly defaults to true and propagation defaults to org.springframework.transaction.annotation.Propagation.REQUIRED

Configuration:

Java Config

@ComponentScan(basePackageClasses = { "com.gradecak.alfresco.mvc.sample.service" })
@EnableAlfrescoMvcProxy(basePackageClasses = { "com.gradecak.alfresco.mvc.sample.service" })

EnableAlfrescoMvcProxy or PackageAutoProxyCreator will auto create spring's proxies for all the classes in the specified package in order to apply the advices

XML

  <context:component-scan base-package="com.gradecak.alfresco.mvc.sample.service">
    <context:include-filter expression="org.springframework.stereotype.Service" type="annotation" />
  </context:component-scan>

  <bean class="com.gradecak.alfresco.mvc.aop.PackageAutoProxyCreator">
    <property name="basePackage" value="com.gradecak.alfresco.mvc.sample.service" />
  </bean>

Notice

Some issues while using CMIS were spotted if the services are registered via @ComponentScan and used in Alfresco behaviors, therefore for now it is recommended to use the xml or java (@Bean) config for service scanning only. This is due to the lifecycle of spring's loading of beans (not reproduced on Alfresco 6 for now).

Prior to Alfresco 6 (and spring 5.x)

There is a spring proxy limitation (spring 3.2.x) in order to use @Autowired on constructors, therefore @Autowired for now should be used on fields. This is due to how CGLIB creates the proxies (a default constructor is needed)

Alfresco @MVC

Clone this wiki locally