diff --git a/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/annotation/Conditional.java b/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/annotation/Conditional.java index a073b2f5a..abb5dcf39 100644 --- a/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/annotation/Conditional.java +++ b/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/annotation/Conditional.java @@ -25,7 +25,7 @@ * * @since 1.0.0 */ -@Target({ElementType.TYPE}) +@Target({ElementType.ANNOTATION_TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface Conditional { diff --git a/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/annotation/ConditionalComposite.java b/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/annotation/ConditionalComposite.java new file mode 100644 index 000000000..cc6bc3dbb --- /dev/null +++ b/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/annotation/ConditionalComposite.java @@ -0,0 +1,28 @@ +/* + * 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.core.extension.annotation; + +import java.lang.annotation.*; + +/** + * An annotation used to mark an annotation type as a conditional composite. + */ +@Target({ElementType.ANNOTATION_TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ConditionalComposite { + +} diff --git a/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/annotation/ConditionalOnMissingClass.java b/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/annotation/ConditionalOnMissingClass.java index 6b502cdf1..8e80043af 100644 --- a/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/annotation/ConditionalOnMissingClass.java +++ b/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/annotation/ConditionalOnMissingClass.java @@ -30,6 +30,7 @@ */ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) +@Repeatable(ConditionalOnMissingClasses.class) @Documented @Conditional(dependOnLoader = true) public @interface ConditionalOnMissingClass { diff --git a/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/condition/Condition.java b/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/condition/Condition.java index c8065d3e8..4713b1832 100644 --- a/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/condition/Condition.java +++ b/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/condition/Condition.java @@ -15,6 +15,11 @@ */ package com.jd.live.agent.core.extension.condition; +import lombok.Getter; + +import java.lang.annotation.Annotation; +import java.util.List; + /** * condition matcher */ @@ -28,4 +33,56 @@ public interface Condition { */ boolean match(ConditionContext context); + /** + * A condition that delegates the condition matching to a provided condition. + * + * @see Condition + * @see ConditionContext + */ + @Getter + class DelegateCondition implements Condition { + + private final Annotation annotation; + + private final Condition condition; + + public DelegateCondition(Annotation annotation, Condition condition) { + this.annotation = annotation; + this.condition = condition; + } + + @Override + public boolean match(ConditionContext context) { + return condition.match(context.getAnnotation() == annotation ? context : context.create(annotation)); + } + } + + /** + * A composite condition that checks if all of its sub-conditions are met. + *

+ * This class represents a composite condition that consists of multiple sub-conditions. The condition is considered + * satisfied if and only if all of its sub-conditions are satisfied. + * + * @see Condition + * @see ConditionContext + */ + class CompositeCondition implements Condition { + + private final List conditions; + + public CompositeCondition(List conditions) { + this.conditions = conditions; + } + + @Override + public boolean match(ConditionContext context) { + for (Condition condition : conditions) { + if (!condition.match(context)) { + return false; + } + } + return true; + } + } + } \ No newline at end of file diff --git a/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/condition/ConditionManager.java b/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/condition/ConditionManager.java index dd0a9f79e..acb825825 100644 --- a/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/condition/ConditionManager.java +++ b/joylive-core/joylive-core-api/src/main/java/com/jd/live/agent/core/extension/condition/ConditionManager.java @@ -18,12 +18,17 @@ import com.jd.live.agent.bootstrap.logger.Logger; import com.jd.live.agent.bootstrap.logger.LoggerFactory; import com.jd.live.agent.core.extension.annotation.Conditional; -import com.jd.live.agent.core.util.cache.LazyObject; +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.Extension; +import com.jd.live.agent.core.extension.condition.Condition.CompositeCondition; +import com.jd.live.agent.core.extension.condition.Condition.DelegateCondition; +import com.jd.live.agent.core.inject.annotation.Injectable; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; import java.util.function.Predicate; @@ -49,9 +54,9 @@ public class ConditionManager implements ConditionMatcher { private static final String CONDITION_PACKAGE = ConditionManager.class.getPackage().getName(); - private static final Map, LazyObject> CONDITIONS = new ConcurrentHashMap<>(); + private static final Map, Optional> CONDITIONS = new ConcurrentHashMap<>(); - private static final Map, List> TYPE_CONDITIONS = new ConcurrentHashMap<>(); + private static final Map, List> TYPE_CONDITIONS = new ConcurrentHashMap<>(); private final ClassLoader classLoader; @@ -80,12 +85,13 @@ public boolean match(Class type, ClassLoader classLoader, Predicate descs = TYPE_CONDITIONS.computeIfAbsent(type, this::getConditionals); - for (ConditionalDesc desc : descs) { - if (predicate == null || predicate.test(desc.annotation)) { - if (desc.condition == null || !desc.condition.match( - new ConditionContext(type, desc.annotation, - classLoader == null ? this.classLoader : classLoader, optional))) { + List conditions = getConditions(type); + Annotation annotation; + for (DelegateCondition condition : conditions) { + annotation = condition.getAnnotation(); + if (predicate == null || predicate.test(annotation)) { + if (annotation == null || !condition.match(new ConditionContext( + type, annotation, classLoader == null ? this.classLoader : classLoader, optional))) { return false; } } @@ -100,21 +106,79 @@ public boolean match(Class type, ClassLoader classLoader, Predicate getConditionals(Class type) { - List result = new ArrayList<>(); + private List getConditions(Class type) { + return TYPE_CONDITIONS.computeIfAbsent(type, this::parseConditions); + } + + /** + * Returns a list of delegate conditions for the given type. + * + * @param type the type to retrieve delegate conditions for + * @return a list of delegate conditions for the given type + */ + private List parseConditions(Class type) { + List result = new ArrayList<>(); Annotation[] annotations = type.getAnnotations(); for (Annotation annotation : annotations) { - Class annotationType = annotation.annotationType(); - Conditional conditional = annotationType.getAnnotation(Conditional.class); - if (conditional != null) { - LazyObject lazyObject = CONDITIONS.computeIfAbsent(annotationType, - t -> new LazyObject<>(newImplement(conditional.value(), t.getSimpleName()))); - result.add(new ConditionalDesc(annotation, lazyObject.get())); + Condition condition = getCondition(annotation.annotationType(), this::parseAnnotation); + if (condition != null) { + result.add(new DelegateCondition(annotation, condition)); } } return result; } + /** + * Parses the given annotation type and returns a condition based on its conditional annotations. + * + * @param annotationType the annotation type to parse + * @return a condition based on the conditional annotations of the given annotation type, or null if the annotation + * type does not have a conditional annotation + */ + private Condition parseAnnotation(Class annotationType) { + Conditional conditional = annotationType.getAnnotation(Conditional.class); + Condition condition = null; + if (conditional != null) { + condition = newImplement(conditional.value(), annotationType.getSimpleName()); + } else { + ConditionalComposite composite = annotationType.getAnnotation(ConditionalComposite.class); + if (composite != null) { + condition = new CompositeCondition(parseConditions(annotationType)); + } + } + return condition; + } + + /** + * Returns a condition for the given annotation type. + *

+ * This method uses a cache to store conditions for annotation types. If the condition for the given annotation type + * is not in the cache, it creates a new condition using the provided function and stores it in the cache. The + * function takes the annotation type as input and returns a new condition. + * + * @param type the annotation type to retrieve a condition for + * @param function a function that creates a new condition for the given annotation type + * @return a condition for the given annotation type, or null if the condition could not be created + */ + private Condition getCondition(Class type, Function, Condition> function) { + if (type == Conditional.class + || type == ConditionalComposite.class + || type == Extension.class + || type == Injectable.class + || type.getName().startsWith("java.")) { + return null; + } + Optional optional = CONDITIONS.get(type); + if (optional == null) { + optional = Optional.ofNullable(function.apply(type)); + Optional old = CONDITIONS.putIfAbsent(type, optional); + if (old != null) { + optional = old; + } + } + return optional.orElse(null); + } + /** * Instantiates a new condition implementation based on the provided class name and conditional name. This method * supports both explicit class names and a naming convention that infers the class name from the conditional @@ -143,24 +207,4 @@ private Condition newImplement(String implementClass, String conditionalName) { return null; } - /** - * A private static class that serves as a container for holding a conditional annotation and its associated - * condition implementation. Each instance of this class represents a single conditional that is to be checked - * against a class type. - * - *

This class is used internally by the {@link ConditionManager} to cache and manage the relationship between - * annotations and their corresponding conditions, enabling efficient conditional matching.

- */ - private static class ConditionalDesc { - - protected final Annotation annotation; - - protected final Condition condition; - - ConditionalDesc(Annotation annotation, Condition condition) { - this.annotation = annotation; - this.condition = condition; - } - } - } diff --git a/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnDubboEnabled.java b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnDubboEnabled.java new file mode 100644 index 000000000..5454e071d --- /dev/null +++ b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnDubboEnabled.java @@ -0,0 +1,37 @@ +/* + * 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.governance.annotation; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring the dubbo rpc feature to be enabled. + *

+ * This annotation is used to indicate that a type requires the dubbo rpc feature to be enabled. The presence of this + * annotation on a type will trigger specific behavior in the governance processing logic. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_DUBBO_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnDubboEnabled { + +} diff --git a/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnFlowControlEnabled.java b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnFlowControlEnabled.java new file mode 100644 index 000000000..c4bc0a7d7 --- /dev/null +++ b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnFlowControlEnabled.java @@ -0,0 +1,37 @@ +/* + * 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.governance.annotation; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring the flow control feature to be enabled. + *

+ * This annotation is used to indicate that a type requires the flow control feature to be enabled. The presence of this + * annotation on a type will trigger specific behavior in the governance processing logic. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnFlowControlEnabled { + +} diff --git a/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnGovernanceEnabled.java b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnGovernanceEnabled.java new file mode 100644 index 000000000..43d20828d --- /dev/null +++ b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnGovernanceEnabled.java @@ -0,0 +1,44 @@ +/* + * 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.governance.annotation; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperties; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.core.extension.annotation.ConditionalRelation; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring at least one of the specified governance features to be enabled. + *

+ * This annotation is used to indicate that a type requires at least one of the specified governance features to be + * enabled. The presence of this annotation on a type will trigger specific behavior in the governance processing + * logic. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProperties(value = { + @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), + @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), + @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) +}, relation = ConditionalRelation.OR) +@ConditionalComposite +public @interface ConditionalOnGovernanceEnabled { + +} diff --git a/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnMqEnabled.java b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnMqEnabled.java new file mode 100644 index 000000000..f8762b7fa --- /dev/null +++ b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnMqEnabled.java @@ -0,0 +1,37 @@ +/* + * 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.governance.annotation; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring the mq feature to be enabled. + *

+ * This annotation is used to indicate that a type requires the mq feature to be enabled. The presence of this + * annotation on a type will trigger specific behavior in the governance processing logic. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_MQ_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnMqEnabled { + +} diff --git a/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnOnlyRouteEnabled.java b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnOnlyRouteEnabled.java new file mode 100644 index 000000000..e7a22bbd0 --- /dev/null +++ b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnOnlyRouteEnabled.java @@ -0,0 +1,44 @@ +/* + * 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.governance.annotation; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.core.extension.annotation.ConditionalRelation; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring either the live or lane feature to be enabled, and the flow control + * feature to be disabled. + *

+ * This annotation is used to indicate that a type requires either the live or lane feature to be enabled, and the flow + * control feature to be disabled. The presence of this annotation on a type will trigger specific behavior in the + * governance processing logic. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProperty(name = { + GovernanceConfig.CONFIG_LIVE_ENABLED, + GovernanceConfig.CONFIG_LANE_ENABLED +}, matchIfMissing = true, relation = ConditionalRelation.OR) +@ConditionalOnProperty(name = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, value = "false") +@ConditionalComposite +public @interface ConditionalOnOnlyRouteEnabled { + +} diff --git a/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnProtectEnabled.java b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnProtectEnabled.java new file mode 100644 index 000000000..027daf3cd --- /dev/null +++ b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnProtectEnabled.java @@ -0,0 +1,40 @@ +/* + * 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.governance.annotation; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring either the protect feature to be enabled, and the flow control + * feature to be disabled. + *

+ * This annotation is used to indicate that a type requires either the protect feature to be enabled, and the flow + * control feature to be disabled. The presence of this annotation on a type will trigger specific behavior in the + * governance processing logic. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED) +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_ENABLED) +@ConditionalComposite +public @interface ConditionalOnProtectEnabled { + +} diff --git a/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnReactive.java b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnReactive.java new file mode 100644 index 000000000..b88870a74 --- /dev/null +++ b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnReactive.java @@ -0,0 +1,31 @@ +/* + * 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.governance.annotation; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnClass(ConditionalOnReactive.REACTOR_MONO) +@ConditionalComposite +public @interface ConditionalOnReactive { + + String REACTOR_MONO = "reactor.core.publisher.Mono"; +} diff --git a/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnRocketmqEnabled.java b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnRocketmqEnabled.java new file mode 100644 index 000000000..5dad6e77f --- /dev/null +++ b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnRocketmqEnabled.java @@ -0,0 +1,37 @@ +/* + * 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.governance.annotation; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring the rocketmq feature to be enabled. + *

+ * This annotation is used to indicate that a type requires the rocketmq feature to be enabled. The presence of this + * annotation on a type will trigger specific behavior in the governance processing logic. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ROCKETMQ_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnRocketmqEnabled { + +} diff --git a/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnSpringEnabled.java b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnSpringEnabled.java new file mode 100644 index 000000000..8b04c1d4f --- /dev/null +++ b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnSpringEnabled.java @@ -0,0 +1,37 @@ +/* + * 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.governance.annotation; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring the spring framework feature to be enabled. + *

+ * This annotation is used to indicate that a type requires the spring framework feature to be enabled. The presence of this + * annotation on a type will trigger specific behavior in the governance processing logic. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnSpringEnabled { + +} diff --git a/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnSpringGatewayEnabled.java b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnSpringGatewayEnabled.java new file mode 100644 index 000000000..bd5b813ff --- /dev/null +++ b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnSpringGatewayEnabled.java @@ -0,0 +1,38 @@ +/* + * 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.governance.annotation; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring the spring gateway feature to be enabled. + *

+ * This annotation is used to indicate that a type requires the spring gateway feature to be enabled. The presence of this + * annotation on a type will trigger specific behavior in the governance processing logic. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringEnabled +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_GATEWAY_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnSpringGatewayEnabled { + +} diff --git a/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnSpringRetry.java b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnSpringRetry.java new file mode 100644 index 000000000..fe5fc0298 --- /dev/null +++ b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnSpringRetry.java @@ -0,0 +1,37 @@ +/* + * 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.governance.annotation; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring the spring retry feature to be enabled. + *

+ * This annotation is used to indicate that a type requires the spring retry feature to be enabled. The presence of this + * annotation on a type will trigger specific behavior in the governance processing logic. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnClass(ConditionalOnSpringRetry.TYPE_RETRY_TEMPLATE) +@ConditionalComposite +public @interface ConditionalOnSpringRetry { + + String TYPE_RETRY_TEMPLATE = "org.springframework.retry.support.RetryTemplate"; +} diff --git a/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnTransmissionEnabled.java b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnTransmissionEnabled.java new file mode 100644 index 000000000..a9fd8d9b1 --- /dev/null +++ b/joylive-core/joylive-governance-api/src/main/java/com/jd/live/agent/governance/annotation/ConditionalOnTransmissionEnabled.java @@ -0,0 +1,32 @@ +/* + * 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.governance.annotation; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to transmission to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnGovernanceEnabled +@ConditionalComposite +public @interface ConditionalOnTransmissionEnabled { + +} diff --git a/joylive-plugin/joylive-application/joylive-application-springboot2/src/main/java/com/jd/live/agent/plugin/application/springboot/v2/definition/ApplicationContextDefinition.java b/joylive-plugin/joylive-application/joylive-application-springboot2/src/main/java/com/jd/live/agent/plugin/application/springboot/v2/definition/ApplicationContextDefinition.java index 1a92c056c..ca3b1c81d 100644 --- a/joylive-plugin/joylive-application/joylive-application-springboot2/src/main/java/com/jd/live/agent/plugin/application/springboot/v2/definition/ApplicationContextDefinition.java +++ b/joylive-plugin/joylive-application/joylive-application-springboot2/src/main/java/com/jd/live/agent/plugin/application/springboot/v2/definition/ApplicationContextDefinition.java @@ -18,24 +18,21 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.event.AgentEvent; import com.jd.live.agent.core.event.Publisher; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; import com.jd.live.agent.plugin.application.springboot.v2.interceptor.ContextStopInterceptor; @Injectable @Extension(value = "ApplicationContextDefinition_v5", order = PluginDefinition.ORDER_APPLICATION) +@ConditionalOnGovernanceEnabled @ConditionalOnClass(ApplicationContextDefinition.TYPE_ABSTRACT_APPLICATION_CONTEXT) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) public class ApplicationContextDefinition extends PluginDefinitionAdapter { protected static final String TYPE_ABSTRACT_APPLICATION_CONTEXT = "org.springframework.context.support.AbstractApplicationContext"; diff --git a/joylive-plugin/joylive-application/joylive-application-springboot2/src/main/java/com/jd/live/agent/plugin/application/springboot/v2/definition/SpringApplicationDefinition.java b/joylive-plugin/joylive-application/joylive-application-springboot2/src/main/java/com/jd/live/agent/plugin/application/springboot/v2/definition/SpringApplicationDefinition.java index d95293814..cbccf7c87 100644 --- a/joylive-plugin/joylive-application/joylive-application-springboot2/src/main/java/com/jd/live/agent/plugin/application/springboot/v2/definition/SpringApplicationDefinition.java +++ b/joylive-plugin/joylive-application/joylive-application-springboot2/src/main/java/com/jd/live/agent/plugin/application/springboot/v2/definition/SpringApplicationDefinition.java @@ -18,26 +18,23 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.event.AgentEvent; import com.jd.live.agent.core.event.Publisher; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; import com.jd.live.agent.governance.policy.PolicySupervisor; import com.jd.live.agent.plugin.application.springboot.v2.interceptor.ApplicationReadyInterceptor; import com.jd.live.agent.plugin.application.springboot.v2.interceptor.ApplicationStartedInterceptor; @Injectable @Extension(value = "SpringApplicationDefinition_v5", order = PluginDefinition.ORDER_APPLICATION) +@ConditionalOnGovernanceEnabled @ConditionalOnClass(SpringApplicationDefinition.TYPE_SPRING_APPLICATION_RUN_LISTENERS) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) public class SpringApplicationDefinition extends PluginDefinitionAdapter { protected static final String TYPE_SPRING_APPLICATION_RUN_LISTENERS = "org.springframework.boot.SpringApplicationRunListeners"; diff --git a/joylive-plugin/joylive-protection/joylive-protection-mariadb2/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v2/condition/ConditionalOnMariadbProtectEnabled.java b/joylive-plugin/joylive-protection/joylive-protection-mariadb2/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v2/condition/ConditionalOnMariadbProtectEnabled.java new file mode 100644 index 000000000..40b9d2301 --- /dev/null +++ b/joylive-plugin/joylive-protection/joylive-protection-mariadb2/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v2/condition/ConditionalOnMariadbProtectEnabled.java @@ -0,0 +1,33 @@ +/* + * 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.protection.mariadb.v2.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.annotation.ConditionalOnProtectEnabled; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProtectEnabled +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_MARIADB_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnMariadbProtectEnabled { + +} diff --git a/joylive-plugin/joylive-protection/joylive-protection-mariadb2/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v2/definition/AbstractQueryProtocolDefinition.java b/joylive-plugin/joylive-protection/joylive-protection-mariadb2/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v2/definition/AbstractQueryProtocolDefinition.java index e0228105e..639b59501 100644 --- a/joylive-plugin/joylive-protection/joylive-protection-mariadb2/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v2/definition/AbstractQueryProtocolDefinition.java +++ b/joylive-plugin/joylive-protection/joylive-protection-mariadb2/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v2/definition/AbstractQueryProtocolDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,8 +24,8 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.protection.mariadb.v2.condition.ConditionalOnMariadbProtectEnabled; import com.jd.live.agent.plugin.protection.mariadb.v2.interceptor.ExecuteBatchStmtInterceptor; import com.jd.live.agent.plugin.protection.mariadb.v2.interceptor.ExecutePrepareInterceptor; import com.jd.live.agent.plugin.protection.mariadb.v2.interceptor.ExecuteQueryInterceptor; @@ -34,9 +33,7 @@ @Injectable @Extension(value = "StandardClientDefinition_v2", order = PluginDefinition.ORDER_PROTECT) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_MARIADB_ENABLED, matchIfMissing = true) +@ConditionalOnMariadbProtectEnabled @ConditionalOnClass(AbstractQueryProtocolDefinition.TYPE_ABSTRACT_QUERY_PROTOCOL) public class AbstractQueryProtocolDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-protection/joylive-protection-mariadb3/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v3/condition/ConditionalOnMariadbProtectEnabled.java b/joylive-plugin/joylive-protection/joylive-protection-mariadb3/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v3/condition/ConditionalOnMariadbProtectEnabled.java new file mode 100644 index 000000000..4bb5d0bf7 --- /dev/null +++ b/joylive-plugin/joylive-protection/joylive-protection-mariadb3/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v3/condition/ConditionalOnMariadbProtectEnabled.java @@ -0,0 +1,33 @@ +/* + * 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.protection.mariadb.v3.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.annotation.ConditionalOnProtectEnabled; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProtectEnabled +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_MARIADB_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnMariadbProtectEnabled { + +} diff --git a/joylive-plugin/joylive-protection/joylive-protection-mariadb3/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v3/definition/StandardClientDefinition.java b/joylive-plugin/joylive-protection/joylive-protection-mariadb3/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v3/definition/StandardClientDefinition.java index 3a9ec72b0..09b85eef2 100644 --- a/joylive-plugin/joylive-protection/joylive-protection-mariadb3/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v3/definition/StandardClientDefinition.java +++ b/joylive-plugin/joylive-protection/joylive-protection-mariadb3/src/main/java/com/jd/live/agent/plugin/protection/mariadb/v3/definition/StandardClientDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,15 +24,13 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.protection.mariadb.v3.condition.ConditionalOnMariadbProtectEnabled; import com.jd.live.agent.plugin.protection.mariadb.v3.interceptor.SendQueryInterceptor; @Injectable @Extension(value = "StandardClientDefinition_v3", order = PluginDefinition.ORDER_PROTECT) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_MARIADB_ENABLED, matchIfMissing = true) +@ConditionalOnMariadbProtectEnabled @ConditionalOnClass(StandardClientDefinition.TYPE_STANDARD_CLIENT) public class StandardClientDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-protection/joylive-protection-mongodb4/src/main/java/com/jd/live/agent/plugin/protection/mongodb/v4/condition/ConditionalOnMongodbProtectEnabled.java b/joylive-plugin/joylive-protection/joylive-protection-mongodb4/src/main/java/com/jd/live/agent/plugin/protection/mongodb/v4/condition/ConditionalOnMongodbProtectEnabled.java new file mode 100644 index 000000000..cb1641de0 --- /dev/null +++ b/joylive-plugin/joylive-protection/joylive-protection-mongodb4/src/main/java/com/jd/live/agent/plugin/protection/mongodb/v4/condition/ConditionalOnMongodbProtectEnabled.java @@ -0,0 +1,33 @@ +/* + * 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.protection.mongodb.v4.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.annotation.ConditionalOnProtectEnabled; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProtectEnabled +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_MONGODB_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnMongodbProtectEnabled { + +} diff --git a/joylive-plugin/joylive-protection/joylive-protection-mongodb4/src/main/java/com/jd/live/agent/plugin/protection/mongodb/v4/definition/CommandOperationHelperDefinition.java b/joylive-plugin/joylive-protection/joylive-protection-mongodb4/src/main/java/com/jd/live/agent/plugin/protection/mongodb/v4/definition/CommandOperationHelperDefinition.java index 87e710e14..b95f9eeaa 100644 --- a/joylive-plugin/joylive-protection/joylive-protection-mongodb4/src/main/java/com/jd/live/agent/plugin/protection/mongodb/v4/definition/CommandOperationHelperDefinition.java +++ b/joylive-plugin/joylive-protection/joylive-protection-mongodb4/src/main/java/com/jd/live/agent/plugin/protection/mongodb/v4/definition/CommandOperationHelperDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,15 +24,13 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.protection.mongodb.v4.condition.ConditionalOnMongodbProtectEnabled; import com.jd.live.agent.plugin.protection.mongodb.v4.interceptor.ExecuteCommandInterceptor; @Injectable @Extension(value = "CommandOperationHelperDefinition_v4", order = PluginDefinition.ORDER_PROTECT) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_MONGODB_ENABLED, matchIfMissing = true) +@ConditionalOnMongodbProtectEnabled @ConditionalOnClass(CommandOperationHelperDefinition.TYPE_COMMAND_OPERATION_HELPER) public class CommandOperationHelperDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-protection/joylive-protection-mongodb4/src/main/java/com/jd/live/agent/plugin/protection/mongodb/v4/definition/MixedBulkWriteOperationDefinition.java b/joylive-plugin/joylive-protection/joylive-protection-mongodb4/src/main/java/com/jd/live/agent/plugin/protection/mongodb/v4/definition/MixedBulkWriteOperationDefinition.java index 1ad3266d1..5a4a79506 100644 --- a/joylive-plugin/joylive-protection/joylive-protection-mongodb4/src/main/java/com/jd/live/agent/plugin/protection/mongodb/v4/definition/MixedBulkWriteOperationDefinition.java +++ b/joylive-plugin/joylive-protection/joylive-protection-mongodb4/src/main/java/com/jd/live/agent/plugin/protection/mongodb/v4/definition/MixedBulkWriteOperationDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,15 +24,13 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.protection.mongodb.v4.condition.ConditionalOnMongodbProtectEnabled; import com.jd.live.agent.plugin.protection.mongodb.v4.interceptor.MixedBulkWriteOperationInterceptor; @Injectable @Extension(value = "MixedBulkWriteOperationDefinition_v4", order = PluginDefinition.ORDER_PROTECT) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_MONGODB_ENABLED, matchIfMissing = true) +@ConditionalOnMongodbProtectEnabled @ConditionalOnClass(MixedBulkWriteOperationDefinition.TYPE_COMMAND_OPERATION_HELPER) public class MixedBulkWriteOperationDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-protection/joylive-protection-opengauss3.0/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_0/condition/ConditionalOnOpenGauss30ProtectEnabled.java b/joylive-plugin/joylive-protection/joylive-protection-opengauss3.0/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_0/condition/ConditionalOnOpenGauss30ProtectEnabled.java new file mode 100644 index 000000000..6e1c0294b --- /dev/null +++ b/joylive-plugin/joylive-protection/joylive-protection-opengauss3.0/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_0/condition/ConditionalOnOpenGauss30ProtectEnabled.java @@ -0,0 +1,37 @@ +/* + * 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.protection.opengauss.v3_0.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.annotation.ConditionalOnProtectEnabled; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProtectEnabled +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_OPENGAUSS_ENABLED, matchIfMissing = true) +@ConditionalOnMissingClass(ConditionalOnOpenGauss30ProtectEnabled.TYPE_SLF4J_LOGGER) +@ConditionalComposite +public @interface ConditionalOnOpenGauss30ProtectEnabled { + + String TYPE_SLF4J_LOGGER = "org.postgresql.log.Slf4JLogger"; + +} diff --git a/joylive-plugin/joylive-protection/joylive-protection-opengauss3.0/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_0/definition/QueryExecutorImplDefinition.java b/joylive-plugin/joylive-protection/joylive-protection-opengauss3.0/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_0/definition/QueryExecutorImplDefinition.java index 0d2827691..ee4a6ccff 100644 --- a/joylive-plugin/joylive-protection/joylive-protection-opengauss3.0/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_0/definition/QueryExecutorImplDefinition.java +++ b/joylive-plugin/joylive-protection/joylive-protection-opengauss3.0/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_0/definition/QueryExecutorImplDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,15 +24,13 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.protection.opengauss.v3_0.condition.ConditionalOnOpenGauss30ProtectEnabled; import com.jd.live.agent.plugin.protection.opengauss.v3_0.interceptor.QueryExecutorImplInterceptor; @Injectable @Extension(value = "QueryExecutorImplDefinition_v3.0", order = PluginDefinition.ORDER_PROTECT) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_OPENGAUSS_ENABLED, matchIfMissing = true) +@ConditionalOnOpenGauss30ProtectEnabled @ConditionalOnClass(QueryExecutorImplDefinition.TYPE_QUERY_EXECUTOR_IMPL) public class QueryExecutorImplDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-protection/joylive-protection-opengauss3.1/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_1/condition/ConditionalOnOpenGauss31ProtectEnabled.java b/joylive-plugin/joylive-protection/joylive-protection-opengauss3.1/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_1/condition/ConditionalOnOpenGauss31ProtectEnabled.java new file mode 100644 index 000000000..0b1f4c0e4 --- /dev/null +++ b/joylive-plugin/joylive-protection/joylive-protection-opengauss3.1/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_1/condition/ConditionalOnOpenGauss31ProtectEnabled.java @@ -0,0 +1,36 @@ +/* + * 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.protection.opengauss.v3_1.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.annotation.ConditionalOnProtectEnabled; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProtectEnabled +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_OPENGAUSS_ENABLED, matchIfMissing = true) +@ConditionalOnClass(ConditionalOnOpenGauss31ProtectEnabled.TYPE_SLF4J_LOGGER) +@ConditionalComposite +public @interface ConditionalOnOpenGauss31ProtectEnabled { + + String TYPE_SLF4J_LOGGER = "org.postgresql.log.Slf4JLogger"; +} diff --git a/joylive-plugin/joylive-protection/joylive-protection-opengauss3.1/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_1/definition/QueryExecutorImplDefinition.java b/joylive-plugin/joylive-protection/joylive-protection-opengauss3.1/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_1/definition/QueryExecutorImplDefinition.java index 289e4453b..0445f6f32 100644 --- a/joylive-plugin/joylive-protection/joylive-protection-opengauss3.1/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_1/definition/QueryExecutorImplDefinition.java +++ b/joylive-plugin/joylive-protection/joylive-protection-opengauss3.1/src/main/java/com/jd/live/agent/plugin/protection/opengauss/v3_1/definition/QueryExecutorImplDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,23 +24,18 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.protection.opengauss.v3_1.condition.ConditionalOnOpenGauss31ProtectEnabled; import com.jd.live.agent.plugin.protection.opengauss.v3_1.interceptor.QueryExecutorImplInterceptor; @Injectable @Extension(value = "QueryExecutorImplDefinition_v3.1", order = PluginDefinition.ORDER_PROTECT) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_OPENGAUSS_ENABLED, matchIfMissing = true) +@ConditionalOnOpenGauss31ProtectEnabled @ConditionalOnClass(QueryExecutorImplDefinition.TYPE_QUERY_EXECUTOR_IMPL) -@ConditionalOnClass(QueryExecutorImplDefinition.TYPE_SLF4J_LOGGER) public class QueryExecutorImplDefinition extends PluginDefinitionAdapter { protected static final String TYPE_QUERY_EXECUTOR_IMPL = "org.postgresql.core.v3.QueryExecutorImpl"; - protected static final String TYPE_SLF4J_LOGGER = "org.postgresql.log.Slf4JLogger"; - private static final String METHOD_SEND_QUERY = "sendQuery"; private static final String[] ARGUMENT_SEND_QUERY = { diff --git a/joylive-plugin/joylive-protection/joylive-protection-postgresql42/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v42/condition/ConditionalOnPostgresqlProtectEnabled.java b/joylive-plugin/joylive-protection/joylive-protection-postgresql42/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v42/condition/ConditionalOnPostgresqlProtectEnabled.java new file mode 100644 index 000000000..fdd0e9067 --- /dev/null +++ b/joylive-plugin/joylive-protection/joylive-protection-postgresql42/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v42/condition/ConditionalOnPostgresqlProtectEnabled.java @@ -0,0 +1,33 @@ +/* + * 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.protection.postgresql.v42.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.annotation.ConditionalOnProtectEnabled; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProtectEnabled +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_POSTGRESQL_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnPostgresqlProtectEnabled { + +} diff --git a/joylive-plugin/joylive-protection/joylive-protection-postgresql42/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v42/definition/QueryExecutorImplDefinition.java b/joylive-plugin/joylive-protection/joylive-protection-postgresql42/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v42/definition/QueryExecutorImplDefinition.java index 52f680855..f3d533d82 100644 --- a/joylive-plugin/joylive-protection/joylive-protection-postgresql42/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v42/definition/QueryExecutorImplDefinition.java +++ b/joylive-plugin/joylive-protection/joylive-protection-postgresql42/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v42/definition/QueryExecutorImplDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,15 +24,13 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.protection.postgresql.v42.condition.ConditionalOnPostgresqlProtectEnabled; import com.jd.live.agent.plugin.protection.postgresql.v42.interceptor.QueryExecutorImplInterceptor; @Injectable @Extension(value = "QueryExecutorImplDefinition_v42", order = PluginDefinition.ORDER_PROTECT) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_POSTGRESQL_ENABLED, matchIfMissing = true) +@ConditionalOnPostgresqlProtectEnabled @ConditionalOnClass(QueryExecutorImplDefinition.TYPE_QUERY_EXECUTOR_IMPL) public class QueryExecutorImplDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-protection/joylive-protection-postgresql9.4/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v9_4/condition/ConditionalOnPostgresqlProtectEnabled.java b/joylive-plugin/joylive-protection/joylive-protection-postgresql9.4/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v9_4/condition/ConditionalOnPostgresqlProtectEnabled.java new file mode 100644 index 000000000..e9196dd23 --- /dev/null +++ b/joylive-plugin/joylive-protection/joylive-protection-postgresql9.4/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v9_4/condition/ConditionalOnPostgresqlProtectEnabled.java @@ -0,0 +1,33 @@ +/* + * 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.protection.postgresql.v9_4.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.annotation.ConditionalOnProtectEnabled; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProtectEnabled +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_POSTGRESQL_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnPostgresqlProtectEnabled { + +} diff --git a/joylive-plugin/joylive-protection/joylive-protection-postgresql9.4/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v9_4/definition/QueryExecutorImplDefinition.java b/joylive-plugin/joylive-protection/joylive-protection-postgresql9.4/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v9_4/definition/QueryExecutorImplDefinition.java index 78df6ab20..43e4da06a 100644 --- a/joylive-plugin/joylive-protection/joylive-protection-postgresql9.4/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v9_4/definition/QueryExecutorImplDefinition.java +++ b/joylive-plugin/joylive-protection/joylive-protection-postgresql9.4/src/main/java/com/jd/live/agent/plugin/protection/postgresql/v9_4/definition/QueryExecutorImplDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,15 +24,13 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.protection.postgresql.v9_4.condition.ConditionalOnPostgresqlProtectEnabled; import com.jd.live.agent.plugin.protection.postgresql.v9_4.interceptor.QueryExecutorImplInterceptor; @Injectable @Extension(value = "QueryExecutorImplDefinition_v9.4", order = PluginDefinition.ORDER_PROTECT) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_POSTGRESQL_ENABLED, matchIfMissing = true) +@ConditionalOnPostgresqlProtectEnabled @ConditionalOnClass(QueryExecutorImplDefinition.TYPE_QUERY_EXECUTOR_IMPL) public class QueryExecutorImplDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-protection/joylive-protection-redis/src/main/java/com/jd/live/agent/plugin/protection/redis/condition/ConditionalOnRedisProtectEnabled.java b/joylive-plugin/joylive-protection/joylive-protection-redis/src/main/java/com/jd/live/agent/plugin/protection/redis/condition/ConditionalOnRedisProtectEnabled.java new file mode 100644 index 000000000..b4ae56138 --- /dev/null +++ b/joylive-plugin/joylive-protection/joylive-protection-redis/src/main/java/com/jd/live/agent/plugin/protection/redis/condition/ConditionalOnRedisProtectEnabled.java @@ -0,0 +1,33 @@ +/* + * 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.protection.redis.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.annotation.ConditionalOnProtectEnabled; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProtectEnabled +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_REDIS_ENABLED) +@ConditionalComposite +public @interface ConditionalOnRedisProtectEnabled { + +} diff --git a/joylive-plugin/joylive-protection/joylive-protection-redis/src/main/java/com/jd/live/agent/plugin/protection/redis/definition/JedisConnectionDefinition.java b/joylive-plugin/joylive-protection/joylive-protection-redis/src/main/java/com/jd/live/agent/plugin/protection/redis/definition/JedisConnectionDefinition.java index 13b863450..6224689ad 100644 --- a/joylive-plugin/joylive-protection/joylive-protection-redis/src/main/java/com/jd/live/agent/plugin/protection/redis/definition/JedisConnectionDefinition.java +++ b/joylive-plugin/joylive-protection/joylive-protection-redis/src/main/java/com/jd/live/agent/plugin/protection/redis/definition/JedisConnectionDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,15 +24,13 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.protection.redis.condition.ConditionalOnRedisProtectEnabled; import com.jd.live.agent.plugin.protection.redis.interceptor.JedisConnectionInterceptor; @Injectable @Extension(value = "JedisConnectionDefinition", order = PluginDefinition.ORDER_PROTECT) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_PROTECT_REDIS_ENABLED) +@ConditionalOnRedisProtectEnabled @ConditionalOnClass(JedisConnectionDefinition.TYPE_JEDIS) public class JedisConnectionDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/condition/ConditionalOnDubbo26Enabled.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/condition/ConditionalOnDubbo26Enabled.java new file mode 100644 index 000000000..b0175d793 --- /dev/null +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/condition/ConditionalOnDubbo26Enabled.java @@ -0,0 +1,34 @@ +/* + * 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.registry.dubbo.v2_6.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; +import com.jd.live.agent.governance.annotation.ConditionalOnDubboEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubboEnabled +@ConditionalOnMissingClass(ConditionalOnDubbo26Enabled.TYPE_REFERENCE_CONFIG) +@ConditionalComposite +public @interface ConditionalOnDubbo26Enabled { + + String TYPE_REFERENCE_CONFIG = "org.apache.dubbo.config.ReferenceConfig"; + +} diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/condition/ConditionalOnDubbo26GovernanceEnabled.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/condition/ConditionalOnDubbo26GovernanceEnabled.java new file mode 100644 index 000000000..c61dbc526 --- /dev/null +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/condition/ConditionalOnDubbo26GovernanceEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.registry.dubbo.v2_6.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubbo26Enabled +@ConditionalOnGovernanceEnabled +@ConditionalComposite +public @interface ConditionalOnDubbo26GovernanceEnabled { + +} diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/definition/ReferenceConfigDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/definition/ReferenceConfigDefinition.java index da28bf2fd..b8c86ac10 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/definition/ReferenceConfigDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/definition/ReferenceConfigDefinition.java @@ -16,7 +16,8 @@ package com.jd.live.agent.plugin.registry.dubbo.v2_6.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.instance.Application; @@ -24,8 +25,8 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.registry.dubbo.v2_6.condition.ConditionalOnDubbo26GovernanceEnabled; import com.jd.live.agent.plugin.registry.dubbo.v2_6.interceptor.ReferenceConfigInterceptor; /** @@ -33,11 +34,7 @@ */ @Injectable @Extension(value = "ReferenceConfigDefinition_v2.6", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnDubbo26GovernanceEnabled @ConditionalOnClass(ReferenceConfigDefinition.TYPE_REFERENCE_CONFIG) public class ReferenceConfigDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/definition/RegistryDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/definition/RegistryDefinition.java index 39bebb84e..4738b46a2 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/definition/RegistryDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/definition/RegistryDefinition.java @@ -17,7 +17,8 @@ import com.jd.live.agent.core.bootstrap.AgentLifecycle; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.instance.Application; @@ -25,8 +26,8 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.registry.Registry; +import com.jd.live.agent.plugin.registry.dubbo.v2_6.condition.ConditionalOnDubbo26GovernanceEnabled; import com.jd.live.agent.plugin.registry.dubbo.v2_6.interceptor.RegistryInterceptor; /** @@ -34,12 +35,7 @@ */ @Injectable @Extension(value = "RegistryDefinition_v2.6", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) -@ConditionalOnClass(ReferenceConfigDefinition.TYPE_REFERENCE_CONFIG) +@ConditionalOnDubbo26GovernanceEnabled @ConditionalOnClass(RegistryDefinition.TYPE_FAILBACK_REGISTRY) public class RegistryDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/definition/ServiceConfigDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/definition/ServiceConfigDefinition.java index 6ebae75d1..1ab4275af 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/definition/ServiceConfigDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.6/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_6/definition/ServiceConfigDefinition.java @@ -16,7 +16,8 @@ package com.jd.live.agent.plugin.registry.dubbo.v2_6.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.instance.Application; @@ -24,8 +25,8 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.registry.dubbo.v2_6.condition.ConditionalOnDubbo26GovernanceEnabled; import com.jd.live.agent.plugin.registry.dubbo.v2_6.interceptor.ServiceConfigInterceptor; /** @@ -33,11 +34,7 @@ */ @Injectable @Extension(value = "ServiceConfigDefinition_v2.6", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnDubbo26GovernanceEnabled @ConditionalOnClass(ServiceConfigDefinition.TYPE_SERVICE_CONFIG) public class ServiceConfigDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/condition/ConditionalOnDubbo27Enabled.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/condition/ConditionalOnDubbo27Enabled.java new file mode 100644 index 000000000..3e1042f74 --- /dev/null +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/condition/ConditionalOnDubbo27Enabled.java @@ -0,0 +1,34 @@ +/* + * 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.registry.dubbo.v2_7.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; +import com.jd.live.agent.governance.annotation.ConditionalOnDubboEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubboEnabled +@ConditionalOnMissingClass(ConditionalOnDubbo27Enabled.TYPE_PROTOCOL_FILTER_WRAPPER) +@ConditionalComposite +public @interface ConditionalOnDubbo27Enabled { + + String TYPE_PROTOCOL_FILTER_WRAPPER = "org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper"; + +} diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/condition/ConditionalOnDubbo27GovernanceEnabled.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/condition/ConditionalOnDubbo27GovernanceEnabled.java new file mode 100644 index 000000000..8d8e8153c --- /dev/null +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/condition/ConditionalOnDubbo27GovernanceEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.registry.dubbo.v2_7.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubbo27Enabled +@ConditionalOnGovernanceEnabled +@ConditionalComposite +public @interface ConditionalOnDubbo27GovernanceEnabled { + +} diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/definition/ReferenceConfigDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/definition/ReferenceConfigDefinition.java index cd3379b71..609dd16b8 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/definition/ReferenceConfigDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/definition/ReferenceConfigDefinition.java @@ -16,7 +16,8 @@ package com.jd.live.agent.plugin.registry.dubbo.v2_7.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.instance.Application; @@ -24,8 +25,8 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.registry.dubbo.v2_7.condition.ConditionalOnDubbo27GovernanceEnabled; import com.jd.live.agent.plugin.registry.dubbo.v2_7.interceptor.ReferenceConfigInterceptor; /** @@ -33,19 +34,12 @@ */ @Injectable @Extension(value = "ServiceConfigDefinition_v2.7", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) -@ConditionalOnClass(ReferenceConfigDefinition.TYPE_PROTOCOL_FILTER_WRAPPER) +@ConditionalOnDubbo27GovernanceEnabled @ConditionalOnClass(ReferenceConfigDefinition.TYPE_REFERENCE_CONFIG) public class ReferenceConfigDefinition extends PluginDefinitionAdapter { protected static final String TYPE_REFERENCE_CONFIG = "org.apache.dubbo.config.ReferenceConfig"; - protected static final String TYPE_PROTOCOL_FILTER_WRAPPER = "org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper"; - private static final String METHOD_CREATE_PROXY = "createProxy"; private static final String[] ARGUMENT_CREATE_PROXY = new String[]{ diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/definition/RegistryDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/definition/RegistryDefinition.java index e580bc79c..588fed5f5 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/definition/RegistryDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/definition/RegistryDefinition.java @@ -17,7 +17,8 @@ import com.jd.live.agent.core.bootstrap.AgentLifecycle; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.instance.Application; @@ -25,8 +26,8 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.registry.Registry; +import com.jd.live.agent.plugin.registry.dubbo.v2_7.condition.ConditionalOnDubbo27GovernanceEnabled; import com.jd.live.agent.plugin.registry.dubbo.v2_7.interceptor.RegistryInterceptor; import java.util.*; @@ -36,12 +37,7 @@ */ @Injectable @Extension(value = "RegistryDefinition_v2.7", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) -@ConditionalOnClass(ReferenceConfigDefinition.TYPE_PROTOCOL_FILTER_WRAPPER) +@ConditionalOnDubbo27GovernanceEnabled @ConditionalOnClass(RegistryDefinition.TYPE_SERVICE_DISCOVERY) public class RegistryDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/definition/ServiceConfigDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/definition/ServiceConfigDefinition.java index a3cdb4e61..822bf1b23 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/definition/ServiceConfigDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo2.7/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v2_7/definition/ServiceConfigDefinition.java @@ -16,7 +16,8 @@ package com.jd.live.agent.plugin.registry.dubbo.v2_7.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.instance.Application; @@ -24,8 +25,8 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.registry.dubbo.v2_7.condition.ConditionalOnDubbo27GovernanceEnabled; import com.jd.live.agent.plugin.registry.dubbo.v2_7.interceptor.ServiceConfigInterceptor; /** @@ -33,12 +34,7 @@ */ @Injectable @Extension(value = "ServiceConfigDefinition_v2.7", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) -@ConditionalOnClass(ReferenceConfigDefinition.TYPE_PROTOCOL_FILTER_WRAPPER) +@ConditionalOnDubbo27GovernanceEnabled @ConditionalOnClass(ServiceConfigDefinition.TYPE_SERVICE_CONFIG) public class ServiceConfigDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/condition/ConditionalOnDubbo3Enabled.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/condition/ConditionalOnDubbo3Enabled.java new file mode 100644 index 000000000..6bc22bbac --- /dev/null +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/condition/ConditionalOnDubbo3Enabled.java @@ -0,0 +1,34 @@ +/* + * 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.registry.dubbo.v3.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; +import com.jd.live.agent.governance.annotation.ConditionalOnDubboEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubboEnabled +@ConditionalOnMissingClass(ConditionalOnDubbo3Enabled.TYPE_CONSUMER_CONTEXT_FILTER) +@ConditionalComposite +public @interface ConditionalOnDubbo3Enabled { + + String TYPE_CONSUMER_CONTEXT_FILTER = "org.apache.dubbo.rpc.cluster.filter.support.ConsumerContextFilter"; + +} diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/condition/ConditionalOnDubbo3GovernanceEnabled.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/condition/ConditionalOnDubbo3GovernanceEnabled.java new file mode 100644 index 000000000..e5c6cd363 --- /dev/null +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/condition/ConditionalOnDubbo3GovernanceEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.registry.dubbo.v3.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubbo3Enabled +@ConditionalOnGovernanceEnabled +@ConditionalComposite +public @interface ConditionalOnDubbo3GovernanceEnabled { + +} diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/definition/ReferenceConfigDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/definition/ReferenceConfigDefinition.java index 150986bf2..b9eb0af60 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/definition/ReferenceConfigDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/definition/ReferenceConfigDefinition.java @@ -16,7 +16,8 @@ package com.jd.live.agent.plugin.registry.dubbo.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.instance.Application; @@ -24,8 +25,8 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.registry.dubbo.v3.condition.ConditionalOnDubbo3GovernanceEnabled; import com.jd.live.agent.plugin.registry.dubbo.v3.interceptor.ReferenceConfigInterceptor; /** @@ -33,12 +34,7 @@ */ @Injectable @Extension(value = "ReferenceConfigDefinition_v3", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) -@ConditionalOnClass(ServiceConfigDefinition.TYPE_CONSUMER_CONTEXT_FILTER) +@ConditionalOnDubbo3GovernanceEnabled @ConditionalOnClass(ReferenceConfigDefinition.TYPE_REFERENCE_CONFIG) public class ReferenceConfigDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/definition/RegistryDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/definition/RegistryDefinition.java index 1d8c2f7d1..07d52c006 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/definition/RegistryDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/definition/RegistryDefinition.java @@ -17,7 +17,8 @@ import com.jd.live.agent.core.bootstrap.AgentLifecycle; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.instance.Application; @@ -25,8 +26,8 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.registry.Registry; +import com.jd.live.agent.plugin.registry.dubbo.v3.condition.ConditionalOnDubbo3GovernanceEnabled; import com.jd.live.agent.plugin.registry.dubbo.v3.interceptor.RegistryInterceptor; import java.util.*; @@ -36,12 +37,7 @@ */ @Injectable @Extension(value = "RegistryDefinition_v3", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) -@ConditionalOnClass(ServiceConfigDefinition.TYPE_CONSUMER_CONTEXT_FILTER) +@ConditionalOnDubbo3GovernanceEnabled @ConditionalOnClass(RegistryDefinition.TYPE_SERVICE_DISCOVERY) public class RegistryDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/definition/ServiceConfigDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/definition/ServiceConfigDefinition.java index f1d0ccae2..8b5b5e095 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/definition/ServiceConfigDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-dubbo3/src/main/java/com/jd/live/agent/plugin/registry/dubbo/v3/definition/ServiceConfigDefinition.java @@ -16,7 +16,8 @@ package com.jd.live.agent.plugin.registry.dubbo.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.instance.Application; @@ -24,8 +25,8 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.registry.dubbo.v3.condition.ConditionalOnDubbo3GovernanceEnabled; import com.jd.live.agent.plugin.registry.dubbo.v3.interceptor.ServiceConfigInterceptor; /** @@ -33,17 +34,10 @@ */ @Injectable @Extension(value = "ServiceConfigDefinition_v3", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) -@ConditionalOnClass(ServiceConfigDefinition.TYPE_CONSUMER_CONTEXT_FILTER) +@ConditionalOnDubbo3GovernanceEnabled @ConditionalOnClass(ServiceConfigDefinition.TYPE_SERVICE_CONFIG) public class ServiceConfigDefinition extends PluginDefinitionAdapter { - protected static final String TYPE_CONSUMER_CONTEXT_FILTER = "org.apache.dubbo.rpc.cluster.filter.support.ConsumerContextFilter"; - protected static final String TYPE_SERVICE_CONFIG = "org.apache.dubbo.config.ServiceConfig"; private static final String METHOD_BUILD_ATTRIBUTES = "buildAttributes"; diff --git a/joylive-plugin/joylive-registry/joylive-registry-sofarpc/src/main/java/com/jd/live/agent/plugin/registry/sofarpc/definition/ConsumerBootstrapDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-sofarpc/src/main/java/com/jd/live/agent/plugin/registry/sofarpc/definition/ConsumerBootstrapDefinition.java index 80e24ca19..a51290fa1 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-sofarpc/src/main/java/com/jd/live/agent/plugin/registry/sofarpc/definition/ConsumerBootstrapDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-sofarpc/src/main/java/com/jd/live/agent/plugin/registry/sofarpc/definition/ConsumerBootstrapDefinition.java @@ -16,12 +16,13 @@ package com.jd.live.agent.plugin.registry.sofarpc.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.instance.Application; import com.jd.live.agent.core.plugin.definition.*; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; import com.jd.live.agent.governance.policy.PolicySupplier; import com.jd.live.agent.plugin.registry.sofarpc.interceptor.ConsumerBootstrapInterceptor; @@ -33,11 +34,7 @@ */ @Injectable @Extension(value = "ConsumerBootstrapDefinition", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnGovernanceEnabled @ConditionalOnClass(ConsumerBootstrapDefinition.TYPE_CONSUMER_BOOTSTRAP) public class ConsumerBootstrapDefinition extends PluginDefinitionAdapter implements PluginImporter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-sofarpc/src/main/java/com/jd/live/agent/plugin/registry/sofarpc/definition/ProviderBootstrapDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-sofarpc/src/main/java/com/jd/live/agent/plugin/registry/sofarpc/definition/ProviderBootstrapDefinition.java index 7dcd98f67..9c6d95843 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-sofarpc/src/main/java/com/jd/live/agent/plugin/registry/sofarpc/definition/ProviderBootstrapDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-sofarpc/src/main/java/com/jd/live/agent/plugin/registry/sofarpc/definition/ProviderBootstrapDefinition.java @@ -16,12 +16,13 @@ package com.jd.live.agent.plugin.registry.sofarpc.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.instance.Application; import com.jd.live.agent.core.plugin.definition.*; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; import com.jd.live.agent.governance.policy.PolicySupplier; import com.jd.live.agent.plugin.registry.sofarpc.interceptor.ProviderBootstrapInterceptor; @@ -33,11 +34,7 @@ */ @Injectable @Extension(value = "ProviderBootstrapDefinition", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnGovernanceEnabled @ConditionalOnClass(ProviderBootstrapDefinition.TYPE_PROVIDER_BOOTSTRAP) public class ProviderBootstrapDefinition extends PluginDefinitionAdapter implements PluginImporter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-sofarpc/src/main/java/com/jd/live/agent/plugin/registry/sofarpc/definition/RegistryDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-sofarpc/src/main/java/com/jd/live/agent/plugin/registry/sofarpc/definition/RegistryDefinition.java index 0be63358c..ae3388724 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-sofarpc/src/main/java/com/jd/live/agent/plugin/registry/sofarpc/definition/RegistryDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-sofarpc/src/main/java/com/jd/live/agent/plugin/registry/sofarpc/definition/RegistryDefinition.java @@ -17,7 +17,8 @@ import com.jd.live.agent.core.bootstrap.AgentLifecycle; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.instance.Application; @@ -25,7 +26,7 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; import com.jd.live.agent.governance.registry.Registry; import com.jd.live.agent.plugin.registry.sofarpc.interceptor.RegistryInterceptor; @@ -36,11 +37,7 @@ */ @Injectable @Extension(value = "RegistryDefinition_v3", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnGovernanceEnabled @ConditionalOnClass(RegistryDefinition.TYPE_REGISTRY) public class RegistryDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/DiscoveryClientDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/DiscoveryClientDefinition.java index b99711155..3ab3af408 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/DiscoveryClientDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/DiscoveryClientDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.registry.springcloud.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; import com.jd.live.agent.governance.policy.PolicySupplier; import com.jd.live.agent.plugin.registry.springcloud.v3.interceptor.DiscoveryClientConstructorInterceptor; import com.jd.live.agent.plugin.registry.springcloud.v3.interceptor.DiscoveryClientGetInterceptor; @@ -33,11 +34,7 @@ */ @Injectable @Extension(value = "DiscoveryClientDefinition_v3", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnGovernanceEnabled @ConditionalOnClass(DiscoveryClientDefinition.TYPE_DISCOVERY_CLIENT) public class DiscoveryClientDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/FeignClientFactoryBeanDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/FeignClientFactoryBeanDefinition.java index 60da1478e..26ac5e74b 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/FeignClientFactoryBeanDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/FeignClientFactoryBeanDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.registry.springcloud.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; import com.jd.live.agent.governance.policy.PolicySupplier; import com.jd.live.agent.plugin.registry.springcloud.v3.interceptor.FeignClientFactoryBeanInterceptor; @@ -32,11 +33,7 @@ */ @Injectable @Extension(value = "FeignClientFactoryBeanDefinition_v3", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnGovernanceEnabled @ConditionalOnClass(FeignClientFactoryBeanDefinition.TYPE_FEIGN_CLIENT_FACTORY_BEAN) public class FeignClientFactoryBeanDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/RegistryDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/RegistryDefinition.java index 6f8b9797f..3b511de50 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/RegistryDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-springcloud3/src/main/java/com/jd/live/agent/plugin/registry/springcloud/v3/definition/RegistryDefinition.java @@ -17,7 +17,8 @@ import com.jd.live.agent.core.bootstrap.AgentLifecycle; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.instance.Application; @@ -25,7 +26,7 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; import com.jd.live.agent.governance.policy.PolicySupplier; import com.jd.live.agent.governance.registry.Registry; import com.jd.live.agent.plugin.registry.springcloud.v3.interceptor.RegistryInterceptor; @@ -38,11 +39,7 @@ */ @Injectable @Extension(value = "ServiceRegistryDefinition_v3", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnGovernanceEnabled @ConditionalOnClass(RegistryDefinition.TYPE_SERVICE_REGISTRY) public class RegistryDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-registry/joylive-registry-springgateway3/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v3/condition/ConditionalOnSpringGateway3Enabled.java b/joylive-plugin/joylive-registry/joylive-registry-springgateway3/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v3/condition/ConditionalOnSpringGateway3Enabled.java new file mode 100644 index 000000000..c11245740 --- /dev/null +++ b/joylive-plugin/joylive-registry/joylive-registry-springgateway3/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v3/condition/ConditionalOnSpringGateway3Enabled.java @@ -0,0 +1,39 @@ +/* + * 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.registry.springgateway.v3.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; +import com.jd.live.agent.governance.annotation.ConditionalOnReactive; +import com.jd.live.agent.governance.annotation.ConditionalOnSpringGatewayEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringGatewayEnabled +@ConditionalOnReactive +@ConditionalOnMissingClass(ConditionalOnSpringGateway3Enabled.TYPE_HTTP_HTTP_STATUS_CODE) +@ConditionalComposite +public @interface ConditionalOnSpringGateway3Enabled { + + String TYPE_HTTP_HTTP_STATUS_CODE = "org.springframework.http.HttpStatusCode"; + +} diff --git a/joylive-plugin/joylive-registry/joylive-registry-springgateway3/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v3/condition/ConditionalOnSpringGateway3GovernanceEnabled.java b/joylive-plugin/joylive-registry/joylive-registry-springgateway3/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v3/condition/ConditionalOnSpringGateway3GovernanceEnabled.java new file mode 100644 index 000000000..936f2aa3c --- /dev/null +++ b/joylive-plugin/joylive-registry/joylive-registry-springgateway3/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v3/condition/ConditionalOnSpringGateway3GovernanceEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.registry.springgateway.v3.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringGateway3Enabled +@ConditionalOnGovernanceEnabled +@ConditionalComposite +public @interface ConditionalOnSpringGateway3GovernanceEnabled { + +} diff --git a/joylive-plugin/joylive-registry/joylive-registry-springgateway3/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v3/definition/RouteDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-springgateway3/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v3/definition/RouteDefinition.java index 0520e82d4..565a09458 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-springgateway3/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v3/definition/RouteDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-springgateway3/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v3/definition/RouteDefinition.java @@ -16,15 +16,16 @@ package com.jd.live.agent.plugin.registry.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.registry.springgateway.v3.condition.ConditionalOnSpringGateway3GovernanceEnabled; import com.jd.live.agent.plugin.registry.springgateway.v3.interceptor.RouteInterceptor; /** @@ -32,19 +33,12 @@ */ @Injectable @Extension(value = "RouteDefinition_v3", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnSpringGateway3GovernanceEnabled @ConditionalOnClass(RouteDefinition.TYPE_ROUTE_DEFINITION_ROUTE_LOCATOR) -@ConditionalOnMissingClass(RouteDefinition.TYPE_HTTP_STATUS_CODE) public class RouteDefinition extends PluginDefinitionAdapter { protected static final String TYPE_ROUTE_DEFINITION_ROUTE_LOCATOR = "org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator"; - protected static final String TYPE_HTTP_STATUS_CODE = "org.springframework.http.HttpStatusCode"; - private static final String METHOD_CONVERT_TO_ROUTE = "convertToRoute"; private static final String[] ARGUMENT_CONVERT_TO_ROUTE = new String[]{ diff --git a/joylive-plugin/joylive-registry/joylive-registry-springgateway4/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v4/condition/ConditionalOnSpringGateway4Enabled.java b/joylive-plugin/joylive-registry/joylive-registry-springgateway4/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v4/condition/ConditionalOnSpringGateway4Enabled.java new file mode 100644 index 000000000..6393d4912 --- /dev/null +++ b/joylive-plugin/joylive-registry/joylive-registry-springgateway4/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v4/condition/ConditionalOnSpringGateway4Enabled.java @@ -0,0 +1,39 @@ +/* + * 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.registry.springgateway.v4.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.governance.annotation.ConditionalOnReactive; +import com.jd.live.agent.governance.annotation.ConditionalOnSpringGatewayEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringGatewayEnabled +@ConditionalOnReactive +@ConditionalOnClass(ConditionalOnSpringGateway4Enabled.TYPE_HTTP_HTTP_STATUS_CODE) +@ConditionalComposite +public @interface ConditionalOnSpringGateway4Enabled { + + String TYPE_HTTP_HTTP_STATUS_CODE = "org.springframework.http.HttpStatusCode"; + +} diff --git a/joylive-plugin/joylive-registry/joylive-registry-springgateway4/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v4/condition/ConditionalOnSpringGateway4GovernanceEnabled.java b/joylive-plugin/joylive-registry/joylive-registry-springgateway4/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v4/condition/ConditionalOnSpringGateway4GovernanceEnabled.java new file mode 100644 index 000000000..6a2ef67f3 --- /dev/null +++ b/joylive-plugin/joylive-registry/joylive-registry-springgateway4/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v4/condition/ConditionalOnSpringGateway4GovernanceEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.registry.springgateway.v4.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringGateway4Enabled +@ConditionalOnGovernanceEnabled +@ConditionalComposite +public @interface ConditionalOnSpringGateway4GovernanceEnabled { + +} diff --git a/joylive-plugin/joylive-registry/joylive-registry-springgateway4/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v4/definition/RouteDefinition.java b/joylive-plugin/joylive-registry/joylive-registry-springgateway4/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v4/definition/RouteDefinition.java index dd48bbee8..b54bf573b 100644 --- a/joylive-plugin/joylive-registry/joylive-registry-springgateway4/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v4/definition/RouteDefinition.java +++ b/joylive-plugin/joylive-registry/joylive-registry-springgateway4/src/main/java/com/jd/live/agent/plugin/registry/springgateway/v4/definition/RouteDefinition.java @@ -16,35 +16,29 @@ package com.jd.live.agent.plugin.registry.springgateway.v4.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.policy.PolicySupplier; +import com.jd.live.agent.plugin.registry.springgateway.v4.condition.ConditionalOnSpringGateway4GovernanceEnabled; import com.jd.live.agent.plugin.registry.springgateway.v4.interceptor.RouteInterceptor; /** * RouteDefinition */ @Injectable -@Extension(value = "RouteDefinition_v3", order = PluginDefinition.ORDER_REGISTRY) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@Extension(value = "RouteDefinition_v4", order = PluginDefinition.ORDER_REGISTRY) +@ConditionalOnSpringGateway4GovernanceEnabled @ConditionalOnClass(RouteDefinition.TYPE_ROUTE_DEFINITION_ROUTE_LOCATOR) -@ConditionalOnClass(RouteDefinition.TYPE_HTTP_STATUS_CODE) public class RouteDefinition extends PluginDefinitionAdapter { protected static final String TYPE_ROUTE_DEFINITION_ROUTE_LOCATOR = "org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator"; - protected static final String TYPE_HTTP_STATUS_CODE = "org.springframework.http.HttpStatusCode"; - private static final String METHOD_CONVERT_TO_ROUTE = "convertToRoute"; private static final String[] ARGUMENT_CONVERT_TO_ROUTE = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/condition/ConditionalOnDubbo26Enabled.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/condition/ConditionalOnDubbo26Enabled.java new file mode 100644 index 000000000..aba509f1a --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/condition/ConditionalOnDubbo26Enabled.java @@ -0,0 +1,30 @@ +/* + * 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.dubbo.v2_6.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnDubboEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubboEnabled +@ConditionalComposite +public @interface ConditionalOnDubbo26Enabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/condition/ConditionalOnDubbo26FlowControlEnabled.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/condition/ConditionalOnDubbo26FlowControlEnabled.java new file mode 100644 index 000000000..1bae5879c --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/condition/ConditionalOnDubbo26FlowControlEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.dubbo.v2_6.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnFlowControlEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubbo26Enabled +@ConditionalOnFlowControlEnabled +@ConditionalComposite +public @interface ConditionalOnDubbo26FlowControlEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/condition/ConditionalOnDubbo26GovernanceEnabled.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/condition/ConditionalOnDubbo26GovernanceEnabled.java new file mode 100644 index 000000000..336eb386f --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/condition/ConditionalOnDubbo26GovernanceEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.dubbo.v2_6.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubbo26Enabled +@ConditionalOnGovernanceEnabled +@ConditionalComposite +public @interface ConditionalOnDubbo26GovernanceEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/condition/ConditionalOnDubbo26OnlyRouteEnabled.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/condition/ConditionalOnDubbo26OnlyRouteEnabled.java new file mode 100644 index 000000000..bc27fb19f --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/condition/ConditionalOnDubbo26OnlyRouteEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.dubbo.v2_6.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnOnlyRouteEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubbo26Enabled +@ConditionalOnOnlyRouteEnabled +@ConditionalComposite +public @interface ConditionalOnDubbo26OnlyRouteEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/definition/ClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/definition/ClusterDefinition.java index 4833b27fe..452a761e3 100644 --- a/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/definition/ClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/definition/ClusterDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,14 +24,13 @@ 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.dubbo.v2_6.condition.ConditionalOnDubbo26FlowControlEnabled; import com.jd.live.agent.plugin.router.dubbo.v2_6.interceptor.ClusterInterceptor; @Injectable @Extension(value = "ClusterDefinition_v2.6") -@ConditionalOnProperty(name = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_DUBBO_ENABLED, matchIfMissing = true) +@ConditionalOnDubbo26FlowControlEnabled @ConditionalOnClass(ClusterDefinition.TYPE_ABSTRACT_CLUSTER) public class ClusterDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/definition/ExceptionFilterDefinition.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/definition/ExceptionFilterDefinition.java index ddb9eb811..7ebb3e560 100644 --- a/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/definition/ExceptionFilterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/definition/ExceptionFilterDefinition.java @@ -16,26 +16,20 @@ package com.jd.live.agent.plugin.router.dubbo.v2_6.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.dubbo.v2_6.condition.ConditionalOnDubbo26GovernanceEnabled; import com.jd.live.agent.plugin.router.dubbo.v2_6.interceptor.ExceptionFilterInterceptor; @Injectable @Extension(value = "ExceptionFilterDefinition_v2.6") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED, - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_DUBBO_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnDubbo26GovernanceEnabled @ConditionalOnClass(ExceptionFilterDefinition.TYPE_EXCEPTION_FILTER) public class ExceptionFilterDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/definition/LoadBalanceDefinition.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/definition/LoadBalanceDefinition.java index 9027b3d14..cf0cef5fd 100644 --- a/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/definition/LoadBalanceDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.6/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_6/definition/LoadBalanceDefinition.java @@ -16,26 +16,20 @@ package com.jd.live.agent.plugin.router.dubbo.v2_6.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.dubbo.v2_6.condition.ConditionalOnDubbo26OnlyRouteEnabled; import com.jd.live.agent.plugin.router.dubbo.v2_6.interceptor.LoadBalanceInterceptor; @Injectable @Extension(value = "LoadBalanceDefinition_v2.6") -@ConditionalOnProperties(value = { - @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(name = GovernanceConfig.CONFIG_LIVE_DUBBO_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnDubbo26OnlyRouteEnabled @ConditionalOnClass(LoadBalanceDefinition.TYPE_ABSTRACT_CLUSTER) public class LoadBalanceDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/condition/ConditionalOnDubbo27Enabled.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/condition/ConditionalOnDubbo27Enabled.java new file mode 100644 index 000000000..1065fee30 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/condition/ConditionalOnDubbo27Enabled.java @@ -0,0 +1,34 @@ +/* + * 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.dubbo.v2_7.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.governance.annotation.ConditionalOnDubboEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubboEnabled +@ConditionalOnClass(ConditionalOnDubbo27Enabled.TYPE_PROTOCOL_FILTER_WRAPPER) +@ConditionalComposite +public @interface ConditionalOnDubbo27Enabled { + + String TYPE_PROTOCOL_FILTER_WRAPPER = "org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper"; + +} diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/condition/ConditionalOnDubbo27FlowControlEnabled.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/condition/ConditionalOnDubbo27FlowControlEnabled.java new file mode 100644 index 000000000..4cf5ace6f --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/condition/ConditionalOnDubbo27FlowControlEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.dubbo.v2_7.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnFlowControlEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubbo27Enabled +@ConditionalOnFlowControlEnabled +@ConditionalComposite +public @interface ConditionalOnDubbo27FlowControlEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/condition/ConditionalOnDubbo27GovernanceEnabled.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/condition/ConditionalOnDubbo27GovernanceEnabled.java new file mode 100644 index 000000000..9f7b18d58 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/condition/ConditionalOnDubbo27GovernanceEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.dubbo.v2_7.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubbo27Enabled +@ConditionalOnGovernanceEnabled +@ConditionalComposite +public @interface ConditionalOnDubbo27GovernanceEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/condition/ConditionalOnDubbo27OnlyRouteEnabled.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/condition/ConditionalOnDubbo27OnlyRouteEnabled.java new file mode 100644 index 000000000..c41b38e73 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/condition/ConditionalOnDubbo27OnlyRouteEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.dubbo.v2_7.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnOnlyRouteEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubbo27Enabled +@ConditionalOnOnlyRouteEnabled +@ConditionalComposite +public @interface ConditionalOnDubbo27OnlyRouteEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/definition/ClassLoaderFilterDefinition.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/definition/ClassLoaderFilterDefinition.java index df85c0f89..ebe209736 100644 --- a/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/definition/ClassLoaderFilterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/definition/ClassLoaderFilterDefinition.java @@ -16,34 +16,25 @@ package com.jd.live.agent.plugin.router.dubbo.v2_7.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.dubbo.v2_7.condition.ConditionalOnDubbo27GovernanceEnabled; import com.jd.live.agent.plugin.router.dubbo.v2_7.interceptor.ClassLoaderFilterInterceptor; @Injectable @Extension(value = "ClassLoaderFilterDefinition_v2.7") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED, - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_DUBBO_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnDubbo27GovernanceEnabled @ConditionalOnClass(ClassLoaderFilterDefinition.TYPE_CLASSLOADER_FILTER) -@ConditionalOnClass(ClassLoaderFilterDefinition.TYPE_PROTOCOL_FILTER_WRAPPER) public class ClassLoaderFilterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_CLASSLOADER_FILTER = "org.apache.dubbo.rpc.filter.ClassLoaderFilter"; - protected static final String TYPE_PROTOCOL_FILTER_WRAPPER = "org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper"; - private static final String METHOD_INVOKE = "invoke"; protected static final String[] ARGUMENT_INVOKE = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/definition/ClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/definition/ClusterDefinition.java index a1c120756..c1d525e49 100644 --- a/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/definition/ClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/definition/ClusterDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,16 +24,14 @@ 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.dubbo.v2_7.condition.ConditionalOnDubbo27FlowControlEnabled; import com.jd.live.agent.plugin.router.dubbo.v2_7.interceptor.ClusterInterceptor; @Injectable @Extension(value = "ClusterDefinition_v2.7") -@ConditionalOnProperty(name = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_DUBBO_ENABLED, matchIfMissing = true) +@ConditionalOnDubbo27FlowControlEnabled @ConditionalOnClass(ClusterDefinition.TYPE_ABSTRACT_CLUSTER) -@ConditionalOnClass(ClassLoaderFilterDefinition.TYPE_PROTOCOL_FILTER_WRAPPER) public class ClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_ABSTRACT_CLUSTER = "org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker"; diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/definition/LoadBalanceDefinition.java b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/definition/LoadBalanceDefinition.java index d897dc3a9..8dfcd7c32 100644 --- a/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/definition/LoadBalanceDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-dubbo2.7/src/main/java/com/jd/live/agent/plugin/router/dubbo/v2_7/definition/LoadBalanceDefinition.java @@ -16,28 +16,21 @@ package com.jd.live.agent.plugin.router.dubbo.v2_7.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.dubbo.v2_7.condition.ConditionalOnDubbo27OnlyRouteEnabled; import com.jd.live.agent.plugin.router.dubbo.v2_7.interceptor.LoadBalanceInterceptor; @Injectable @Extension(value = "LoadBalanceDefinition_v2.7") -@ConditionalOnProperties(value = { - @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(name = GovernanceConfig.CONFIG_LIVE_DUBBO_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnDubbo27OnlyRouteEnabled @ConditionalOnClass(LoadBalanceDefinition.TYPE_ABSTRACT_CLUSTER) -@ConditionalOnClass(ClassLoaderFilterDefinition.TYPE_PROTOCOL_FILTER_WRAPPER) public class LoadBalanceDefinition extends PluginDefinitionAdapter { protected static final String TYPE_ABSTRACT_CLUSTER = "com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker"; diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/condition/ConditionalOnDubbo3Enabled.java b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/condition/ConditionalOnDubbo3Enabled.java new file mode 100644 index 000000000..71b9d6511 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/condition/ConditionalOnDubbo3Enabled.java @@ -0,0 +1,34 @@ +/* + * 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.dubbo.v3.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.governance.annotation.ConditionalOnDubboEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubboEnabled +@ConditionalOnClass(ConditionalOnDubbo3Enabled.TYPE_CONSUMER_CLASSLOADER_FILTER) +@ConditionalComposite +public @interface ConditionalOnDubbo3Enabled { + + String TYPE_CONSUMER_CLASSLOADER_FILTER = "org.apache.dubbo.rpc.cluster.filter.support.ConsumerClassLoaderFilter"; + +} diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/condition/ConditionalOnDubbo3FlowControlEnabled.java b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/condition/ConditionalOnDubbo3FlowControlEnabled.java new file mode 100644 index 000000000..acd5e09f6 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/condition/ConditionalOnDubbo3FlowControlEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.dubbo.v3.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnFlowControlEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubbo3Enabled +@ConditionalOnFlowControlEnabled +@ConditionalComposite +public @interface ConditionalOnDubbo3FlowControlEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/condition/ConditionalOnDubbo3GovernanceEnabled.java b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/condition/ConditionalOnDubbo3GovernanceEnabled.java new file mode 100644 index 000000000..4d45d88f7 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/condition/ConditionalOnDubbo3GovernanceEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.dubbo.v3.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubbo3Enabled +@ConditionalOnGovernanceEnabled +@ConditionalComposite +public @interface ConditionalOnDubbo3GovernanceEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/condition/ConditionalOnDubbo3OnlyRouteEnabled.java b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/condition/ConditionalOnDubbo3OnlyRouteEnabled.java new file mode 100644 index 000000000..f3d58c66f --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/condition/ConditionalOnDubbo3OnlyRouteEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.dubbo.v3.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnOnlyRouteEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnDubbo3Enabled +@ConditionalOnOnlyRouteEnabled +@ConditionalComposite +public @interface ConditionalOnDubbo3OnlyRouteEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/definition/ClassLoaderFilterDefinition.java b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/definition/ClassLoaderFilterDefinition.java index a7f4b6026..ec58578d4 100644 --- a/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/definition/ClassLoaderFilterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/definition/ClassLoaderFilterDefinition.java @@ -16,34 +16,25 @@ package com.jd.live.agent.plugin.router.dubbo.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.dubbo.v3.condition.ConditionalOnDubbo3GovernanceEnabled; import com.jd.live.agent.plugin.router.dubbo.v3.interceptor.ClassLoaderFilterInterceptor; @Injectable @Extension(value = "ClassLoaderFilterDefinition_v3") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED, - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_DUBBO_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnDubbo3GovernanceEnabled @ConditionalOnClass(ClassLoaderFilterDefinition.TYPE_CLASSLOADER_FILTER) -@ConditionalOnClass(ClassLoaderFilterDefinition.TYPE_CONSUMER_CLASSLOADER_FILTER) public class ClassLoaderFilterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_CLASSLOADER_FILTER = "org.apache.dubbo.rpc.filter.ClassLoaderFilter"; - protected static final String TYPE_CONSUMER_CLASSLOADER_FILTER = "org.apache.dubbo.rpc.cluster.filter.support.ConsumerClassLoaderFilter"; - private static final String METHOD_INVOKE = "invoke"; protected static final String[] ARGUMENT_INVOKE = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/definition/ClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/definition/ClusterDefinition.java index 06be41291..b6b66046e 100644 --- a/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/definition/ClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/definition/ClusterDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,16 +24,14 @@ 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.dubbo.v3.condition.ConditionalOnDubbo3FlowControlEnabled; import com.jd.live.agent.plugin.router.dubbo.v3.interceptor.ClusterInterceptor; @Injectable -@Extension(value = "ClusterDefinition_v2.7") -@ConditionalOnProperty(name = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_DUBBO_ENABLED, matchIfMissing = true) +@Extension(value = "ClusterDefinition_v3") +@ConditionalOnDubbo3FlowControlEnabled @ConditionalOnClass(ClusterDefinition.TYPE_ABSTRACT_CLUSTER) -@ConditionalOnClass(ClassLoaderFilterDefinition.TYPE_CONSUMER_CLASSLOADER_FILTER) public class ClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_ABSTRACT_CLUSTER = "org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker"; diff --git a/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/definition/LoadBalanceDefinition.java b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/definition/LoadBalanceDefinition.java index 669ad21de..79189bd45 100644 --- a/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/definition/LoadBalanceDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-dubbo3/src/main/java/com/jd/live/agent/plugin/router/dubbo/v3/definition/LoadBalanceDefinition.java @@ -16,28 +16,21 @@ package com.jd.live.agent.plugin.router.dubbo.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.dubbo.v3.condition.ConditionalOnDubbo3OnlyRouteEnabled; import com.jd.live.agent.plugin.router.dubbo.v3.interceptor.LoadBalanceInterceptor; @Injectable -@Extension(value = "LoadBalanceDefinition_v2.7") -@ConditionalOnProperties(value = { - @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(name = GovernanceConfig.CONFIG_LIVE_DUBBO_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@Extension(value = "LoadBalanceDefinition_v3") +@ConditionalOnDubbo3OnlyRouteEnabled @ConditionalOnClass(LoadBalanceDefinition.TYPE_ABSTRACT_CLUSTER) -@ConditionalOnClass(ClassLoaderFilterDefinition.TYPE_CONSUMER_CLASSLOADER_FILTER) public class LoadBalanceDefinition extends PluginDefinitionAdapter { protected static final String TYPE_ABSTRACT_CLUSTER = "com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker"; diff --git a/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/condition/ConditionalOnGrpcEnabled.java b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/condition/ConditionalOnGrpcEnabled.java new file mode 100644 index 000000000..577184e64 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/condition/ConditionalOnGrpcEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.gprc.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_GRPC_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnGrpcEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/condition/ConditionalOnGrpcGovernanceEnabled.java b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/condition/ConditionalOnGrpcGovernanceEnabled.java new file mode 100644 index 000000000..0eaf7bd93 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/condition/ConditionalOnGrpcGovernanceEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.gprc.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnGovernanceEnabled +@ConditionalOnGrpcEnabled +@ConditionalComposite +public @interface ConditionalOnGrpcGovernanceEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/ClientInterceptorsDefinition.java b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/ClientInterceptorsDefinition.java index c6e7e8d3e..c6f8b9085 100644 --- a/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/ClientInterceptorsDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/ClientInterceptorsDefinition.java @@ -17,8 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; -import com.jd.live.agent.core.extension.annotation.ConditionalRelation; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -26,18 +24,13 @@ import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.gprc.condition.ConditionalOnGrpcGovernanceEnabled; import com.jd.live.agent.plugin.router.gprc.interceptor.ClientInterceptorsInterceptor; @Injectable @Extension(value = "ClientInterceptorsDefinition", order = PluginDefinition.ORDER_ROUTER) -@ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED, - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED -}, matchIfMissing = true, relation = ConditionalRelation.OR) -@ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_GRPC_ENABLED, matchIfMissing = true) +@ConditionalOnGrpcGovernanceEnabled @ConditionalOnClass(ClientInterceptorsDefinition.TYPE) public class ClientInterceptorsDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/GrpcClientBeanDefinition.java b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/GrpcClientBeanDefinition.java index 5746db1a9..5846ebc8f 100644 --- a/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/GrpcClientBeanDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/GrpcClientBeanDefinition.java @@ -17,23 +17,16 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; -import com.jd.live.agent.core.extension.annotation.ConditionalRelation; import com.jd.live.agent.core.extension.annotation.Extension; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.plugin.router.gprc.condition.ConditionalOnGrpcGovernanceEnabled; import com.jd.live.agent.plugin.router.gprc.interceptor.GrpcClientBeanInterceptor; @Extension(value = "GrpcClientBeanDefinition", order = PluginDefinition.ORDER_ROUTER) -@ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED, - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED -}, matchIfMissing = true, relation = ConditionalRelation.OR) -@ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_GRPC_ENABLED, matchIfMissing = true) +@ConditionalOnGrpcGovernanceEnabled @ConditionalOnClass(GrpcClientBeanDefinition.TYPE) public class GrpcClientBeanDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/GrpcServerDefinition.java b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/GrpcServerDefinition.java index 20bb712df..23f0f9226 100644 --- a/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/GrpcServerDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/GrpcServerDefinition.java @@ -16,25 +16,21 @@ package com.jd.live.agent.plugin.router.gprc.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.gprc.condition.ConditionalOnGrpcGovernanceEnabled; import com.jd.live.agent.plugin.router.gprc.interceptor.GrpcServerInterceptor; @Injectable @Extension(value = "GrpcServerDefinition", order = PluginDefinition.ORDER_ROUTER) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) -@ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_GRPC_ENABLED, matchIfMissing = true) +@ConditionalOnGrpcGovernanceEnabled @ConditionalOnClass(GrpcServerDefinition.TYPE_SERVER_IMPL_BUILDER) public class GrpcServerDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/LoadbalancerDefinition.java b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/LoadbalancerDefinition.java index dc15d3ee9..65d4367b4 100644 --- a/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/LoadbalancerDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/LoadbalancerDefinition.java @@ -16,7 +16,8 @@ package com.jd.live.agent.plugin.router.gprc.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.plugin.definition.InterceptorDefinition; @@ -24,17 +25,12 @@ import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; import com.jd.live.agent.core.util.time.Timer; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.plugin.router.gprc.condition.ConditionalOnGrpcGovernanceEnabled; import com.jd.live.agent.plugin.router.gprc.interceptor.LoadbalancerInterceptor; @Injectable @Extension(value = "LoadbalancerDefinition", order = PluginDefinition.ORDER_ROUTER) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) -@ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_GRPC_ENABLED, matchIfMissing = true) +@ConditionalOnGrpcGovernanceEnabled @ConditionalOnClass(LoadbalancerDefinition.TYPE) public class LoadbalancerDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/NameResolverDefinition.java b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/NameResolverDefinition.java index f607dc927..9c38256c0 100644 --- a/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/NameResolverDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-grpc/src/main/java/com/jd/live/agent/plugin/router/gprc/definition/NameResolverDefinition.java @@ -16,23 +16,19 @@ package com.jd.live.agent.plugin.router.gprc.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.plugin.router.gprc.condition.ConditionalOnGrpcGovernanceEnabled; import com.jd.live.agent.plugin.router.gprc.interceptor.NameResolverInterceptor; @Injectable @Extension(value = "NameResolverDefinition", order = PluginDefinition.ORDER_ROUTER) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) -@ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_GRPC_ENABLED, matchIfMissing = true) +@ConditionalOnGrpcGovernanceEnabled @ConditionalOnClass(NameResolverDefinition.TYPE) public class NameResolverDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/condition/ConditionalOnKafkaAnyRouteEnabled.java b/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/condition/ConditionalOnKafkaAnyRouteEnabled.java new file mode 100644 index 000000000..e8887e231 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/condition/ConditionalOnKafkaAnyRouteEnabled.java @@ -0,0 +1,36 @@ +/* + * 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.kafka.v3.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.annotation.ConditionalOnMqEnabled; +import com.jd.live.agent.governance.annotation.ConditionalOnOnlyRouteEnabled; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnOnlyRouteEnabled +@ConditionalOnMqEnabled +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_KAFKA_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnKafkaAnyRouteEnabled { + +} + diff --git a/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/definition/ConsumerConfigDefinition.java b/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/definition/ConsumerConfigDefinition.java index 5f815cea8..15004123f 100644 --- a/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/definition/ConsumerConfigDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/definition/ConsumerConfigDefinition.java @@ -17,15 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.kafka.v3.condition.ConditionalOnKafkaAnyRouteEnabled; import com.jd.live.agent.plugin.router.kafka.v3.interceptor.GroupInterceptor; /** @@ -35,11 +34,7 @@ */ @Injectable @Extension(value = "ConsumerConfigDefinition_v3") -@ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED -}, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_PULSAR_ENABLED) +@ConditionalOnKafkaAnyRouteEnabled @ConditionalOnClass(ConsumerConfigDefinition.TYPE_CONSUMER_CONFIG) public class ConsumerConfigDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/definition/FetchDefinition.java b/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/definition/FetchDefinition.java index a4f6574bd..ae8858d25 100644 --- a/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/definition/FetchDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/definition/FetchDefinition.java @@ -17,16 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; -import com.jd.live.agent.core.extension.annotation.ConditionalRelation; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.kafka.v3.condition.ConditionalOnKafkaAnyRouteEnabled; import com.jd.live.agent.plugin.router.kafka.v3.interceptor.FetchInterceptor; /** @@ -36,12 +34,7 @@ */ @Injectable @Extension(value = "FetchDefinition_v3") -@ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED -}, relation = ConditionalRelation.OR, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_MQ_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_PULSAR_ENABLED) +@ConditionalOnKafkaAnyRouteEnabled @ConditionalOnClass(FetchDefinition.TYPE_FETCH) public class FetchDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/definition/FetcherDefinition.java b/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/definition/FetcherDefinition.java index 6e658529f..677006a7e 100644 --- a/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/definition/FetcherDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-kafka3/src/main/java/com/jd/live/agent/plugin/router/kafka/v3/definition/FetcherDefinition.java @@ -17,16 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; -import com.jd.live.agent.core.extension.annotation.ConditionalRelation; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.kafka.v3.condition.ConditionalOnKafkaAnyRouteEnabled; import com.jd.live.agent.plugin.router.kafka.v3.interceptor.FetcherInterceptor; /** @@ -36,12 +34,7 @@ */ @Injectable @Extension(value = "FetcherDefinition_v3") -@ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED -}, relation = ConditionalRelation.OR, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_MQ_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_PULSAR_ENABLED) +@ConditionalOnKafkaAnyRouteEnabled @ConditionalOnClass(FetcherDefinition.TYPE_FETCHER) public class FetcherDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/condition/ConditionalOnRocketmq4AnyRouteEnabled.java b/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/condition/ConditionalOnRocketmq4AnyRouteEnabled.java new file mode 100644 index 000000000..d5a112197 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/condition/ConditionalOnRocketmq4AnyRouteEnabled.java @@ -0,0 +1,40 @@ +/* + * 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.rocketmq.v4.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.annotation.ConditionalOnMqEnabled; +import com.jd.live.agent.governance.annotation.ConditionalOnOnlyRouteEnabled; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnOnlyRouteEnabled +@ConditionalOnMqEnabled +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ROCKETMQ_ENABLED, matchIfMissing = true) +@ConditionalOnClass(ConditionalOnRocketmq4AnyRouteEnabled.TYPE_CLIENT_LOGGER) +@ConditionalComposite +public @interface ConditionalOnRocketmq4AnyRouteEnabled { + + String TYPE_CLIENT_LOGGER = "org.apache.rocketmq.client.log.ClientLogger"; + +} + diff --git a/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/LitePullConsumerDefinition.java b/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/LitePullConsumerDefinition.java index cc8f47d8b..d66f99e92 100644 --- a/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/LitePullConsumerDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/LitePullConsumerDefinition.java @@ -17,15 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.rocketmq.v4.condition.ConditionalOnRocketmq4AnyRouteEnabled; import com.jd.live.agent.plugin.router.rocketmq.v4.interceptor.GroupInterceptor; /** @@ -35,14 +34,8 @@ */ @Injectable @Extension(value = "LitePullConsumerDefinition_v4") -@ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED -}, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_MQ_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ROCKETMQ_ENABLED, matchIfMissing = true) +@ConditionalOnRocketmq4AnyRouteEnabled @ConditionalOnClass(LitePullConsumerDefinition.TYPE_LITE_PULL_CONSUMER) -@ConditionalOnClass(PullAPIWrapperDefinition.TYPE_CLIENT_LOGGER) public class LitePullConsumerDefinition extends PluginDefinitionAdapter { protected static final String TYPE_LITE_PULL_CONSUMER = "org.apache.rocketmq.client.consumer.LitePullConsumer"; diff --git a/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/MQPullConsumerDefinition.java b/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/MQPullConsumerDefinition.java index 43720f3d9..495810c19 100644 --- a/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/MQPullConsumerDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/MQPullConsumerDefinition.java @@ -17,15 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.rocketmq.v4.condition.ConditionalOnRocketmq4AnyRouteEnabled; import com.jd.live.agent.plugin.router.rocketmq.v4.interceptor.GroupInterceptor; /** @@ -35,14 +34,8 @@ */ @Injectable @Extension(value = "MQPullConsumerDefinition_v4") -@ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED -}, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_MQ_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ROCKETMQ_ENABLED, matchIfMissing = true) +@ConditionalOnRocketmq4AnyRouteEnabled @ConditionalOnClass(MQPullConsumerDefinition.TYPE_MQ_PULL_CONSUMER) -@ConditionalOnClass(PullAPIWrapperDefinition.TYPE_CLIENT_LOGGER) public class MQPullConsumerDefinition extends PluginDefinitionAdapter { protected static final String TYPE_MQ_PULL_CONSUMER = "org.apache.rocketmq.client.consumer.MQPullConsumer"; diff --git a/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/MQPushConsumerDefinition.java b/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/MQPushConsumerDefinition.java index 2996b0ed5..f11c44306 100644 --- a/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/MQPushConsumerDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/MQPushConsumerDefinition.java @@ -17,15 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.rocketmq.v4.condition.ConditionalOnRocketmq4AnyRouteEnabled; import com.jd.live.agent.plugin.router.rocketmq.v4.interceptor.GroupInterceptor; /** @@ -35,14 +34,8 @@ */ @Injectable @Extension(value = "MQPushConsumerDefinition_v4") -@ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED -}, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_MQ_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ROCKETMQ_ENABLED, matchIfMissing = true) +@ConditionalOnRocketmq4AnyRouteEnabled @ConditionalOnClass(MQPushConsumerDefinition.TYPE_MQ_PUSH_CONSUMER) -@ConditionalOnClass(PullAPIWrapperDefinition.TYPE_CLIENT_LOGGER) public class MQPushConsumerDefinition extends PluginDefinitionAdapter { protected static final String TYPE_MQ_PUSH_CONSUMER = "org.apache.rocketmq.client.consumer.MQPushConsumer"; diff --git a/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/PullAPIWrapperDefinition.java b/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/PullAPIWrapperDefinition.java index f200f1800..d97f35387 100644 --- a/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/PullAPIWrapperDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-rocketmq4/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v4/definition/PullAPIWrapperDefinition.java @@ -17,16 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; -import com.jd.live.agent.core.extension.annotation.ConditionalRelation; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.rocketmq.v4.condition.ConditionalOnRocketmq4AnyRouteEnabled; import com.jd.live.agent.plugin.router.rocketmq.v4.interceptor.PullInterceptor; import com.jd.live.agent.plugin.router.rocketmq.v4.interceptor.RegisterFilterInterceptor; @@ -37,20 +35,12 @@ */ @Injectable @Extension(value = "PullAPIWrapperDefinition_v4") -@ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED -}, relation = ConditionalRelation.OR, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_MQ_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ROCKETMQ_ENABLED, matchIfMissing = true) +@ConditionalOnRocketmq4AnyRouteEnabled @ConditionalOnClass(PullAPIWrapperDefinition.TYPE_PULL_API_WRAPPER) -@ConditionalOnClass(PullAPIWrapperDefinition.TYPE_CLIENT_LOGGER) public class PullAPIWrapperDefinition extends PluginDefinitionAdapter { protected static final String TYPE_PULL_API_WRAPPER = "org.apache.rocketmq.client.impl.consumer.PullAPIWrapper"; - protected static final String TYPE_CLIENT_LOGGER = "org.apache.rocketmq.client.log.ClientLogger"; - private static final String METHOD_REGISTER_FILTER_MESSAGE_HOOK = "registerFilterMessageHook"; private static final String[] ARGUMENT_REGISTER_FILTER_MESSAGE_HOOK = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/condition/ConditionalOnRocketmq5AnyRouteEnabled.java b/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/condition/ConditionalOnRocketmq5AnyRouteEnabled.java new file mode 100644 index 000000000..f84448f12 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/condition/ConditionalOnRocketmq5AnyRouteEnabled.java @@ -0,0 +1,40 @@ +/* + * 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.rocketmq.v5.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.annotation.ConditionalOnMqEnabled; +import com.jd.live.agent.governance.annotation.ConditionalOnOnlyRouteEnabled; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnOnlyRouteEnabled +@ConditionalOnMqEnabled +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ROCKETMQ_ENABLED, matchIfMissing = true) +@ConditionalOnClass(ConditionalOnRocketmq5AnyRouteEnabled.TYPE_ACK_CALLBACK) +@ConditionalComposite +public @interface ConditionalOnRocketmq5AnyRouteEnabled { + + String TYPE_ACK_CALLBACK = "org.apache.rocketmq.client.consumer.AckCallback"; + +} + diff --git a/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/LitePullConsumerDefinition.java b/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/LitePullConsumerDefinition.java index 5d801abac..550e4cfca 100644 --- a/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/LitePullConsumerDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/LitePullConsumerDefinition.java @@ -17,15 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.rocketmq.v5.condition.ConditionalOnRocketmq5AnyRouteEnabled; import com.jd.live.agent.plugin.router.rocketmq.v5.interceptor.GroupInterceptor; /** @@ -35,14 +34,8 @@ */ @Injectable @Extension(value = "LitePullConsumerDefinition_v5") -@ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED -}, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_MQ_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ROCKETMQ_ENABLED, matchIfMissing = true) +@ConditionalOnRocketmq5AnyRouteEnabled @ConditionalOnClass(LitePullConsumerDefinition.TYPE_LITE_PULL_CONSUMER) -@ConditionalOnClass(PullAPIWrapperDefinition.TYPE_ACK_CALLBACK) public class LitePullConsumerDefinition extends PluginDefinitionAdapter { protected static final String TYPE_LITE_PULL_CONSUMER = "org.apache.rocketmq.client.consumer.LitePullConsumer"; diff --git a/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/MQPullConsumerDefinition.java b/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/MQPullConsumerDefinition.java index 97ba3d2c7..5254d6415 100644 --- a/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/MQPullConsumerDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/MQPullConsumerDefinition.java @@ -17,15 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.rocketmq.v5.condition.ConditionalOnRocketmq5AnyRouteEnabled; import com.jd.live.agent.plugin.router.rocketmq.v5.interceptor.GroupInterceptor; /** @@ -35,14 +34,8 @@ */ @Injectable @Extension(value = "MQPullConsumerDefinition_v5") -@ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED -}, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_MQ_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ROCKETMQ_ENABLED, matchIfMissing = true) +@ConditionalOnRocketmq5AnyRouteEnabled @ConditionalOnClass(MQPullConsumerDefinition.TYPE_MQ_PULL_CONSUMER) -@ConditionalOnClass(PullAPIWrapperDefinition.TYPE_ACK_CALLBACK) public class MQPullConsumerDefinition extends PluginDefinitionAdapter { protected static final String TYPE_MQ_PULL_CONSUMER = "org.apache.rocketmq.client.consumer.MQPullConsumer"; diff --git a/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/MQPushConsumerDefinition.java b/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/MQPushConsumerDefinition.java index 7735465ed..3c76a5a69 100644 --- a/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/MQPushConsumerDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/MQPushConsumerDefinition.java @@ -17,15 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.rocketmq.v5.condition.ConditionalOnRocketmq5AnyRouteEnabled; import com.jd.live.agent.plugin.router.rocketmq.v5.interceptor.GroupInterceptor; /** @@ -35,14 +34,8 @@ */ @Injectable @Extension(value = "MQPushConsumerDefinition_v5") -@ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED -}, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_MQ_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ROCKETMQ_ENABLED, matchIfMissing = true) +@ConditionalOnRocketmq5AnyRouteEnabled @ConditionalOnClass(MQPushConsumerDefinition.TYPE_MQ_PUSH_CONSUMER) -@ConditionalOnClass(PullAPIWrapperDefinition.TYPE_ACK_CALLBACK) public class MQPushConsumerDefinition extends PluginDefinitionAdapter { protected static final String TYPE_MQ_PUSH_CONSUMER = "org.apache.rocketmq.client.consumer.MQPushConsumer"; diff --git a/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/PullAPIWrapperDefinition.java b/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/PullAPIWrapperDefinition.java index 4dda58296..6bdd2eb6a 100644 --- a/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/PullAPIWrapperDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-rocketmq5/src/main/java/com/jd/live/agent/plugin/router/rocketmq/v5/definition/PullAPIWrapperDefinition.java @@ -17,16 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; -import com.jd.live.agent.core.extension.annotation.ConditionalRelation; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.rocketmq.v5.condition.ConditionalOnRocketmq5AnyRouteEnabled; import com.jd.live.agent.plugin.router.rocketmq.v5.interceptor.PullInterceptor; import com.jd.live.agent.plugin.router.rocketmq.v5.interceptor.RegisterFilterInterceptor; @@ -37,20 +35,12 @@ */ @Injectable @Extension(value = "PullAPIWrapperDefinition_v5") -@ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED -}, relation = ConditionalRelation.OR, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_MQ_ENABLED) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ROCKETMQ_ENABLED, matchIfMissing = true) +@ConditionalOnRocketmq5AnyRouteEnabled @ConditionalOnClass(PullAPIWrapperDefinition.TYPE_PULL_API_WRAPPER) -@ConditionalOnClass(PullAPIWrapperDefinition.TYPE_ACK_CALLBACK) public class PullAPIWrapperDefinition extends PluginDefinitionAdapter { protected static final String TYPE_PULL_API_WRAPPER = "org.apache.rocketmq.client.impl.consumer.PullAPIWrapper"; - protected static final String TYPE_ACK_CALLBACK = "org.apache.rocketmq.client.consumer.AckCallback"; - private static final String METHOD_REGISTER_FILTER_MESSAGE_HOOK = "registerFilterMessageHook"; private static final String[] ARGUMENT_REGISTER_FILTER_MESSAGE_HOOK = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/condition/ConditionalOnSofaRpcEnabled.java b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/condition/ConditionalOnSofaRpcEnabled.java new file mode 100644 index 000000000..dce5c6b99 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/condition/ConditionalOnSofaRpcEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.sofarpc.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; +import com.jd.live.agent.governance.config.GovernanceConfig; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SOFARPC_ENABLED, matchIfMissing = true) +@ConditionalComposite +public @interface ConditionalOnSofaRpcEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/condition/ConditionalOnSofaRpcFlowControlEnabled.java b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/condition/ConditionalOnSofaRpcFlowControlEnabled.java new file mode 100644 index 000000000..1e32dea5b --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/condition/ConditionalOnSofaRpcFlowControlEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.sofarpc.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnFlowControlEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSofaRpcEnabled +@ConditionalOnFlowControlEnabled +@ConditionalComposite +public @interface ConditionalOnSofaRpcFlowControlEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/condition/ConditionalOnSofaRpcGovernanceEnabled.java b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/condition/ConditionalOnSofaRpcGovernanceEnabled.java new file mode 100644 index 000000000..0043557d6 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/condition/ConditionalOnSofaRpcGovernanceEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.sofarpc.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSofaRpcEnabled +@ConditionalOnGovernanceEnabled +@ConditionalComposite +public @interface ConditionalOnSofaRpcGovernanceEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/condition/ConditionalOnSofaRpcOnlyRouteEnabled.java b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/condition/ConditionalOnSofaRpcOnlyRouteEnabled.java new file mode 100644 index 000000000..70a5be8d4 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/condition/ConditionalOnSofaRpcOnlyRouteEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.sofarpc.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnOnlyRouteEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSofaRpcEnabled +@ConditionalOnOnlyRouteEnabled +@ConditionalComposite +public @interface ConditionalOnSofaRpcOnlyRouteEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/definition/ClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/definition/ClusterDefinition.java index cdde9769d..114ef8033 100644 --- a/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/definition/ClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/definition/ClusterDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,14 +24,13 @@ 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.sofarpc.condition.ConditionalOnSofaRpcFlowControlEnabled; import com.jd.live.agent.plugin.router.sofarpc.interceptor.ClusterInterceptor; @Injectable @Extension(value = "ClusterDefinition") -@ConditionalOnProperty(name = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_SOFARPC_ENABLED, matchIfMissing = true) +@ConditionalOnSofaRpcFlowControlEnabled @ConditionalOnClass(ClusterDefinition.TYPE_ABSTRACT_CLUSTER) public class ClusterDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/definition/LoadBalanceDefinition.java b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/definition/LoadBalanceDefinition.java index 991795f8b..830cad824 100644 --- a/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/definition/LoadBalanceDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/definition/LoadBalanceDefinition.java @@ -16,27 +16,21 @@ package com.jd.live.agent.plugin.router.sofarpc.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.parser.ObjectParser; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.sofarpc.condition.ConditionalOnSofaRpcOnlyRouteEnabled; import com.jd.live.agent.plugin.router.sofarpc.interceptor.LoadBalanceInterceptor; @Injectable @Extension(value = "LoadBalanceDefinition") -@ConditionalOnProperties(value = { - @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(name = GovernanceConfig.CONFIG_LIVE_SOFARPC_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnSofaRpcOnlyRouteEnabled @ConditionalOnClass(LoadBalanceDefinition.TYPE_ABSTRACT_CLUSTER) public class LoadBalanceDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/definition/ProviderInvokerDefinition.java b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/definition/ProviderInvokerDefinition.java index 50e3cddc6..ff0e17ced 100644 --- a/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/definition/ProviderInvokerDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-sofarpc/src/main/java/com/jd/live/agent/plugin/router/sofarpc/definition/ProviderInvokerDefinition.java @@ -16,26 +16,20 @@ package com.jd.live.agent.plugin.router.sofarpc.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.sofarpc.condition.ConditionalOnSofaRpcGovernanceEnabled; import com.jd.live.agent.plugin.router.sofarpc.interceptor.ProviderInvokerInterceptor; @Injectable @Extension(value = "ProviderInvokerDefinition") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED, - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SOFARPC_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnSofaRpcGovernanceEnabled @ConditionalOnClass(ProviderInvokerDefinition.TYPE_PROVIDER_INVOKER) public class ProviderInvokerDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/condition/ConditionalOnSpringCloud2Enabled.java b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/condition/ConditionalOnSpringCloud2Enabled.java new file mode 100644 index 000000000..1b23229fb --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/condition/ConditionalOnSpringCloud2Enabled.java @@ -0,0 +1,33 @@ +/* + * 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.springcloud.v2.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; +import com.jd.live.agent.governance.annotation.ConditionalOnSpringEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringEnabled +@ConditionalOnMissingClass(ConditionalOnSpringCloud2Enabled.TYPE_STICKY_SESSION_SUPPLIER) +@ConditionalComposite +public @interface ConditionalOnSpringCloud2Enabled { + + String TYPE_STICKY_SESSION_SUPPLIER = "org.springframework.cloud.loadbalancer.core.RequestBasedStickySessionServiceInstanceListSupplier"; +} diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/condition/ConditionalOnSpringCloud2GovernanceEnabled.java b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/condition/ConditionalOnSpringCloud2GovernanceEnabled.java new file mode 100644 index 000000000..11e29eb17 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/condition/ConditionalOnSpringCloud2GovernanceEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.springcloud.v2.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringCloud2Enabled +@ConditionalOnGovernanceEnabled +@ConditionalComposite +public @interface ConditionalOnSpringCloud2GovernanceEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/BlockingClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/BlockingClusterDefinition.java index ff9e86ef0..e19338170 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/BlockingClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/BlockingClusterDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.router.springcloud.v2.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v2.condition.ConditionalOnSpringCloud2GovernanceEnabled; import com.jd.live.agent.plugin.router.springcloud.v2.interceptor.BlockingClusterInterceptor; /** @@ -33,22 +34,12 @@ */ @Injectable @Extension(value = "BlockingClusterDefinition_v2") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnSpringCloud2GovernanceEnabled @ConditionalOnClass(BlockingClusterDefinition.TYPE_LOADBALANCER_INTERCEPTOR) -@ConditionalOnMissingClass(BlockingClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) public class BlockingClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_LOADBALANCER_INTERCEPTOR = "org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor"; - protected static final String TYPE_STICKY_SESSION_SUPPLIER = "org.springframework.cloud.loadbalancer.core.RequestBasedStickySessionServiceInstanceListSupplier"; - private static final String METHOD_INTERCEPT = "intercept"; private static final String[] ARGUMENT_INTERCEPT = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/FeignClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/FeignClusterDefinition.java index bddb641de..30b4894d5 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/FeignClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/FeignClusterDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.router.springcloud.v2.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v2.condition.ConditionalOnSpringCloud2GovernanceEnabled; import com.jd.live.agent.plugin.router.springcloud.v2.interceptor.FeignClusterInterceptor; /** @@ -33,16 +34,8 @@ */ @Injectable @Extension(value = "FeignClusterDefinition_v2") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnSpringCloud2GovernanceEnabled @ConditionalOnClass(FeignClusterDefinition.TYPE_FEIGN_BLOCKING_LOADBALANCER_CLIENT) -@ConditionalOnMissingClass(BlockingClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) public class FeignClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_FEIGN_BLOCKING_LOADBALANCER_CLIENT = "org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient"; diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/FeignRibbonClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/FeignRibbonClusterDefinition.java index ce5948351..5f6e58028 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/FeignRibbonClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/FeignRibbonClusterDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.router.springcloud.v2.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v2.condition.ConditionalOnSpringCloud2GovernanceEnabled; import com.jd.live.agent.plugin.router.springcloud.v2.interceptor.FeignClusterInterceptor; /** @@ -33,16 +34,8 @@ */ @Injectable @Extension(value = "FeignRibbonClusterDefinition_v2") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnSpringCloud2GovernanceEnabled @ConditionalOnClass(FeignRibbonClusterDefinition.TYPE_FEIGN_BLOCKING_LOADBALANCER_CLIENT) -@ConditionalOnMissingClass(BlockingClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) public class FeignRibbonClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_FEIGN_BLOCKING_LOADBALANCER_CLIENT = "org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient"; diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/RetryableBlockingClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/RetryableBlockingClusterDefinition.java index 0820f6849..59b011936 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/RetryableBlockingClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/RetryableBlockingClusterDefinition.java @@ -17,16 +17,15 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.annotation.ConditionalOnSpringRetry; import com.jd.live.agent.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v2.condition.ConditionalOnSpringCloud2GovernanceEnabled; import com.jd.live.agent.plugin.router.springcloud.v2.interceptor.BlockingClusterInterceptor; /** @@ -36,17 +35,13 @@ */ @Injectable @Extension(value = "BlockingRetryClusterDefinition_v2") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringCloud2GovernanceEnabled +@ConditionalOnSpringRetry @ConditionalOnClass(RetryableBlockingClusterDefinition.TYPE_RETRY_LOADBALANCER_INTERCEPTOR) -@ConditionalOnClass(RetryableBlockingClusterDefinition.TYPE_RETRY_TEMPLATE) -@ConditionalOnMissingClass(BlockingClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) public class RetryableBlockingClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_RETRY_LOADBALANCER_INTERCEPTOR = "org.springframework.cloud.client.loadbalancer.RetryLoadBalancerInterceptor"; - protected static final String TYPE_RETRY_TEMPLATE = "org.springframework.retry.support.RetryTemplate"; - private static final String METHOD_INTERCEPT = "intercept"; private static final String[] ARGUMENT_INTERCEPT = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/RetryableFeignClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/RetryableFeignClusterDefinition.java index 80eaa2865..a0cef094f 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/RetryableFeignClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/RetryableFeignClusterDefinition.java @@ -16,14 +16,16 @@ package com.jd.live.agent.plugin.router.springcloud.v2.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.annotation.ConditionalOnSpringRetry; import com.jd.live.agent.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v2.condition.ConditionalOnSpringCloud2GovernanceEnabled; import com.jd.live.agent.plugin.router.springcloud.v2.interceptor.FeignClusterInterceptor; /** @@ -33,23 +35,13 @@ */ @Injectable @Extension(value = "FeignRetryableClientDefinition_v2") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnSpringCloud2GovernanceEnabled +@ConditionalOnSpringRetry @ConditionalOnClass(RetryableFeignClusterDefinition.TYPE_RETRYABLE_FEIGN_BLOCKING_LOADBALANCER_CLIENT) -@ConditionalOnClass(RetryableFeignClusterDefinition.TYPE_RETRY_TEMPLATE) -@ConditionalOnMissingClass(BlockingClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) public class RetryableFeignClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_RETRYABLE_FEIGN_BLOCKING_LOADBALANCER_CLIENT = "org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient"; - protected static final String TYPE_RETRY_TEMPLATE = "org.springframework.retry.support.RetryTemplate"; - private static final String METHOD_EXECUTE = "execute"; private static final String[] ARGUMENT_FILTER = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/ServiceInstanceListSupplierDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/ServiceInstanceListSupplierDefinition.java index af5a482e0..b58862ecc 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/ServiceInstanceListSupplierDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud2/src/main/java/com/jd/live/agent/plugin/router/springcloud/v2/definition/ServiceInstanceListSupplierDefinition.java @@ -16,7 +16,8 @@ package com.jd.live.agent.plugin.router.springcloud.v2.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Config; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,6 +26,7 @@ import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v2.condition.ConditionalOnSpringCloud2GovernanceEnabled; import com.jd.live.agent.plugin.router.springcloud.v2.interceptor.ServiceInstanceListSupplierInterceptor; import java.util.Set; @@ -36,16 +38,8 @@ */ @Injectable @Extension(value = "ServiceInstanceListSupplierPluginDefinition_v2") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnSpringCloud2GovernanceEnabled @ConditionalOnClass(ServiceInstanceListSupplierDefinition.TYPE_SERVICE_INSTANCE_LIST_SUPPLIER) -@ConditionalOnMissingClass(BlockingClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) public class ServiceInstanceListSupplierDefinition extends PluginDefinitionAdapter { protected static final String TYPE_SERVICE_INSTANCE_LIST_SUPPLIER = "org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier"; diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/condition/ConditionalOnSpringCloud3Enabled.java b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/condition/ConditionalOnSpringCloud3Enabled.java new file mode 100644 index 000000000..8d9b5f440 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/condition/ConditionalOnSpringCloud3Enabled.java @@ -0,0 +1,37 @@ +/* + * 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.springcloud.v3.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; +import com.jd.live.agent.governance.annotation.ConditionalOnSpringEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringEnabled +@ConditionalOnClass(ConditionalOnSpringCloud3Enabled.TYPE_STICKY_SESSION_SUPPLIER) +@ConditionalOnMissingClass(ConditionalOnSpringCloud3Enabled.TYPE_HTTP_STATUS_CODE) +@ConditionalComposite +public @interface ConditionalOnSpringCloud3Enabled { + + String TYPE_STICKY_SESSION_SUPPLIER = "org.springframework.cloud.loadbalancer.core.RequestBasedStickySessionServiceInstanceListSupplier"; + + String TYPE_HTTP_STATUS_CODE = "org.springframework.http.HttpStatusCode"; +} diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/condition/ConditionalOnSpringCloud3FlowControlEnabled.java b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/condition/ConditionalOnSpringCloud3FlowControlEnabled.java new file mode 100644 index 000000000..3c6c15f87 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/condition/ConditionalOnSpringCloud3FlowControlEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.springcloud.v3.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnFlowControlEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringCloud3Enabled +@ConditionalOnFlowControlEnabled +@ConditionalComposite +public @interface ConditionalOnSpringCloud3FlowControlEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/condition/ConditionalOnSpringCloud3GovernanceEnabled.java b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/condition/ConditionalOnSpringCloud3GovernanceEnabled.java new file mode 100644 index 000000000..057f62e84 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/condition/ConditionalOnSpringCloud3GovernanceEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.springcloud.v3.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringCloud3Enabled +@ConditionalOnGovernanceEnabled +@ConditionalComposite +public @interface ConditionalOnSpringCloud3GovernanceEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/BlockingClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/BlockingClusterDefinition.java index c0338e0f4..19c378fe8 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/BlockingClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/BlockingClusterDefinition.java @@ -17,16 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v3.condition.ConditionalOnSpringCloud3FlowControlEnabled; import com.jd.live.agent.plugin.router.springcloud.v3.interceptor.BlockingClusterInterceptor; /** @@ -36,19 +34,12 @@ */ @Injectable @Extension(value = "BlockingClusterDefinition_v3") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringCloud3FlowControlEnabled @ConditionalOnClass(BlockingClusterDefinition.TYPE_LOADBALANCER_INTERCEPTOR) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) -@ConditionalOnMissingClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) public class BlockingClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_LOADBALANCER_INTERCEPTOR = "org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor"; - protected static final String TYPE_STICKY_SESSION_SUPPLIER = "org.springframework.cloud.loadbalancer.core.RequestBasedStickySessionServiceInstanceListSupplier"; - - protected static final String TYPE_HTTP_STATUS_CODE = "org.springframework.http.HttpStatusCode"; - private static final String METHOD_INTERCEPT = "intercept"; private static final String[] ARGUMENT_INTERCEPT = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/FeignClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/FeignClusterDefinition.java index e765f1198..eb4cc80d0 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/FeignClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/FeignClusterDefinition.java @@ -17,16 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v3.condition.ConditionalOnSpringCloud3FlowControlEnabled; import com.jd.live.agent.plugin.router.springcloud.v3.interceptor.FeignClusterInterceptor; /** @@ -36,11 +34,8 @@ */ @Injectable @Extension(value = "FeignClusterDefinition_v3") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringCloud3FlowControlEnabled @ConditionalOnClass(FeignClusterDefinition.TYPE_FEIGN_BLOCKING_LOADBALANCER_CLIENT) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) -@ConditionalOnMissingClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) public class FeignClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_FEIGN_BLOCKING_LOADBALANCER_CLIENT = "org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient"; diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/ReactiveClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/ReactiveClusterDefinition.java index f9e6664ad..4425026e8 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/ReactiveClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/ReactiveClusterDefinition.java @@ -17,31 +17,27 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.annotation.ConditionalOnReactive; import com.jd.live.agent.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v3.condition.ConditionalOnSpringCloud3FlowControlEnabled; import com.jd.live.agent.plugin.router.springcloud.v3.interceptor.ReactiveClusterInterceptor; /** - * ClientClusterDefinition + * ReactiveClusterDefinition * * @since 1.0.0 */ @Injectable @Extension(value = "ClientClusterDefinition_v3") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringCloud3FlowControlEnabled +@ConditionalOnReactive @ConditionalOnClass(ReactiveClusterDefinition.TYPE_LOADBALANCED_EXCHANGE_FILTER_FUNCTION) -@ConditionalOnClass(ReactiveClusterDefinition.REACTOR_MONO) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) -@ConditionalOnMissingClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) public class ReactiveClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_LOADBALANCED_EXCHANGE_FILTER_FUNCTION = "org.springframework.cloud.client.loadbalancer.reactive.LoadBalancedExchangeFilterFunction"; diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/ReactorLoadBalancerDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/ReactorLoadBalancerDefinition.java index c5cb5ee13..e472c9feb 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/ReactorLoadBalancerDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/ReactorLoadBalancerDefinition.java @@ -16,11 +16,13 @@ package com.jd.live.agent.plugin.router.springcloud.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; 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.governance.annotation.ConditionalOnReactive; +import com.jd.live.agent.plugin.router.springcloud.v3.condition.ConditionalOnSpringCloud3GovernanceEnabled; import com.jd.live.agent.plugin.router.springcloud.v3.interceptor.ReactorLoadBalancerInterceptor; /** @@ -29,18 +31,9 @@ * @since 1.0.0 */ @Extension(value = "ReactorLoadBalancerDefinition_v3") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED, - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnSpringCloud3GovernanceEnabled +@ConditionalOnReactive @ConditionalOnClass(ReactorLoadBalancerDefinition.TYPE_REACTOR_LOAD_BALANCER) -@ConditionalOnClass(ReactiveClusterDefinition.REACTOR_MONO) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) -@ConditionalOnMissingClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) public class ReactorLoadBalancerDefinition extends PluginDefinitionAdapter { protected static final String TYPE_REACTOR_LOAD_BALANCER = "org.springframework.cloud.loadbalancer.core.ReactorLoadBalancer"; diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/RetryableBlockingClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/RetryableBlockingClusterDefinition.java index a075ea939..6af91454a 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/RetryableBlockingClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/RetryableBlockingClusterDefinition.java @@ -17,16 +17,15 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.annotation.ConditionalOnSpringRetry; import com.jd.live.agent.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v3.condition.ConditionalOnSpringCloud3FlowControlEnabled; import com.jd.live.agent.plugin.router.springcloud.v3.interceptor.BlockingClusterInterceptor; /** @@ -36,18 +35,13 @@ */ @Injectable @Extension(value = "BlockingRetryClusterDefinition_v3") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringCloud3FlowControlEnabled +@ConditionalOnSpringRetry @ConditionalOnClass(RetryableBlockingClusterDefinition.TYPE_RETRY_LOADBALANCER_INTERCEPTOR) -@ConditionalOnClass(RetryableBlockingClusterDefinition.TYPE_RETRY_TEMPLATE) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) -@ConditionalOnMissingClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) public class RetryableBlockingClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_RETRY_LOADBALANCER_INTERCEPTOR = "org.springframework.cloud.client.loadbalancer.RetryLoadBalancerInterceptor"; - protected static final String TYPE_RETRY_TEMPLATE = "org.springframework.retry.support.RetryTemplate"; - private static final String METHOD_INTERCEPT = "intercept"; private static final String[] ARGUMENT_INTERCEPT = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/RetryableFeignClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/RetryableFeignClusterDefinition.java index ac8a78b7b..76b7b2b28 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/RetryableFeignClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/RetryableFeignClusterDefinition.java @@ -17,16 +17,15 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.annotation.ConditionalOnSpringRetry; import com.jd.live.agent.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v3.condition.ConditionalOnSpringCloud3FlowControlEnabled; import com.jd.live.agent.plugin.router.springcloud.v3.interceptor.FeignClusterInterceptor; /** @@ -36,18 +35,13 @@ */ @Injectable @Extension(value = "FeignRetryableClientDefinition_v3") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringCloud3FlowControlEnabled +@ConditionalOnSpringRetry @ConditionalOnClass(RetryableFeignClusterDefinition.TYPE_RETRYABLE_FEIGN_BLOCKING_LOADBALANCER_CLIENT) -@ConditionalOnClass(RetryableFeignClusterDefinition.TYPE_RETRY_TEMPLATE) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) -@ConditionalOnMissingClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) public class RetryableFeignClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_RETRYABLE_FEIGN_BLOCKING_LOADBALANCER_CLIENT = "org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient"; - protected static final String TYPE_RETRY_TEMPLATE = "org.springframework.retry.support.RetryTemplate"; - private static final String METHOD_EXECUTE = "execute"; private static final String[] ARGUMENT_FILTER = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/ServiceInstanceListSupplierDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/ServiceInstanceListSupplierDefinition.java index 0b29e8bab..d4ba8eead 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/ServiceInstanceListSupplierDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud3/src/main/java/com/jd/live/agent/plugin/router/springcloud/v3/definition/ServiceInstanceListSupplierDefinition.java @@ -16,7 +16,8 @@ package com.jd.live.agent.plugin.router.springcloud.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Config; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,6 +26,7 @@ import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v3.condition.ConditionalOnSpringCloud3GovernanceEnabled; import com.jd.live.agent.plugin.router.springcloud.v3.interceptor.ServiceInstanceListSupplierInterceptor; import java.util.Set; @@ -37,17 +39,8 @@ */ @Injectable @Extension(value = "ServiceInstanceListSupplierPluginDefinition_v3") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnSpringCloud3GovernanceEnabled @ConditionalOnClass(ServiceInstanceListSupplierDefinition.TYPE_SERVICE_INSTANCE_LIST_SUPPLIER) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) -@ConditionalOnMissingClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) public class ServiceInstanceListSupplierDefinition extends PluginDefinitionAdapter { protected static final String TYPE_SERVICE_INSTANCE_LIST_SUPPLIER = "org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier"; diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/condition/ConditionalOnSpringCloud4Enabled.java b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/condition/ConditionalOnSpringCloud4Enabled.java new file mode 100644 index 000000000..a74dabdd2 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/condition/ConditionalOnSpringCloud4Enabled.java @@ -0,0 +1,33 @@ +/* + * 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.springcloud.v4.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.governance.annotation.ConditionalOnSpringEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringEnabled +@ConditionalOnClass(ConditionalOnSpringCloud4Enabled.TYPE_HTTP_STATUS_CODE) +@ConditionalComposite +public @interface ConditionalOnSpringCloud4Enabled { + + String TYPE_HTTP_STATUS_CODE = "org.springframework.http.HttpStatusCode"; +} diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/condition/ConditionalOnSpringCloud4FlowControlEnabled.java b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/condition/ConditionalOnSpringCloud4FlowControlEnabled.java new file mode 100644 index 000000000..18143fd45 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/condition/ConditionalOnSpringCloud4FlowControlEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.springcloud.v4.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnFlowControlEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringCloud4Enabled +@ConditionalOnFlowControlEnabled +@ConditionalComposite +public @interface ConditionalOnSpringCloud4FlowControlEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/condition/ConditionalOnSpringCloud4GovernanceEnabled.java b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/condition/ConditionalOnSpringCloud4GovernanceEnabled.java new file mode 100644 index 000000000..7ee9e252d --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/condition/ConditionalOnSpringCloud4GovernanceEnabled.java @@ -0,0 +1,31 @@ +/* + * 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.springcloud.v4.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringCloud4Enabled +@ConditionalOnGovernanceEnabled +@ConditionalComposite +public @interface ConditionalOnSpringCloud4GovernanceEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/BlockingClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/BlockingClusterDefinition.java index 39e40619b..ab4d6d735 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/BlockingClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/BlockingClusterDefinition.java @@ -17,15 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v4.condition.ConditionalOnSpringCloud4FlowControlEnabled; import com.jd.live.agent.plugin.router.springcloud.v4.interceptor.BlockingClusterInterceptor; /** @@ -34,17 +33,13 @@ * @since 1.0.0 */ @Injectable -@Extension(value = "BlockingClusterDefinition_v3") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@Extension(value = "BlockingClusterDefinition_v4") +@ConditionalOnSpringCloud4FlowControlEnabled @ConditionalOnClass(BlockingClusterDefinition.TYPE_LOADBALANCER_INTERCEPTOR) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) public class BlockingClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_LOADBALANCER_INTERCEPTOR = "org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor"; - protected static final String TYPE_HTTP_STATUS_CODE = "org.springframework.http.HttpStatusCode"; - private static final String METHOD_INTERCEPT = "intercept"; private static final String[] ARGUMENT_INTERCEPT = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/FeignClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/FeignClusterDefinition.java index b219c47be..8fe96ffe0 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/FeignClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/FeignClusterDefinition.java @@ -17,15 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v4.condition.ConditionalOnSpringCloud4FlowControlEnabled; import com.jd.live.agent.plugin.router.springcloud.v4.interceptor.FeignClusterInterceptor; /** @@ -34,11 +33,9 @@ * @since 1.0.0 */ @Injectable -@Extension(value = "FeignClusterDefinition_v3") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@Extension(value = "FeignClusterDefinition_v4") +@ConditionalOnSpringCloud4FlowControlEnabled @ConditionalOnClass(FeignClusterDefinition.TYPE_FEIGN_BLOCKING_LOADBALANCER_CLIENT) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) public class FeignClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_FEIGN_BLOCKING_LOADBALANCER_CLIENT = "org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient"; diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/ReactiveClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/ReactiveClusterDefinition.java index 524682640..2ab38aa2f 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/ReactiveClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/ReactiveClusterDefinition.java @@ -17,32 +17,30 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.annotation.ConditionalOnReactive; import com.jd.live.agent.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v4.condition.ConditionalOnSpringCloud4FlowControlEnabled; import com.jd.live.agent.plugin.router.springcloud.v4.interceptor.ReactiveClusterInterceptor; /** - * ClientClusterDefinition + * ReactiveClusterDefinition * * @since 1.0.0 */ @Injectable -@Extension(value = "ClientClusterDefinition_v3") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -@ConditionalOnClass(ReactiveClusterDefinition.TYPE_LOADBALANCED_EXCHANGE_FILTER_FUNCTION) -@ConditionalOnClass(ReactiveClusterDefinition.REACTOR_MONO) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) +@Extension(value = "ClientClusterDefinition_v4") +@ConditionalOnSpringCloud4FlowControlEnabled +@ConditionalOnReactive +@ConditionalOnClass(ReactiveClusterDefinition.TYPE_LOADBALANCER_EXCHANGE_FILTER_FUNCTION) public class ReactiveClusterDefinition extends PluginDefinitionAdapter { - protected static final String TYPE_LOADBALANCED_EXCHANGE_FILTER_FUNCTION = "org.springframework.cloud.client.loadbalancer.reactive.LoadBalancedExchangeFilterFunction"; + protected static final String TYPE_LOADBALANCER_EXCHANGE_FILTER_FUNCTION = "org.springframework.cloud.client.loadbalancer.reactive.LoadBalancedExchangeFilterFunction"; private static final String METHOD_FILTER = "filter"; @@ -51,13 +49,11 @@ public class ReactiveClusterDefinition extends PluginDefinitionAdapter { "org.springframework.web.reactive.function.client.ExchangeFunction" }; - protected static final String REACTOR_MONO = "reactor.core.publisher.Mono"; - @Inject(InvocationContext.COMPONENT_INVOCATION_CONTEXT) private InvocationContext context; public ReactiveClusterDefinition() { - this.matcher = () -> MatcherBuilder.isImplement(TYPE_LOADBALANCED_EXCHANGE_FILTER_FUNCTION); + this.matcher = () -> MatcherBuilder.isImplement(TYPE_LOADBALANCER_EXCHANGE_FILTER_FUNCTION); this.interceptors = new InterceptorDefinition[]{ new InterceptorDefinitionAdapter( MatcherBuilder.named(METHOD_FILTER). diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/ReactorLoadBalancerDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/ReactorLoadBalancerDefinition.java index b7063466d..3a1483391 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/ReactorLoadBalancerDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/ReactorLoadBalancerDefinition.java @@ -16,11 +16,13 @@ package com.jd.live.agent.plugin.router.springcloud.v4.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; 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.governance.annotation.ConditionalOnReactive; +import com.jd.live.agent.plugin.router.springcloud.v4.condition.ConditionalOnSpringCloud4GovernanceEnabled; import com.jd.live.agent.plugin.router.springcloud.v4.interceptor.ReactorLoadBalancerInterceptor; /** @@ -28,17 +30,10 @@ * * @since 1.0.0 */ -@Extension(value = "ReactorLoadBalancerDefinition_v3") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED, - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@Extension(value = "ReactorLoadBalancerDefinition_v4") +@ConditionalOnSpringCloud4GovernanceEnabled +@ConditionalOnReactive @ConditionalOnClass(ReactorLoadBalancerDefinition.TYPE_REACTOR_LOAD_BALANCER) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) public class ReactorLoadBalancerDefinition extends PluginDefinitionAdapter { protected static final String TYPE_REACTOR_LOAD_BALANCER = "org.springframework.cloud.loadbalancer.core.ReactorLoadBalancer"; diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/RetryableBlockingClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/RetryableBlockingClusterDefinition.java index f1b6a4f70..f17bbd95f 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/RetryableBlockingClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/RetryableBlockingClusterDefinition.java @@ -17,15 +17,15 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.annotation.ConditionalOnSpringRetry; import com.jd.live.agent.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v4.condition.ConditionalOnSpringCloud4FlowControlEnabled; import com.jd.live.agent.plugin.router.springcloud.v4.interceptor.BlockingClusterInterceptor; /** @@ -34,18 +34,14 @@ * @since 1.0.0 */ @Injectable -@Extension(value = "BlockingRetryClusterDefinition_v3") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@Extension(value = "BlockingRetryClusterDefinition_v4") +@ConditionalOnSpringCloud4FlowControlEnabled +@ConditionalOnSpringRetry @ConditionalOnClass(RetryableBlockingClusterDefinition.TYPE_RETRY_LOADBALANCER_INTERCEPTOR) -@ConditionalOnClass(RetryableBlockingClusterDefinition.TYPE_RETRY_TEMPLATE) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) public class RetryableBlockingClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_RETRY_LOADBALANCER_INTERCEPTOR = "org.springframework.cloud.client.loadbalancer.RetryLoadBalancerInterceptor"; - protected static final String TYPE_RETRY_TEMPLATE = "org.springframework.retry.support.RetryTemplate"; - private static final String METHOD_INTERCEPT = "intercept"; private static final String[] ARGUMENT_INTERCEPT = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/RetryableFeignClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/RetryableFeignClusterDefinition.java index 3769ddbf4..bd22a2fcb 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/RetryableFeignClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/RetryableFeignClusterDefinition.java @@ -17,35 +17,31 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.annotation.ConditionalOnSpringRetry; import com.jd.live.agent.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v4.condition.ConditionalOnSpringCloud4FlowControlEnabled; import com.jd.live.agent.plugin.router.springcloud.v4.interceptor.FeignClusterInterceptor; /** - * FeignRetryableClientDefinition + * RetryableFeignClusterDefinition * * @since 1.0.0 */ @Injectable @Extension(value = "FeignRetryableClientDefinition_v3") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringCloud4FlowControlEnabled +@ConditionalOnSpringRetry @ConditionalOnClass(RetryableFeignClusterDefinition.TYPE_RETRYABLE_FEIGN_BLOCKING_LOADBALANCER_CLIENT) -@ConditionalOnClass(RetryableFeignClusterDefinition.TYPE_RETRY_TEMPLATE) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) public class RetryableFeignClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_RETRYABLE_FEIGN_BLOCKING_LOADBALANCER_CLIENT = "org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient"; - protected static final String TYPE_RETRY_TEMPLATE = "org.springframework.retry.support.RetryTemplate"; - private static final String METHOD_EXECUTE = "execute"; private static final String[] ARGUMENT_FILTER = new String[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/ServiceInstanceListSupplierDefinition.java b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/ServiceInstanceListSupplierDefinition.java index 87092d663..43b9443b3 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/ServiceInstanceListSupplierDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/definition/ServiceInstanceListSupplierDefinition.java @@ -16,7 +16,8 @@ package com.jd.live.agent.plugin.router.springcloud.v4.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Config; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; @@ -25,6 +26,7 @@ import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springcloud.v4.condition.ConditionalOnSpringCloud4GovernanceEnabled; import com.jd.live.agent.plugin.router.springcloud.v4.interceptor.ServiceInstanceListSupplierInterceptor; import java.util.Set; @@ -36,17 +38,9 @@ * @since 1.0.0 */ @Injectable -@Extension(value = "ServiceInstanceListSupplierPluginDefinition_v3") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(name = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@Extension(value = "ServiceInstanceListSupplierPluginDefinition_v4") +@ConditionalOnSpringCloud4GovernanceEnabled @ConditionalOnClass(ServiceInstanceListSupplierDefinition.TYPE_SERVICE_INSTANCE_LIST_SUPPLIER) -@ConditionalOnClass(BlockingClusterDefinition.TYPE_HTTP_STATUS_CODE) public class ServiceInstanceListSupplierDefinition extends PluginDefinitionAdapter { protected static final String TYPE_SERVICE_INSTANCE_LIST_SUPPLIER = "org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier"; diff --git a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/interceptor/ReactorLoadBalancerInterceptor.java b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/interceptor/ReactorLoadBalancerInterceptor.java index 0dcbefa24..790f61213 100644 --- a/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/interceptor/ReactorLoadBalancerInterceptor.java +++ b/joylive-plugin/joylive-router/joylive-router-springcloud4/src/main/java/com/jd/live/agent/plugin/router/springcloud/v4/interceptor/ReactorLoadBalancerInterceptor.java @@ -18,8 +18,6 @@ import com.jd.live.agent.bootstrap.bytekit.context.ExecutableContext; import com.jd.live.agent.core.plugin.definition.InterceptorAdaptor; import com.jd.live.agent.core.util.cache.LazyObject; -import com.jd.live.agent.core.util.type.ClassUtils; -import com.jd.live.agent.core.util.type.FieldDesc; import com.jd.live.agent.governance.context.RequestContext; import com.jd.live.agent.governance.context.bag.Carrier; import org.springframework.cloud.loadbalancer.core.ReactorLoadBalancer; @@ -27,6 +25,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import static com.jd.live.agent.core.util.type.ClassUtils.getValue; + /** * ReactorLoadBalancerInterceptor * @@ -54,13 +54,6 @@ public void onEnter(ExecutableContext ctx) { * an "empty" {@code LazyObject} is returned. */ private LazyObject getServiceId(ReactorLoadBalancer loadBalancer) { - FieldDesc fieldDesc = ClassUtils.describe(loadBalancer.getClass()).getFieldList().getField(FIELD_SERVICE_ID); - if (fieldDesc != null) { - try { - return LazyObject.of((String) fieldDesc.get(loadBalancer)); - } catch (Throwable ignore) { - } - } - return LazyObject.empty(); + return LazyObject.of(getValue(loadBalancer, FIELD_SERVICE_ID)); } } diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/condition/ConditionalOnSpringGateway2Enabled.java b/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/condition/ConditionalOnSpringGateway2Enabled.java new file mode 100644 index 000000000..595a53bbd --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/condition/ConditionalOnSpringGateway2Enabled.java @@ -0,0 +1,39 @@ +/* + * 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.v2.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; +import com.jd.live.agent.governance.annotation.ConditionalOnReactive; +import com.jd.live.agent.governance.annotation.ConditionalOnSpringGatewayEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringGatewayEnabled +@ConditionalOnMissingClass(ConditionalOnSpringGateway2Enabled.TYPE_STICKY_SESSION_SUPPLIER) +@ConditionalOnReactive +@ConditionalComposite +public @interface ConditionalOnSpringGateway2Enabled { + + // spring gateway 3/4 + String TYPE_STICKY_SESSION_SUPPLIER = "org.springframework.cloud.loadbalancer.core.RequestBasedStickySessionServiceInstanceListSupplier"; +} diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/condition/ConditionalOnSpringGateway2FlowControlEnabled.java b/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/condition/ConditionalOnSpringGateway2FlowControlEnabled.java new file mode 100644 index 000000000..fd4c40125 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/condition/ConditionalOnSpringGateway2FlowControlEnabled.java @@ -0,0 +1,34 @@ +/* + * 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.v2.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnFlowControlEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringGateway2Enabled +@ConditionalOnFlowControlEnabled +@ConditionalComposite +public @interface ConditionalOnSpringGateway2FlowControlEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/condition/ConditionalOnSpringGateway2OnlyRouteEnabled.java b/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/condition/ConditionalOnSpringGateway2OnlyRouteEnabled.java new file mode 100644 index 000000000..35e55d03f --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/condition/ConditionalOnSpringGateway2OnlyRouteEnabled.java @@ -0,0 +1,34 @@ +/* + * 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.v2.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnOnlyRouteEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringGateway2Enabled +@ConditionalOnOnlyRouteEnabled +@ConditionalComposite +public @interface ConditionalOnSpringGateway2OnlyRouteEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/definition/GatewayClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/definition/GatewayClusterDefinition.java index c113e43e1..c3b0e0ccb 100644 --- a/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/definition/GatewayClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/definition/GatewayClusterDefinition.java @@ -17,8 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Config; import com.jd.live.agent.core.inject.annotation.Inject; @@ -26,8 +24,8 @@ 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springgateway.v2.condition.ConditionalOnSpringGateway2FlowControlEnabled; import com.jd.live.agent.plugin.router.springgateway.v2.config.GatewayConfig; import com.jd.live.agent.plugin.router.springgateway.v2.interceptor.GatewayClusterInterceptor; @@ -37,27 +35,19 @@ * @since 1.5.0 */ @Extension(value = "GatewayClusterDefinition_v2") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_GATEWAY_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringGateway2FlowControlEnabled @ConditionalOnClass(GatewayClusterDefinition.TYPE_FILTERING_WEB_HANDLER) -@ConditionalOnClass(GatewayClusterDefinition.REACTOR_MONO) -@ConditionalOnMissingClass(GatewayClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) @Injectable public class GatewayClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_FILTERING_WEB_HANDLER = "org.springframework.cloud.gateway.handler.FilteringWebHandler"; - protected static final String TYPE_STICKY_SESSION_SUPPLIER = "org.springframework.cloud.loadbalancer.core.RequestBasedStickySessionServiceInstanceListSupplier"; - 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"; - @Inject(InvocationContext.COMPONENT_INVOCATION_CONTEXT) private InvocationContext context; diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/definition/GatewayDefinition.java b/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/definition/GatewayDefinition.java index 3ee740f77..7105ac7f4 100644 --- a/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/definition/GatewayDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/definition/GatewayDefinition.java @@ -16,11 +16,12 @@ package com.jd.live.agent.plugin.router.springgateway.v2.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; 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.v2.condition.ConditionalOnSpringGateway2OnlyRouteEnabled; import com.jd.live.agent.plugin.router.springgateway.v2.interceptor.GatewayInterceptor; /** @@ -29,13 +30,8 @@ * @since 1.5.0 */ @Extension(value = "GatewayDefinition_v2") -@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) +@ConditionalOnSpringGateway2OnlyRouteEnabled @ConditionalOnClass(GatewayDefinition.TYPE_FILTERING_WEB_HANDLER) -@ConditionalOnClass(GatewayClusterDefinition.REACTOR_MONO) -@ConditionalOnMissingClass(GatewayClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) public class GatewayDefinition extends PluginDefinitionAdapter { protected static final String TYPE_FILTERING_WEB_HANDLER = "org.springframework.cloud.gateway.handler.FilteringWebHandler"; diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/definition/GatewayRouteDefinition.java b/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/definition/GatewayRouteDefinition.java index f18ca2563..4abd9c0bc 100644 --- a/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/definition/GatewayRouteDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springgateway2/src/main/java/com/jd/live/agent/plugin/router/springgateway/v2/definition/GatewayRouteDefinition.java @@ -17,14 +17,12 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Injectable; 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.v2.condition.ConditionalOnSpringGateway2FlowControlEnabled; import com.jd.live.agent.plugin.router.springgateway.v2.interceptor.GatewayRouteInterceptor; /** @@ -33,11 +31,8 @@ * @since 1.6.0 */ @Extension(value = "GatewayRouteDefinition_v4") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_GATEWAY_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringGateway2FlowControlEnabled @ConditionalOnClass(GatewayRouteDefinition.TYPE_REFRESH_ROUTES_EVENT) -@ConditionalOnMissingClass(GatewayClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) @Injectable public class GatewayRouteDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/condition/ConditionalOnSpringGateway3Enabled.java b/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/condition/ConditionalOnSpringGateway3Enabled.java new file mode 100644 index 000000000..6ae0a0d28 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/condition/ConditionalOnSpringGateway3Enabled.java @@ -0,0 +1,44 @@ +/* + * 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.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; +import com.jd.live.agent.governance.annotation.ConditionalOnReactive; +import com.jd.live.agent.governance.annotation.ConditionalOnSpringGatewayEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringGatewayEnabled +@ConditionalOnReactive +@ConditionalOnClass(ConditionalOnSpringGateway3Enabled.TYPE_STICKY_SESSION_SUPPLIER) +@ConditionalOnMissingClass(ConditionalOnSpringGateway3Enabled.TYPE_HTTP_HTTP_STATUS_CODE) +@ConditionalComposite +public @interface ConditionalOnSpringGateway3Enabled { + + // spring gateway 4 + String TYPE_HTTP_HTTP_STATUS_CODE = "org.springframework.http.HttpStatusCode"; + // spring gateway 3/4 + String TYPE_STICKY_SESSION_SUPPLIER = "org.springframework.cloud.loadbalancer.core.RequestBasedStickySessionServiceInstanceListSupplier"; + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/condition/ConditionalOnSpringGateway3FlowControlEnabled.java b/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/condition/ConditionalOnSpringGateway3FlowControlEnabled.java new file mode 100644 index 000000000..c76fcc0fb --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/condition/ConditionalOnSpringGateway3FlowControlEnabled.java @@ -0,0 +1,34 @@ +/* + * 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.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnFlowControlEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringGateway3Enabled +@ConditionalOnFlowControlEnabled +@ConditionalComposite +public @interface ConditionalOnSpringGateway3FlowControlEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/condition/ConditionalOnSpringGateway3OnlyRouteEnabled.java b/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/condition/ConditionalOnSpringGateway3OnlyRouteEnabled.java new file mode 100644 index 000000000..88bc70258 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/condition/ConditionalOnSpringGateway3OnlyRouteEnabled.java @@ -0,0 +1,34 @@ +/* + * 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.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnOnlyRouteEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringGateway3Enabled +@ConditionalOnOnlyRouteEnabled +@ConditionalComposite +public @interface ConditionalOnSpringGateway3OnlyRouteEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/definition/GatewayClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/definition/GatewayClusterDefinition.java index 95f69d7b0..29f02c716 100644 --- a/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/definition/GatewayClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/definition/GatewayClusterDefinition.java @@ -17,8 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Config; import com.jd.live.agent.core.inject.annotation.Inject; @@ -26,8 +24,8 @@ 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springgateway.v3.condition.ConditionalOnSpringGateway3FlowControlEnabled; import com.jd.live.agent.plugin.router.springgateway.v3.config.GatewayConfig; import com.jd.live.agent.plugin.router.springgateway.v3.interceptor.GatewayClusterInterceptor; @@ -37,21 +35,12 @@ * @since 1.0.0 */ @Extension(value = "GatewayClusterDefinition_v3") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_GATEWAY_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringGateway3FlowControlEnabled @ConditionalOnClass(GatewayClusterDefinition.TYPE_FILTERING_WEB_HANDLER) -@ConditionalOnClass(GatewayClusterDefinition.REACTOR_MONO) -@ConditionalOnClass(GatewayClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) -@ConditionalOnMissingClass(GatewayClusterDefinition.TYPE_HTTP_STATUS_CODE) @Injectable public class GatewayClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_FILTERING_WEB_HANDLER = "org.springframework.cloud.gateway.handler.FilteringWebHandler"; - // spring gateway 4 - protected static final String TYPE_HTTP_STATUS_CODE = "org.springframework.http.HttpStatusCode"; - // spring gateway 3/4 - protected static final String TYPE_STICKY_SESSION_SUPPLIER = "org.springframework.cloud.loadbalancer.core.RequestBasedStickySessionServiceInstanceListSupplier"; private static final String METHOD_HANDLE = "handle"; @@ -59,8 +48,6 @@ public class GatewayClusterDefinition extends PluginDefinitionAdapter { "org.springframework.web.server.ServerWebExchange" }; - protected static final String REACTOR_MONO = "reactor.core.publisher.Mono"; - @Inject(InvocationContext.COMPONENT_INVOCATION_CONTEXT) private InvocationContext context; diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/definition/GatewayDefinition.java b/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/definition/GatewayDefinition.java index 6d9c47fe6..75bf0f42f 100644 --- a/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/definition/GatewayDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/definition/GatewayDefinition.java @@ -16,11 +16,12 @@ 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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; 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.condition.ConditionalOnSpringGateway3OnlyRouteEnabled; import com.jd.live.agent.plugin.router.springgateway.v3.interceptor.GatewayInterceptor; /** @@ -29,14 +30,8 @@ * @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) +@ConditionalOnSpringGateway3OnlyRouteEnabled @ConditionalOnClass(GatewayDefinition.TYPE_FILTERING_WEB_HANDLER) -@ConditionalOnClass(GatewayClusterDefinition.REACTOR_MONO) -@ConditionalOnClass(GatewayClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) -@ConditionalOnMissingClass(GatewayClusterDefinition.TYPE_HTTP_STATUS_CODE) public class GatewayDefinition extends PluginDefinitionAdapter { protected static final String TYPE_FILTERING_WEB_HANDLER = "org.springframework.cloud.gateway.handler.FilteringWebHandler"; diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/definition/GatewayRouteDefinition.java b/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/definition/GatewayRouteDefinition.java index 07e8b64bb..2e98e9eba 100644 --- a/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/definition/GatewayRouteDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springgateway3/src/main/java/com/jd/live/agent/plugin/router/springgateway/v3/definition/GatewayRouteDefinition.java @@ -17,14 +17,12 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Injectable; 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.condition.ConditionalOnSpringGateway3FlowControlEnabled; import com.jd.live.agent.plugin.router.springgateway.v3.interceptor.GatewayRouteInterceptor; /** @@ -32,13 +30,9 @@ * * @since 1.6.0 */ -@Extension(value = "GatewayRouteDefinition_v4") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_GATEWAY_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@Extension(value = "GatewayRouteDefinition_v3") +@ConditionalOnSpringGateway3FlowControlEnabled @ConditionalOnClass(GatewayRouteDefinition.TYPE_REFRESH_ROUTES_EVENT) -@ConditionalOnClass(GatewayClusterDefinition.TYPE_STICKY_SESSION_SUPPLIER) -@ConditionalOnMissingClass(GatewayClusterDefinition.TYPE_HTTP_STATUS_CODE) @Injectable public class GatewayRouteDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/condition/ConditionalOnSpringGateway4Enabled.java b/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/condition/ConditionalOnSpringGateway4Enabled.java new file mode 100644 index 000000000..19f20b700 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/condition/ConditionalOnSpringGateway4Enabled.java @@ -0,0 +1,40 @@ +/* + * 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.v4.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.governance.annotation.ConditionalOnReactive; +import com.jd.live.agent.governance.annotation.ConditionalOnSpringGatewayEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringGatewayEnabled +@ConditionalOnReactive +@ConditionalOnClass(ConditionalOnSpringGateway4Enabled.TYPE_HTTP_HTTP_STATUS_CODE) +@ConditionalComposite +public @interface ConditionalOnSpringGateway4Enabled { + + // spring gateway 4 + String TYPE_HTTP_HTTP_STATUS_CODE = "org.springframework.http.HttpStatusCode"; + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/condition/ConditionalOnSpringGateway4FlowControlEnabled.java b/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/condition/ConditionalOnSpringGateway4FlowControlEnabled.java new file mode 100644 index 000000000..bd16981f8 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/condition/ConditionalOnSpringGateway4FlowControlEnabled.java @@ -0,0 +1,34 @@ +/* + * 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.v4.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnFlowControlEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringGateway4Enabled +@ConditionalOnFlowControlEnabled +@ConditionalComposite +public @interface ConditionalOnSpringGateway4FlowControlEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/condition/ConditionalOnSpringGateway4OnlyRouteEnabled.java b/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/condition/ConditionalOnSpringGateway4OnlyRouteEnabled.java new file mode 100644 index 000000000..4334f54e4 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/condition/ConditionalOnSpringGateway4OnlyRouteEnabled.java @@ -0,0 +1,34 @@ +/* + * 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.v4.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.governance.annotation.ConditionalOnOnlyRouteEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnSpringGateway4Enabled +@ConditionalOnOnlyRouteEnabled +@ConditionalComposite +public @interface ConditionalOnSpringGateway4OnlyRouteEnabled { + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/definition/GatewayClusterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/definition/GatewayClusterDefinition.java index 3c59c2902..1b0964582 100644 --- a/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/definition/GatewayClusterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/definition/GatewayClusterDefinition.java @@ -17,7 +17,6 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Config; import com.jd.live.agent.core.inject.annotation.Inject; @@ -25,8 +24,8 @@ 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springgateway.v4.condition.ConditionalOnSpringGateway4FlowControlEnabled; import com.jd.live.agent.plugin.router.springgateway.v4.config.GatewayConfig; import com.jd.live.agent.plugin.router.springgateway.v4.interceptor.GatewayClusterInterceptor; @@ -36,18 +35,12 @@ * @since 1.0.0 */ @Extension(value = "GatewayClusterDefinition_v4") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_GATEWAY_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringGateway4FlowControlEnabled @ConditionalOnClass(GatewayClusterDefinition.TYPE_FILTERING_WEB_HANDLER) -@ConditionalOnClass(GatewayClusterDefinition.REACTOR_MONO) -@ConditionalOnClass(GatewayClusterDefinition.TYPE_HTTP_STATUS_CODE) @Injectable public class GatewayClusterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_FILTERING_WEB_HANDLER = "org.springframework.cloud.gateway.handler.FilteringWebHandler"; - // spring gateway 4 - protected static final String TYPE_HTTP_STATUS_CODE = "org.springframework.http.HttpStatusCode"; private static final String METHOD_HANDLE = "handle"; @@ -55,8 +48,6 @@ public class GatewayClusterDefinition extends PluginDefinitionAdapter { "org.springframework.web.server.ServerWebExchange" }; - protected static final String REACTOR_MONO = "reactor.core.publisher.Mono"; - @Inject(InvocationContext.COMPONENT_INVOCATION_CONTEXT) private InvocationContext context; diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/definition/GatewayDefinition.java b/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/definition/GatewayDefinition.java index c5c18127f..026d14243 100644 --- a/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/definition/GatewayDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/definition/GatewayDefinition.java @@ -16,11 +16,12 @@ package com.jd.live.agent.plugin.router.springgateway.v4.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; 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.v4.condition.ConditionalOnSpringGateway4OnlyRouteEnabled; import com.jd.live.agent.plugin.router.springgateway.v4.interceptor.GatewayInterceptor; /** @@ -29,19 +30,12 @@ * @since 1.0.0 */ @Extension(value = "GatewayDefinition_v4") -@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) +@ConditionalOnSpringGateway4OnlyRouteEnabled @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[]{ diff --git a/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/definition/GatewayRouteDefinition.java b/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/definition/GatewayRouteDefinition.java index 13e04c48f..049691ea5 100644 --- a/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/definition/GatewayRouteDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springgateway4/src/main/java/com/jd/live/agent/plugin/router/springgateway/v4/definition/GatewayRouteDefinition.java @@ -17,13 +17,12 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Injectable; 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.v4.condition.ConditionalOnSpringGateway4FlowControlEnabled; import com.jd.live.agent.plugin.router.springgateway.v4.interceptor.GatewayRouteInterceptor; /** @@ -32,11 +31,8 @@ * @since 1.6.0 */ @Extension(value = "GatewayRouteDefinition_v4") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_GATEWAY_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringGateway4FlowControlEnabled @ConditionalOnClass(GatewayRouteDefinition.TYPE_REFRESH_ROUTES_EVENT) -@ConditionalOnClass(GatewayClusterDefinition.TYPE_HTTP_STATUS_CODE) @Injectable public class GatewayRouteDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/condition/ConditionalOnSpringWeb5FlowControlEnabled.java b/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/condition/ConditionalOnSpringWeb5FlowControlEnabled.java new file mode 100644 index 000000000..efde794e4 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/condition/ConditionalOnSpringWeb5FlowControlEnabled.java @@ -0,0 +1,40 @@ +/* + * 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.springweb.v5.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; +import com.jd.live.agent.governance.annotation.ConditionalOnFlowControlEnabled; +import com.jd.live.agent.governance.annotation.ConditionalOnSpringEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnFlowControlEnabled +@ConditionalOnSpringEnabled +@ConditionalOnMissingClass(ConditionalOnSpringWeb5FlowControlEnabled.TYPE_ERROR_RESPONSE) +@ConditionalComposite +public @interface ConditionalOnSpringWeb5FlowControlEnabled { + + // spring web 6 + String TYPE_ERROR_RESPONSE = "org.springframework.web.ErrorResponse"; + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/condition/ConditionalOnSpringWeb5GovernanceEnabled.java b/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/condition/ConditionalOnSpringWeb5GovernanceEnabled.java new file mode 100644 index 000000000..6d845273d --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/condition/ConditionalOnSpringWeb5GovernanceEnabled.java @@ -0,0 +1,40 @@ +/* + * 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.springweb.v5.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; +import com.jd.live.agent.governance.annotation.ConditionalOnSpringEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnGovernanceEnabled +@ConditionalOnSpringEnabled +@ConditionalOnMissingClass(ConditionalOnSpringWeb5GovernanceEnabled.TYPE_ERROR_RESPONSE) +@ConditionalComposite +public @interface ConditionalOnSpringWeb5GovernanceEnabled { + + // spring web 6 + String TYPE_ERROR_RESPONSE = "org.springframework.web.ErrorResponse"; + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/definition/DispatcherHandlerDefinition.java b/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/definition/DispatcherHandlerDefinition.java index d37337474..e87b9aeeb 100644 --- a/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/definition/DispatcherHandlerDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/definition/DispatcherHandlerDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.router.springweb.v5.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springweb.v5.condition.ConditionalOnSpringWeb5GovernanceEnabled; import com.jd.live.agent.plugin.router.springweb.v5.interceptor.DispatcherHandlerInterceptor; /** @@ -34,22 +35,14 @@ */ @Injectable @Extension(value = "DispatcherHandlerDefinition_v5") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED, - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnSpringWeb5GovernanceEnabled @ConditionalOnClass(DispatcherHandlerDefinition.TYPE_DISPATCHER_HANDLER) -@ConditionalOnMissingClass(DispatcherHandlerDefinition.TYPE_ERROR_RESPONSE) @ConditionalOnClass(DispatcherHandlerDefinition.REACTOR_MONO) public class DispatcherHandlerDefinition extends PluginDefinitionAdapter { protected static final String TYPE_DISPATCHER_HANDLER = "org.springframework.web.reactive.DispatcherHandler"; - protected static final String TYPE_ERROR_RESPONSE = "org.springframework.web.ErrorResponse"; + protected static final String REACTOR_MONO = "reactor.core.publisher.Mono"; private static final String METHOD_INVOKE_HANDLER = "invokeHandler"; @@ -58,8 +51,6 @@ public class DispatcherHandlerDefinition extends PluginDefinitionAdapter { "java.lang.Object" }; - protected static final String REACTOR_MONO = "reactor.core.publisher.Mono"; - @Inject(InvocationContext.COMPONENT_INVOCATION_CONTEXT) private InvocationContext context; diff --git a/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/definition/ExceptionCarryingDefinition.java b/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/definition/ExceptionCarryingDefinition.java index ad4317e2e..fcf35627b 100644 --- a/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/definition/ExceptionCarryingDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/definition/ExceptionCarryingDefinition.java @@ -17,16 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnMissingClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.config.ServiceConfig; +import com.jd.live.agent.plugin.router.springweb.v5.condition.ConditionalOnSpringWeb5FlowControlEnabled; import com.jd.live.agent.plugin.router.springweb.v5.interceptor.ExceptionCarryingInterceptor; /** @@ -34,10 +32,8 @@ */ @Injectable @Extension(value = "ExceptionCarryingDefinition_v5") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringWeb5FlowControlEnabled @ConditionalOnClass(ExceptionCarryingDefinition.TYPE_DISPATCHER_SERVLET) -@ConditionalOnMissingClass(DispatcherHandlerDefinition.TYPE_ERROR_RESPONSE) public class ExceptionCarryingDefinition extends PluginDefinitionAdapter { protected static final String TYPE_DISPATCHER_SERVLET = "org.springframework.web.servlet.DispatcherServlet"; diff --git a/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/definition/HandlerAdapterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/definition/HandlerAdapterDefinition.java index 7974a0eae..a72121979 100644 --- a/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/definition/HandlerAdapterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springweb5/src/main/java/com/jd/live/agent/plugin/router/springweb/v5/definition/HandlerAdapterDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.router.springweb.v5.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springweb.v5.condition.ConditionalOnSpringWeb5GovernanceEnabled; import com.jd.live.agent.plugin.router.springweb.v5.interceptor.HandlerAdapterInterceptor; /** @@ -33,16 +34,8 @@ */ @Injectable @Extension(value = "HandlerAdapterDefinition_v5") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED, - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnSpringWeb5GovernanceEnabled @ConditionalOnClass(HandlerAdapterDefinition.TYPE_HANDLER_ADAPTER) -@ConditionalOnMissingClass(DispatcherHandlerDefinition.TYPE_ERROR_RESPONSE) public class HandlerAdapterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_HANDLER_ADAPTER = "org.springframework.web.servlet.HandlerAdapter"; diff --git a/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/condition/ConditionalOnSpringWeb6FlowControlEnabled.java b/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/condition/ConditionalOnSpringWeb6FlowControlEnabled.java new file mode 100644 index 000000000..868614055 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/condition/ConditionalOnSpringWeb6FlowControlEnabled.java @@ -0,0 +1,40 @@ +/* + * 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.springweb.v6.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.governance.annotation.ConditionalOnFlowControlEnabled; +import com.jd.live.agent.governance.annotation.ConditionalOnSpringEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnFlowControlEnabled +@ConditionalOnSpringEnabled +@ConditionalOnClass(ConditionalOnSpringWeb6FlowControlEnabled.TYPE_ERROR_RESPONSE) +@ConditionalComposite +public @interface ConditionalOnSpringWeb6FlowControlEnabled { + + // spring web 6 + String TYPE_ERROR_RESPONSE = "org.springframework.web.ErrorResponse"; + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/condition/ConditionalOnSpringWeb6GovernanceEnabled.java b/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/condition/ConditionalOnSpringWeb6GovernanceEnabled.java new file mode 100644 index 000000000..e2c2421d8 --- /dev/null +++ b/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/condition/ConditionalOnSpringWeb6GovernanceEnabled.java @@ -0,0 +1,40 @@ +/* + * 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.springweb.v6.condition; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.governance.annotation.ConditionalOnGovernanceEnabled; +import com.jd.live.agent.governance.annotation.ConditionalOnSpringEnabled; + +import java.lang.annotation.*; + +/** + * An annotation used to mark a type as requiring specific conditions related to Spring Gateway to be met. + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnGovernanceEnabled +@ConditionalOnSpringEnabled +@ConditionalOnClass(ConditionalOnSpringWeb6GovernanceEnabled.TYPE_ERROR_RESPONSE) +@ConditionalComposite +public @interface ConditionalOnSpringWeb6GovernanceEnabled { + + // spring web 6 + String TYPE_ERROR_RESPONSE = "org.springframework.web.ErrorResponse"; + +} diff --git a/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/definition/DispatcherHandlerDefinition.java b/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/definition/DispatcherHandlerDefinition.java index 812de034a..86a46ea2e 100644 --- a/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/definition/DispatcherHandlerDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/definition/DispatcherHandlerDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.router.springweb.v6.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springweb.v6.condition.ConditionalOnSpringWeb6GovernanceEnabled; import com.jd.live.agent.plugin.router.springweb.v6.interceptor.DispatcherHandlerInterceptor; import com.jd.live.agent.plugin.router.springweb.v6.interceptor.HandleResultInterceptor; @@ -35,23 +36,13 @@ */ @Injectable @Extension(value = "DispatcherHandlerDefinition_v6") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED, - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnSpringWeb6GovernanceEnabled @ConditionalOnClass(DispatcherHandlerDefinition.TYPE_DISPATCHER_HANDLER) -@ConditionalOnClass(DispatcherHandlerDefinition.TYPE_ERROR_RESPONSE) @ConditionalOnClass(DispatcherHandlerDefinition.REACTOR_MONO) public class DispatcherHandlerDefinition extends PluginDefinitionAdapter { protected static final String TYPE_DISPATCHER_HANDLER = "org.springframework.web.reactive.DispatcherHandler"; - protected static final String TYPE_ERROR_RESPONSE = "org.springframework.web.ErrorResponse"; - // For spring web 6 private static final String METHOD_HANDLE_REQUEST_WITH = "handleRequestWith"; // For spring web flux 6.1.* diff --git a/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/definition/ExceptionCarryingDefinition.java b/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/definition/ExceptionCarryingDefinition.java index 53b7ef370..38caf2e1b 100644 --- a/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/definition/ExceptionCarryingDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/definition/ExceptionCarryingDefinition.java @@ -17,15 +17,14 @@ import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.config.ServiceConfig; +import com.jd.live.agent.plugin.router.springweb.v6.condition.ConditionalOnSpringWeb6FlowControlEnabled; import com.jd.live.agent.plugin.router.springweb.v6.interceptor.ExceptionCarryingInterceptor; /** @@ -33,10 +32,8 @@ */ @Injectable @Extension(value = "ExceptionCarryingDefinition_v6") -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -@ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) +@ConditionalOnSpringWeb6FlowControlEnabled @ConditionalOnClass(ExceptionCarryingDefinition.TYPE_DISPATCHER_SERVLET) -@ConditionalOnClass(DispatcherHandlerDefinition.TYPE_ERROR_RESPONSE) public class ExceptionCarryingDefinition extends PluginDefinitionAdapter { protected static final String TYPE_DISPATCHER_SERVLET = "org.springframework.web.servlet.DispatcherServlet"; diff --git a/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/definition/HandlerAdapterDefinition.java b/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/definition/HandlerAdapterDefinition.java index 96b57cbf4..3b600d58f 100644 --- a/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/definition/HandlerAdapterDefinition.java +++ b/joylive-plugin/joylive-router/joylive-router-springweb6/src/main/java/com/jd/live/agent/plugin/router/springweb/v6/definition/HandlerAdapterDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.router.springweb.v6.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.governance.invoke.InvocationContext; +import com.jd.live.agent.plugin.router.springweb.v6.condition.ConditionalOnSpringWeb6GovernanceEnabled; import com.jd.live.agent.plugin.router.springweb.v6.interceptor.HandlerAdapterInterceptor; /** @@ -33,16 +34,8 @@ */ @Injectable @Extension(value = "HandlerAdapterDefinition_v6") -@ConditionalOnProperties(value = { - @ConditionalOnProperty(name = { - GovernanceConfig.CONFIG_LIVE_ENABLED, - GovernanceConfig.CONFIG_LANE_ENABLED, - GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED - }, matchIfMissing = true, relation = ConditionalRelation.OR), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_SPRING_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.AND) +@ConditionalOnSpringWeb6GovernanceEnabled @ConditionalOnClass(HandlerAdapterDefinition.TYPE_HANDLER_ADAPTER) -@ConditionalOnClass(DispatcherHandlerDefinition.TYPE_ERROR_RESPONSE) public class HandlerAdapterDefinition extends PluginDefinitionAdapter { protected static final String TYPE_HANDLER_ADAPTER = "org.springframework.web.servlet.HandlerAdapter"; @@ -55,7 +48,6 @@ public class HandlerAdapterDefinition extends PluginDefinitionAdapter { "java.lang.Object" }; - @Inject(InvocationContext.COMPONENT_INVOCATION_CONTEXT) private InvocationContext context; diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.6/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_6/definition/DubboConsumerDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.6/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_6/definition/DubboConsumerDefinition.java index de3d6718a..19db80635 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.6/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_6/definition/DubboConsumerDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.6/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_6/definition/DubboConsumerDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.transmission.dubbo.v2_6.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.context.bag.CargoRequire; import com.jd.live.agent.plugin.transmission.dubbo.v2_6.interceptor.DubboConsumerInterceptor; @@ -31,11 +32,7 @@ @Extension(value = "DubboConsumerDefinition_v2.6", order = PluginDefinition.ORDER_TRANSMISSION) @Injectable -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(DubboConsumerDefinition.TYPE_ABSTRACT_CLUSTER_INVOKER) public class DubboConsumerDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.6/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_6/definition/DubboProviderDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.6/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_6/definition/DubboProviderDefinition.java index 6662cdf0f..eea526103 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.6/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_6/definition/DubboProviderDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.6/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_6/definition/DubboProviderDefinition.java @@ -16,28 +16,23 @@ package com.jd.live.agent.plugin.transmission.dubbo.v2_6.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.context.bag.CargoRequire; import com.jd.live.agent.plugin.transmission.dubbo.v2_6.interceptor.DubboProviderInterceptor; import java.util.List; -import static com.jd.live.agent.plugin.transmission.dubbo.v2_6.definition.DubboConsumerDefinition.ARGUMENT_INVOKE; - @Injectable @Extension(value = "DubboProviderDefinition_v2.6", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(DubboProviderDefinition.TYPE_CONTEXT_FILTER) public class DubboProviderDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.7/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_7/contidion/ConditionalOnDubbo27TransmissionEnabled.java b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.7/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_7/contidion/ConditionalOnDubbo27TransmissionEnabled.java new file mode 100644 index 000000000..c9c86b5e8 --- /dev/null +++ b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.7/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_7/contidion/ConditionalOnDubbo27TransmissionEnabled.java @@ -0,0 +1,33 @@ +/* + * 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.transmission.dubbo.v2_7.contidion; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnTransmissionEnabled +@ConditionalOnClass(ConditionalOnDubbo27TransmissionEnabled.TYPE_PROTOCOL_FILTER_WRAPPER) +@ConditionalComposite +public @interface ConditionalOnDubbo27TransmissionEnabled { + + String TYPE_PROTOCOL_FILTER_WRAPPER = "org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper"; +} diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.7/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_7/definition/DubboConsumerDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.7/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_7/definition/DubboConsumerDefinition.java index e4ad664ac..a459f334c 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.7/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_7/definition/DubboConsumerDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.7/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_7/definition/DubboConsumerDefinition.java @@ -16,34 +16,28 @@ package com.jd.live.agent.plugin.transmission.dubbo.v2_7.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.context.bag.CargoRequire; +import com.jd.live.agent.plugin.transmission.dubbo.v2_7.contidion.ConditionalOnDubbo27TransmissionEnabled; import com.jd.live.agent.plugin.transmission.dubbo.v2_7.interceptor.DubboConsumerInterceptor; import java.util.List; @Extension(value = "DubboConsumerDefinition_v2.7", order = PluginDefinition.ORDER_TRANSMISSION) @Injectable -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnDubbo27TransmissionEnabled @ConditionalOnClass(DubboConsumerDefinition.TYPE_ABSTRACT_CLUSTER_INVOKER) -@ConditionalOnClass(DubboConsumerDefinition.TYPE_PROTOCOL_FILTER_WRAPPER) public class DubboConsumerDefinition extends PluginDefinitionAdapter { protected static final String TYPE_ABSTRACT_CLUSTER_INVOKER = "org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker"; - public static final String TYPE_PROTOCOL_FILTER_WRAPPER = "org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper"; - private static final String METHOD_INVOKE = "invoke"; protected static final String[] ARGUMENT_INVOKE = new String[]{ diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.7/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_7/definition/DubboProviderDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.7/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_7/definition/DubboProviderDefinition.java index 9253939d3..5f579f5ab 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.7/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_7/definition/DubboProviderDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo2.7/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v2_7/definition/DubboProviderDefinition.java @@ -16,31 +16,27 @@ package com.jd.live.agent.plugin.transmission.dubbo.v2_7.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.context.bag.CargoRequire; +import com.jd.live.agent.plugin.transmission.dubbo.v2_7.contidion.ConditionalOnDubbo27TransmissionEnabled; import com.jd.live.agent.plugin.transmission.dubbo.v2_7.interceptor.DubboProviderInterceptor; import java.util.List; @Injectable @Extension(value = "DubboProviderDefinition_v2.7", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) -@ConditionalOnClass(DubboConsumerDefinition.TYPE_PROTOCOL_FILTER_WRAPPER) -@ConditionalOnClass(DubboProviderDefinition.TYPE_MONITOR_FILTER) +@ConditionalOnDubbo27TransmissionEnabled +@ConditionalOnClass(DubboProviderDefinition.TYPE_CONTEXT_FILTER) public class DubboProviderDefinition extends PluginDefinitionAdapter { - protected static final String TYPE_MONITOR_FILTER = "org.apache.dubbo.rpc.filter.ContextFilter"; + protected static final String TYPE_CONTEXT_FILTER = "org.apache.dubbo.rpc.filter.ContextFilter"; private static final String METHOD_INVOKE = "invoke"; @@ -53,7 +49,7 @@ public class DubboProviderDefinition extends PluginDefinitionAdapter { private List requires; public DubboProviderDefinition() { - this.matcher = () -> MatcherBuilder.named(TYPE_MONITOR_FILTER); + this.matcher = () -> MatcherBuilder.named(TYPE_CONTEXT_FILTER); this.interceptors = new InterceptorDefinition[]{ new InterceptorDefinitionAdapter( MatcherBuilder.named(METHOD_INVOKE). diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo3/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v3/contidion/ConditionalOnDubbo3TransmissionEnabled.java b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo3/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v3/contidion/ConditionalOnDubbo3TransmissionEnabled.java new file mode 100644 index 000000000..d8ad979ac --- /dev/null +++ b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo3/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v3/contidion/ConditionalOnDubbo3TransmissionEnabled.java @@ -0,0 +1,33 @@ +/* + * 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.transmission.dubbo.v3.contidion; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnTransmissionEnabled +@ConditionalOnClass(ConditionalOnDubbo3TransmissionEnabled.TYPE_CONSUMER_CLASSLOADER_FILTER) +@ConditionalComposite +public @interface ConditionalOnDubbo3TransmissionEnabled { + + String TYPE_CONSUMER_CLASSLOADER_FILTER = "org.apache.dubbo.rpc.cluster.filter.support.ConsumerClassLoaderFilter"; +} diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo3/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v3/definition/DubboConsumerDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo3/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v3/definition/DubboConsumerDefinition.java index a990f53a2..4820b45da 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo3/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v3/definition/DubboConsumerDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo3/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v3/definition/DubboConsumerDefinition.java @@ -16,34 +16,28 @@ package com.jd.live.agent.plugin.transmission.dubbo.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.context.bag.CargoRequire; +import com.jd.live.agent.plugin.transmission.dubbo.v3.contidion.ConditionalOnDubbo3TransmissionEnabled; import com.jd.live.agent.plugin.transmission.dubbo.v3.interceptor.DubboConsumerInterceptor; import java.util.List; @Extension(value = "DubboConsumerDefinition_v3", order = PluginDefinition.ORDER_TRANSMISSION) @Injectable -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnDubbo3TransmissionEnabled @ConditionalOnClass(DubboConsumerDefinition.TYPE_ABSTRACT_CLUSTER_INVOKER) -@ConditionalOnClass(DubboConsumerDefinition.TYPE_CONSUMER_CLASSLOADER_FILTER) public class DubboConsumerDefinition extends PluginDefinitionAdapter { public static final String TYPE_ABSTRACT_CLUSTER_INVOKER = "org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker"; - protected static final String TYPE_CONSUMER_CLASSLOADER_FILTER = "org.apache.dubbo.rpc.cluster.filter.support.ConsumerClassLoaderFilter"; - private static final String METHOD_INVOKE = "invoke"; protected static final String[] ARGUMENT_INVOKE = new String[]{ diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo3/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v3/definition/DubboProviderDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo3/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v3/definition/DubboProviderDefinition.java index a6d42de4d..0a0fa0bda 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-dubbo3/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v3/definition/DubboProviderDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-dubbo3/src/main/java/com/jd/live/agent/plugin/transmission/dubbo/v3/definition/DubboProviderDefinition.java @@ -16,29 +16,23 @@ package com.jd.live.agent.plugin.transmission.dubbo.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.context.bag.CargoRequire; +import com.jd.live.agent.plugin.transmission.dubbo.v3.contidion.ConditionalOnDubbo3TransmissionEnabled; import com.jd.live.agent.plugin.transmission.dubbo.v3.interceptor.DubboProviderInterceptor; import java.util.List; -import static com.jd.live.agent.plugin.transmission.dubbo.v3.definition.DubboConsumerDefinition.ARGUMENT_INVOKE; - @Injectable @Extension(value = "DubboProviderDefinition_v3", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) -@ConditionalOnClass(DubboConsumerDefinition.TYPE_CONSUMER_CLASSLOADER_FILTER) +@ConditionalOnDubbo3TransmissionEnabled @ConditionalOnClass(DubboProviderDefinition.TYPE_CONTEXT_FILTER) public class DubboProviderDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-grpc/src/main/java/com/jd/live/agent/plugin/transmission/grpc/definition/ClientCallImplDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-grpc/src/main/java/com/jd/live/agent/plugin/transmission/grpc/definition/ClientCallImplDefinition.java index 0fd754119..7a76bdbb7 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-grpc/src/main/java/com/jd/live/agent/plugin/transmission/grpc/definition/ClientCallImplDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-grpc/src/main/java/com/jd/live/agent/plugin/transmission/grpc/definition/ClientCallImplDefinition.java @@ -16,19 +16,16 @@ package com.jd.live.agent.plugin.transmission.grpc.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transmission.grpc.interceptor.ClientCallImplInterceptor; @Extension(value = "ClientCallImplDefinition", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(ClientCallImplDefinition.TYPE_CLIENT_CALL_IMPL) public class ClientCallImplDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-grpc/src/main/java/com/jd/live/agent/plugin/transmission/grpc/definition/GrpcServerDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-grpc/src/main/java/com/jd/live/agent/plugin/transmission/grpc/definition/GrpcServerDefinition.java index be609422b..21c86bca1 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-grpc/src/main/java/com/jd/live/agent/plugin/transmission/grpc/definition/GrpcServerDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-grpc/src/main/java/com/jd/live/agent/plugin/transmission/grpc/definition/GrpcServerDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.transmission.grpc.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.context.bag.CargoRequire; import com.jd.live.agent.plugin.transmission.grpc.interceptor.GrpcServerInterceptor; @@ -31,11 +32,7 @@ @Injectable @Extension(value = "GrpcServerDefinition", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(GrpcServerDefinition.TYPE_SERVER_IMPL_BUILDER) public class GrpcServerDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-httpclient3/src/main/java/com/jd/live/agent/plugin/transmission/httpclient/v3/definition/HttpClientDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-httpclient3/src/main/java/com/jd/live/agent/plugin/transmission/httpclient/v3/definition/HttpClientDefinition.java index fa9f39d6c..226081c68 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-httpclient3/src/main/java/com/jd/live/agent/plugin/transmission/httpclient/v3/definition/HttpClientDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-httpclient3/src/main/java/com/jd/live/agent/plugin/transmission/httpclient/v3/definition/HttpClientDefinition.java @@ -16,20 +16,16 @@ package com.jd.live.agent.plugin.transmission.httpclient.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transmission.httpclient.v3.interceptor.HttpClientInterceptor; - @Extension(value = "HttpClientDefinition_v3", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(HttpClientDefinition.TYPE_HTTP_CLIENT) public class HttpClientDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-httpclient4/src/main/java/com/jd/live/agent/plugin/transmission/httpclient/v4/definition/HttpClientDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-httpclient4/src/main/java/com/jd/live/agent/plugin/transmission/httpclient/v4/definition/HttpClientDefinition.java index 77814b523..70f919521 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-httpclient4/src/main/java/com/jd/live/agent/plugin/transmission/httpclient/v4/definition/HttpClientDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-httpclient4/src/main/java/com/jd/live/agent/plugin/transmission/httpclient/v4/definition/HttpClientDefinition.java @@ -16,19 +16,16 @@ package com.jd.live.agent.plugin.transmission.httpclient.v4.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transmission.httpclient.v4.interceptor.HttpClientInterceptor; @Extension(value = "HttpClientDefinition_v4", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(HttpClientDefinition.TYPE_ABSTRACT_HTTP_CLIENT) public class HttpClientDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-jdkhttp/src/main/java/com/jd/live/agent/plugin/transmission/jdkhttp/definition/JavaHttpClientDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-jdkhttp/src/main/java/com/jd/live/agent/plugin/transmission/jdkhttp/definition/JavaHttpClientDefinition.java index 7a673e28d..2a8f2467c 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-jdkhttp/src/main/java/com/jd/live/agent/plugin/transmission/jdkhttp/definition/JavaHttpClientDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-jdkhttp/src/main/java/com/jd/live/agent/plugin/transmission/jdkhttp/definition/JavaHttpClientDefinition.java @@ -16,38 +16,21 @@ package com.jd.live.agent.plugin.transmission.jdkhttp.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transmission.jdkhttp.interceptor.JavaHttpClientInterceptor; /** * Defines the instrumentation for the Java HTTP Client's HttpRequestBuilderImpl class. * This class specifies the conditions under which the {@link JavaHttpClientInterceptor} * is applied to modify or monitor HTTP requests during their construction. - * - *

Annotations used:

- * - * - * @see PluginDefinitionAdapter - * @see JavaHttpClientInterceptor */ @Extension(value = "JavaHttpClientDefinition", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(JavaHttpClientDefinition.TYPE_HTTP_REQUEST_BUILDER_IMPL) public class JavaHttpClientDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-jdkhttp/src/main/java/com/jd/live/agent/plugin/transmission/jdkhttp/definition/SunHttpClientDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-jdkhttp/src/main/java/com/jd/live/agent/plugin/transmission/jdkhttp/definition/SunHttpClientDefinition.java index dc2b805a1..453aca8da 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-jdkhttp/src/main/java/com/jd/live/agent/plugin/transmission/jdkhttp/definition/SunHttpClientDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-jdkhttp/src/main/java/com/jd/live/agent/plugin/transmission/jdkhttp/definition/SunHttpClientDefinition.java @@ -16,12 +16,13 @@ package com.jd.live.agent.plugin.transmission.jdkhttp.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginImporter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transmission.jdkhttp.interceptor.SunHttpClientInterceptor; /** @@ -30,26 +31,9 @@ * conditions under which the {@link SunHttpClientInterceptor} is applied, aiming * to monitor or modify HTTP request writing behavior. * - *

Annotations used:

- * - * - * @see PluginDefinitionAdapter - * @see SunHttpClientInterceptor */ @Extension(value = "JdkHttpClientDefinition", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(SunHttpClientDefinition.TYPE_HTTP_CLIENT) public class SunHttpClientDefinition extends PluginDefinitionAdapter implements PluginImporter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-kafka3/src/main/java/com/jd/live/agent/plugin/transmission/kafka/v3/definition/KafkaConsumerRecordDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-kafka3/src/main/java/com/jd/live/agent/plugin/transmission/kafka/v3/definition/KafkaConsumerRecordDefinition.java index 8fa47dadc..a339194a3 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-kafka3/src/main/java/com/jd/live/agent/plugin/transmission/kafka/v3/definition/KafkaConsumerRecordDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-kafka3/src/main/java/com/jd/live/agent/plugin/transmission/kafka/v3/definition/KafkaConsumerRecordDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.transmission.kafka.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.context.bag.CargoRequire; import com.jd.live.agent.plugin.transmission.kafka.v3.interceptor.KafkaConsumerRecordInterceptor; @@ -31,11 +32,7 @@ @Injectable @Extension(value = "KafkaConsumerRecordDefinition_v3", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(KafkaConsumerRecordDefinition.TYPE_CONSUMER_RECORD) public class KafkaConsumerRecordDefinition extends PluginDefinitionAdapter { public static final String TYPE_CONSUMER_RECORD = "org.apache.kafka.clients.consumer.ConsumerRecord"; diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-kafka3/src/main/java/com/jd/live/agent/plugin/transmission/kafka/v3/definition/KafkaProducerDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-kafka3/src/main/java/com/jd/live/agent/plugin/transmission/kafka/v3/definition/KafkaProducerDefinition.java index 300d7f9f5..e0d794768 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-kafka3/src/main/java/com/jd/live/agent/plugin/transmission/kafka/v3/definition/KafkaProducerDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-kafka3/src/main/java/com/jd/live/agent/plugin/transmission/kafka/v3/definition/KafkaProducerDefinition.java @@ -16,19 +16,16 @@ package com.jd.live.agent.plugin.transmission.kafka.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transmission.kafka.v3.interceptor.KafkaProducerInterceptor; @Extension(value = "KafkaProducerDefinition_v3", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(KafkaProducerDefinition.TYPE_KAFKA_PRODUCER) public class KafkaProducerDefinition extends PluginDefinitionAdapter { public static final String TYPE_KAFKA_PRODUCER = "org.apache.kafka.clients.producer.KafkaProducer"; diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-nettyhttp1/src/main/java/com/jd/live/agent/plugin/transimission/nettyhttp/v1/definition/NettyHttpClientDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-nettyhttp1/src/main/java/com/jd/live/agent/plugin/transimission/nettyhttp/v1/definition/NettyHttpClientDefinition.java index eee700a31..0bbafde5a 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-nettyhttp1/src/main/java/com/jd/live/agent/plugin/transimission/nettyhttp/v1/definition/NettyHttpClientDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-nettyhttp1/src/main/java/com/jd/live/agent/plugin/transimission/nettyhttp/v1/definition/NettyHttpClientDefinition.java @@ -16,19 +16,16 @@ package com.jd.live.agent.plugin.transimission.nettyhttp.v1.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transimission.nettyhttp.v1.interceptor.NettyHttpClientInterceptor; @Extension(value = "NettyHttpClientDefinition_v1", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(NettyHttpClientDefinition.TYPE_HTTP_CLIENT) @Deprecated public class NettyHttpClientDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-okhttp1/src/main/java/com/jd/live/agent/plugin/transmission/okhttp/v1/definition/OkHttpClientDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-okhttp1/src/main/java/com/jd/live/agent/plugin/transmission/okhttp/v1/definition/OkHttpClientDefinition.java index b6997b356..50140a0a7 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-okhttp1/src/main/java/com/jd/live/agent/plugin/transmission/okhttp/v1/definition/OkHttpClientDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-okhttp1/src/main/java/com/jd/live/agent/plugin/transmission/okhttp/v1/definition/OkHttpClientDefinition.java @@ -16,19 +16,16 @@ package com.jd.live.agent.plugin.transmission.okhttp.v1.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transmission.okhttp.v1.interceptor.OkHttpClientInterceptor; @Extension(value = "OkHttpClientDefinition_v1", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(OkHttpClientDefinition.TYPE_REQUEST_BUILDER) public class OkHttpClientDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-okhttp3/src/main/java/com/jd/live/agent/plugin/transmission/okhttp/v3/definition/OkHttpClientDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-okhttp3/src/main/java/com/jd/live/agent/plugin/transmission/okhttp/v3/definition/OkHttpClientDefinition.java index 943890a51..9e850eafd 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-okhttp3/src/main/java/com/jd/live/agent/plugin/transmission/okhttp/v3/definition/OkHttpClientDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-okhttp3/src/main/java/com/jd/live/agent/plugin/transmission/okhttp/v3/definition/OkHttpClientDefinition.java @@ -16,19 +16,16 @@ package com.jd.live.agent.plugin.transmission.okhttp.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transmission.okhttp.v3.interceptor.OkHttpClientInterceptor; @Extension(value = "OkHttpClientDefinition_v3", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(OkHttpClientDefinition.TYPE_OK_HTTPCLIENT) public class OkHttpClientDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-pulsar3/src/main/java/com/jd/live/agent/plugin/transmission/pulsar/v3/definition/MessageBuilderDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-pulsar3/src/main/java/com/jd/live/agent/plugin/transmission/pulsar/v3/definition/MessageBuilderDefinition.java index 31bdee4b9..d25bf6904 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-pulsar3/src/main/java/com/jd/live/agent/plugin/transmission/pulsar/v3/definition/MessageBuilderDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-pulsar3/src/main/java/com/jd/live/agent/plugin/transmission/pulsar/v3/definition/MessageBuilderDefinition.java @@ -16,19 +16,16 @@ package com.jd.live.agent.plugin.transmission.pulsar.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transmission.pulsar.v3.interceptor.SendInterceptor; @Extension(value = "MessageBuilderDefinition_v3", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(MessageBuilderDefinition.TYPE_TYPED_MESSAGE_BUILDER) public class MessageBuilderDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-pulsar3/src/main/java/com/jd/live/agent/plugin/transmission/pulsar/v3/definition/MessageDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-pulsar3/src/main/java/com/jd/live/agent/plugin/transmission/pulsar/v3/definition/MessageDefinition.java index 0742044ba..08706b2f8 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-pulsar3/src/main/java/com/jd/live/agent/plugin/transmission/pulsar/v3/definition/MessageDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-pulsar3/src/main/java/com/jd/live/agent/plugin/transmission/pulsar/v3/definition/MessageDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.transmission.pulsar.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.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.context.bag.CargoRequire; import com.jd.live.agent.plugin.transmission.pulsar.v3.interceptor.MessageInterceptor; @@ -31,11 +32,7 @@ @Injectable @Extension(value = "MessageDefinition_v3", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(MessageDefinition.TYPE_MESSAGE) public class MessageDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-rabbitmq5/src/main/java/com/jd/live/agent/plugin/transmission/rabbitmq/v5/definition/ChannelNDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-rabbitmq5/src/main/java/com/jd/live/agent/plugin/transmission/rabbitmq/v5/definition/ChannelNDefinition.java index 0f2b1bcda..386cdc787 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-rabbitmq5/src/main/java/com/jd/live/agent/plugin/transmission/rabbitmq/v5/definition/ChannelNDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-rabbitmq5/src/main/java/com/jd/live/agent/plugin/transmission/rabbitmq/v5/definition/ChannelNDefinition.java @@ -16,19 +16,16 @@ package com.jd.live.agent.plugin.transmission.rabbitmq.v5.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transmission.rabbitmq.v5.interceptor.PublishInterceptor; @Extension(value = "ChannelNDefinition_v5", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(ChannelNDefinition.TYPE_CHANNEL_N) public class ChannelNDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-rabbitmq5/src/main/java/com/jd/live/agent/plugin/transmission/rabbitmq/v5/definition/ConsumerDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-rabbitmq5/src/main/java/com/jd/live/agent/plugin/transmission/rabbitmq/v5/definition/ConsumerDefinition.java index f039a7b4a..d1bf60905 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-rabbitmq5/src/main/java/com/jd/live/agent/plugin/transmission/rabbitmq/v5/definition/ConsumerDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-rabbitmq5/src/main/java/com/jd/live/agent/plugin/transmission/rabbitmq/v5/definition/ConsumerDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.transmission.rabbitmq.v5.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.context.bag.CargoRequire; import com.jd.live.agent.plugin.transmission.rabbitmq.v5.interceptor.HandleInterceptor; @@ -31,11 +32,7 @@ @Injectable @Extension(value = "ConsumerDefinition_v5", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(ConsumerDefinition.TYPE_CONSUMER) public class ConsumerDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-rabbitmq5/src/main/java/com/jd/live/agent/plugin/transmission/rabbitmq/v5/definition/DeliveryDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-rabbitmq5/src/main/java/com/jd/live/agent/plugin/transmission/rabbitmq/v5/definition/DeliveryDefinition.java index 635f7f70a..e170ca653 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-rabbitmq5/src/main/java/com/jd/live/agent/plugin/transmission/rabbitmq/v5/definition/DeliveryDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-rabbitmq5/src/main/java/com/jd/live/agent/plugin/transmission/rabbitmq/v5/definition/DeliveryDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.transmission.rabbitmq.v5.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.context.bag.CargoRequire; import com.jd.live.agent.plugin.transmission.rabbitmq.v5.interceptor.GetBodyInterceptor; @@ -31,11 +32,7 @@ @Injectable @Extension(value = "DeliveryDefinition_v5", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(DeliveryDefinition.TYPE_MESSAGE) public class DeliveryDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/contidion/ConditionalOnRocketmq4TransmissionEnabled.java b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/contidion/ConditionalOnRocketmq4TransmissionEnabled.java new file mode 100644 index 000000000..dd359293a --- /dev/null +++ b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/contidion/ConditionalOnRocketmq4TransmissionEnabled.java @@ -0,0 +1,33 @@ +/* + * 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.transmission.rocketmq.v4.contidion; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnTransmissionEnabled +@ConditionalOnClass(ConditionalOnRocketmq4TransmissionEnabled.TYPE_CLIENT_LOGGER) +@ConditionalComposite +public @interface ConditionalOnRocketmq4TransmissionEnabled { + + String TYPE_CLIENT_LOGGER = "org.apache.rocketmq.client.log.ClientLogger"; +} diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/definition/MQProducerDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/definition/MQProducerDefinition.java index 0a67e6474..4cf6298d7 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/definition/MQProducerDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/definition/MQProducerDefinition.java @@ -16,21 +16,17 @@ package com.jd.live.agent.plugin.transmission.rocketmq.v4.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.plugin.transmission.rocketmq.v4.contidion.ConditionalOnRocketmq4TransmissionEnabled; import com.jd.live.agent.plugin.transmission.rocketmq.v4.interceptor.MQProducerInterceptor; @Extension(value = "MQProducerDefinition_v4", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnRocketmq4TransmissionEnabled @ConditionalOnClass(MQProducerDefinition.TYPE_MQ_PRODUCER) -@ConditionalOnClass(MessageDefinition.TYPE_CLIENT_LOGGER) public class MQProducerDefinition extends PluginDefinitionAdapter { protected static final String TYPE_MQ_PRODUCER = "org.apache.rocketmq.client.producer.MQProducer"; diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/definition/MessageDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/definition/MessageDefinition.java index bc3ba762f..284f7113c 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/definition/MessageDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/definition/MessageDefinition.java @@ -16,36 +16,30 @@ package com.jd.live.agent.plugin.transmission.rocketmq.v4.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.context.bag.CargoRequire; +import com.jd.live.agent.plugin.transmission.rocketmq.v4.contidion.ConditionalOnRocketmq4TransmissionEnabled; import com.jd.live.agent.plugin.transmission.rocketmq.v4.interceptor.MessageInterceptor; import java.util.List; @Injectable @Extension(value = "MessageDefinition_v4", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnRocketmq4TransmissionEnabled @ConditionalOnClass(MessageDefinition.TYPE_MESSAGE) -@ConditionalOnClass(MessageDefinition.TYPE_CLIENT_LOGGER) public class MessageDefinition extends PluginDefinitionAdapter { protected static final String TYPE_MESSAGE = "org.apache.rocketmq.common.message.Message"; private static final String METHOD_GET_BODY = "getBody"; - public static final String TYPE_CLIENT_LOGGER = "org.apache.rocketmq.client.log.ClientLogger"; - @Inject private List requires; diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/definition/MessageUtilDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/definition/MessageUtilDefinition.java index 6d65954e7..f5c719d9a 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/definition/MessageUtilDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq4/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v4/definition/MessageUtilDefinition.java @@ -16,28 +16,24 @@ package com.jd.live.agent.plugin.transmission.rocketmq.v4.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.context.bag.CargoRequire; +import com.jd.live.agent.plugin.transmission.rocketmq.v4.contidion.ConditionalOnRocketmq4TransmissionEnabled; import com.jd.live.agent.plugin.transmission.rocketmq.v4.interceptor.MessageUtilInterceptor; import java.util.List; @Injectable -@Extension(value = "MessageUtilDefinition_v5", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@Extension(value = "MessageUtilDefinition_v4", order = PluginDefinition.ORDER_TRANSMISSION) +@ConditionalOnRocketmq4TransmissionEnabled @ConditionalOnClass(MessageUtilDefinition.TYPE_MESSAGE_UTIL) -@ConditionalOnClass(MessageDefinition.TYPE_CLIENT_LOGGER) public class MessageUtilDefinition extends PluginDefinitionAdapter { protected static final String TYPE_MESSAGE_UTIL = "org.apache.rocketmq.client.utils.MessageUtil"; diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/contidion/ConditionalOnRocketmq5TransmissionEnabled.java b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/contidion/ConditionalOnRocketmq5TransmissionEnabled.java new file mode 100644 index 000000000..6f1fdf9f5 --- /dev/null +++ b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/contidion/ConditionalOnRocketmq5TransmissionEnabled.java @@ -0,0 +1,33 @@ +/* + * 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.transmission.rocketmq.v5.contidion; + +import com.jd.live.agent.core.extension.annotation.ConditionalComposite; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@ConditionalOnTransmissionEnabled +@ConditionalOnClass(ConditionalOnRocketmq5TransmissionEnabled.TYPE_ACK_CALLBACK) +@ConditionalComposite +public @interface ConditionalOnRocketmq5TransmissionEnabled { + + String TYPE_ACK_CALLBACK = "org.apache.rocketmq.client.consumer.AckCallback"; +} diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/definition/MQProducerDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/definition/MQProducerDefinition.java index f3884e35a..87dfe4ac4 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/definition/MQProducerDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/definition/MQProducerDefinition.java @@ -16,21 +16,17 @@ package com.jd.live.agent.plugin.transmission.rocketmq.v5.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.plugin.transmission.rocketmq.v5.contidion.ConditionalOnRocketmq5TransmissionEnabled; import com.jd.live.agent.plugin.transmission.rocketmq.v5.interceptor.MQProducerInterceptor; @Extension(value = "MQProducerDefinition_v5", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnRocketmq5TransmissionEnabled @ConditionalOnClass(MQProducerDefinition.TYPE_MQ_PRODUCER) -@ConditionalOnClass(MessageDefinition.TYPE_ACK_CALLBACK) public class MQProducerDefinition extends PluginDefinitionAdapter { protected static final String TYPE_MQ_PRODUCER = "org.apache.rocketmq.client.producer.MQProducer"; diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/definition/MessageDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/definition/MessageDefinition.java index eecc4a35f..b3c7924b2 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/definition/MessageDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/definition/MessageDefinition.java @@ -16,36 +16,30 @@ package com.jd.live.agent.plugin.transmission.rocketmq.v5.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.context.bag.CargoRequire; +import com.jd.live.agent.plugin.transmission.rocketmq.v5.contidion.ConditionalOnRocketmq5TransmissionEnabled; import com.jd.live.agent.plugin.transmission.rocketmq.v5.interceptor.MessageInterceptor; import java.util.List; @Injectable @Extension(value = "Message_v5", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnRocketmq5TransmissionEnabled @ConditionalOnClass(MessageDefinition.TYPE_MESSAGE) -@ConditionalOnClass(MessageDefinition.TYPE_ACK_CALLBACK) public class MessageDefinition extends PluginDefinitionAdapter { protected static final String TYPE_MESSAGE = "org.apache.rocketmq.common.message.Message"; private static final String METHOD_GET_BODY = "getBody"; - public static final String TYPE_ACK_CALLBACK = "org.apache.rocketmq.client.consumer.AckCallback"; - @Inject private List requires; diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/definition/MessageUtilDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/definition/MessageUtilDefinition.java index f94eae62f..1f8ed9e2d 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/definition/MessageUtilDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-rocketmq5/src/main/java/com/jd/live/agent/plugin/transmission/rocketmq/v5/definition/MessageUtilDefinition.java @@ -16,28 +16,24 @@ package com.jd.live.agent.plugin.transmission.rocketmq.v5.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.governance.context.bag.CargoRequire; +import com.jd.live.agent.plugin.transmission.rocketmq.v5.contidion.ConditionalOnRocketmq5TransmissionEnabled; import com.jd.live.agent.plugin.transmission.rocketmq.v5.interceptor.MessageUtilInterceptor; import java.util.List; @Injectable @Extension(value = "MessageUtilDefinition_v5", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnRocketmq5TransmissionEnabled @ConditionalOnClass(MessageUtilDefinition.TYPE_MESSAGE_UTIL) -@ConditionalOnClass(MessageDefinition.TYPE_ACK_CALLBACK) public class MessageUtilDefinition extends PluginDefinitionAdapter { protected static final String TYPE_MESSAGE_UTIL = "org.apache.rocketmq.client.utils.MessageUtil"; diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-servlet-jakarta/src/main/java/com/jd/live/agent/plugin/transmission/servlet/jakarta/definition/HttpServletDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-servlet-jakarta/src/main/java/com/jd/live/agent/plugin/transmission/servlet/jakarta/definition/HttpServletDefinition.java index 381c733a8..6c551bc45 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-servlet-jakarta/src/main/java/com/jd/live/agent/plugin/transmission/servlet/jakarta/definition/HttpServletDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-servlet-jakarta/src/main/java/com/jd/live/agent/plugin/transmission/servlet/jakarta/definition/HttpServletDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.transmission.servlet.jakarta.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.context.bag.CargoRequire; import com.jd.live.agent.plugin.transmission.servlet.jakarta.interceptor.HttpServletInterceptor; @@ -31,11 +32,7 @@ @Injectable @Extension(value = "HttpServletDefinition_jakarta", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(HttpServletDefinition.TYPE_HTTP_SERVLET) public class HttpServletDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-servlet-javax/src/main/java/com/jd/live/agent/plugin/transmission/servlet/javax/definition/HttpServletDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-servlet-javax/src/main/java/com/jd/live/agent/plugin/transmission/servlet/javax/definition/HttpServletDefinition.java index 3f4cc97aa..7a84146ba 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-servlet-javax/src/main/java/com/jd/live/agent/plugin/transmission/servlet/javax/definition/HttpServletDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-servlet-javax/src/main/java/com/jd/live/agent/plugin/transmission/servlet/javax/definition/HttpServletDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.transmission.servlet.javax.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.context.bag.CargoRequire; import com.jd.live.agent.plugin.transmission.servlet.javax.interceptor.HttpServletInterceptor; @@ -31,11 +32,7 @@ @Injectable @Extension(value = "HttpServletDefinition_javax", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(HttpServletDefinition.TYPE_HTTP_SERVLET) public class HttpServletDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-sofarpc/src/main/java/com/jd/live/agent/plugin/transmission/sofarpc/definition/SofaRpcClientDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-sofarpc/src/main/java/com/jd/live/agent/plugin/transmission/sofarpc/definition/SofaRpcClientDefinition.java index 6717fa184..85a411f00 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-sofarpc/src/main/java/com/jd/live/agent/plugin/transmission/sofarpc/definition/SofaRpcClientDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-sofarpc/src/main/java/com/jd/live/agent/plugin/transmission/sofarpc/definition/SofaRpcClientDefinition.java @@ -16,27 +16,23 @@ package com.jd.live.agent.plugin.transmission.sofarpc.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.context.bag.CargoRequire; import com.jd.live.agent.plugin.transmission.sofarpc.interceptor.SofaRpcClientInterceptor; import java.util.List; - @Injectable @Extension(value = "SofaRpcClientDefinition", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(SofaRpcClientDefinition.TYPE_ABSTRACT_CLUSTER) public class SofaRpcClientDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-sofarpc/src/main/java/com/jd/live/agent/plugin/transmission/sofarpc/definition/SofaRpcServerDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-sofarpc/src/main/java/com/jd/live/agent/plugin/transmission/sofarpc/definition/SofaRpcServerDefinition.java index 08595b89c..48c43f604 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-sofarpc/src/main/java/com/jd/live/agent/plugin/transmission/sofarpc/definition/SofaRpcServerDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-sofarpc/src/main/java/com/jd/live/agent/plugin/transmission/sofarpc/definition/SofaRpcServerDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.transmission.sofarpc.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.context.bag.CargoRequire; import com.jd.live.agent.plugin.transmission.sofarpc.interceptor.SofaRpcServerInterceptor; @@ -31,11 +32,7 @@ @Injectable @Extension(value = "SofaRpcServerDefinition", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(SofaRpcServerDefinition.TYPE_PROVIDER_BAGGAGE_FILTER) public class SofaRpcServerDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/ClientHttpRequestFactoryDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/ClientHttpRequestFactoryDefinition.java index 0329b28c3..50105be6c 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/ClientHttpRequestFactoryDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/ClientHttpRequestFactoryDefinition.java @@ -16,13 +16,14 @@ package com.jd.live.agent.plugin.transmission.springweb.v5.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transmission.springweb.v5.interceptor.ClientHttpRequestFactoryInterceptor; /** @@ -33,11 +34,7 @@ */ @Injectable @Extension(value = "ClientHttpRequestFactoryDefinition_v5", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(ClientHttpRequestFactoryDefinition.TYPE_CLIENT_HTTP_REQUEST_FACTORY) public class ClientHttpRequestFactoryDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/DefaultExchangeFunctionDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/DefaultExchangeFunctionDefinition.java index 1e27cc525..d416472ac 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/DefaultExchangeFunctionDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/DefaultExchangeFunctionDefinition.java @@ -16,11 +16,12 @@ package com.jd.live.agent.plugin.transmission.springweb.v5.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.plugin.definition.InterceptorDefinitionAdapter; import com.jd.live.agent.core.plugin.definition.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transmission.springweb.v5.interceptor.DefaultExchangeFunctionInterceptor; /** @@ -29,11 +30,7 @@ * @since 1.0.0 */ @Extension(value = "DefaultExchangeFunctionDefinition_v5", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(DefaultExchangeFunctionDefinition.TYPE_DEFAULT_EXCHANGE_FUNCTION) public class DefaultExchangeFunctionDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/HandshakeWebSocketServiceDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/HandshakeWebSocketServiceDefinition.java index 805a729d0..672b226a8 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/HandshakeWebSocketServiceDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/HandshakeWebSocketServiceDefinition.java @@ -16,13 +16,14 @@ package com.jd.live.agent.plugin.transmission.springweb.v5.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.plugin.transmission.springweb.v5.interceptor.HandshakeWebSocketServiceInterceptor; /** @@ -32,11 +33,7 @@ */ @Injectable @Extension(value = "HandshakeWebSocketServiceDefinition_v5", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(HandshakeWebSocketServiceDefinition.TYPE_REACTOR_LOADBALANCER) public class HandshakeWebSocketServiceDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/WebHandlerDecoratorDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/WebHandlerDecoratorDefinition.java index 456bde903..44062f4cd 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/WebHandlerDecoratorDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-springweb5/src/main/java/com/jd/live/agent/plugin/transmission/springweb/v5/definition/WebHandlerDecoratorDefinition.java @@ -16,14 +16,15 @@ package com.jd.live.agent.plugin.transmission.springweb.v5.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.*; +import com.jd.live.agent.core.extension.annotation.ConditionalOnClass; +import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; 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.PluginDefinition; import com.jd.live.agent.core.plugin.definition.PluginDefinitionAdapter; -import com.jd.live.agent.governance.config.GovernanceConfig; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.context.bag.CargoRequire; import com.jd.live.agent.plugin.transmission.springweb.v5.interceptor.WebHandlerDecoratorInterceptor; @@ -37,11 +38,7 @@ */ @Injectable @Extension(value = "WebHandlerDecoratorDefinition_v5", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnClass(WebHandlerDecoratorDefinition.TYPE_FILTERING_WEB_HANDLER) @ConditionalOnClass(WebHandlerDecoratorDefinition.TYPE_MONO) public class WebHandlerDecoratorDefinition extends PluginDefinitionAdapter { diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-thread/src/main/java/com/jd/live/agent/plugin/transmission/thread/definition/ExecutorDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-thread/src/main/java/com/jd/live/agent/plugin/transmission/thread/definition/ExecutorDefinition.java index 8ca1fa253..96e097d48 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-thread/src/main/java/com/jd/live/agent/plugin/transmission/thread/definition/ExecutorDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-thread/src/main/java/com/jd/live/agent/plugin/transmission/thread/definition/ExecutorDefinition.java @@ -16,14 +16,13 @@ package com.jd.live.agent.plugin.transmission.thread.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperties; import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; -import com.jd.live.agent.core.extension.annotation.ConditionalRelation; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.plugin.definition.*; import com.jd.live.agent.core.thread.Camera; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.plugin.transmission.thread.interceptor.ExecutorInterceptor; @@ -34,11 +33,7 @@ */ @Injectable @Extension(value = "ExecutorDefinition", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnProperty(value = GovernanceConfig.CONFIG_TRANSMISSION_THREADPOOL_ENABLED) public class ExecutorDefinition extends PluginDefinitionAdapter implements PluginImporter { private static final String TYPE_EXECUTOR = "java.util.concurrent.Executor"; diff --git a/joylive-plugin/joylive-transmission/joylive-transmission-thread/src/main/java/com/jd/live/agent/plugin/transmission/thread/definition/ScheduledExecutorServiceDefinition.java b/joylive-plugin/joylive-transmission/joylive-transmission-thread/src/main/java/com/jd/live/agent/plugin/transmission/thread/definition/ScheduledExecutorServiceDefinition.java index f313fafeb..fb92e70a3 100644 --- a/joylive-plugin/joylive-transmission/joylive-transmission-thread/src/main/java/com/jd/live/agent/plugin/transmission/thread/definition/ScheduledExecutorServiceDefinition.java +++ b/joylive-plugin/joylive-transmission/joylive-transmission-thread/src/main/java/com/jd/live/agent/plugin/transmission/thread/definition/ScheduledExecutorServiceDefinition.java @@ -16,14 +16,13 @@ package com.jd.live.agent.plugin.transmission.thread.definition; import com.jd.live.agent.core.bytekit.matcher.MatcherBuilder; -import com.jd.live.agent.core.extension.annotation.ConditionalOnProperties; import com.jd.live.agent.core.extension.annotation.ConditionalOnProperty; -import com.jd.live.agent.core.extension.annotation.ConditionalRelation; import com.jd.live.agent.core.extension.annotation.Extension; import com.jd.live.agent.core.inject.annotation.Inject; import com.jd.live.agent.core.inject.annotation.Injectable; import com.jd.live.agent.core.plugin.definition.*; import com.jd.live.agent.core.thread.Camera; +import com.jd.live.agent.governance.annotation.ConditionalOnTransmissionEnabled; import com.jd.live.agent.governance.config.GovernanceConfig; import com.jd.live.agent.plugin.transmission.thread.interceptor.ExecutorInterceptor; @@ -34,11 +33,7 @@ */ @Injectable @Extension(value = "ScheduledExecutorServiceDefinition", order = PluginDefinition.ORDER_TRANSMISSION) -@ConditionalOnProperties(value = { - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LIVE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_LANE_ENABLED, matchIfMissing = true), - @ConditionalOnProperty(value = GovernanceConfig.CONFIG_FLOW_CONTROL_ENABLED, matchIfMissing = true) -}, relation = ConditionalRelation.OR) +@ConditionalOnTransmissionEnabled @ConditionalOnProperty(value = GovernanceConfig.CONFIG_TRANSMISSION_THREADPOOL_ENABLED) public class ScheduledExecutorServiceDefinition extends PluginDefinitionAdapter implements PluginImporter { private static final String TYPE_SCHEDULED_EXECUTOR_SERVICE = "java.util.concurrent.ScheduledExecutorService";