dependency-injection

Injecting a static EJB, nonsense?

走远了吗. 提交于 2020-01-19 05:51:47
问题 I want to write this piece of code : @Stateless public class MyEjb { @EJB private static MyOtherEjbWhichIWantStatic myOtherEjb; } It makes sense to me, that I want to inject an EJB in my class, as a static element, for various reason. Java is not very happy with that unfortunately com.sun.enterprise.container.common.spi.util.InjectionException: Illegal use of static field private static MyOtherEjbWhichIWantStatic myOtherEjb on class that only supports instance-based injection I don't get it,

Zend AMF custom dispatcher

落花浮王杯 提交于 2020-01-17 09:33:09
问题 Is it possible to use a custom dispatcher when using Zend_AMF? I know I can pass either a class name or an object to setClass() for Zend_AMF. However, when I pass an object to setClass, it does not seem to store a copy of that object. Instead it worksout the class name and then instantiates a copy of the object itself. This is a problem as I use the yadif dependency injection container. Objects should be instantiated with constructor dependencies and/or property dependencies. Since the Zend

Injecting new constructor parameters every time a type is resolved using unity

不打扰是莪最后的温柔 提交于 2020-01-17 06:58:28
问题 I've just come across an issue recently where I want new types injected into the requested type every time it is resolved. The current code I have to register the type is container.RegisterType<IFirstT, FirstT>(); container.RegisterType<ISecondT, SecondT>(); container.RegisterType<IInjectableT, InjectableT>() .Configure<InjectedMembers>() .ConfigureInjectionFor<InjectableT>( new InjectionConstructor( container.Resolve<IFirstT>(), container.Resolve<ISecondT>(), ) ); I've now come to realise

ASP.Net vNext DbContext Dependency Injection multiple request issues.

拟墨画扇 提交于 2020-01-17 05:54:38
问题 I am attempting to use ASP.Net vNext, MVC, EF7, and the repository pattern (not the issue here, I don't think)... The issue I'm having is that when multiple requests are made against the database, I'm getting the following error: "There is already an open DataReader associated with this Command which must be closed first." Here's some code: public class Startup { public IConfiguration Configuration { get; set; } public Startup(IHostingEnvironment env) { Configuration = new Configuration()

Injecting a property into a singleton service in Prism (Unity, MVVM)

删除回忆录丶 提交于 2020-01-17 04:26:45
问题 For reference, I have a service that I want to register as a singleton in the unity container. I want this service to have the IEventAggerator injected into the service somehow, either by property or constructor injection. public class BeckhoffService: IProgrammableLogicController { ...} and I'll either want this: [Dependency] public IEventAggregator eventAggregator{get;set;} or in the constructor: BeckhoffService(IEventAggregator eventAggregator) My issue comes when I register this service

How to resolve Dependency within Dependency

…衆ロ難τιáo~ 提交于 2020-01-17 04:11:10
问题 I have 4 Projects in a solution DAL_Project BLL_Project Interface_Project WebApi_Project Interface_Project has two interfaces ICar_DAL and ICar_BLL DAL_Project has a class Car_DAL that implements ICar_DAL BLL_Project has a class Car_BLL that implements ICar_BLL and its constructor takes in ICar_DAL WebApi_Project has an api controller CarApiController and its constructor takes in ICar_BLL the dependency resolution of WebApi Controller's constructor is done by Unity.WebApi using this in

Custom Membership provider & MVC 4

妖精的绣舞 提交于 2020-01-17 03:52:47
问题 Continue from this solution : How to configure Ninject for MVC4 & custom Membership provide? I declare public interface IUserRepository : IRepository<UserModel> { MembershipUser CreateUser(string username, ... , string providername = null); void Logout(); Boolean Login(string userName, string Password, bool persistCookie = false); bool RegisterUser(UserModel user); } And implement within UserRepository public class UserRepository : RepositoryBase<MyDbContext, UserModel>, IUserRepository {

Spring Injection not working if i use “implements” in class

戏子无情 提交于 2020-01-16 18:32:18
问题 This was my previous SO question Spring Injection not working in different service class @Service("securityService") @Transactional public class SecurityService implements UserDetailsService { protected static Logger logger = Logger.getLogger("service"); @Autowired public RegistrationDAO registrationDAO; public String test(){ logger.debug(registrationDAO.findUserByID(1) ); return "test"; } In above code registrationDAO is not properly injected and give null pointer exception but Now i have

Getting a “WELD-001408 Unsatisfied dependencies error when deploying a class injected with an interface”

孤街醉人 提交于 2020-01-16 13:17:09
问题 I'm doing some unit tests using Arquillian on JUnit4 and Jboss6. There is a facade(SomeFacadeclass) that has the "SomeClass"(which is an interface) injected to it. When Arquillian deploys the test.war for testing the above deployment error pops up. What should i do to solve this? 回答1: I would guess that you don't have an implementation of SomeClass in your bean archives 回答2: Everything was solved. I added the implementation class to the @Deployment archive and some other bunch of dependent

Unable to resolve service for type Microsoft Extensions Configuration IConfiguration

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-16 08:24:05
问题 I am getting this error, could not understand for the life of me. Unable to resolve service for type 'Microsoft.Extensions.Configuration.IConfiguration' while attempting to activate 'Microsoft.FeatureManagement.ConfigurationFeatureSettingsProvider'. This is a simple .net core 2.2 console app, with the following nuget packages added. Microsoft.Extensions.Configuration.Json Microsoft.Extensions.DependencyInjection Microsoft.FeatureManagement using System; using System.Threading.Tasks; using