dependency-injection

integrating GWT with CDI (Seam/Weld)

倖福魔咒の 提交于 2019-12-12 20:30:24
问题 What's the best way to integrate CDI with GWT? In particular, I'd like to know how to make dependency injection work for my RemoteServiceServlet extensions. Apparently CDI won't work with classes derived from javax.servlet.Servlet. I'm happy to ditch RemoteServiceServlet if there is an alternative. I don't really need DI on the GWT client-side, but would happily use it if it Just Worked. 回答1: It turns out to be a bug in Weld, which is already fixed in version 1.1.0. Intellij IDEA X also has

How do i use WindsorInstaller across multiple assemblies for registration

人走茶凉 提交于 2019-12-12 19:23:47
问题 I am using Castle Windsor to handle my Dependency Injection and it has been working great up until now. However, i am now trying to extend my project and add some additional libraries - im now struggling to figure the best way to leverage Castle. I currently have the following assemblies MyProject.Interfaces (contains IDBContext interface) MyProject.BusinessLogic (contains the Castle Windsor implementation) MyProject.DataAccess (contains implementation of IDBContext) I currently have an

Failed to execute goal org.codehaus.mojo exec-maven-plugin

余生颓废 提交于 2019-12-12 17:23:17
问题 I have an issue that I spend 5 days without resolving it: When executing mvn exec:java it fails to correctly parse the configuration arguments, throwing the following error: "Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.1:java (default-cli) on project poll-translator: An exception occured while executing the Java class. null: InvocationTargetException: Error creating bean with name 'serviceLocator' defined in class path resource [META-INF/dsol/dsol.xml]: Cannot resolve

Inject a Class<T> with GIN

有些话、适合烂在心里 提交于 2019-12-12 17:03:51
问题 Is there a way to inject a class type Class<T> in gin? I can't seem to get it working, for example: class GenericFoo<T> { private final Class<T> klass; @Inject public GenericFoo(Class<T> klass) { this.klass = klass; } } class Bar { } with an instance injected somewhere: .. @Inject GenericFoo<Bar> instance; .. and a GinModule containing something along the lines of: bind(new TypeLiteral<Class<Bar>>() {}).to(Bar.class); Thanks 回答1: It's not possible. Reflection is forbidden on the client side,

Should injected dependencies be publicly accessible or private?

本小妞迷上赌 提交于 2019-12-12 16:55:11
问题 Should dependencies be stored to private fields or properties with private setters and public getters? This applies to constructor DI. To be clear, in the property example, I would not expect these to be added to an accompanying interface unless it made sense - i.e. they would only be visible in the implementation type: interface IFoo { void DoSomething(); } class Foo : IFoo { private readonly IService dependency; public Foo(IService dependency) { this.dependency = dependency; } } class Bar :

How not to use the default constructor using the MVVM UI Pattern?

做~自己de王妃 提交于 2019-12-12 16:51:33
问题 Using DI in a WPF application along with the MVVM UI Architecture Design Pattern. When setting the Window.DataContext property, the compiler complains: The type [("my view model type")] does not include any accessible constructors. Which had to be that there was no default constructor set in my view model class. ProductManagementViewModel public class ProductManagementViewModel : ViewModel<ObservableCollection<Product>, Product> { public ProductManagementViewModel(ObservableCollection<Product

ASP.NET MVC3 - Use DependencyResolver AND Windsor Castle: Why?

可紊 提交于 2019-12-12 16:31:32
问题 Can somebody shine a little light for me? I've got my website all running using Windsor Castle. I have a controller factory and installers for controllers and services. All nice. Now I've just created a IDependencyResolver implementing class called WindsorDependencyResolver with a straigh-forward implementation: public class WindsorDependencyResolver : System.Web.Mvc.IDependencyResolver { private readonly IKernel _kernel; public WindsorDependencyResolver (IKernel kernel) { _kernel = kernel; }

Is there a way to add an httpModule when webApi is running with the HttpSelfHostServer?

為{幸葍}努か 提交于 2019-12-12 16:19:07
问题 I have a MVC4 webapi controller. It has no parameter-less constructors. So, i use Windsor dependency resolver and everything is fine when work under System.Web.Http.WebHost. But, when I try to use HttpSelfHostServer, i get the exception message: Looks like you forgot to register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule To fix this add <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" /> to the

How do I create Constructor Subscription in vNext Dependency Injection

时光毁灭记忆、已成空白 提交于 2019-12-12 16:17:43
问题 I am experimenting with a throwaway vNext application. What I'm trying to do is create a dummy class called 'DataService' which will return some data, and then create objects which use DI to take an IDataService parameter as the constructor. So my IDataService/DataService definitions are: public interface IDataService { DateTime Created { get; } } public class DataService : IDataService { private DateTime created = DateTime.Now; public DateTime Created { get { return created; } } } In my

How to inject dependencies through Scala Reader from Java code

北城以北 提交于 2019-12-12 16:16:56
问题 Here is a dependency service: public class Service1 {} Scala code that uses it via reader: object TupleEx { type FailFast[A] = Either[List[String], A] type Env[A] = ReaderT[FailFast, Service1, A] import cats.syntax.applicative._ import cats.instances.either._ def f:Env[Int] = 10.pure[Env] } Java test where I try to inject Service1: @Test public void testf() { Service1 s = new Service1(); TupleEx.f().run(s); } I am getting an exception: Error:(10, 16) java: method run in class cats.data