by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 11 06:12

    xerial on master

    Update scalafmt-core to 2.6.3 (… (compare)

  • Jul 11 06:12
    xerial closed #1181
  • Jul 11 00:51
    codecov[bot] commented #1181
  • Jul 11 00:46
    scala-steward opened #1181
  • Jul 09 23:23
    codecov[bot] commented #1178
  • Jul 09 23:18
    codecov[bot] commented #1178
  • Jul 09 23:17
    xerial synchronize #1178
  • Jul 09 17:57
    codecov[bot] commented #1178
  • Jul 09 17:52
    codecov[bot] commented #1178
  • Jul 09 17:52
    xerial synchronize #1178
  • Jul 09 05:55
    codecov[bot] commented #1178
  • Jul 09 05:51
    xerial closed #260
  • Jul 09 05:51
    xerial commented #260
  • Jul 09 05:51
    xerial edited #839
  • Jul 09 05:49
    codecov[bot] commented #1178
  • Jul 09 05:49
    xerial synchronize #1178
  • Jul 09 05:23
    codecov[bot] commented #1178
  • Jul 09 05:18
    codecov[bot] commented #1178
  • Jul 09 05:18
    xerial synchronize #1178
  • Jul 09 05:14
    codecov[bot] commented #1178
Taro L. Saito
@xerial
Practically speaking, there is no difference in what they mean
Taro L. Saito
@xerial
Duy Pham
@phamthaibaoduy
Hello, could someone please help me explain this snippet of code about in-trait injection

https://wvlet.org/airframe/docs/index.html#in-trait-injection

I don't get how airframe can know which name should be used for the database

Naoki Takezoe
@takezoe
@phamthaibaoduy This example may not work because name is not given.
@xerial Probably we should fix this example. Simply removing name from Connection is ok?
Naoki Takezoe
@takezoe
Sorry, it was removing from Database, not Connection.
Naoki Takezoe
@takezoe
I created a pull request: wvlet/airframe#354
Taro L. Saito
@xerial
thx for the fix
Duy Pham
@phamthaibaoduy
Thanks
Duy Pham
@phamthaibaoduy
Hello, I have one question. It is possible to do multi-binding with provider method?
I wanna inject a Logger into target class, but Logger should be created with target class name
Duy Pham
@phamthaibaoduy
@xerial Thank Taro, but this can not be used for my purpose
Taro L. Saito
@xerial
How about using bind { s:String => Logger} (provider binding)?
Duy Pham
@phamthaibaoduy
Yes that would be helpful, only if Airframe somehow can correctly pass target class name as input for the provider
Taro L. Saito
@xerial
def newLogger(name:String) = Logger(name), and
bind {newLogger}
will work
I see. We need to resolve the logger nave automatically
Duy Pham
@phamthaibaoduy
Yes
I'm wondering if it's possible to have some contextual param, which would be passed by airfame to provider

case class Context (target: ClassMetaData)

something like this

Taro L. Saito
@xerial
Unfortunately there is no feature like that.
Duy Pham
@phamthaibaoduy
design
  .bind[Logger].toInstanceProvider{ (context: Context) => 
    new Logger(context.target.getClass) 
  }
Are you a maintainer of the airframe
Taro L. Saito
@xerial
Yes. I’m the creator of Airframe :)
Duy Pham
@phamthaibaoduy
Do you happen to know if it's possible to implement this feature, I would love to work on it but I need some help, the airframe source code is quite complex to me, a scala beginner
Wow
Taro L. Saito
@xerial
For this logger example, we don’t need to use provider. Just binding a provider that creates a new logger:
bind { new Logger(this.getClass) }
Duy Pham
@phamthaibaoduy
I wanna keep dependencies injected via constructor args
Taro L. Saito
@xerial
Then you can try using val f = bindFactory[Context => Logger], then you need to manually call f(context)
Duy Pham
@phamthaibaoduy
I can think of a work-around, which is to inject the LoggerFactory into target
Taro L. Saito
@xerial
Actually we already have a ticket for this use case wvlet/airframe#190
Duy Pham
@phamthaibaoduy
But it would be nice if the DI framework auto-wiring can fully take care of building dependencies
wow
Do you have any plan to get that issue resolved any time soon :D
Taro L. Saito
@xerial
This functionality can be implemented by writing a helper class (e.g., creating a logger from a given LoggerFactory and a context class information), so I believe we should not add this functionality to Airframe (because it makes the framework much more complex). Just having an example for doing so will be enough in this case.
Duy Pham
@phamthaibaoduy
@xerial I just found out that Alias type binding does not work with Constructor, I guess it is because of constructor injecting is done at runtime
If it's true, maybe we should update the document https://wvlet.org/airframe/docs/bindings.html#type-alias-binding
Taro L. Saito
@xerial
Could you give me an example code which didn’t work?
Duy Pham
@phamthaibaoduy
Sorry Taro, I thought I left response for your questions
It was mistake from my side, I did not know exactly what it is, but the problem went away after a clean recompile
Taro L. Saito
@xerial
Good to know that. Thanks for reporting!
Duy Pham
@phamthaibaoduy
Thank you
Duy Pham
@phamthaibaoduy
@xerial is it possible to use life cycles with design binding
I guess it's only useable with in trait injection?
Taro L. Saito
@xerial
onXXX hooks are available only for in-trait injection. For regular classes, you can use JSR250 annotations
like PostConstruct, PreDestroy
Duy Pham
@phamthaibaoduy
Thanks for answering