dependency-injection

Interface laravel doesn't bind why?

岁酱吖の 提交于 2019-12-13 19:01:00
问题 Hello guys I was creating a package and i was trying to implement a dependency injection on my class without success. I followed all the instruction for do it work. I'm getting crazy on it. When i try to call Player::team_players(2); it throw me an error: Argument 1 passed to Team\Player\Player::__construct() must be an instance of Team\Player\StatusPlayerInterface, none given, called in C:\wamp\www\ultima\workbench\team\player\src\Team\Player\PlayerServiceProvider.php on line 35 and defined

DI Singleton instance vs Transient instance

泄露秘密 提交于 2019-12-13 18:35:35
问题 Several years ago IoC performance guidelines stated IoC containers should be used to resolve only long-lived instances (singletons basically), whereas transient type objects should be created using a singleton factory (held by the container). I am reading now about ASP.NET Core, and several examples I have seen use Transient lifetime for their injected objects. Has something changed where transient is now the preferred method for services that provide static methods (and are stateless)? 回答1:

Pass Context or Activity to adapter using Dagger 2

假如想象 提交于 2019-12-13 17:42:59
问题 I inject an Adapter using Dagger 2 without context and it is working, but I am not able to do when I am passing context parameter. Error is coming like this error: android.content.Context cannot be provided without an @Provides-annotated method. Dagger Component @PerActivity @Component(dependencies = ApplicationComponent.class, modules = MainFragmentModule.class) public interface MainFragmentComponent { void inject(MainFragment mainFragment); @ActivityContext Context provideContext(); }

Whats is the order dependency injection in spring?

老子叫甜甜 提交于 2019-12-13 16:57:02
问题 I have a question regarding spring dependency injection. I need to know whether dependency gets injected in the order in which it has been declared in the XML or there is no order as such. Example : <bean id="empBean" class="com.test.EmployeeBean"> <property name="jdbcTemplate" ref="jdbcTemplate" /> <property name="empAddress" ref="empAddress" /> </bean> Can we guarantee that always jdbcTemplate will be initialized before empName ? Please help 回答1: You cannot guarantee that these will be

Is there a good DI framework suitable for Java 1.4 and SE (Swing) apps?

北战南征 提交于 2019-12-13 16:42:58
问题 I am looking for a dependency injection framework for a Java SE (Swing) application that runs under JDK 1.4. Are there any recommended DI frameworks that I can use? (Guice and other annotation-based frameworks are out, and I don't want to mess with something like Retroweaver.) Also, is Spring suitable for use in a Java SE application? edit: this is a legacy application (which is why it's jdk 1.4) - I want to use spring to get some sanity into the ball of mud 回答1: yes, it is. There is even a

How to create an Http instance without using constructor DI?

半城伤御伤魂 提交于 2019-12-13 16:39:18
问题 For some reason, I don't want to use constructor(private http: Http) DI. Looked at https://angular.io/docs/ts/latest/api/http/index/Http-class.html and tried const injector = ReflectiveInjector.resolveAndCreate([ BaseRequestOptions, XHRConnection, { provide: Http, useFactory: (backend, defaultOptions) => new Http(backend, defaultOptions), deps: [XHRConnection, BaseRequestOptions] } ]); this.http = injector.get(Http); Error says ORIGINAL EXCEPTION: Cannot resolve all parameters for

IOC container working with asp.net mvc 2.0

百般思念 提交于 2019-12-13 16:29:27
问题 Is there any IOC container that already implements a controller factory compatible with asp.net mvc 2.0 ....if so i'll move my projects to 2.0 to test... Anyone know a good reference about it? 回答1: We're using NInject and it works like a charm, too. I compiled it with MVC2 RTM and it works even with that. 回答2: MVCContrib has four different flavors for you ( StructureMap, Windsor, Spring.Net, Unity ) http://github.com/mvccontrib/MvcContrib/tree/mvc2/src/ Here is a direct link to the Unity one:

AngularJS - Dependency injection involving asynchronous data

自闭症网瘾萝莉.ら 提交于 2019-12-13 16:24:57
问题 I want to make the currently logged in user's ID and user name available to my Angular directives. I have created an API end-point to retrieve this information (along with some other information). The problem is that the API call is asynchronous: var url = baseUrl + 'api/sessions'; $http.get(url) I am trying to create a factory that will return the JSON object returned by the API. However, since the call is asynchronous, I don't know how to implement the factory method. Additionally, I don't

Angular 2 dependency injection error on NgFor in dynamically created component

两盒软妹~` 提交于 2019-12-13 16:00:05
问题 I've dynamically created an Angular 2 component using DynamicComponentLoader.loadAsRoot(), and am trying to give it a useful template (involving NgFor), but this is somehow yielding me a ' DI exception ' dependency injection error. I had already injected NgFor itself though, so specifically now it gave me a No provider for IterableDiffers! (NgFor -> IterableDiffers) . So I injected that, which got me to a No provider for Array! (NgFor -> IterableDiffers -> Array) . At this point I got stumped

Is it possible to inject the class requesting injection using Guice?

纵饮孤独 提交于 2019-12-13 15:26:40
问题 I'd like an injected instance of an object to know the name of the class that is requesting its injection. I'm aware that this kind of violates the entire concept of dependency injection, but it seems like a valid use case for supporting useful logging. Is this possible with Guice? Example: class InjectorAware { @Inject public InjectorAware(Class injectorClass){ System.out.println("I was injected into a "+injectorClass.getCanonicalName()); } } class NeedsInjectorAwareField { @Inject