Java????????????????
???????????? ???????[ 2015/10/26 14:53:20 ] ??????????????? ???????????
???????????????????????????£?????′??????“??????…”?????????????????????
?????????????????????????????????????????????????????????????
?????????????
??????????????????е???????е??????????????????????????????????????????
????????????????????????????????????÷??????????????????????????á???????????á?
?????????????????????????????????е????
????1??????????????????????
????2???????????????????г??????????????
????3???????????????????????????
????????CS?е????????java??????
??????????????????????????????msg?????????????????5?????????????????????????????????£?
????????????
????/**
????* @author Jeff Lee
????* @since 2015-10-21 21:34:21
????* ?????-????????
????*/
????public interface CSCallBack {
????public void process(String status);
????}
????????????
????/**
????* @author Jeff Lee
????* @since 2015-10-21 21:25:14
????* ?????-?????????
????*/
????public class Client implements CSCallBack {
????private Server server;
????public Client(Server server) {
????this.server = server;
????}
????public void sendMsg(final String msg){
????System.out.println("?????????????????" + msg);
????new Thread(new Runnable() {
????@Override
????public void run() {
????server.getClientMsg(Client.this??msg);
????}
????}).start();
????System.out.println("??????????????");
????}
????@Override
????public void process(String status) {
????System.out.println("??????????????????" + status);
????}
????}
???????????:
????/**
????* @author Jeff Lee
????* @since 2015-10-21 21:24:15
????* ?????-?????????
????*/
????public class Server {
????public void getClientMsg(CSCallBack csCallBack ?? String msg) {
????System.out.println("????????????????????????????:" + msg);
????// ????????????????????
????try {
????Thread.sleep(5 * 1000);
????} catch (InterruptedException e) {
????e.printStackTrace();
????}
????System.out.println("?????:??????????????????? 200");
????String status = "200";
????csCallBack.process(status);
????}
????}
??????????
????/**
????* @author Jeff Lee
????* @since 2015-10-21 21:24:15
????* ?????-??????
????*/
????public class CallBackTest {
????public static void main(String[] args) {
????Server server = new Server();
????Client client = new Client(server);
????client.sendMsg("Server??Hello~");
????}
????}
?????????2????? — ?????????£?
?????????????????????Server??Hello~
??????????????????
????????????????????????????????:Server??Hello~
???????????????????????????????5??
????????????????????????????? 200
??????????????????????200
???????????????′??????????????
????1?????????????????????????????????????????
????2??Client??sendMsg?????У??????final?????????????????μ?????????á???????????????
????3??????server??getClientMsg()????????????Client???????????????
?????????????????
????— ????????????gitHub???~
???????????????ó???
???????????????????????????????????????????????
????1??Windows???????????
????2????????????????????????????????????????
????3??Servlet?е?Filter(??????)???????????????????????
???????????? Filter(??????)??Interceptor(??????)??????????????????Java????????????????????????????????????????
???????????????????????????壨??????????????????????????
????????????
???????潲??Filter??Intercepter??????????????????????????????????—???????????????????
?????????????
????GOF??? — “??????????????????????????????????????????????????ж?????????????????????????”?????????????????????????????????????????????????
???????????
??????????????????????????????????????????
?????塢???
?????????????
?????????????????
?????????????????
??????????峽????????????
??????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11