diff --git a/services/src/main/java/org/keycloak/services/FormService.java b/services/src/main/java/org/keycloak/services/FormService.java
index 716e76bfb5..83aac731b2 100755
--- a/services/src/main/java/org/keycloak/services/FormService.java
+++ b/services/src/main/java/org/keycloak/services/FormService.java
@@ -27,13 +27,13 @@ import org.keycloak.models.UserModel;
import org.keycloak.services.resources.flows.FormFlows;
import org.keycloak.social.SocialProvider;
-import javax.imageio.spi.ServiceRegistry;
import javax.ws.rs.core.MultivaluedMap;
import java.net.URI;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.ServiceLoader;
/**
* @author Viliam Rockai
@@ -98,7 +98,7 @@ public interface FormService {
socialProviders = new LinkedList();
Map socialConfig = realm.getSocialConfig();
if (socialConfig != null) {
- for (Iterator itr = ServiceRegistry.lookupProviders(org.keycloak.social.SocialProvider.class); itr.hasNext(); ) {
+ for (Iterator itr = ServiceLoader.load(org.keycloak.social.SocialProvider.class).iterator(); itr.hasNext(); ) {
SocialProvider p = itr.next();
if (socialConfig.containsKey(p.getId() + ".key") && socialConfig.containsKey(p.getId() + ".secret")) {
socialProviders.add(p);
diff --git a/services/src/main/java/org/keycloak/services/resources/SocialResource.java b/services/src/main/java/org/keycloak/services/resources/SocialResource.java
index 9877beefa1..54dac0d713 100755
--- a/services/src/main/java/org/keycloak/services/resources/SocialResource.java
+++ b/services/src/main/java/org/keycloak/services/resources/SocialResource.java
@@ -45,7 +45,6 @@ import org.keycloak.social.SocialProviderException;
import org.keycloak.services.managers.SocialRequestManager;
import org.keycloak.social.SocialUser;
-import javax.imageio.spi.ServiceRegistry;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
@@ -68,6 +67,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.ServiceLoader;
import java.util.UUID;
/**
@@ -305,7 +305,7 @@ public class SocialResource {
}
private RequestDetails getRequestDetails(Map queryParams) {
- Iterator itr = ServiceRegistry.lookupProviders(SocialProvider.class);
+ Iterator itr = ServiceLoader.load(SocialProvider.class).iterator();
while (itr.hasNext()) {
SocialProvider provider = itr.next();
@@ -322,7 +322,7 @@ public class SocialResource {
}
private SocialProvider getProvider(String providerId) {
- Iterator itr = ServiceRegistry.lookupProviders(SocialProvider.class);
+ Iterator itr = ServiceLoader.load(SocialProvider.class).iterator();
while (itr.hasNext()) {
SocialProvider provider = itr.next();
diff --git a/services/src/main/java/org/keycloak/services/resources/flows/FormFlows.java b/services/src/main/java/org/keycloak/services/resources/flows/FormFlows.java
index f55b7fb2cc..5657ecf22c 100755
--- a/services/src/main/java/org/keycloak/services/resources/flows/FormFlows.java
+++ b/services/src/main/java/org/keycloak/services/resources/flows/FormFlows.java
@@ -33,7 +33,6 @@ import org.keycloak.services.email.EmailSender;
import org.keycloak.services.managers.AccessCodeEntry;
import org.keycloak.services.messages.Messages;
-import javax.imageio.spi.ServiceRegistry;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
@@ -44,6 +43,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.ServiceLoader;
/**
* @author Stian Thorgersen
@@ -137,7 +137,7 @@ public class FormFlows {
formDataBean.setSocialRegistration(socialRegistration);
// Find the service and process relevant template
- Iterator itr = ServiceRegistry.lookupProviders(FormService.class);
+ Iterator itr = ServiceLoader.load(FormService.class).iterator();
while (itr.hasNext()) {
FormService provider = itr.next();