dependency-injection

Simpleinjector: Is this the right way to RegisterManyForOpenGeneric when I have 2 implementations and want to pick one?

爱⌒轻易说出口 提交于 2019-12-18 17:26:16
问题 Using simple injector with the command pattern described here and the query pattern described here. For one of the commands, I have 2 handler implementations. The first is a "normal" implementation that executes synchronously: public class SendEmailMessageHandler : IHandleCommands<SendEmailMessageCommand> { public SendEmailMessageHandler(IProcessQueries queryProcessor , ISendMail mailSender , ICommandEntities entities , IUnitOfWork unitOfWork , ILogExceptions exceptionLogger) { // save

@EJB annotation vs JNDI lookup

有些话、适合烂在心里 提交于 2019-12-18 17:25:14
问题 Is there any situation where it's better to use JNDI than to inject a stateless session bean using the @EJB annotation? We're using JSF 1.2 with Sun Application Server 9.0_01. Our team is debating which approach is better when using SLSBs in a Managed Bean. I've read the following questions, but was wondering if there was a situation where lookup is preferred. EJB3 - obtaining bean via injection vs lookup - what are the differences, implications, gotchas? @EJB injection vs lookup -

What is the best way of using NLog with MEF?

旧时模样 提交于 2019-12-18 16:59:14
问题 I am wondering what is the best way to use NLog with Managed Extensibility Framework (MEF)? I have an application that support plugins using MEF architecture (Import and Exports etc) I want to add logging capability to my application. As a logging component I want to use NLog. What would you recommend? 1. Create a wrapper for NLog, i.e. additional plugin that configures NLog and exports functions like void Log(string level, string message) that other plugins importing 2. Every plugin should

Instance per matching lifetime scope, with default?

折月煮酒 提交于 2019-12-18 16:53:15
问题 I'd like to have an instance per matching lifetime scoped registration in Autofac, but occasionally need to request an instance from a global container (where there is no matching lifetime scope). In scenarios where no matching lifetime scope exists, I want to give a top-level instance instead of throwing an exception. Is this possible? 回答1: I think you'd better extend Autofac by introducing a new lifetime option. I took the Autofac sources and modified them a bit: public static class

Spring3 's @Transactional @Scheduled not committed to DB?

别来无恙 提交于 2019-12-18 16:31:11
问题 This is my 1st time trying Spring3's @Scheduled , but found I cannot commit to DB. This is my code : @Service public class ServiceImpl implements Service , Serializable { @Inject private Dao dao; @Override @Scheduled(cron="0 0 * * * ?") @Transactional(rollbackFor=Exception.class) public void hourly() { // get xxx from dao , modify it dao.update(xxx); } } I think it should work , I can see it starts-up hourly and load xxx from DB , but data is not committed to DB. There's been tx:annotation

Module depending on another module in Dagger

倾然丶 夕夏残阳落幕 提交于 2019-12-18 15:57:53
问题 I'm trying to use Dagger to do Dependency Injection on an app that I'm building, and running into trouble constructing proper DAGs when I have one package's Module depending on values provided by the Injector (presumably provided by another Module). If I have a simple module for some configurable variables (that I might want to swap out for testing environments, for example) @Module( injects = DependentModule.class, ) public class ConfigModule { @Provides @Named("ConfigOption") String

Using StackExchange.Redis in a ASP.NET Core Controller

只谈情不闲聊 提交于 2019-12-18 15:31:17
问题 I'd like to use Redis features such as bitfields and hashfields from an MVC controller. I understand there's built in caching support in ASP.NET core but this only supports basic GET and SET commands, not the commands that I need in my application. I know how to use StackExchange.Redis from a normal (eg. console) application, but I'm not sure how to set it up in an ASP site. Where should I put all the connection initialisation code so that I can have access to it afterwards from a controller?

Using StackExchange.Redis in a ASP.NET Core Controller

旧街凉风 提交于 2019-12-18 15:30:03
问题 I'd like to use Redis features such as bitfields and hashfields from an MVC controller. I understand there's built in caching support in ASP.NET core but this only supports basic GET and SET commands, not the commands that I need in my application. I know how to use StackExchange.Redis from a normal (eg. console) application, but I'm not sure how to set it up in an ASP site. Where should I put all the connection initialisation code so that I can have access to it afterwards from a controller?

Should domain objects have dependencies injected into them?

混江龙づ霸主 提交于 2019-12-18 14:57:10
问题 I'm specifically referring to this question: DDD - How to implement factories The selected answer has stated: "factories should not be tied with dependency injection because domain objects shouldn't have dependencies injected into them." My question is: what is the reasoning of not being able to inject dependencies in to your entities? Or am I just misunderstanding the statement? Can someone please clarify? 回答1: Domain Objects aren't Factories, Repos, etc. They are only Entities, Value

Azure service fabric actor dependency injection

给你一囗甜甜゛ 提交于 2019-12-18 14:10:55
问题 Is there any way to inject dependencies in to the Azure Service Fabric Actor's constructor? 回答1: Having had a bit of a dig-around in this area with dotPeek a while back (trying to resolve actors from an Autofac lifetime scope per-invocation), I think the trick is to create your own implementation of StatelessActorServiceFactory, and your own extension method to register the actor with it. Although the factory class is marked as internal, its interface (IStatelessServiceFactory) and the