iota-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cristofolini <...@git.apache.org>
Subject [GitHub] incubator-iota pull request #35: IOTA-41: Spring dependency injection for fe...
Date Mon, 10 Jul 2017 22:57:49 GMT
Github user cristofolini commented on a diff in the pull request:

    https://github.com/apache/incubator-iota/pull/35#discussion_r126557616
  
    --- 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 --
    
    You'd only need a @Qualifier if the bean id in the XML and the autowired attribute's name
are different.
    
    The difference between by_name and by_type is exactly what it says on the tin. By_name
will autowire beans with an id that matches the name, while by_type will look for a bean of
the same type. I don't really have strong reasons to go either way. Do you think it might
be better to go by_type?
    
    If so I can change that when I get the tests in.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message