cancel
Showing results for 
Search instead for 
Did you mean: 

Calling an operation from an event listener: how to inject dependencies ?

Antoine_Cordier
Star Contributor
Star Contributor

Hi,

I need to call the "ExportStructureToFS" operation from an event listener in order to trigger a scheduled export mys documents.

I found this explanation about how to call operations from java code, but I can't get the AutomationService and OperationContext injected as suggested in the example.

I use this declarations:

@Context
protected AutomationService service;

@Context
protected OperationContext context;

Both service and context end being set to null using this technique.

What's wrong ?

Thanks

4 REPLIES 4

Vladimir_Pasqui
Star Collaborator
Star Collaborator

Hello,

Antoine_Cordier
Star Contributor
Star Contributor

Hi,

Antoine_Cordier
Star Contributor
Star Contributor

I've just read about the @context annotation and it seems to precisely be out of context here. If i'm right dependency injection is not available in this case except for unit testing.

Antoine_Cordier
Star Contributor
Star Contributor

Dependency injection via the @context annotation works calling one operation from another.

In that case using:

AutomationService automationService = Framework.getService(AutomationService.class);

To get the service implementation

And

automationService.run(new OperationContext(), "ExportStructureToFS", parameters);

Solved my problem

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.