public RouteStates( Stream<ProxyRouteConfig> proxyRouteConfigs, ApplicationState applicationState, ProxyClientFactory clientFactory) { List<ProxyRouteState> proxyRouteStates = proxyRouteConfigs .map( (ProxyRouteConfig config) -> ProxyRouteState.create( applicationState, config, new PersistentProxyHandler( clientFactory, config, new SocketAddressHelper()))) .collect(Collectors.toList()); LinkedHashMap<String, ProxyRouteState> routeMap = new LinkedHashMap<>(); proxyRouteStates.forEach((ProxyRouteState state) -> routeMap.put(state.path(), state)); this.routeMap = new AtomicReference<>(ImmutableMap.copyOf(routeMap)); }
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); subject = new SocketAddressHelper(); }
@Override public ChannelHandler getApplicationRouter() { return new PipelineRouter( ImmutableMap.of( "none", ProxyRouteState.create( appState, proxyConfig, new ProxyHandler( factory, proxyConfig, new SocketAddressHelper())))); } });
EdgeProxyState(EdgeProxyConfig config) { super(config); clientFactory = new ProxyClientFactory(this); routeStates = new RouteStates<ProxyRouteState>( // create an ImmutableMap from ... ImmutableMap.copyOf( config .routeConfigs // iterate over a stream of ProxyRouteConfig .stream() // for each ProxyRouteConfig create a ProxyRouteState .map( (ProxyRouteConfig prConfig) -> ProxyRouteState.create( this, prConfig, new ProxyHandler( clientFactory, prConfig, new SocketAddressHelper()))) // collect the stream of ProxyRouteState into // LinkedHashMap<String, ProxyRouteState> where the // route path is the key and // ProxyRouteState is the value .collect(toLinkedMap(RouteState::path, state -> state)))); }