-
Notifications
You must be signed in to change notification settings - Fork 24
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
8 changed files
with
139 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> | ||
<output url="file://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<excludeFolder url="file://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:javax.servlet-api:4.0.1" level="project" /> | ||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.5" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.2" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.2" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.6" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.12" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.2" level="project" /> | ||
</component> | ||
</module> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.fengwenyi.javalib.handler; | ||
|
||
import com.fengwenyi.javalib.messageengine.CommonMessage; | ||
|
||
/** | ||
* Handler | ||
* | ||
* 这是一个公用的接口,你需要写一个class来实现这个接口中的方法,以便调用 | ||
* | ||
* @author Wenyi Feng | ||
* @since 2018-08-27 | ||
*/ | ||
public interface Handler { | ||
|
||
/** | ||
* 执行 | ||
* @param message 消息 | ||
* @throws Exception 异常,可能会有异常,你可以抛出了,或是处理掉 | ||
*/ | ||
void execute(CommonMessage message) throws Exception; | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/fengwenyi/javalib/handler/HandlerRegister.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.fengwenyi.javalib.handler; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* <类说明> | ||
* <p> | ||
* <功能详细描述> | ||
* | ||
* @author Wenyi Feng | ||
* @since 2018-08-27 | ||
*/ | ||
public class HandlerRegister { | ||
|
||
/** handler的集合 */ | ||
private Map<String, Handler> handlers; | ||
|
||
/** | ||
* 获取handler | ||
* @param key 通过map-key获取handler | ||
* @return handler,map-value | ||
*/ | ||
public Handler getHandler(String key) { | ||
return handlers.get(key); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/fengwenyi/javalib/messageengine/CommonMessage.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,45 @@ | ||
package com.fengwenyi.javalib.messageengine; | ||
|
||
import com.fengwenyi.javalib.util.StringUtil; | ||
import lombok.Data; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* 通用消息组件 | ||
* | ||
* 消息的基类,如果该类不满足你的需求,你可以继续继承他 | ||
* | ||
* @author Wenyi Feng | ||
* @since 2018-08-27 | ||
*/ | ||
@Data | ||
public class CommonMessage { | ||
|
||
/** 消息头 */ | ||
private Map<String, Object> header = new HashMap<>(); | ||
|
||
/** 消息体 */ | ||
private Object body; | ||
|
||
/** | ||
* 设置消息头的属性(key-value) | ||
* @param key map-key | ||
* @param value map-value | ||
*/ | ||
public void setProperty(String key, Object value) { | ||
if (StringUtil.isNotEmpty(key)) | ||
header.put(key, value); | ||
} | ||
|
||
/** | ||
* 设置消息体 | ||
* @param body 数据(Object) | ||
*/ | ||
public void setBody(Object body) { | ||
if (body != null) | ||
this.body = body; | ||
} | ||
|
||
} |
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