From e1c3008b6283f22359ffcdb0483933d57fb2ab83 Mon Sep 17 00:00:00 2001 From: Maxime Dor Date: Sat, 11 Feb 2017 21:48:39 +0100 Subject: [PATCH] Only sort providers once --- .../mxisd/lookup/PriorityLookupStrategy.groovy | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/groovy/io/kamax/mxisd/lookup/PriorityLookupStrategy.groovy b/src/main/groovy/io/kamax/mxisd/lookup/PriorityLookupStrategy.groovy index d5b2389..740b6d8 100644 --- a/src/main/groovy/io/kamax/mxisd/lookup/PriorityLookupStrategy.groovy +++ b/src/main/groovy/io/kamax/mxisd/lookup/PriorityLookupStrategy.groovy @@ -21,21 +21,18 @@ package io.kamax.mxisd.lookup import io.kamax.mxisd.api.ThreePidType +import org.springframework.beans.factory.InitializingBean import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component @Component -class PriorityLookupStrategy implements LookupStrategy { +class PriorityLookupStrategy implements LookupStrategy, InitializingBean { @Autowired private List providers @Override - Optional find(ThreePidType type, String threePid) { - if (ThreePidType.email != type) { - throw new IllegalArgumentException("${type} is currently not supported") - } - + void afterPropertiesSet() throws Exception { providers.sort(new Comparator() { @Override @@ -44,6 +41,13 @@ class PriorityLookupStrategy implements LookupStrategy { } }) + } + + @Override + Optional find(ThreePidType type, String threePid) { + if (ThreePidType.email != type) { + throw new IllegalArgumentException("${type} is currently not supported") + } for (ThreePidProvider provider : providers) { Optional lookupDataOpt = provider.find(type, threePid)