dependency-injection

Symfony2 create a service [closed]

浪尽此生 提交于 2019-12-23 13:16:20
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . There used to be a how-to in the symfony2 doc on how to create a service (my_mailer) but I can't seem to find it anywhere. Can anyone tell me where to find it, or some other tutorial on how to create a service in symfony2 ? 回答1: Service Container - http://symfony.com/doc/current/book/service_container.html

CreationException: Unable to create injector error in Play 2.5.18 in replacement for GlobalSettings Java code using com.google.inject.AbstractModule

落花浮王杯 提交于 2019-12-23 13:09:03
问题 I am upgrading my Play application from 2.5.12 to 2.5.18 and when I start up the application (using sbt ), I am receiving this error: CreationException: Unable to create injector, see the following errors: 1) Error injecting constructor, java.lang.NullPointerException at modules.OnStart.<init>(OnStart.java:15) at modules.Global.configure(Global.java:9) (via modules: com.google.inject.util.Modules$OverrideModule -> modules.Global) while locating modules.OnStart 1 error The rest of the error is

Double injection in AngularJS via ngInject and ng-annotate

对着背影说爱祢 提交于 2019-12-23 13:03:48
问题 I'm using Gulp to build my main javascript file (app.js) for an AngularJS application. Everything is working fine except for one small thing that is bothering me. I am using ng-annotate to automatically parse my angular js and add dependency injection syntax. So I went from this (manual injection without using ng-annotate): angular.module('base.controllers') .controller('RandomeCtrl', ['$scope', '$routeParams', ..., function($scope, $routeParams, ...) { To this (code that will be modified

Ninject: give the parent instance to a child being resolved

旧城冷巷雨未停 提交于 2019-12-23 13:03:21
问题 I have this class hierarchy: public interface ISR { } public interface ICU { } public interface IFI { } public class CU : ICU { } public class SR : ISR { public SR(IFI fi) { FI = fi; } public IFI FI { get; set; } } public class FI : IFI { public FI(ISR sr, ICU cu) { SR = sr; CU = cu; } public ISR SR { get; set; } public ICU CU { get; set; } } public class Module : NinjectModule { public override void Load() { Bind<ISR>().To<SR>(); Bind<ICU>().To<CU>(); Bind<IFI>().To<FI>(); } } class Program

Issue Wiring an EntityManager from EntityManagerFactory

只愿长相守 提交于 2019-12-23 12:51:58
问题 I know spring has it's own object factories for JPA but I want to just get this working as is... From there I will investigate best practice. I am just in the understanding process. This is the actual code I am trying to produce beans for: EntityManagerFactory emf = Persistence.createEntityManagerFactory("test"); EntityManager em = emf.createEntityManager(); What I have to get it working (but isn't working) ( Edit : note myFactoryBean compiles without issue emf is the culprit): <?xml version=

Dependency Injection into Entity Class

非 Y 不嫁゛ 提交于 2019-12-23 12:51:05
问题 Using Asp.Net Core we can make use of Dependency Injection in controllers/repositories. However, I wish do do some logging in my Entity Class. class Person { private ILogger<Person> _logger; private List<Pets> pets; public Person(ILogger<Person> logger) { _logger = logger; } public bool HasCat() { _logger.LogTrace("Checking to see if person has a cat."); // logic to determine cat ownership hasCat = true; return hasCat; } } When the Person class is instantiated by EntityFramework it does not

DryIOC Container configuration for property injection

∥☆過路亽.° 提交于 2019-12-23 12:36:12
问题 I have search far and wide for a simple example of how to configure a DryIoc container to simply inject dependencies as properties the same way that it injects constructor args. Given the following working example... Container registration: public static void Register(HttpConfiguration config) { var c = new Container().WithWebApi(config); c.Register<IWidgetService, WidgetService>(Reuse.Singleton); c.Register<IWidgetRepository, WidgetRepository>(Reuse.Singleton); } Widget Service: public class

Can I access semantic configuration in a compiler pass?

。_饼干妹妹 提交于 2019-12-23 12:11:13
问题 I have semantic configuration for a bundle that needs to be interpreted during a compiler pass for the same bundle. Is it possible to access it without storing it in an intermediate container variable? 回答1: Yes, kind of: <?php namespace Acme\DemoBundle\DependencyInjection; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; class CompilerPass implements CompilerPassInterface { public function process

Why do Dagger components have to declare their scope?

人走茶凉 提交于 2019-12-23 12:02:52
问题 Why do I have to annotate a Dagger component with the scopes it's going to use? Why is it not enough to annotate the class itself? 回答1: Because scopes by themselves don't mean anything. It's the components and their relationships that introduce meaning to scopes. Unscoped objects can be provided from any component if their dependencies are available. Since they are unscoped there will be a new object created every time that you call their provider. A scoped object will share the lifecycle of

Order of dependency injection when using scopes

守給你的承諾、 提交于 2019-12-23 11:56:07
问题 I'm currently trying to figure out Dagger 2. I am trying to set up 4 scopes: App, User, Activity, Fragment. User and Activity components are Subcomponents of App. Fragment is a Component with Activity as its dependency. Say my UserSettingsActivity needs a Toolbar (provided by ActivityModule), and a UserProfile (provided by UserModule). I won't get a UserProfile until I ask for it from the database, whereas the Toolbar can be provided right away. So the order of injection that takes place is