TransactionService and ServiceRegistry - Spring injection

Vous êtes ici

5 contributions / 0 nouveau(x)
Dernière contribution
TransactionService and ServiceRegistry - Spring injection

Hi all.

I need to write a Java package in order to manipulate Alfresco repository objects in custom ways. I am just creating a custom Java package and I want to have a reference to alfresco services (nodeService, ...) inside my Java classes, so I am going to direct inject Alfresco beans into my classes. Because I need to manage all the task in a transactional way, I need a reference to TransactionService into my classes. I was thinking about direct injecting a TransactionService bean into my classes, but it failed.

My questions are the following:
1) how to direct inject TransactionService into my classes (if possible)?
2) Instead of TransactionService is it possible to direct inject the ServiceRegistry bean?

I followed the FirstFoundationClient example, but it creates a new ApplicationContext, on the contrary I want to use the ApplicationContext already created during the Alfresco boot.

I tried the write a Java bean and direct inject the TransactionComponent and the AuthenticationComponentImpl beans. My bean has an init() method as the following:

public void init ()

try {
} catch (NotSupportedException e) {
// TODO Auto-generated catch block
} catch (SystemException e) {
// TODO Auto-generated catch block
this.authenticationService.authenticate("admin", "admin".toCharArray());

It works fine but I would like to know if this is the correct way to go on or not.

Many thanks to all.


Sergio D'Ascia
cell telephone number: +39 347 3186203
location: Bologna - Italy

forums index