dependency-injection

Scheduling of SAS generated codes in SAS DI studio to IBM TWS

Hi Guys, I`m sure some you might have used both SAS DI studio and IBM TWS. Has anone managed to run codes generated in SAS DI studio in TWS scheduler , What are the kind of issues you have faced? And it would be great if you could suggest possible solutions ...

How to do manual DI with deep object graphs and many dependencies properly

I believe this questions has been asked in some or the other way but i'm not getting it yet. We do a GWT project and my project leader disallowed to use GIN/Guice as an DI framework (new programmers are not going to understand it, he argued) so I try to do the DI manually. Now I have a problem with deep object graphs. The object hierar...

StructureMap HowTo: Conditional Construction on Deep Object

I'm having difficulty conditionally creating a dependency. Googling, I have yet to find a good example of using the BuildStack and Conditional Predicates. Here's what I'm doing in the Registry: //snip public SomeRegistry() { this.InstanceOf<IFoo>().Is.Conditional( c => { c.TheDefault.Is.Constru...

Unit testing an MVC action method with a Cache dependency?

I’m relatively new to testing and MVC and came across a sticking point today. I’m attempting to test an action method that has a dependency on HttpContext.Current.Cache and wanted to know the best practice for achieving the “low coupling” to allow for easy testing. Here's what I've got so far... public class CacheHandler : ICacheHan...

How to inject dependencies into HttpSessionListener, using Spring?

How to inject dependencies into HttpSessionListener, using Spring and without calls, like context.getBean("foo-bar") ? ...

Dependency injection and aggregation/association

In both association and aggregation, one class maintains a reference to another class. Then, does constructor injection imply composition? Going by the same logic, is it safe to say that setter injection leads to an association, and not an aggregation? ...

Considerations when architecting an extensible application using MEF

I've begun experimenting with dependency injection (in particular, MEF) for one of my projects, which has a number of different extensibility points. I'm starting to get a feel for what I can do with MEF, but I'd like to hear from others who have more experience with the technology. A few specific cases: My main use case at the momen...

How far does Dependency Injection reach?

My web app solution consists of 3 projects: Web App (ASP.NET MVC) Business Logic Layer (Class Library) Database Layer (Entity Framework) I want to use Ninject to manage the lifetime of the DataContext generated by the Entity Framework in the Database Layer. The Business Logic layer consists of classes which reference repositories (...

How test guice injections?

I gave to Google Guice the responsability of wiring my objects. But, How can I test if the bindings are working well. For example, suppose we have a class A which has a dependence B. How can I test than B is injected correctly. class A { private B b; public A() {} @Inject public void setB(B b) { this.b = b ...

How do I pass values to the constructor on my wcf service?

I wish to pass values into the constructor on the class that implements my service. However ServiceHost only lets me pass in the name of the type to create, not what arguments to pass to it’s contractor. I would live to be able to pass in a “factor” that creates my service object. What I have found so far: WCF Dependency Injection...

Injecting Mockito mocks into a Spring bean

I would like to inject a Mockito mock object into a Spring (3+) bean for the purposes of unit testing with JUnit. My bean dependencies are currently injected by using the @Autowired annotation on private member fields. I have considered using ReflectionTestUtils.setField but the bean instance that I wish to inject is actually a proxy an...

Autowire Annotation in Spring without using Component Scanning

Is it possible to autowire beans using the @Autowired annotation without using component scanning? ...

Best IoC practices in large projects

What techniques have you found useful for managing dependencies of large projects with Inversion of Control containers? Do you bootstrap everything in one place, or do you split it up? Do you ever use multiple containers? ...

What benefits does IOC provide over soft-coding?

Take the following article for example: http://weblogs.asp.net/psteele/archive/2009/11/23/use-dependency-injection-to-simplify-application-settings.aspx?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+dotnetmvp+%28Patrick+Steele%27s+.NET+Blog%29 I don't see what benefit there is from the IOC approach as opposed to th...

Rhino Mocks, Dependency Injection, and Separation of Concerns

I am new to mocking and dependency injection and need some guidance. My application is using a typical N-Tier architecture where the BLL references the DAL, and the UI references the BLL but not the DAL. Pretty straight forward. Lets say, for example, I have the following classes: class MyDataAccess : IMyDataAccess {} class MyBusines...

Exercise 26 of The Pragmatic Programmer

There is a code snippet presented in The Pragmatic Programmer on page 143 as: public class Colada { private Blender myBlender; private Vector myStuff; public Colada() { myBlender = new Blender(); myStuff = new Vector(); } private doSomething() { myBlender.addIngredients(myStuff.elements()); ...

Spring: Inject static member (System.in) via constructor

I wrote some sort of console client for a simple application. To be more flexible, I thought it would be nice to only depend on java.io.Input-/OutputStream, instead of accessing System.in/out directly. I renamed the class ConsoleClient to StreamClient, added setters and made sure that the instance fields are used instead of System.in/ou...

Using IoC and Dependency Injection, how do I wrap an existing implementation with a new layer of implementation without changing existing code so as not to violate the Open-Closed principle?

I'm trying to figure out how this would be done in practice, so as not to violate the Open Closed principle. Say I have a class called HttpFileDownloader that has one function that takes a url and downloads a file returning the html as a string. This class implements an IFileDownloader interface which just has the one function. So all...

Logging exceptions during bean injection

I think this is a pretty basic question, but after Googling around I can't seem to find the answer. What I need is a way to log some custom output with log4j during Spring bean construction. I have a factory class called ResponderFactory (being used as an instance factory in Spring) with a factory method that can throw 2 different types...

Contructor parameters for dependent classes with Unity Framework

I just started using the Unity Application Block to try to decouple my classes and make it easier for unit testing. I ran into a problem though that I'm not sure how to get around. Looked through the documentation and did some Googling but I'm coming up dry. Here's the situation: I have a facade-type class which is a chat bot. It is a s...