service-locator

GetServiceLocator in Zend Framework 3

一个人想着一个人 提交于 2019-12-02 09:19:13
Good morning, i have been learning to program using a framework (Zend Framework). In my past experiences i was using a skeleton application v.2.5. That been said, all my past developed Modules work around servicelocator() from ServiceManager. Is there any way of installing ServiceManager(with the servicelocator functionality) in zend framework 3? If not, can you send me a propor way to work around servicelocator? Thank You for atention, have a awesome day :) */ UPDATED - Small module as example. As an example i will show you a login authentication module that i was using back in 2.5: my Module

Dealing with how MongoDB stores DateTime when used with Service Locator Pattern

孤街浪徒 提交于 2019-12-02 04:26:58
问题 My colleague and I are at an impasse in a debate and other's input would be greatly appreciated. We utilize the Service Locator Pattern and a common interface to abstract all of our data access so we can easily swap between different data sources as our needs change. Our calling code has no indication of where the data is being stored or how. It simply accesses the data via the service it is fed from the service registry. The issue we are debating occurs when we have DateTime fields on an

Service locator for generics

大憨熊 提交于 2019-12-02 03:36:49
I have say a dozen types T which inherit from EntityObject and IDataObject . I have generic the following interface IDataManager<T> where T : EntityObject, IDataObject ... I have also base class for data managers BaseDataManager<T> : IDataManager<T> where T : EntityObject, IDataObject .... And i have particular classes public class Result : EntityObject, IDataObject .... public class ResultDataManager : BaseDataManager<Result> ... I want to implement service locator, which will return instance of IDataManager<T> for T But I stucked how to implement it in a neat way without a lot of castings.

@EJB injection vs lookup - performance issue

此生再无相见时 提交于 2019-12-01 18:43:36
I have a question related with possible performance issue while using @EJB annotation. Imagine following scenario public class MyBean1 implements MyBean1Remote{ @EJB private MyBean2Remote myBean2; @EJB private MyBean2Remote myBean3; ... @EJB private MyBean20Remote myBean20; } There is a bean with many dependencies to other beans. According to EJB spec if I would like to inject MyBean1Remote to some other bean, container would have to take all required dependencies from its pool inject it into MyBean1Remote and then inject reference to MyBean1Remote stub. so in following scenario container

How to avoid manually passing my $registry container into constructor of every new class I make?

爷,独闯天下 提交于 2019-12-01 10:45:28
I've been doing MVC for several months now, and I store everything in my $registry object. When I create a new class, I only ever pass the registry usually, but I'm having to constantly pass the $this->registry when creating a new class. e.g. class something { public function __construct($registry) { $this->registry = registry; $this->db = $registry->db; $this->user = $registry->user; // ...... } public function something() { $class = new something_class($this->registry); $class->do(); } } class something_class { public function __construct($registry) { $this->registry = $registry; } public

How to avoid manually passing my $registry container into constructor of every new class I make?

我怕爱的太早我们不能终老 提交于 2019-12-01 10:09:53
问题 I've been doing MVC for several months now, and I store everything in my $registry object. When I create a new class, I only ever pass the registry usually, but I'm having to constantly pass the $this->registry when creating a new class. e.g. class something { public function __construct($registry) { $this->registry = registry; $this->db = $registry->db; $this->user = $registry->user; // ...... } public function something() { $class = new something_class($this->registry); $class->do(); } }

Dependency management in Zend Framework 2 MVC applications

房东的猫 提交于 2019-12-01 07:12:41
As the ServiceLocatorAwareInterface will likely be removed from the AbstractController in ZF3 , dependencies should instead be passed via the constructor or via setter methods. With this in mind, consider the use case of a user or site controller with actions such as register, activate account, login, logout, etc. At a minimum, this would require a UserService and 2 forms. Add a few more related actions (remote authentication, linking of accounts, etc.) and you end up with 4 or 5 forms. Passing all these dependencies via the constructor would be messy at best, and more importantly, only 1 form

How to declare the Unity InjectionFactory in XML configuration

谁都会走 提交于 2019-12-01 04:22:53
I'm in the process of moving our Unity configuration to the web.config file. I'm stuck on how to migrate the following code config to the xml format: var container = new UnityContainer(); container.RegisterType<IPrincipal>(new InjectionFactory(x=> HttpContext.Current.User)); return container; Here are the XML declartion: <unity xmlns="http://schemas.microsoft.com/practices/2010/unity"> <alias alias="IRepository" type="Model.IRepository, Model" /> <alias alias="Repository" type="Data.Repository, Data" /> <container> <register type="IRepository" mapTo="Repository" /> </container> </unity>

Logging and Dependency Injection

余生颓废 提交于 2019-12-01 03:26:10
I try to build and application based on Java. For dependency injection I use Google Guice. Now I came up with the problem of logging some information during the application. I do not talk about general logging in a way of method calls etc. I know about AOP and that I can do like method call tracing etc. with that. What I look for is manual logging. I need some way of logging in nearly each class in my application. So I thought about two options: getting the logger by using the Guice injection framework doing this for me through the constructor (or setter or private ...) but it feels like

Logging and Dependency Injection

我是研究僧i 提交于 2019-11-30 23:12:59
问题 I try to build and application based on Java. For dependency injection I use Google Guice. Now I came up with the problem of logging some information during the application. I do not talk about general logging in a way of method calls etc. I know about AOP and that I can do like method call tracing etc. with that. What I look for is manual logging. I need some way of logging in nearly each class in my application. So I thought about two options: getting the logger by using the Guice injection