-
Notifications
You must be signed in to change notification settings - Fork 3
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
longyun
committed
Aug 3, 2022
1 parent
eab34b9
commit fc009ed
Showing
15 changed files
with
496 additions
and
75 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...config-spring/src/main/java/com/wheel/yun/config/spring/context/ConfigsParamsContext.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,28 @@ | ||
package com.wheel.yun.config.spring.context; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Description: 自定义xml配置中的键值对参数值 | ||
* tg: <xsd:attribute name="id" type="xsd:string"></xsd:attribute> | ||
* <xsd:attribute name="address" type="xsd:string"></xsd:attribute> | ||
* | ||
* @author longyun | ||
* @version 1.0 | ||
* @date 2022/8/3 10:31 | ||
*/ | ||
public class ConfigsParamsContext { | ||
public static Map<Class, List<String>> PARAMS = new HashMap<>(); | ||
|
||
public static Map<Class,List<String>> ClassMapBeanName = new HashMap<>(); | ||
|
||
public static void putParams(Class clazz,List<String> params){ | ||
PARAMS.put(clazz,params); | ||
} | ||
|
||
public static void putClassAndBeanName(Class clazz,List<String> ids){ | ||
ClassMapBeanName.put(clazz,ids); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...g-spring/src/main/java/com/wheel/yun/config/spring/context/RegistryXMLConfigsContext.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,27 @@ | ||
package com.wheel.yun.config.spring.context; | ||
|
||
import com.wheel.yun.common.utils.Pair; | ||
import com.wheel.yun.config.spring.util.RegistryXMLConfigs; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Description: | ||
* | ||
* @author longyun | ||
* @version 1.0 | ||
* @date 2022/8/3 10:01 | ||
*/ | ||
public class RegistryXMLConfigsContext { | ||
private static List<Pair<String,Class>> ConfigsContext = new ArrayList<>(); | ||
|
||
public static List<Pair<String,Class>> getConfigsContext(){ | ||
RegistryXMLConfigsContext.ConfigsContext.addAll(RegistryXMLConfigs.getRegistryXMLConfigs()); | ||
return RegistryXMLConfigsContext.ConfigsContext; | ||
} | ||
|
||
|
||
|
||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...eel-config-spring/src/main/java/com/wheel/yun/config/spring/enums/ConfigStrategyEnum.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,31 @@ | ||
package com.wheel.yun.config.spring.enums; | ||
|
||
|
||
import com.wheel.yun.config.common.*; | ||
import com.wheel.yun.config.spring.ReferenceBean; | ||
import com.wheel.yun.config.spring.ServiceBean; | ||
|
||
public enum ConfigStrategyEnum { | ||
WheelApplication("application", ApplicationConfig.class), | ||
WheelProtocol("protocol", ProtocolConfig.class), | ||
WheelReference("reference", ReferenceBean.class), | ||
WheelRegistry("registry", RegistryConfig.class), | ||
WheelService("service", ServiceBean.class); | ||
|
||
private String configString; | ||
private Class configClass; | ||
|
||
ConfigStrategyEnum(String configString,Class configClass){ | ||
this.configString = configString; | ||
this.configClass = configClass; | ||
} | ||
|
||
public Class getConfigClass() { | ||
return configClass; | ||
} | ||
|
||
public String getConfigString() { | ||
return configString; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...onfig-spring/src/main/java/com/wheel/yun/config/spring/processor/ConfigPostProcessor.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,7 @@ | ||
package com.wheel.yun.config.spring.processor; | ||
|
||
import java.util.List; | ||
|
||
public interface ConfigPostProcessor { | ||
List<Class> getConfigPostProcessorList(); | ||
} |
15 changes: 15 additions & 0 deletions
15
...pring/src/main/java/com/wheel/yun/config/spring/processor/ConfigsParamsPostProcessor.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,15 @@ | ||
package com.wheel.yun.config.spring.processor; | ||
|
||
|
||
|
||
|
||
import java.util.List; | ||
|
||
|
||
public interface ConfigsParamsPostProcessor { | ||
void postProcessConfigParams(); | ||
|
||
List<String> getParams(); | ||
|
||
void getBeanName(); | ||
} |
36 changes: 36 additions & 0 deletions
36
...ig-spring/src/main/java/com/wheel/yun/config/spring/processor/XMLConfigPostProcessor.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,36 @@ | ||
package com.wheel.yun.config.spring.processor; | ||
|
||
import com.wheel.yun.config.spring.processor.params.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Description: | ||
* | ||
* @author longyun | ||
* @version 1.0 | ||
* @date 2022/8/3 13:53 | ||
*/ | ||
public class XMLConfigPostProcessor implements ConfigPostProcessor{ | ||
private List<Class> configSetPostProcessor = new ArrayList<>(); | ||
|
||
public XMLConfigPostProcessor(){ | ||
configSetPostProcessor.add(ApplicationParamsPostProcessor.class); | ||
configSetPostProcessor.add(ProtocolParamsPostProcessor.class); | ||
configSetPostProcessor.add(ReferenceParamsPostProcessor.class); | ||
configSetPostProcessor.add(RegistryParamsPostProcessor.class); | ||
configSetPostProcessor.add(ServiceParamsPostProcessor.class); | ||
} | ||
@Override | ||
public List<Class> getConfigPostProcessorList() { | ||
this.beforeSetXMLConfig(this.configSetPostProcessor); | ||
return this.configSetPostProcessor; | ||
} | ||
|
||
/** | ||
* 空方法,可以继承该类,添加自定义配置后置处理器 | ||
* @param list | ||
*/ | ||
public void beforeSetXMLConfig(List<Class> list){} | ||
} |
46 changes: 46 additions & 0 deletions
46
...ain/java/com/wheel/yun/config/spring/processor/params/ApplicationParamsPostProcessor.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,46 @@ | ||
package com.wheel.yun.config.spring.processor.params; | ||
|
||
import com.wheel.yun.config.common.ApplicationConfig; | ||
import com.wheel.yun.config.spring.context.ConfigsParamsContext; | ||
import com.wheel.yun.config.spring.processor.ConfigsParamsPostProcessor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Description: | ||
* | ||
* @author longyun | ||
* @version 1.0 | ||
* @date 2022/8/3 10:43 | ||
*/ | ||
public class ApplicationParamsPostProcessor implements ConfigsParamsPostProcessor { | ||
|
||
public ApplicationParamsPostProcessor(){ | ||
this.postProcessConfigParams(); | ||
} | ||
|
||
|
||
@Override | ||
public void postProcessConfigParams() { | ||
List<String> params = this.getParams(); | ||
ConfigsParamsContext.putParams(ApplicationConfig.class,params); | ||
this.getBeanName(); | ||
} | ||
|
||
@Override | ||
public List<String> getParams() { | ||
List<String> params = new ArrayList<>(); | ||
params.add("name"); | ||
return params; | ||
} | ||
|
||
@Override | ||
public void getBeanName() { | ||
List<String> ids = new ArrayList<>(); | ||
ids.add("name"); | ||
ConfigsParamsContext.putClassAndBeanName(ApplicationConfig.class,ids); | ||
} | ||
|
||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...c/main/java/com/wheel/yun/config/spring/processor/params/ProtocolParamsPostProcessor.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,44 @@ | ||
package com.wheel.yun.config.spring.processor.params; | ||
|
||
import com.wheel.yun.config.common.ProtocolConfig; | ||
import com.wheel.yun.config.spring.context.ConfigsParamsContext; | ||
import com.wheel.yun.config.spring.processor.ConfigsParamsPostProcessor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Description: | ||
* | ||
* @author longyun | ||
* @version 1.0 | ||
* @date 2022/8/3 10:56 | ||
*/ | ||
public class ProtocolParamsPostProcessor implements ConfigsParamsPostProcessor { | ||
|
||
public ProtocolParamsPostProcessor(){ | ||
this.postProcessConfigParams(); | ||
} | ||
|
||
@Override | ||
public void postProcessConfigParams() { | ||
List<String> params = this.getParams(); | ||
ConfigsParamsContext.putParams(ProtocolConfig.class,params); | ||
this.getBeanName(); | ||
} | ||
|
||
@Override | ||
public List<String> getParams() { | ||
List<String> params = new ArrayList<>(); | ||
params.add("protocol"); | ||
params.add("port"); | ||
return params; | ||
} | ||
|
||
@Override | ||
public void getBeanName() { | ||
List<String> ids = new ArrayList<>(); | ||
ids.add("protocol"); | ||
ConfigsParamsContext.putClassAndBeanName(ProtocolConfig.class,ids); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
.../main/java/com/wheel/yun/config/spring/processor/params/ReferenceParamsPostProcessor.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,54 @@ | ||
package com.wheel.yun.config.spring.processor.params; | ||
|
||
import com.wheel.yun.config.spring.ReferenceBean; | ||
import com.wheel.yun.config.spring.context.ConfigsParamsContext; | ||
import com.wheel.yun.config.spring.processor.ConfigsParamsPostProcessor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Description: | ||
* | ||
* @author longyun | ||
* @version 1.0 | ||
* @date 2022/8/3 10:58 | ||
*/ | ||
public class ReferenceParamsPostProcessor implements ConfigsParamsPostProcessor { | ||
|
||
|
||
public ReferenceParamsPostProcessor(){ | ||
this.postProcessConfigParams(); | ||
} | ||
|
||
@Override | ||
public void postProcessConfigParams() { | ||
List<String> params = this.getParams(); | ||
ConfigsParamsContext.putParams(ReferenceBean.class,params); | ||
this.getBeanName(); | ||
} | ||
|
||
@Override | ||
public List<String> getParams() { | ||
List<String> params = new ArrayList<>(); | ||
params.add("id"); | ||
params.add("interface"); | ||
params.add("version"); | ||
params.add("group"); | ||
params.add("timeout"); | ||
params.add("failStrategy"); | ||
params.add("retryCount"); | ||
return params; | ||
} | ||
|
||
@Override | ||
public void getBeanName() { | ||
List<String> ids = new ArrayList<>(); | ||
ids.add("id"); | ||
ids.add("interface"); | ||
ids.add("version"); | ||
ids.add("group"); | ||
ConfigsParamsContext.putClassAndBeanName(ReferenceBean.class,ids); | ||
|
||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...c/main/java/com/wheel/yun/config/spring/processor/params/RegistryParamsPostProcessor.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,48 @@ | ||
package com.wheel.yun.config.spring.processor.params; | ||
|
||
|
||
|
||
import com.wheel.yun.config.common.RegistryConfig; | ||
import com.wheel.yun.config.spring.context.ConfigsParamsContext; | ||
import com.wheel.yun.config.spring.processor.ConfigsParamsPostProcessor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Description: | ||
* | ||
* @author longyun | ||
* @version 1.0 | ||
* @date 2022/8/3 10:54 | ||
*/ | ||
public class RegistryParamsPostProcessor implements ConfigsParamsPostProcessor { | ||
|
||
|
||
public RegistryParamsPostProcessor(){ | ||
this.postProcessConfigParams(); | ||
} | ||
|
||
|
||
@Override | ||
public void postProcessConfigParams() { | ||
List<String> params = this.getParams(); | ||
ConfigsParamsContext.putParams(RegistryConfig.class,params); | ||
this.getBeanName(); | ||
} | ||
|
||
@Override | ||
public List<String> getParams() { | ||
List<String> params = new ArrayList<>(); | ||
params.add("id"); | ||
params.add("address"); | ||
return params; | ||
} | ||
|
||
@Override | ||
public void getBeanName() { | ||
List<String> ids = new ArrayList<>(); | ||
ids.add("id"); | ||
ConfigsParamsContext.putClassAndBeanName(RegistryConfig.class,ids); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...rc/main/java/com/wheel/yun/config/spring/processor/params/ServiceParamsPostProcessor.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,51 @@ | ||
package com.wheel.yun.config.spring.processor.params; | ||
|
||
import com.wheel.yun.config.spring.ServiceBean; | ||
import com.wheel.yun.config.spring.context.ConfigsParamsContext; | ||
import com.wheel.yun.config.spring.processor.ConfigsParamsPostProcessor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Description: | ||
* | ||
* @author longyun | ||
* @version 1.0 | ||
* @date 2022/8/3 11:00 | ||
*/ | ||
public class ServiceParamsPostProcessor implements ConfigsParamsPostProcessor { | ||
|
||
public ServiceParamsPostProcessor(){ | ||
this.postProcessConfigParams(); | ||
} | ||
|
||
@Override | ||
public void postProcessConfigParams() { | ||
List<String> params = this.getParams(); | ||
ConfigsParamsContext.putParams(ServiceBean.class,params); | ||
this.getBeanName(); | ||
} | ||
|
||
@Override | ||
public List<String> getParams() { | ||
List<String> params = new ArrayList<>(); | ||
params.add("interface"); | ||
params.add("version"); | ||
params.add("ref"); | ||
params.add("group"); | ||
params.add("timeout"); | ||
params.add("failStrategy"); | ||
params.add("retryCount"); | ||
params.add("weight"); | ||
params.add("loadbalance"); | ||
return params; | ||
} | ||
|
||
@Override | ||
public void getBeanName() { | ||
List<String> ids = new ArrayList<>(); | ||
ids.add("interface"); | ||
ConfigsParamsContext.putClassAndBeanName(ServiceBean.class,ids); | ||
} | ||
} |
Oops, something went wrong.