-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from jd-opensource/58-support-spring-cloud-gat…
…eway-only-enable-multi-live-and-lane-feature Fix #58
- Loading branch information
Showing
18 changed files
with
342 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...n/java/com/jd/live/agent/plugin/router/springgateway/v3/definition/GatewayDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright © ${year} ${owner} (${email}) | ||
* | ||
* 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 com.jd.live.agent.plugin.router.springgateway.v3.definition; | ||
|
||
import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; | ||
import com.jd.live.agent.core.extension.annotation.*; | ||
import com.jd.live.agent.core.plugin.definition.InterceptorDefinition; | ||
import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; | ||
import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; | ||
import com.jd.live.agent.governance.config.GovernanceConfig; | ||
import com.jd.live.agent.plugin.router.springgateway.v3.interceptor.GatewayInterceptor; | ||
|
||
/** | ||
* GatewayDefinition | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
@Extension(value = "GatewayDefinition_v3") | ||
@ConditionalOnProperty(name = {GovernanceConfig.CONFIG_LIVE_ENABLED, GovernanceConfig.CONFIG_LANE_ENABLED}, matchIfMissing = true, relation = ConditionalRelation.OR) | ||
@ConditionalOnProperty(name = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, value = "false") | ||
@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_GATEWAY_ENABLED, matchIfMissing = true) | ||
@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) | ||
@ConditionalOnClass(GatewayDefinition.TYPE_FILTERING_WEB_HANDLER) | ||
@ConditionalOnClass(GatewayDefinition.REACTOR_MONO) | ||
@ConditionalOnMissingClass(GatewayDefinition.TYPE_HTTP_STATUS_CODE) | ||
public class GatewayDefinition extends PluginDefinitionAdapter { | ||
|
||
protected static final String TYPE_FILTERING_WEB_HANDLER = "org.springframework.cloud.gateway.handler.FilteringWebHandler"; | ||
|
||
protected static final String TYPE_HTTP_STATUS_CODE = "org.springframework.http.HttpStatusCode"; | ||
|
||
private static final String METHOD_HANDLE = "handle"; | ||
|
||
private static final String[] ARGUMENT_HANDLE = new String[]{ | ||
"org.springframework.web.server.ServerWebExchange" | ||
}; | ||
|
||
protected static final String REACTOR_MONO = "reactor.core.publisher.Mono"; | ||
|
||
public GatewayDefinition() { | ||
this.matcher = () -> MatcherBuilder.named(TYPE_FILTERING_WEB_HANDLER); | ||
this.interceptors = new InterceptorDefinition[]{ | ||
new InterceptorDefinitionAdapter( | ||
MatcherBuilder.named(METHOD_HANDLE). | ||
and(MatcherBuilder.arguments(ARGUMENT_HANDLE)), | ||
GatewayInterceptor::new | ||
) | ||
}; | ||
} | ||
} |
Oops, something went wrong.