rogeralsing/Pigeon — pull request #37 by Aaronontheweb (2014-02-20 21:10:28+00:00)
Title: added a DynamicProps sub-class in order to support Dependency Injection

Not sure how Akka DI support works (they do advertise that they support it), but I tried my hand at implementing it in Pigeon through a DynamicProps subclass.

This class retains its factory function and invokes that instead of using the Activator to spawn new Actor instances.

This is appropriate for long-lived Actors that need to access to `IDisposable` objects like database connections and Streams. In my case, I'm using this for Actors that keep open connections to Cassandra and self-recycle after a period of time.

In order to make this work I had to change some of the Props members to protected and virtual. I could have, in theory, done all of this inside the Props class itself and just used flags to change its `NewActor` and `Copy` behavior, but I felt that this was a cleaner solution.

The `Create(Expression> factory)` will automatically detect what type of expression was used to create this Actor and then will act accordingly.

Thoughts?