servicelocator

Who is using P&P Common Service Locator?

Who is using it? Is there any OS framework that relies on it? ...

Flex and Cairngorm Error: C0001E: Only one ServiceLocator instance can be instantiated.

Hey guys, I’m new to Flex and Cairngorm.While I’m using ServiceLocator,I do run into the problem: Error: C0001E: Only one ServiceLocator instance can be instantiated. My Code is like this: In Serives.mxml: <cairngorm:ServiceLocator xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:cairngorm="com.adobe.cairngorm.business.*"> <mx:HTTPSer...

How to combine designable components with dependency injection

When creating a designable .NET component, you are required to provide a default constructor. From the IComponent documentation: To be a component, a class must implement the IComponent interface and provide a basic constructor that requires no parameters or a single parameter of type IContainer. This makes it impossible to...

Scope of View Models when using Service Locator Pattern in WPF app

Hi there, When using a Service Locator class to serve up ViewModels for your WPF pages to bind to. Should the ViewModels be Singleton scoped or Factory scoped? Is one generally a better idea for WPF applications?? I'm aware that in Silverlight, Singleton lends itself better to pages which are User Controls and are only moved into and o...

Singleton Vs ServiceLocator

What are the advantages and disadvantages of using a Service Locator versus a singleton? I've read that singletons are bad but I'm wondering if s Service Locator would be generally a better way of doing things. ...

Autofac, ASP.NET and Microsoft.Practices.ServiceLocation

I've been working thru the details of implementing IoC in my web apps but in a way that leverages Microsoft.Practices.ServiceLocation. I am specifically using Autofac and the asp.net integration, but I wanted to leave myself open to other containers. Along the lines of this question, i was concerned about how to access the container in m...

Is it bad to use servicelocation instead of constructor injection to avoid writing loads of factory classes

Right now we use DI/IOC and when we need to pass extra parameters to a constructor we use a factory class e.g. public class EmailSender { internal EmailSender(string toEmail, string subject,String body, ILogger emailLogger) {.....} } public class EmailSenderFactory { ILogger emailLogger; public EmailSenderFactory(ILog...

Testing ServiceLocator using JUnit

This is a follow up question to my previous question. I am trying to write test case for my ServiceLocator class but it gives me the following error: com/iplanet/ias/admin/common/ASException java.lang.NoClassDefFoundError: com/iplanet/ias/admin/common/ASException at java.lang.ClassLoader.defineClass1(Native Method) My test ca...

Is the StaticFactory<T> in codecampserver a well known pattern?

CodeCampServer source code contains a generic StaticFactory. I'm surmising that this is a key piece of the mechanism for how the framework plays well with Dependency Injection. Subclasses of which use it's DefaultUnconfiguredState to provide static access to, well, a Default Unconfigured State for themselves which the dependency resolu...

Unity and MVVM. Class fields become null

Hello! My application is pretty complex, so even simplified example would be complex enough. So I'll try to point some its fundamentals and the problem itself. It is an MDI application. MDI is of custom implementation since there is no native MDI in WPF. The problem is in main container window. It is called Shell and as it is an MVVM ap...

Service locator for generics

Hi everyone, 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...

J2EE/EJB + service locator: is it safe to cache EJB Home lookup result ?

In a J2EE application, we are using EJB2 in weblogic. To avoid losing time building the initial context and looking up EJB Home interface, I'm considering the Service Locator Pattern. But after a few search on the web I found that event if this pattern is often recommended for the InitialContext caching, there are some negative opinion...

Rational use of unity and service locator pattern

Hello! I've recently introduced to unity block and to DI and ServiceLocator patterns. It seems to have sense, but on practice some questions concerned about its rational use arise. I mean, that I've came to unity from articles about service locator, which is used to decouple classes realize some functionality (services) from classes th...

Validation without ServiceLocator

Hi, I am getting back again and again to it thinking about the best way to perform validation on POCO objects that need access to some context (ISession in NH, IRepository for example). The only option I still can see is to use Service Locator, so my validation would look like: public User : ICanValidate { public User() {} // We n...

Are Consumers of ServiceLocator supposed to call ServiceLocator.Current?

I'm trying to refactor my code to use the Common Service Locator. I have a Shared Library that is used by some other components. What I don't understand is: Are these components supposed to call ServiceLocator.Current and resolve their types? In that case, how can I make sure that ServiceLocator.Current is actually set? Should I create ...

WPF DI Service Locator

So I'm looking for some clarification how it would be possible to remove the service locator from my application. I have a ViewManagerService that is responsible for knowing which view is active, which views are open and creating a new view. Currently my ViewModels get an IViewManagerService injected into them via constructor injection...

HtmlHelper building a dropdownlist, using ServiceLocator : code smell ?

Is it a code smell to have to following pattern, given the following code (highly simplified to get straight to the point) ? The models : class Product { public int Id { get; set; } public string Name { get; set; } public Category Cat { get; set; } } class Category { public int Id { get; set; } public string Label ...

MVVM setup design time services?

Im working with the MVVM pattern + a simple ServiceLocator implementation, now to my problem how am i supposed to setup the services when the views are running in design time? Iv tryed this but it does not seem to work in VS 2010 or some thing, i know it worked on my old computer but on my new it does not. so does any one know a good al...

EJB call from swing

I have app on GF V3.01 server and remote methods in EJB container. When I call remote methods from my remote swing app process take long time to execute. I read about ServiceLocator , but can no find examples for remote Swing app. Someone please help! give some idea to speedup remote method calls. I create this test and make some comm...

Unity ServiceLocator, register types at runtime

Hi everybody, I have a small toolkit which uses Unity DI plus EntLib Service Locator. The problem appears when a third party apps try to use the EntLib service locator. It looks like the EntLib Service Locator is singleton so when the third party app bootstrap its service locator, it wipes out the configuration of my service locator. The...