Does an MEF ObjectBuilder exist for NServiceBus at the moment?
Check out this thread where Chris Ortman attached an ObjectBuilder for MEF:
nservicebus-mef-support
Here is the current list, and MEF is not one of them:
AutoFac
Castle Windsor
Spring
StructureMap
Unity
Ninject - this came through very recently
Related
I am trying to inject a UnitOfWork into my repositories using Guice in Play. I am trying to configure the UnitOfWork to be RequestScoped, but there does not seem to be a way to do this.
I have googled and been on stack overflow for a while now and have not come across a clear answer for this. What is the state of RequestScoped for Play in 2019?
Play Framework is Stateless by default. From its Web Page:
Play is based on a lightweight, stateless, web-friendly architecture.
So everything that you inject with Guice is created newly.
There is an exception if you annotate a class with Singleton then this class will be injected only once per Node.
All,
There has been a lot of posts about Unity Lifetime Managers but I have yet to find someone state a good rule of thumb for "in these cases you should always use X". Let me describe my application, I have an ASP.NET MVC 4 Web Application. I have a Visual Studio solution containing 3 projects, my 'Core' project which has all of my EF stuff, a testing project, and the MVC Web Project. I am using Unity for dependency injection and have the following code right now:
// Context
container.RegisterType<IDatabaseFactory, DatabaseFactory>(
new ContainerControlledLifetimeManager();
container.RegisterType<UnitOfWork>(
new ContainerControlledLifetimeManager());
However, I'm noticing that my context is not recreated with every new web request which is what I think I would want (let me know if I'm wrong in that assumption). I'm having a hard time analyzing all of the information from the sites listed below and have read about a lot of people creating their own class named PerHttpRequestLifetimeManager to handle this.
What truly is the best practice here?
Understanding Lifetime Managers by Microsoft's Developer Network - http://msdn.microsoft.com/en-us/library/ff660872(v=PandP.20).aspx
MVC DI & Unity with Lifetime Manager via CodeProject - http://www.codeproject.com/Articles/424743/MVC-DI-Unity-with-Lifetime-Manager
ASP.NET MVC Tip: Dependency Injection with Unity Application Block via Shiju Varghese's Blog - http://weblogs.asp.net/shijuvarghese/archive/2008/10/24/asp-net-mvc-tip-dependency-injection-with-unity-application-block.aspx
MVC, EF - DataContext singleton instance Per-Web-Request in Unity via Stack Overflow - MVC, EF - DataContext singleton instance Per-Web-Request in Unity
Inject same DataContext instance across several types with Unity via Stack Overflow - Inject same DataContext instance across several types with Unity
Yes, you usually want one DbContext per request.
A PerHttpRequestLifetimeManager or child container created on every request are the typical ways this is handled.
The latest release of Unity introduces the Unity bootstrapper for ASP.NET MVC which has a new built-in lifetime manager: PerRequestLifetimeManager.
You can read more in the Developer's Guide to Dependency Injection Using Unity chapter 3, Dependency Injection with Unity.
I'm a Gwt beginner. My remote service implementation now uses a DAO.
For the sake of example, I'm creating it myself:
StocksDAO myDao = new StocksDAO();
Now I was thinking to add Spring IOC for injecting it.
Then I came across this GUICE framework... it can be interesting but...
How to quick start? Is there a simple tutorial over the web suitable to my simplicity example?
GWT remote service is implemented as a Servlet. To use Guice with Servlets, look at the docs: http://code.google.com/p/google-guice/wiki/Servlets
Also, this has been discussed earlier: GWT Guice/Gin on the server side problem
Have a look at the sample application which will demonstrate use of Guice with GWT specifically with Request Factory.
http://code.google.com/p/guice-gwt/
I'm using Entity Framework and the Unity as IoC. I want to use constructor injection within entities with ability to configure them from both config and run-time. I don't want to use the injection via properties. I want to make it the way so I don't need and any handlers in object context that supports injection for my entities. This sample I consider as the last resort Sample but I hope there are other ways to implement this. There may be some extensions to the Unity or other IoC so that ObjectContext could resolve dependencies on its own.
thanks in advance.
use [Dependency] attribute for you constructor
see Unity 2 documentation in codeplex or msdn
Is Spring.NET a good framework to use in web development?
Are there alternatives?
Update (for Frederik):
Are there drawbacks when using Spring.NET (or IoC container) in Web Development. I always used spring.actionscript in client side flex applications, but client applications aren't the same as Web Applications.
Is there a Microsoft IoC Containter Framework?
How does it handle concurrency?
As a Spring.NET committer I am biased of course, but Spring.Web was entirely built and refined out of our own needs over the past years. Imho it provides the broadest support compared to other containers when it comes to WebForms development. MVC support is still TDB though.
Spring.NET itself also is entirely thread-safe. Of course your own singleton implementations need to be threadsafe, if not you can always use "request" scope.
hth,
Erich
"Is there a Microsoft IoC Containter Framework?"
- Yes, it's called Unity
Is it a good framework ? Depends on your requirements.
Are there alternatives ? Yes.
(Castle Windsor, StructureMap, PicoContainer, ...).
Google can show you the way ...