Replaced javax.imageio.spi.ServiceRegistry with java.util.ServiceLoader

This commit is contained in:
Stian Thorgersen 2013-12-10 17:35:12 +00:00
parent a4842fe6bc
commit 00a7d88dee
3 changed files with 7 additions and 7 deletions

View file

@ -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 <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
@ -98,7 +98,7 @@ public interface FormService {
socialProviders = new LinkedList<SocialProvider>();
Map<String, String> socialConfig = realm.getSocialConfig();
if (socialConfig != null) {
for (Iterator<SocialProvider> itr = ServiceRegistry.lookupProviders(org.keycloak.social.SocialProvider.class); itr.hasNext(); ) {
for (Iterator<SocialProvider> 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);

View file

@ -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<String, String[]> queryParams) {
Iterator<SocialProvider> itr = ServiceRegistry.lookupProviders(SocialProvider.class);
Iterator<SocialProvider> 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<SocialProvider> itr = ServiceRegistry.lookupProviders(SocialProvider.class);
Iterator<SocialProvider> itr = ServiceLoader.load(SocialProvider.class).iterator();
while (itr.hasNext()) {
SocialProvider provider = itr.next();

View file

@ -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 <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
@ -137,7 +137,7 @@ public class FormFlows {
formDataBean.setSocialRegistration(socialRegistration);
// Find the service and process relevant template
Iterator<FormService> itr = ServiceRegistry.lookupProviders(FormService.class);
Iterator<FormService> itr = ServiceLoader.load(FormService.class).iterator();
while (itr.hasNext()) {
FormService provider = itr.next();