From 0c7ce4655ce468b238db240b995de3353a610393 Mon Sep 17 00:00:00 2001 From: snoop Date: Tue, 11 Apr 2017 10:41:57 +0900 Subject: [PATCH] fixed return , error type --- .../{ => overflow}/rpc/Application.java | 2 +- .../{ => overflow}/rpc/ApplicationConfig.java | 2 +- .../loafle/{ => overflow}/rpc/api/Remote.java | 16 ++++----- .../{ => overflow}/rpc/api/RemoteImpl.java | 36 +++++++++++++------ .../loafle/overflow/rpc/crawler/Crawler.java | 32 +++++++++++++++++ .../{ => overflow}/rpc/model/Input.java | 2 +- .../{ => overflow}/rpc/model/Output.java | 8 ++--- .../java/com/loafle/rpc/crawler/Crawler.java | 34 ------------------ 8 files changed, 72 insertions(+), 60 deletions(-) rename src/main/java/com/loafle/{ => overflow}/rpc/Application.java (89%) rename src/main/java/com/loafle/{ => overflow}/rpc/ApplicationConfig.java (93%) rename src/main/java/com/loafle/{ => overflow}/rpc/api/Remote.java (53%) rename src/main/java/com/loafle/{ => overflow}/rpc/api/RemoteImpl.java (63%) create mode 100644 src/main/java/com/loafle/overflow/rpc/crawler/Crawler.java rename src/main/java/com/loafle/{ => overflow}/rpc/model/Input.java (93%) rename src/main/java/com/loafle/{ => overflow}/rpc/model/Output.java (79%) delete mode 100644 src/main/java/com/loafle/rpc/crawler/Crawler.java diff --git a/src/main/java/com/loafle/rpc/Application.java b/src/main/java/com/loafle/overflow/rpc/Application.java similarity index 89% rename from src/main/java/com/loafle/rpc/Application.java rename to src/main/java/com/loafle/overflow/rpc/Application.java index 47c1f32..80ade13 100644 --- a/src/main/java/com/loafle/rpc/Application.java +++ b/src/main/java/com/loafle/overflow/rpc/Application.java @@ -1,4 +1,4 @@ -package com.loafle.rpc; +package com.loafle.overflow.rpc; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/src/main/java/com/loafle/rpc/ApplicationConfig.java b/src/main/java/com/loafle/overflow/rpc/ApplicationConfig.java similarity index 93% rename from src/main/java/com/loafle/rpc/ApplicationConfig.java rename to src/main/java/com/loafle/overflow/rpc/ApplicationConfig.java index b5303f4..c6d47e5 100644 --- a/src/main/java/com/loafle/rpc/ApplicationConfig.java +++ b/src/main/java/com/loafle/overflow/rpc/ApplicationConfig.java @@ -1,4 +1,4 @@ -package com.loafle.rpc; +package com.loafle.overflow.rpc; import com.googlecode.jsonrpc4j.spring.AutoJsonRpcServiceImplExporter; import org.springframework.context.annotation.Bean; diff --git a/src/main/java/com/loafle/rpc/api/Remote.java b/src/main/java/com/loafle/overflow/rpc/api/Remote.java similarity index 53% rename from src/main/java/com/loafle/rpc/api/Remote.java rename to src/main/java/com/loafle/overflow/rpc/api/Remote.java index 331988e..ebc349d 100644 --- a/src/main/java/com/loafle/rpc/api/Remote.java +++ b/src/main/java/com/loafle/overflow/rpc/api/Remote.java @@ -1,13 +1,13 @@ -package com.loafle.rpc.api; +package com.loafle.overflow.rpc.api; import com.fasterxml.jackson.core.JsonProcessingException; import com.googlecode.jsonrpc4j.JsonRpcMethod; import com.googlecode.jsonrpc4j.JsonRpcService; -import com.loafle.rpc.crawler.Crawler; +import com.loafle.overflow.rpc.crawler.Crawler; -import com.loafle.rpc.model.Input; -import com.loafle.rpc.model.Output; +import com.loafle.overflow.rpc.model.Input; +import com.loafle.overflow.rpc.model.Output; @@ -16,21 +16,21 @@ import com.loafle.rpc.model.Output; public interface Remote { @JsonRpcMethod("RPC.Init") - Output init(Input input) throws JsonProcessingException; + Output init(Input input) throws Exception; @JsonRpcMethod("RPC.Add") - Output add(Input input) throws JsonProcessingException ; + Output add(Input input) throws Exception ; // @JsonRpcMethod("Remote.remove") int addDelegate(String name , Crawler crawler); @JsonRpcMethod("RPC.Get") - Output get(Input input) throws JsonProcessingException; + Output get(Input input) throws Exception; @JsonRpcMethod("RPC.Remove") - Output remove(Input input) throws JsonProcessingException; + Output remove(Input input) throws Exception; } \ No newline at end of file diff --git a/src/main/java/com/loafle/rpc/api/RemoteImpl.java b/src/main/java/com/loafle/overflow/rpc/api/RemoteImpl.java similarity index 63% rename from src/main/java/com/loafle/rpc/api/RemoteImpl.java rename to src/main/java/com/loafle/overflow/rpc/api/RemoteImpl.java index 50e618f..845f829 100644 --- a/src/main/java/com/loafle/rpc/api/RemoteImpl.java +++ b/src/main/java/com/loafle/overflow/rpc/api/RemoteImpl.java @@ -1,10 +1,10 @@ -package com.loafle.rpc.api; +package com.loafle.overflow.rpc.api; import com.fasterxml.jackson.core.JsonProcessingException; import com.googlecode.jsonrpc4j.spring.AutoJsonRpcServiceImpl; -import com.loafle.rpc.crawler.Crawler; -import com.loafle.rpc.model.Input; -import com.loafle.rpc.model.Output; +import com.loafle.overflow.rpc.crawler.Crawler; +import com.loafle.overflow.rpc.model.Input; +import com.loafle.overflow.rpc.model.Output; import org.springframework.stereotype.Service; import java.util.Date; @@ -19,7 +19,7 @@ public class RemoteImpl implements Remote { @Override - public Output init(Input input) throws JsonProcessingException { + public Output init(Input input) throws Exception { for (String v : input.getPaths()) { System.out.println(v); @@ -32,13 +32,18 @@ public class RemoteImpl implements Remote { } @Override - public Output add(Input input) throws JsonProcessingException { + public Output add(Input input) throws Exception { Crawler crawler = this.crawlerMap.get(input.getName()); if(crawler == null) { System.out.println(input.getName() + "_crawler == null"); return null; } else { - return crawler.add(input.getId()); + Output out = new Output(); + out.setStartDate(new Date()); + out.setEndDate(new Date()); + out.setData(crawler.add(input.getId())); + + return out; } } @@ -59,26 +64,35 @@ public class RemoteImpl implements Remote { } @Override - public Output get(Input input) throws JsonProcessingException { + public Output get(Input input) throws Exception { Crawler crawler = this.crawlerMap.get(input.getName()); if(crawler == null) { System.out.println(input.getName() + "_crawler == null"); return null; } else { - return crawler.get(input.getId()); + + Output out = new Output(); + out.setStartDate(new Date()); + out.setEndDate(new Date()); + out.setData(crawler.get(input.getId())); + return out; } } @Override - public Output remove(Input input) throws JsonProcessingException { + public Output remove(Input input) throws Exception { Crawler crawler = this.crawlerMap.get(input.getName()); if(crawler == null) { System.out.println(input.getName() + "_crawler == null"); return null; } else { - return crawler.remove(input.getId()); + Output out = new Output(); + out.setStartDate(new Date()); + out.setEndDate(new Date()); + out.setData(crawler.remove(input.getId())); + return out; } } } \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/rpc/crawler/Crawler.java b/src/main/java/com/loafle/overflow/rpc/crawler/Crawler.java new file mode 100644 index 0000000..20c4a7c --- /dev/null +++ b/src/main/java/com/loafle/overflow/rpc/crawler/Crawler.java @@ -0,0 +1,32 @@ +package com.loafle.overflow.rpc.crawler; + + + +/** + * Created by root on 17. 4. 10. + */ +public abstract class Crawler { + + public Object add(String id) throws Exception { + + return null; + } + + public abstract Object get(String id) throws Exception ; + + public Object getConfig(String id) throws Exception { + + return null; + } + + public Object init(String config) throws Exception { + + return null; + } + + public Object remove(String id) throws Exception { + + return null; + } + +} diff --git a/src/main/java/com/loafle/rpc/model/Input.java b/src/main/java/com/loafle/overflow/rpc/model/Input.java similarity index 93% rename from src/main/java/com/loafle/rpc/model/Input.java rename to src/main/java/com/loafle/overflow/rpc/model/Input.java index 59ffe0f..8b0a78e 100644 --- a/src/main/java/com/loafle/rpc/model/Input.java +++ b/src/main/java/com/loafle/overflow/rpc/model/Input.java @@ -1,4 +1,4 @@ -package com.loafle.rpc.model; +package com.loafle.overflow.rpc.model; /** * Created by root on 17. 4. 6. diff --git a/src/main/java/com/loafle/rpc/model/Output.java b/src/main/java/com/loafle/overflow/rpc/model/Output.java similarity index 79% rename from src/main/java/com/loafle/rpc/model/Output.java rename to src/main/java/com/loafle/overflow/rpc/model/Output.java index 154f878..3e8dd33 100644 --- a/src/main/java/com/loafle/rpc/model/Output.java +++ b/src/main/java/com/loafle/overflow/rpc/model/Output.java @@ -1,4 +1,4 @@ -package com.loafle.rpc.model; +package com.loafle.overflow.rpc.model; import java.util.Date; @@ -8,7 +8,7 @@ import java.util.Date; public class Output { private Date startDate; private Date endDate; - private byte[] data; + private Object data; public Date getStartDate() { return startDate; @@ -26,11 +26,11 @@ public class Output { this.endDate = endDate; } - public byte[] getData() { + public Object getData() { return data; } - public void setData(byte[] data) { + public void setData(Object data) { this.data = data; } } diff --git a/src/main/java/com/loafle/rpc/crawler/Crawler.java b/src/main/java/com/loafle/rpc/crawler/Crawler.java deleted file mode 100644 index dc36912..0000000 --- a/src/main/java/com/loafle/rpc/crawler/Crawler.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.loafle.rpc.crawler; - -import com.fasterxml.jackson.core.JsonProcessingException; - -import com.loafle.rpc.model.Output; - -/** - * Created by root on 17. 4. 10. - */ -public abstract class Crawler { - - public Output add(String id) throws JsonProcessingException { - - return null; - } - - public abstract Output get(String id) throws JsonProcessingException ; - - public Output getConfig(String id) throws JsonProcessingException { - - return null; - } - - public Output init(String config) throws JsonProcessingException { - - return null; - } - - public Output remove(String id) throws JsonProcessingException { - - return null; - } - -}