dependency-injection

Symfony2: Inject current user in Service

删除回忆录丶 提交于 2019-12-29 18:34:30
问题 I am trying to inject the currently logged in user into a service. My goal is to extend some twig functionality to output it based on user preferences. In this example I want to output any date function using the user specific Timezone. There doesn't seem to be any way to inject the current user into a service, which seems really odd to me. When injecting the security context, it doesn't have a token even if the user is logged in I am using FOS user bundle. services: ... twigdate.listener

Property injection in custom membership provider using Castle

给你一囗甜甜゛ 提交于 2019-12-29 09:04:25
问题 So far in reading about possibilities of injection to custom membership providers, I've found two possible ways to do it: One is the following: http://bugsquash.blogspot.com/2010/11/windsor-managed-membershipproviders.html Here the author basically suggests to register your custom provider and then have a rather questionable windsor adapter for membership (I don't really like the way in which it instances your provider using a container it gets from HttpApplication , which it ultimately wraps

Inject not working for nested objects[Jersey 2.22.1]

巧了我就是萌 提交于 2019-12-29 08:14:09
问题 I have a Jersey resource with a facade object injected. This is configured in my ResourceConfig and the facade gets injected fine. The facade contains a DAO class which also should be injected and is configured in the same ResourceConfig . Now to my problem; the DAO class is null. Thus, not injected. @ApplicationPath("/service") public class SystemSetup extends ResourceConfig { public SystemSetup() { packages(false, "com.foo.bar"); packages("org.glassfish.jersey.jackson"); register

Inject not working for nested objects[Jersey 2.22.1]

爷,独闯天下 提交于 2019-12-29 08:14:08
问题 I have a Jersey resource with a facade object injected. This is configured in my ResourceConfig and the facade gets injected fine. The facade contains a DAO class which also should be injected and is configured in the same ResourceConfig . Now to my problem; the DAO class is null. Thus, not injected. @ApplicationPath("/service") public class SystemSetup extends ResourceConfig { public SystemSetup() { packages(false, "com.foo.bar"); packages("org.glassfish.jersey.jackson"); register

Dagger 2 Named cannot be provided without a @Provides method

☆樱花仙子☆ 提交于 2019-12-29 07:32:10
问题 Trying to grok Dagger 2 and having an issue with named providers. I have a simple setup as follows: // Module @Module class AppModule(private val app: App) { @Provides @AppScope fun providesApp() = app @Provides @AppScope fun provideSharedPreferences(app: App) = PreferenceManager.getDefaultSharedPreferences(app) @Provides @AppScope @Named("Uri1") fun providesUri1() = Uri.Builder().scheme("https").authority("authory1").build() @Provides @AppScope @Named("Uri2") fun providesUri2() = Uri.Builder

Difference between Reflective Injector and Injector in Angular

你说的曾经没有我的故事 提交于 2019-12-29 07:18:18
问题 I tried to create dependency explictly using two ways. Both are almost same but I am little bit confusing what's the advantage of using Reflective Injector over the normal Injector and which one is recommended way? Using Injector import { Injector } from '@angular/core'; constructor( private injector: Injector) { this.myService = this.injector.get(MyService); } Using Reflective Injector import { ReflectiveInjector } from '@angular/core'; constructor() { var injector= ReflectiveInjector

Anyway to @Inject/@Autowire an inner class into an outer class?

雨燕双飞 提交于 2019-12-29 06:28:51
问题 In Spring/JSR-330, is there a way to properly declare an inner class which requires dependency injection, such that I can inject it into the outer class? For example: @Component public class TestClass{ // How to declare this class? private class TestClassInner{ @Autowired private SomeBean somebean; public boolean doSomeWork(){ return somebean.doSomething(); } } // Inject the inner class here in the outer class such that the outer class can use an instance of it @Autowired TestClassInner

Ninject passing in constructor values

妖精的绣舞 提交于 2019-12-29 05:55:29
问题 With Ninject, how do you configure the kernel so I can define what constructor values are passing into the instantiation of an object? I have the following configured in a module: Bind<IService1>() .To<Service1Impl>() .InSingletonScope() .Named("LIVE"); Bind<IService2>() .To<Service2Impl>() .InSingletonScope() .Named("LIVE") .WithConstructorArgument( "service1", Kernel.Get<IService1>("LIVE")); Service2Impl takes a constructor parameter of IService1 but I want this to come from the container.

Symfony2: Injecting @security.context to get the current user. How to avoid a “ServiceCircularReferenceException”? Inject the whole container? [duplicate]

六眼飞鱼酱① 提交于 2019-12-29 05:37:05
问题 This question already has answers here : Injecting SecurityContext into a Listener prePersist or preUpdate in Symfony2 to get User in a createdBy or updatedBy Causes Circular Reference Error (4 answers) Closed 5 years ago . Coming from this post and after fix things I'm in another issue/security question/problem. As yours may see in the other post I'm trying to inject security context in the listener but if I leave the code intact without touch I got this error:

Castle Windsor - Injecting IActionInvoker Implementation Issue

回眸只為那壹抹淺笑 提交于 2019-12-29 05:34:13
问题 I am trying to use the approach from this article, but I am missing something - I am currently getting an error within WindsorControllerFactory.GetControllerInstance when it tries to resolve IActionInvoker since WindsorActionInvoker has a dependency on IWindsorContainer. Given that WindsorControllerFactory already has a reference to IWindsorContainer, could I pass that reference in? If so - how? The only examples I have found are about passing value types as constructor parameters, not