commit 9e8322f6d259beb02680a371a87e74894873978b Author: Zed Date: Tue Aug 25 11:14:30 2020 +0800 提供demo diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..46baf74 --- /dev/null +++ b/build.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..201d82a --- /dev/null +++ b/plugin.xml @@ -0,0 +1,22 @@ + + + com.fr.plugin.rpc.print + + yes + no + 1.0 + 10.0~ + 2020-8-10 + zed + + [2020-08-21]实现

+ ]]>
+ + + + + + + +
\ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..af21dad --- /dev/null +++ b/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + + com.fr.decision + decision-feature + 10.0 + compile + + + com.fr.decision + decision-feature + 10.0 + compile + + + + com.fr.plugin + starter + 10.0 + + jar + decision.message.event + + + ${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.decision.batch.role-1.0/classes + + + org.apache.maven.plugins + maven-compiler-plugin + + 6 + 6 + + + + + \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e5d1c6c --- /dev/null +++ b/readme.md @@ -0,0 +1,9 @@ +# 插件rpc实现 +让插件支持注册集群入场券,实现rpc代理 + +# 效果截图 + +![result](screenshots/result1.png) + + + diff --git a/rpc-print.iml b/rpc-print.iml new file mode 100644 index 0000000..06de2fa --- /dev/null +++ b/rpc-print.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/screenshots/result1.png b/screenshots/result1.png new file mode 100644 index 0000000..ffd433d Binary files /dev/null and b/screenshots/result1.png differ diff --git a/src/main/java/com/fr/plugin/rpc/MyTicket.java b/src/main/java/com/fr/plugin/rpc/MyTicket.java new file mode 100644 index 0000000..d7f31d2 --- /dev/null +++ b/src/main/java/com/fr/plugin/rpc/MyTicket.java @@ -0,0 +1,21 @@ +package com.fr.plugin.rpc; + +import com.fr.cluster.entry.ClusterTicket; +import com.fr.plugin.transform.FunctionRecorder; +import com.fr.cluster.engine.fun.impl.AbstractClusterTicketProvider; + +/** + * @author Zed + * @version 10.0 + * Created by Zed on 2020/8/21 + *

+ * 插件接口的实现 + */ +@FunctionRecorder +public class MyTicket extends AbstractClusterTicketProvider { + + @Override + public ClusterTicket getTicket() { + return PrintImpl.INSTANCE.getTicket(); + } +} diff --git a/src/main/java/com/fr/plugin/rpc/Print.java b/src/main/java/com/fr/plugin/rpc/Print.java new file mode 100644 index 0000000..803a5ac --- /dev/null +++ b/src/main/java/com/fr/plugin/rpc/Print.java @@ -0,0 +1,14 @@ +package com.fr.plugin.rpc; + +import com.fr.cluster.rpc.proxy.filter.BroadCast; + +/** + * @author Zed + * @version 10.0 + * Created by Zed on 2020/8/21 + */ +public interface Print { + + @BroadCast + void print(); +} diff --git a/src/main/java/com/fr/plugin/rpc/PrintImpl.java b/src/main/java/com/fr/plugin/rpc/PrintImpl.java new file mode 100644 index 0000000..2bd1a11 --- /dev/null +++ b/src/main/java/com/fr/plugin/rpc/PrintImpl.java @@ -0,0 +1,22 @@ +package com.fr.plugin.rpc; + +import com.fr.cluster.engine.core.jchannel.MachineMarker; +import com.fr.cluster.rpc.proxy.Ticket; +import com.fr.cluster.rpc.proxy.TicketProxyBuilder; + +/** + * @author Zed + * @version 10.0 + * Created by Zed on 2020/8/21 + */ +@Ticket +public class PrintImpl extends TicketProxyBuilder implements Print { + + public static final PrintImpl INSTANCE = new PrintImpl(); + + @Override + public void print() { + System.out.println("hi zed! this is " + MachineMarker.currentID()); + } + +} diff --git a/src/main/java/com/fr/plugin/rpc/RPCController.java b/src/main/java/com/fr/plugin/rpc/RPCController.java new file mode 100644 index 0000000..a07b2ed --- /dev/null +++ b/src/main/java/com/fr/plugin/rpc/RPCController.java @@ -0,0 +1,30 @@ +package com.fr.plugin.rpc; + +import com.fr.decision.webservice.Response; +import com.fr.third.springframework.stereotype.Controller; +import com.fr.third.springframework.web.bind.annotation.RequestMapping; +import com.fr.third.springframework.web.bind.annotation.RequestMethod; +import com.fr.third.springframework.web.bind.annotation.ResponseBody; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author Zed + * @version 10.0 + * Created by Zed on 2020/8/21 + * + * 测试用的rest api + */ +@Controller +public class RPCController { + + @RequestMapping(value = "/print", method = RequestMethod.GET) + @ResponseBody + public Response batch(HttpServletRequest req, + HttpServletResponse res) throws Exception { + + PrintImpl.INSTANCE.getProxy().print(); + return Response.success(); + } +} diff --git a/src/main/java/com/fr/plugin/rpc/RPCControllerRegister.java b/src/main/java/com/fr/plugin/rpc/RPCControllerRegister.java new file mode 100644 index 0000000..ef5fd55 --- /dev/null +++ b/src/main/java/com/fr/plugin/rpc/RPCControllerRegister.java @@ -0,0 +1,18 @@ +package com.fr.plugin.rpc; + +import com.fr.decision.fun.impl.AbstractControllerRegisterProvider; + +/** + * @author Zed + * @version 10.0 + * Created by Zed on 2020/8/21 + * + * 注册rest api + */ +public class RPCControllerRegister extends AbstractControllerRegisterProvider { + + @Override + public Class[] getControllers() { + return new Class[]{RPCController.class}; + } +}