5 changed files with 4 additions and 187 deletions
@ -1,49 +0,0 @@
@@ -1,49 +0,0 @@
|
||||
/* |
||||
* Copyright 2013-2017 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
package org.springframework.cloud.gateway.config; |
||||
|
||||
import java.util.Collections; |
||||
import java.util.Map; |
||||
|
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.env.EnvironmentPostProcessor; |
||||
import org.springframework.core.Ordered; |
||||
import org.springframework.core.env.ConfigurableEnvironment; |
||||
import org.springframework.core.env.MapPropertySource; |
||||
|
||||
/** |
||||
* @author Spencer Gibb |
||||
*/ |
||||
public class GatewayEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered { |
||||
|
||||
public static final int DEFAULT_ORDER = Ordered.HIGHEST_PRECEDENCE + 10; |
||||
|
||||
@Override |
||||
public int getOrder() { |
||||
return DEFAULT_ORDER; |
||||
} |
||||
|
||||
@Override |
||||
public void postProcessEnvironment(ConfigurableEnvironment configurableEnvironment, SpringApplication springApplication) { |
||||
//TODO: make this configurable?
|
||||
//TODO: should I have to do this?
|
||||
final Map<String, Object> properties = Collections.singletonMap("spring.resources.add-mappings", "false"); |
||||
configurableEnvironment.getPropertySources().addLast(new MapPropertySource("gateway", properties)); |
||||
} |
||||
} |
||||
|
@ -1,55 +0,0 @@
@@ -1,55 +0,0 @@
|
||||
/* |
||||
* Copyright 2013-2017 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
package org.springframework.cloud.gateway.config; |
||||
|
||||
import java.util.Collections; |
||||
import java.util.Map; |
||||
|
||||
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; |
||||
import org.springframework.context.ApplicationListener; |
||||
import org.springframework.core.Ordered; |
||||
import org.springframework.core.env.ConfigurableEnvironment; |
||||
import org.springframework.core.env.MapPropertySource; |
||||
|
||||
import static org.springframework.cloud.bootstrap.BootstrapApplicationListener.BOOTSTRAP_PROPERTY_SOURCE_NAME; |
||||
import static org.springframework.cloud.bootstrap.BootstrapApplicationListener.DEFAULT_ORDER; |
||||
|
||||
/** |
||||
* Reenables reactive http server after bootstrap. |
||||
* TODO: remove when boot 2.0 handles the NONE web case |
||||
* @author Spencer Gibb |
||||
*/ |
||||
public class PostBootstrapApplicationListener |
||||
implements ApplicationListener<ApplicationEnvironmentPreparedEvent>, Ordered { |
||||
@Override |
||||
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { |
||||
ConfigurableEnvironment environment = event.getEnvironment(); |
||||
// don't listen to events in a bootstrap context
|
||||
if (environment.getPropertySources().contains(BOOTSTRAP_PROPERTY_SOURCE_NAME)) { |
||||
return; |
||||
} |
||||
final Map<String, Object> map = Collections.singletonMap("spring.reactive.enabled", "true"); |
||||
environment.getPropertySources().addBefore("bootstrap-web-disabled", |
||||
new MapPropertySource("bootstrap-web-reenable", map)); |
||||
} |
||||
|
||||
@Override |
||||
public int getOrder() { |
||||
return DEFAULT_ORDER+1; |
||||
} |
||||
} |
@ -1,54 +0,0 @@
@@ -1,54 +0,0 @@
|
||||
/* |
||||
* Copyright 2013-2017 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
package org.springframework.cloud.gateway.config; |
||||
|
||||
import java.util.Collections; |
||||
import java.util.Map; |
||||
|
||||
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; |
||||
import org.springframework.context.ApplicationListener; |
||||
import org.springframework.core.Ordered; |
||||
import org.springframework.core.env.ConfigurableEnvironment; |
||||
import org.springframework.core.env.MapPropertySource; |
||||
|
||||
import static org.springframework.cloud.bootstrap.BootstrapApplicationListener.BOOTSTRAP_PROPERTY_SOURCE_NAME; |
||||
import static org.springframework.cloud.bootstrap.BootstrapApplicationListener.DEFAULT_ORDER; |
||||
|
||||
/** |
||||
* Disables reactive http server just before bootstrap. |
||||
* TODO: remove when boot 2.0 handles the NONE web case |
||||
* @author Spencer Gibb |
||||
*/ |
||||
public class PreBootstrapApplicationListener |
||||
implements ApplicationListener<ApplicationEnvironmentPreparedEvent>, Ordered { |
||||
@Override |
||||
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { |
||||
ConfigurableEnvironment environment = event.getEnvironment(); |
||||
// don't listen to events in a bootstrap context
|
||||
if (environment.getPropertySources().contains(BOOTSTRAP_PROPERTY_SOURCE_NAME)) { |
||||
return; |
||||
} |
||||
final Map<String, Object> map = Collections.singletonMap("spring.reactive.enabled", "false"); |
||||
environment.getPropertySources().addLast(new MapPropertySource("bootstrap-web-disabled", map)); |
||||
} |
||||
|
||||
@Override |
||||
public int getOrder() { |
||||
return DEFAULT_ORDER-1; |
||||
} |
||||
} |
Loading…
Reference in new issue