Java dependency injection with Java EE?

46 views
Skip to first unread message

Harit Himanshu

unread,
Apr 25, 2015, 11:52:43 AM4/25/15
to akka...@googlegroups.com
Hello

I am learning Akka and immediately one question popped up in my mind.
I use Java EE dependency injection a lot in my projects for following reasons

  1. Inject dependencies on run time so that I can test them
  2. Injecting different properties (*.properties) which are usually part of src/main/resources
I was wondering how these mechanism are achieved in Akka or if Java EE and Akka play well together.

Thoughts?

Thanks a lot
+ Harit Himanshu

Akka Team

unread,
May 4, 2015, 5:04:46 AM5/4/15
to Akka User List
Hi Harit,

Dependency injection as it is implemented by these frameworks is not as useful with Akka, since actor creation must be always controlled by Akka itself (otherwise supervision would not work). Nevertheless, this post contains some pointers:

http://letitcrash.com/post/55958814293/akka-dependency-injection

-Endre

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Akka Team
Typesafe - Reactive apps on the JVM
Blog: letitcrash.com
Twitter: @akkateam

Chanan Braunstein

unread,
May 4, 2015, 7:07:42 AM5/4/15
to akka...@googlegroups.com
You can still benefit from Dependency Injection and keep supervision working. For example my project: AkkaGuice: https://github.com/chanan/AkkaGuice

You can choose to inject a fully formed actor into your code (with all its dependencies resolved) which will indeed only give you a top level actor, but you can also use the PropsContext which will give you the resolved props of an actor to be used as a child actor.

Chanan. 

Harit Himanshu

unread,
May 4, 2015, 1:01:45 PM5/4/15
to akka...@googlegroups.com
Thanks! I will look at the pointers and keep that suggestion in mind while designing apps

You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/LvIN91H8IZ0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages