At my company we want to start using a dependency injection (DI) framework for managing our dependencies. I have some difficulty with explaining the business value of such a framework. Currently I have come up with these reasons.
Less source code, delete all the builder patterns in the code.
Increase in flexibility. Easier to switch de...
I just usually do applications for myself as a hobby. It looks like DI frameworks have a big momentum in the community, so I thought maybe I should learn it to improve my coding skills. From what I understand, it seems to be geared more towards big projects. Is it still a good idea to use it for example in a 5k lines project?
Thanks
...
I'm trying to use @Autowired annotation with my generic Dao interface like this:
public interface DaoContainer<E extends DomainObject> {
public int numberOfItems();
// Other methods omitted for brevity
}
I use this interface in my Controller in following fashion:
@Configurable
public class HelloWorld {
@Autowired
pri...
Hi all,
I have a issue with my Spring.Net configuration where its not injecting an object. I have a CommService to which an object named GeneralEmail is injected to. Here is the configuration:
<!-- GeneralMail Object --> <object id="GeneralMailObject" type="CommUtil.Email.GeneralEmail, CommUtil">
<constructor-arg name="host" value="...
I have an existing object hierarchy where some objects have fields that need to be injected. Also there are some other objects that are constructed using Google Guice and need to be injected with references to some objects from previously described object hierarchy. How do I do such kind of injection with Guice?
The problem is that obje...
Is it good practice to have a Factory method to retrieve injected objects or is it OK to just use the factory method from the DI framework?
I'm using structure map, should I just use ObjectFactory.GetInstance();, or should I create factory class and inside this class call ObjectFactory.GetInstance();? because if I call ObjectFactory.Get...
Is it ok to have a static field in my controller for my modelbinder to call ?
Eg.
public class AuctionItemsController : Controller
{
private IRepository<IAuctionItem> GenericAuctionItemRepository;
private IAuctionItemRepository AuctionItemRepository;
public AuctionItemsController(IRepository<IAuctionItem> genericAuctionIt...
I have a singleton that has a spring injected Dao (simplified below):
public class MyService<T> implements Service<T> {
private final Map<String, T> objects;
private static MyService instance;
MyDao myDao;
public void set MyDao(MyDao myDao) {
this. myDao = myDao;
}
private MyService() {
this.ob...
Take Java syntax as an example, though the question itself is language independent. If the following snippet takes an object MyAbstractEmailTemplate as input argument in the method setTemplate, the class MyGateway will then become tightly-coupled with the object MyAbstractEmailTemplate, which lessens the re-usability of the class MyGatew...
I am using Spring for the first time and must be doing something wrong. I have a project with several Bean implementations and now I am trying to create a test class with Spring Test and JUnit. I am trying to use Spring Test to inject a customized bean into the test class.
Here is my test-applicationContext.xml:
<?xml version="1.0" e...
Basically in my Global.asax code I have the following IKernel property for Ninject setup like this (Also taking advantage of Microsoft.Practices.ServiceLocation). This Container is automatically called upon once it seems on the CreateKernel() override:
protected override IKernel CreateKernel()
{
return Container;
...
I have in my applicationContext.xml
<context:property-placeholder location="classpath*:*.properties" />
<bean id="clientPreferencesManager" class="pl.bildpresse.bildchat2.business.ClientPreferencesManager" >
<property name="clientApiUrl" value="${clientapi.url}" />
</bean>
Is it possible to do the same by autowire ? Somethi...
I'm using a UserNamePasswordValidator in WCF along with Unity for my dependency injection, but since WCF creates the instance of the UserNamePasswordValidator, I cannot inject my container into the class. So how would one go about this?
The simplest solution I can think of is to create a static proxy/wrapper class around a static insta...
Given registered services:
builder.RegisterType<Foo1>().Named<IFoo>("one").As<IFoo>();
builder.RegisterType<Foo2>().Named<IFoo>("two").As<IFoo>();
builder.RegisterType<Foo3>().Named<IFoo>("three").As<IFoo>();
Can I retrieve named implementations of IFoo interface by injecting something like Func<string, IFoo> ?
public class SomeClass...
Hi,
I am trying to learn about dependency injection and i'm using the unity application block to help.
What I want to do is, have a console app that will register a class (as long as it implements a specific interface) and execute a method...
So the method on the class that implements the method will be executed.
Hope that makes sense...
Hi,
I was reading somewhere that with MEF I can simply drop a dll into a directory and my application (with some MEF magic) will be able to read it and execute the code in it?
Hopefully only classes that implement an interface that I define??
Can someone help me to get going, with some links maybe for my problem.
I've looked through so...
Let's say I have an User entity and I would want to set it's CreationTime property in the constructor to DateTime.Now. But being a unit test adopter I don't want to access DateTime.Now directly but use an ITimeProvider :
public class User {
public User(ITimeProvider timeProvider) {
// ...
this.CreationTime = timeProv...
I'm looking into Guice and I've been reading its documentation recently.
Reading the motivation section I don't understand the factories part, why they name it that way. To me that factory is just a wrapper for the implementing class they want it to return after calling getInstance().
public class CreditCardProcessorFactory {
privat...
I'd like to be able to specify that an object's member variables are immutable once the object has been "initialized", which to me means after it has been injected with any dependencies, and has performed any other initialization operations that it can only perform after DI.
Are there languages that satisfy my interest - that formalize ...
I've raised this question before but am still struggling to find an example that I can get my head around (please don't just tell me to look at the S#arp Architecture project without at least some directions).
So far I have achieved near persistance ignorance in my web project. My repository classes (in my data project) take an ISession...