forked from Nepxion/Discovery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
134 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
.../main/java/com/nepxion/discovery/plugin/strategy/condition/AbstractStrategyCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.nepxion.discovery.plugin.strategy.condition; | ||
|
||
/** | ||
* <p>Title: Nepxion Discovery</p> | ||
* <p>Description: Nepxion Discovery</p> | ||
* <p>Copyright: Copyright (c) 2017-2050</p> | ||
* <p>Company: Nepxion</p> | ||
* @author Haojun Ren | ||
* @version 1.0 | ||
*/ | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import com.nepxion.discovery.plugin.strategy.context.StrategyContextHolder; | ||
|
||
public abstract class AbstractStrategyCondition implements StrategyCondition { | ||
@Autowired | ||
protected StrategyContextHolder strategyContextHolder; | ||
|
||
public StrategyContextHolder getStrategyContextHolder() { | ||
return strategyContextHolder; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...n/java/com/nepxion/discovery/plugin/strategy/condition/HeaderEqualsStrategyCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.nepxion.discovery.plugin.strategy.condition; | ||
|
||
/** | ||
* <p>Title: Nepxion Discovery</p> | ||
* <p>Description: Nepxion Discovery</p> | ||
* <p>Copyright: Copyright (c) 2017-2050</p> | ||
* <p>Company: Nepxion</p> | ||
* @author Haojun Ren | ||
* @version 1.0 | ||
*/ | ||
|
||
import java.util.Map; | ||
|
||
import org.apache.commons.collections4.MapUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import com.nepxion.discovery.common.entity.StrategyConditionEntity; | ||
|
||
public class HeaderEqualsStrategyCondition extends AbstractStrategyCondition { | ||
@Override | ||
public boolean isTriggered(StrategyConditionEntity strategyConditionEntity) { | ||
Map<String, String> conditionHeaderMap = strategyConditionEntity.getConditionHeaderMap(); | ||
if (MapUtils.isNotEmpty(conditionHeaderMap)) { | ||
for (Map.Entry<String, String> entry : conditionHeaderMap.entrySet()) { | ||
String headerName = entry.getKey(); | ||
String headerValue = entry.getValue(); | ||
|
||
String value = strategyContextHolder.getHeader(headerName); | ||
if (!StringUtils.equals(headerValue, value)) { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...va/com/nepxion/discovery/plugin/strategy/condition/HeaderExpressionStrategyCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.nepxion.discovery.plugin.strategy.condition; | ||
|
||
/** | ||
* <p>Title: Nepxion Discovery</p> | ||
* <p>Description: Nepxion Discovery</p> | ||
* <p>Copyright: Copyright (c) 2017-2050</p> | ||
* <p>Company: Nepxion</p> | ||
* @author Haojun Ren | ||
* @version 1.0 | ||
*/ | ||
|
||
import com.nepxion.discovery.common.entity.StrategyConditionEntity; | ||
|
||
public class HeaderExpressionStrategyCondition extends AbstractStrategyCondition { | ||
@Override | ||
public boolean isTriggered(StrategyConditionEntity strategyConditionEntity) { | ||
// 此为包含若干个Header的表达式 | ||
// String conditionHeader = strategyConditionEntity.getConditionHeader(); | ||
|
||
// 待实现 | ||
return true; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...tegy/src/main/java/com/nepxion/discovery/plugin/strategy/condition/StrategyCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.nepxion.discovery.plugin.strategy.condition; | ||
|
||
/** | ||
* <p>Title: Nepxion Discovery</p> | ||
* <p>Description: Nepxion Discovery</p> | ||
* <p>Copyright: Copyright (c) 2017-2050</p> | ||
* <p>Company: Nepxion</p> | ||
* @author Haojun Ren | ||
* @version 1.0 | ||
*/ | ||
|
||
import com.nepxion.discovery.common.entity.StrategyConditionEntity; | ||
|
||
public interface StrategyCondition { | ||
boolean isTriggered(StrategyConditionEntity strategyConditionEntity); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters