I've been reading up on how Akka would handle dependency injection (
http://doc.akka.io/docs/akka/current/scala/actors.html#dependency-injection),
and it seems that, as far as Akka is concerned, upon creating an Actor, we
could pass a DependencyInjector and an ApplicationContext within the
actor's Props.

So now I'm imagining that bringing this functionality to Fey would be a
simple matter of adding a few extra items (the DependencyInjector class and
the ApplicationContext) to the json that defines an orchestration, and once
the json is processed, verifying if those items are present, and adding
those to the Props before calling akka to instance the actor.

Still, I'm curious to see what you guys think about bringing this feature
to the fey-engine.

On Sun, Jun 4, 2017 at 1:21 PM, Rafael Weingärtner <
[email protected]> wrote:

> We started developing our first agents (performers) using Fey, and we
> found our first “problem”. There is no integration of Fey and Spring.  Or
> at least, we did not understand how to integrate Fey with Spring.
>
> We want to instantiate our agents in Spring to enjoy all of its benefits
> (e.g. dependency injection, object management, easy transaction
> configuration and so forth). Therefore, instead of telling Fey the
> performer class to instantiate, we would have to tell Fey the source as the
> application context name and the bean name; so Fey can retrieve the agent
> (object) already instantiated by Spring.
>
> This would have consequences on the performer constructor; we would need
> to add another hook to configure an agent in Fey such as a post-constructor
> method that would be intended to do the same as the constructor today. I
> mean, we maintain everything we have so far, and we add only a default
> constructor with no parameters and the post-constructor method that would
> be hooked in Fey’s performer life-cycle.
>
> Then, we would have to possibilities, first the one we already have to
> instantiate an agent:
>
>  "source": {
>
>             "name": *"agentJarWithDependencies.jar"*,
>
>             "classPath": *"org.awesomeCompany.agentOne"*,
>
>             "parameters": {
>
>             }
>
> And an alternative for agent objects managed by Spring:
>
> "source": {
>
>             "name": *" agentJarWithDependencies.jar"*,
>
>             "applicationContextName": *"agentOneApplicationContext.xml"*,
>
>             "performerBeanName": *"agentOneApplicationContext.xml"*
>
>
> This would require Fey to instantiate the Spring’s application context,
> and then look the bean up there. The idea is that application context file
> can be found in the classpath.
>
>
>
> What do you guys think about this? We can work to create this integration
> after we discussed the changes that would be applied to Fey.
>
>
>
> --
> Rafael Weingärtner
>

Reply via email to