Questions tagged [serviceloader]

ServiceLoader is a Java SDK way to load different providers for a class from the classpath. It uses special configuration files in META-INF/services.

The full documentation is provided by Oracle at http://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html

163 questions
0
votes
1 answer

Service Loader Class In Java, Having Issue with META-INF/services folder

I'm stuck in service loader class(java) can anybody help, here is my code and pic attached with it. see the pic to understand completely and tell me what's the issue Interface Code package ServiceLoader_.SL; interface Account { String…
0
votes
1 answer

Getting a simple ServiceLoader to work in Java using 2 supplementary Modules

I am fairly new to using ServiceLoader and I am trying to get a very simple example up and running. Currently have 4 Modules: BLCore, BLInterface, BLMod1, BLMod2 BLCore depends on: BLInterface, BLMod1, BLMod2 BLInterface depends on: Nonne BLMod1…
user11119570
0
votes
1 answer

Separate ServiceProviders for Unit Testing and Production Code

I am using ServiceLoader to dynamically load Plugins. In purpose of unit testing I want to Mock some behavior of these Plugins. These Mock-Plugins should be used when unit testing, but not when building the Project. How would one do this though? I…
0
votes
1 answer

ServiceLoader cannot find service loaded from path

I have been trying to do a kind of plugin-system using the ServiceLoader. There are 2 modules, the first provides the abstract class LoadedRealmPlugin. The second one extends this class. I have added the file corresponding to the full name of the…
Jakob Tinhofer
  • 313
  • 3
  • 16
0
votes
1 answer

Java - How i can restart ServiceLoader

How can I stop the ServiceLoader so that I can reload the jars? I have tried to call the load method again. Unfortunately this did not help.
LiIRCode
  • 3
  • 2
0
votes
1 answer

Java Service Class loader called multiple times

I've created a service class loader in a multimodule project while using also Hibernate Integrator to run some DB scripts, but i noticed the application enters my Integrator class 5 times. I implemented following class: public class FlywayIntegrator…
Stephan
  • 696
  • 15
  • 37
0
votes
0 answers

How Can I Find a Java Class Implementing a Generic Interface Given an Instance of the Generic Type?

I’m working on a project that has a series of “Rule” classes (CustomerRule, VolumeRule, TimeRule, etc.). These classes are auto-generated and shouldn’t be modified from their generated form. To process these rules, I have a series of “RuleProcessor”…
pconrey
  • 5,805
  • 7
  • 29
  • 38
0
votes
1 answer

Java app with JDK 9 modules: ServiceLoader not finding service (because of Maven build?)

I use a working example derived from CodeFx's book and code sample (here), which I stripped to the essentials: a Monitor module a Monitor Observer module a Mock Observed Service module All three are visible on Github here. The goal is to get the…
seinecle
  • 10,118
  • 14
  • 61
  • 120
0
votes
0 answers

HtmlUnit - Unable to derive module descriptor for xalan-2.7.2.jar

I am new to HtmlUnit, and really anything outside of the standard java library, and I am getting this error when I try to compile a simple program to print the contents of a webpage. Error occurred during initialization of boot…
Matt
  • 1
  • 1
0
votes
1 answer

Child first class loader and Service Provider Interface (SPI)

I found a custom class loader, which loads classes by child-first principle. And it works fine, but I faced with the following issue. When I try to load classes that use SPI I get the exception: Exception in thread "main"…
I3rutt
  • 574
  • 4
  • 18
0
votes
0 answers

DocumentBuilder.class operator loads the class in System Classloader

We are using Child first classloader to avoid jar conflicts and load the classes from a particular path. With the service loader and the xml-apis jar in the child classloader's classpath, we are facing issues. xerces2 jars service loader creates an…
aravinth
  • 416
  • 1
  • 5
  • 20
0
votes
1 answer

Parameters, return value of static ServiceLoader.load() method?

Actually this a three part question. When I looked at the documentation of static ServiceLoader.load() method of ServiceLoader class it contained public static ServiceLoader load(Class service) 1 I need to know how to call this method,…
0
votes
1 answer

Singleton Design Pattern with JAVA service loaders

I have been finding answers for my question on service loaders in the web and came across a solution that uses singleton design pattern. I implemented my program according to that pattern and it gave me the expected output. But I still have some…
0
votes
0 answers

Classloader error when loading a class from external jar

I have an application that has an Abstract class defined. The jar file of this application is, lets say, application.jar I have another application which has implementations for the Abstract class defined in application.jar. This application is…
Ram
  • 11
  • 3
0
votes
1 answer

Why won't the ServiceLoader load any implementations from another module?

I have a multi-module maven project which is making use of the JPMS features. The consumer module is not loading the implementations present in the provider module. Here's the maven project structure: ServiceLoaderExample ├── consumer ├──…
gjvatsalya
  • 1,129
  • 13
  • 29