Start structural port from Spring Boot to Undertow
This commit is contained in:
@@ -28,24 +28,23 @@ import io.kamax.mxisd.lookup.fetcher.IBridgeFetcher;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
public class BridgeFetcher implements IBridgeFetcher {
|
||||
|
||||
private Logger log = LoggerFactory.getLogger(BridgeFetcher.class);
|
||||
private transient final Logger log = LoggerFactory.getLogger(BridgeFetcher.class);
|
||||
|
||||
@Autowired
|
||||
private RecursiveLookupBridgeConfig cfg;
|
||||
|
||||
@Autowired
|
||||
private RemoteIdentityServerFetcher fetcher;
|
||||
|
||||
public BridgeFetcher(RecursiveLookupBridgeConfig cfg, RemoteIdentityServerFetcher fetcher) {
|
||||
this.cfg = cfg;
|
||||
this.fetcher = fetcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SingleLookupReply> find(SingleLookupRequest request) {
|
||||
Optional<String> mediumUrl = Optional.ofNullable(cfg.getMappings().get(request.getType()));
|
||||
|
||||
@@ -30,24 +30,23 @@ import io.kamax.mxisd.matrix.IdentityServerUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.RecursiveTask;
|
||||
|
||||
@Component
|
||||
class DnsLookupProvider implements IThreePidProvider {
|
||||
|
||||
private Logger log = LoggerFactory.getLogger(DnsLookupProvider.class);
|
||||
private transient final Logger log = LoggerFactory.getLogger(DnsLookupProvider.class);
|
||||
|
||||
@Autowired
|
||||
private MatrixConfig mxCfg;
|
||||
|
||||
@Autowired
|
||||
private MatrixConfig cfg;
|
||||
private IRemoteIdentityServerFetcher fetcher;
|
||||
|
||||
public DnsLookupProvider(MatrixConfig cfg, IRemoteIdentityServerFetcher fetcher) {
|
||||
this.cfg = cfg;
|
||||
this.fetcher = fetcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
@@ -74,7 +73,7 @@ class DnsLookupProvider implements IThreePidProvider {
|
||||
|
||||
// TODO use caching mechanism
|
||||
private Optional<String> findIdentityServerForDomain(String domain) {
|
||||
if (StringUtils.equals(mxCfg.getDomain(), domain)) {
|
||||
if (StringUtils.equals(cfg.getDomain(), domain)) {
|
||||
log.info("We are authoritative for {}, no remote lookup", domain);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@@ -28,27 +28,25 @@ import io.kamax.mxisd.lookup.ThreePidMapping;
|
||||
import io.kamax.mxisd.lookup.fetcher.IRemoteIdentityServerFetcher;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
class ForwarderProvider implements IThreePidProvider {
|
||||
public class ForwarderProvider implements IThreePidProvider {
|
||||
|
||||
private Logger log = LoggerFactory.getLogger(ForwarderProvider.class);
|
||||
private transient final Logger log = LoggerFactory.getLogger(ForwarderProvider.class);
|
||||
|
||||
@Autowired
|
||||
private ForwardConfig cfg;
|
||||
|
||||
@Autowired
|
||||
private MatrixConfig mxCfg;
|
||||
|
||||
@Autowired
|
||||
private IRemoteIdentityServerFetcher fetcher;
|
||||
|
||||
public ForwarderProvider(ForwardConfig cfg, MatrixConfig mxCfg, IRemoteIdentityServerFetcher fetcher) {
|
||||
this.cfg = cfg;
|
||||
this.mxCfg = mxCfg;
|
||||
this.fetcher = fetcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
|
||||
@@ -24,8 +24,8 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import io.kamax.matrix.json.GsonUtil;
|
||||
import io.kamax.mxisd.controller.identity.v1.ClientBulkLookupRequest;
|
||||
import io.kamax.mxisd.exception.InvalidResponseJsonException;
|
||||
import io.kamax.mxisd.http.io.identity.ClientBulkLookupRequest;
|
||||
import io.kamax.mxisd.lookup.SingleLookupReply;
|
||||
import io.kamax.mxisd.lookup.SingleLookupRequest;
|
||||
import io.kamax.mxisd.lookup.ThreePidMapping;
|
||||
@@ -41,10 +41,6 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
@@ -52,19 +48,20 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
@Scope("prototype")
|
||||
@Lazy
|
||||
public class RemoteIdentityServerFetcher implements IRemoteIdentityServerFetcher {
|
||||
|
||||
private Logger log = LoggerFactory.getLogger(RemoteIdentityServerFetcher.class);
|
||||
private transient final Logger log = LoggerFactory.getLogger(RemoteIdentityServerFetcher.class);
|
||||
|
||||
// FIXME remove
|
||||
private Gson gson = new Gson();
|
||||
private GsonParser parser = new GsonParser(gson);
|
||||
|
||||
@Autowired
|
||||
private CloseableHttpClient client;
|
||||
|
||||
public RemoteIdentityServerFetcher(CloseableHttpClient client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsable(String remote) {
|
||||
return IdentityServerUtils.isUsable(remote);
|
||||
|
||||
Reference in New Issue
Block a user