All Questions
Tagged with service-locator java
30 questions
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() {
...
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 ...
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;
}
}
...
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 ...
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]/...
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 ...
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
// ...
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) ...
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 ...
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?
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 ...
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 ...
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 ...
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> ...
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....
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;
@...
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 ...
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(
...
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 ...
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 ...
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 ...
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 ...
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> ...
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 ...
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 ...
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 ...
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 ...
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....
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,...
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 ...