[
https://issues.apache.org/jira/browse/IOTA-41?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16081334#comment-16081334
]
ASF GitHub Bot commented on IOTA-41:
------------------------------------
Github user rafaelweingartner commented on a diff in the pull request:
https://github.com/apache/incubator-iota/pull/35#discussion_r126560025
--- Diff:
fey-core/src/main/scala/org/apache/iota/fey/FeyGenericSpringActor.scala ---
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.iota.fey
+
+import akka.actor.ActorRef
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory
+
+import scala.concurrent.duration._
+import org.springframework.context.ApplicationContext
+import org.springframework.context.support.ClassPathXmlApplicationContext
+
+abstract class FeyGenericSpringActor(override val params:
Map[String,String] = Map.empty,
+ override val backoff: FiniteDuration =
1.minutes,
+ override val connectTo:
Map[String,ActorRef] = Map.empty,
+ override val schedulerTimeInterval:
FiniteDuration = 2.seconds,
+ override val orchestrationName: String
= "",
+ override val orchestrationID: String =
"",
+ override val autoScale: Boolean =
false,
+ val appContextPath: String = "")
extends FeyGenericActor {
+
+ val appContext: ApplicationContext = new
ClassPathXmlApplicationContext()(appContextPath)
+ val factory: AutowireCapableBeanFactory =
appContext.getAutowireCapableBeanFactory
+
+ override def onStart(): Unit = {
+ super.onStart()
+ factory.autowireBeanProperties(this,
AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, true)
--- End diff --
I do find the by_type better, because then we do not need to care about
variable names and object names/ids.
> Spring dependency injection for fey performers
> ----------------------------------------------
>
> Key: IOTA-41
> URL: https://issues.apache.org/jira/browse/IOTA-41
> Project: Iota
> Issue Type: Improvement
> Reporter: Lucas Cristofolini
>
> There are many benefits to using the Spring framework (dependency injection,
> object management, etc.).
> Integrating these functionalities into fey performers would be a great
> improvement for the project.
> Our proposed implementation consists of creating a class that extends the
> original FeyGenericActor (named FeyGenericSpringActor), which allows for one
> more argument to be passed within its constructor, which is a String
> containing a path for the XML file containing that actor's Spring context,
> which can be an absolute or relative filesystem path (relative to the current
> VM working directory) or obtained from the classpath (by specifying a
> "classpath:" prefix); other protocols and prefixes may be supported by the
> Spring framework. The new actor class has two attributes: an
> ApplicationContext and its AutowireCapableBeanFactory, which will allow us to
> instantiate the beans specified in the actor's context.
> Other modifications to the fey engine core include the necessary changes
> related to parsing the orchestration JSON: adding an entry for the actor
> context's file path on the JSON validator and parser method, along with a
> conditional check to see if a path to the actor's context was specified in
> the JSON, so that fey will instantiate a FeyGenericSpringActor instead of a
> FeyGenericActor.
> Lastly, we've created a FeySpringContext.xml, which should be the parent
> context to all actor contexts created, and will contain useful universal
> declarations. For now, all it does is enable annotation usage in all Spring
> actors.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)