dependency-injection

Requested bean is currently in creation: Is there an unresolvable circular reference?

久未见 提交于 2019-12-17 17:53:34
问题 i am using spring 3, and i have two beans of view scope: 1- Bean1: @Component("bean1") @Scope("view") public class Bean1 { @Autowired private Bean2 bean2; } 2- Bean2: @Component("bean2") @Scope("view") public class Bean2 { @Autowired private Bean1 bean1; } the view is a custom scope: <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer"> <property name="scopes"> <map> <entry key="view"> <bean class="${project.groupId}.utils.ViewScope" /> </entry> </map> </property> <

Ways of keeping configuration code out of logic code using Dependency Injection

核能气质少年 提交于 2019-12-17 17:39:25
问题 How can keep all the configuration file code out of my logic code using Settings (ApplicationSettingsBase) and Dependency Injection? With configuration I mean a customer specific configuration file. Do I really have to inject a configuration class everytime I need it or is there another pattern? It would be great to get some sample code! Samples: Static Configuration: public static class StaticConfiguration { public static bool ShouldApplySpecialLogic { get; set; } public static string

Android MVVM Design Pattern Examples

穿精又带淫゛_ 提交于 2019-12-17 17:19:12
问题 I currently do a lot of WPF development and have started creating some basic Android apps. When creating WPF apps I often use MVVM, normally using Prism, and would like to know if there are any examples of MVVM for the Android platform? 回答1: I am the developer of Android-Binding. Like @Brentley said, it's a very new project but I do hope to get more buzz and experience so that it can be improved. Back to your question, I have written some simple introduction/tutorials on MVVM with android

Custom ResourceProviderFactory Dependency Injection

喜你入骨 提交于 2019-12-17 16:37:17
问题 Is there anywhere in ASP.NET MVC where you can get a reference to the ResourceProviderFactory that is instantiated in order to perform Property Injection to add a custom DB Implementation to retrieve the resources from? I have a custom resource provider being loaded but I wanted to know whether there was an alternative to using a Static DI container to inject the dependency within the Provider. Similar to how you can inject for the Role and Membership providers in MVC. 回答1: The trick is to

I'm confused about interface abstractions when using IoC

让人想犯罪 __ 提交于 2019-12-17 16:28:12
问题 I've recently been trying to learn IoC, and have a couple questions based on the following code: public class WarriorModule : NinjectModule { public override void Load() { Bind<IWeapon>().To<Sword>(); Bind<Samurai>().ToSelf(); } } I'm having trouble grasping the new concept of interfaces. Before I would create an interface such as IRunnable , implementing the function void Run() . With IoC, I'm now viewing an interface as something that only maps to a single concrete class. Assuming that, how

Angular2 DI - initializing multiple different instances in the same constructor

半城伤御伤魂 提交于 2019-12-17 16:24:13
问题 I have an Angular2 DI question. Say I have a TestService and I want to use 2 different instances of this service inside the same component. If I simply add a provider to the component and I add the 2 instances to the constructor I end up with the same service instance. For example: TestService import {Injectable} from "@angular/core"; @Injectable() export class TestService { public id: number = Math.random(); public toString(): string { return "Id: " + this.id; } } Test component import

Dependency Injection with Custom Membership Provider

坚强是说给别人听的谎言 提交于 2019-12-17 16:08:02
问题 I have an ASP.NET MVC web application that implements a custom membership provider. The custom membership provider takes a UserRepository to its constructor that provides an interface between the membership provider and NHibernate. The UserRepository is provided by the Ninject IoC container. Obviously, however, this doesn't work when the provider is instantiated by .NET: the parameterless constructor does not have a UserRepository and cannot create one (the UserRepository requires an

Castle Windsor passing constructor parameters

妖精的绣舞 提交于 2019-12-17 15:58:09
问题 I have an IAddress class with a few properties. I then have a concrete type that implements this interface. This concrete type has a couple of different constructors I could use. How can I pass parameter values to one of these constructors at run-time? I cannot use the config file as I will be reusing this concrete type multiple times and each time the parameter values will be different. IWindsorContainer container = new WindsorContainer(new XmlInterpreter()); IAddress address = container

Spring Dependency Injection Autowiring Null [duplicate]

巧了我就是萌 提交于 2019-12-17 15:58:08
问题 This question already has answers here : Why is my Spring @Autowired field null? (16 answers) Closed 3 years ago . I was able to use RestTemplate and autowire it. However I want to move my rest template related part of code into another class as follows: public class Bridge { private final String BASE_URL = "http://localhost:8080/u"; @Autowired RestTemplate restTemplate; public void addW() { Map<String, String> x = new HashMap<String, String>(); W c = restTemplate.getForObject(BASE_URL + "

Angular2 DI in Typescript. Can we use it in node.js / non-angular projects?

偶尔善良 提交于 2019-12-17 15:54:26
问题 Was the angular2 dependency injection container designed for standalone use, and is it possible to use it for typescript/javascript server-side applications ? I opened an issue on Oct. 16 (https://github.com/angular/di.js/issues/108) on the di project which was I guess supposed to make it into v2. Apparently this was not possible. What's up with the new angular2 di ? Can I use it in a standalone fashion with js / es6 / ts projects? 回答1: Seems someone has extracted dependency injection from