Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
236 views

Spring framework customize ServiceLocatorFactoryBean with complex type

I am trying to customize the way we use service locator pattern to have more complex type @Configuration public class VehicleConfig { @Bean public FactoryBean<?> factoryBean() { ...
Ravi's user avatar
  • 13
0 votes
1 answer
443 views

Avoid Service locator in strategy design pattern [closed]

Take a look on that pseudocode class A,B,C implements StrategyInterface { private dep; constructor(Dep dep) { this->dep = dep; } } class StrategyResolver { private ...
colorgreen's user avatar
0 votes
2 answers
860 views

Spring service locator without autowiring it

Having this code: public class ClassA { private InterfaceB interfaceB; private int a private int b; public ClassA(int a, int b) { this.a = a; this.b = b; } } ...
MABC's user avatar
  • 595
1 vote
2 answers
988 views

Problem with JNDI look-up in WildFly 17: java.lang.ClassCastException: class is in unnamed module of loader

I use Wildfly 17 and have a couple of stateless EJBs, one of which causes me sometimes ( but not always) problems upon JNDI lookup. This is my EJB: @Stateless public class AVeDBService { //other ...
Alex Mi's user avatar
  • 1,459
0 votes
2 answers
1k views

How to handle very long XPATH? Is there any alternative for this?

emphasized text //div[@class='preheader']//following-sibling::table/tbody/tr[7]/td/table[1]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr[4]/td/table/tbody/tr/td[1]/...
gopal agarwal's user avatar
1 vote
1 answer
346 views

Running Lagom Service Locator / Kafka / Cassandra separately

In order to have a complete control on the components of my architecture, I'd like to deploy all the infrastructure components (Service Locator, Cassandra, Kafka) and services individually. I'm able ...
suat's user avatar
  • 4,289
18 votes
6 answers
15k views

Inject Koin in Java classes

I'm trying to replace Dagger 2 to Koin in my current project and I don't want to rewrite some classes in Kotlin to use it. Is possible to inject with Koin in java classes? In Kotlin is just // ...
Rafa Araujo's user avatar
0 votes
1 answer
31 views

is ServiceLocator, ConfigurationClass needed for implementing multilanguage on java application?

I am really not that experienced with these properties on making an application multilingual. I've got a main class, which will start my Login_View, where I should choose the language(english, german) ...
Michael T.'s user avatar
7 votes
2 answers
2k views

SPI + JDK 9 + module-info.java

I am experimenting with SPI on JDK 9. Entire example works on JDK 9 without "module-info.java". After adding "module-info.java" ServiceLocator is not finding implementing class. I ...
Radosław Osiński's user avatar
2 votes
2 answers
785 views

Is IOC container an example of Service locator pattern?

Container allows us to provide required dependencies for classes. It can create any bean if the class is known to container. Is it example of service locator?
SubZr0's user avatar
  • 137
1 vote
1 answer
637 views

Is this valid implementation of ServiceLocator pattern in java?

I have an existential doubt. I saw an implementation of ServiceLocator pattern in C++ in some blog (Service Locator). So, I'm trying to extend the same implementation on Java SE (without any other ...
Ariel's user avatar
  • 121
1 vote
0 answers
300 views

An alternative to service locator for an application which should be expansible

I'm working on a game which has different items which all have different behavior. All items can be improved by buying different upgrades for different aspects of the item. I save the player's data in ...
Frozn's user avatar
  • 539
1 vote
3 answers
1k views

Is JNDI bad as service locator design pattern?

I'm a Java EE nooby developer, According to many resources on the internet which claim that service locator design pattern is an anti-pattern because it hides classes dependecies and more things and ...
La VloZ Merrill's user avatar
0 votes
1 answer
410 views

Building a service locator (registry) for generic factories

So I have a service locator to find factories (here registry): public interface Registry { void addFactory(Factory<? extends Component> factory); Factory<? extends Component> ...
estani's user avatar
  • 26.3k
0 votes
1 answer
1k views

Using Hk2 to generate an instance with the specified constructor args

I am using HK2 and the service locator pattern in my code. The following is the Interface: package org.swx.nursing.tools.sqlfinder.gui; import org.jvnet.hk2.annotations.Contract; import org.swx....
Rookie's user avatar
  • 5,437
4 votes
2 answers
2k views

HK2 using @Named to inject implementations not working

I am trying to learn HK2 to use the service locator pattern. The following is some code i have written: package org.swx.nursing.ccquerytool.file; import org.jvnet.hk2.annotations.Contract; @...
Rookie's user avatar
  • 5,437
2 votes
2 answers
3k views

How to test with mocks when using the Service Locator pattern?

Preface: My default mode of operation is using an IoC container and constructor injection. This makes testing with mocked dependencies trivial. I am starting to develop an IntelliJ plugin and I want ...
Niel de Wet's user avatar
  • 8,380
1 vote
1 answer
469 views

Proper use of GWT RequestFactory ServiceLocator and DI

I am experimenting with RequestFactory (RF) for the first time and am struggling to implement my first ServiceLocator. From the RequestContext: // Sign a user in or out of the app. @ServiceName( ...
IAmYourFaja's user avatar
  • 56.8k
4 votes
1 answer
2k views

EJB Service Locator with caching

I am using a Service Locator implementation which caches the result of javax.naming.Context#lookup call, and maps it to the requested EJB interface, so all subsequent requests (for the same EJB) after ...
alterfox's user avatar
  • 1,695
0 votes
1 answer
140 views

Creating a pluggable StrategyFactory with DI

I have an engine that creates strategies for text file processing. These files are in various formats and the engine selects an appropriate strategy by passing the file through a chain of strategies ...
tom's user avatar
  • 2,714
16 votes
2 answers
13k views

Spring ServiceLocator or pure factory pattern?

99% of my dependency is manage with DI pattern via @Autowired Spring annotation. Nevertheless in a particular scenario, I can't determine which implementation to be used until run-time. The most ...
Kakawait's user avatar
  • 4,029
13 votes
2 answers
8k views

Logging and Dependency Injection

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 ...
SimFirehawk's user avatar
1 vote
1 answer
382 views

Command queue bootstrap code looks like Service Locator pattern not Dependency Injection

I have a project that is using CQRS and Dependency Injection. The Query side of the system is fine. For the command side of the system I have chosen to use a queue: BlockingQueue<Command> ...
Dave E's user avatar
  • 165
1 vote
1 answer
2k views

Looking for help with implementation of Service Locator pattern

I have a small web application that I am building. Primarily to improve my unit testing ability (and also decouple my code further) I am implementing a service locator pattern to look up concrete ...
Chris Knight's user avatar
5 votes
1 answer
2k views

Java - Automatic implementation of service locator pattern using annotations

Spring almost provides what I want. In Spring you can simply annotate classes with @Component and then use "context:component-scan" to have Spring automatically search for components. Then later you ...
jonas789's user avatar
  • 229
1 vote
2 answers
2k views

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 ...
dimitri's user avatar
  • 97
5 votes
3 answers
3k views

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 ...
Guillaume's user avatar
  • 5,557
0 votes
3 answers
2k views

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....
Omnipresent's user avatar
  • 30.3k
7 votes
3 answers
2k views

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,...
mcintyre321's user avatar
  • 13.3k
2 votes
1 answer
2k views

Guice-style service locator

Has anybody ever seen/attempted to write a service locator pattern which uses a Guice style configuration system? Currently I have a GWT project (which happens to use GWT-RPC) that uses a command ...
benstpierre's user avatar
  • 33.5k