diff --git a/demo/src/main/java/io/xream/x7/demo/remote/TestServiceRemote.java b/demo/src/main/java/io/xream/x7/demo/remote/TestServiceRemote.java
index b87f7418..62864135 100644
--- a/demo/src/main/java/io/xream/x7/demo/remote/TestServiceRemote.java
+++ b/demo/src/main/java/io/xream/x7/demo/remote/TestServiceRemote.java
@@ -1,15 +1,16 @@
package io.xream.x7.demo.remote;
-import io.xream.x7.reyc.ReyClient;
import io.xream.x7.demo.CatRO;
+import io.xream.x7.reyc.ReyClient;
import org.springframework.web.bind.annotation.RequestMapping;
@ReyClient(value = "127.0.0.1:8868", circuitBreaker = "")
public interface TestServiceRemote {
- @RequestMapping("/xxx/reyc/test")
+
+ @RequestMapping(value = "/xxx/reyc/test")
Boolean test(CatRO ro);
}
diff --git a/spring-boot-starter-x7/spring-boot-starter-x7.iml b/spring-boot-starter-x7/spring-boot-starter-x7.iml
index 41efd657..ceb0bd68 100644
--- a/spring-boot-starter-x7/spring-boot-starter-x7.iml
+++ b/spring-boot-starter-x7/spring-boot-starter-x7.iml
@@ -15,70 +15,107 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/x7-config/x7-config.iml b/x7-config/x7-config.iml
index 01effa30..1cbf673d 100644
--- a/x7-config/x7-config.iml
+++ b/x7-config/x7-config.iml
@@ -20,48 +20,54 @@
-
-
-
+
+
+
-
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/x7-core/src/main/java/x7/core/util/HttpClientUtil.java b/x7-core/src/main/java/x7/core/util/HttpClientUtil.java
index 1222f3e0..50637736 100644
--- a/x7-core/src/main/java/x7/core/util/HttpClientUtil.java
+++ b/x7-core/src/main/java/x7/core/util/HttpClientUtil.java
@@ -27,6 +27,7 @@
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import x7.core.bean.KV;
import java.io.*;
import java.net.HttpURLConnection;
@@ -34,6 +35,7 @@
import java.net.URLConnection;
import java.net.URLDecoder;
import java.util.Arrays;
+import java.util.List;
import java.util.Map;
@@ -42,10 +44,10 @@ public class HttpClientUtil {
private final static Logger logger = LoggerFactory.getLogger(HttpClientUtil.class);
public static String post(String url, Object param) {
- return post(url, param, 15000, 15000);
+ return post(url, param, null, 15000, 15000);
}
- public static String post(String url, Object param, int connectTimeoutMS, int socketTimeoutMS) {
+ public static String post(String url, Object param, List hearderList, int connectTimeoutMS, int socketTimeoutMS) {
CloseableHttpClient httpclient = HttpClients.createDefault();
@@ -59,6 +61,12 @@ public static String post(String url, Object param, int connectTimeoutMS, int so
httpPost.setConfig(requestConfig);
+ if (hearderList != null) {
+ for (KV kv : hearderList) {
+ httpPost.addHeader(kv.getK(), kv.getV().toString());
+ }
+ }
+
String json = "";
if (param != null) {
json = JsonX.toJson(param);
@@ -102,10 +110,10 @@ public static String post(String url, Object param, int connectTimeoutMS, int so
}
public static String getUrl(String urlString) {
- return getUrl(urlString, 15000, 15000);
+ return getUrl(urlString, null,15000, 15000);
}
- public static String getUrl(String urlString, int connectTimeoutMS, int readTimeoutMS) {
+ public static String getUrl(String urlString, List hearderList, int connectTimeoutMS, int readTimeoutMS) {
StringBuffer sb = new StringBuffer();
BufferedReader reader = null;
try {
@@ -115,6 +123,13 @@ public static String getUrl(String urlString, int connectTimeoutMS, int readTime
conn.setConnectTimeout(connectTimeoutMS);
conn.setReadTimeout(readTimeoutMS);
+
+ if (hearderList != null) {
+ for (KV kv : hearderList) {
+ conn.addRequestProperty(kv.getK(),kv.getV().toString());
+ }
+ }
+
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
for (String line = null; (line = reader.readLine()) != null; ) {
@@ -126,7 +141,9 @@ public static String getUrl(String urlString, int connectTimeoutMS, int readTime
throw new RuntimeException(ExceptionUtil.getMessage(e));
}finally {
try {
- reader.close();
+ if (reader != null) {
+ reader.close();
+ }
} catch (IOException e) {
}
}
diff --git a/x7-core/x7-core.iml b/x7-core/x7-core.iml
index 8267f9c9..13d478f4 100644
--- a/x7-core/x7-core.iml
+++ b/x7-core/x7-core.iml
@@ -16,6 +16,7 @@
+
diff --git a/x7-parent.iml b/x7-parent.iml
index 190cf932..229fad27 100644
--- a/x7-parent.iml
+++ b/x7-parent.iml
@@ -9,48 +9,54 @@
-
-
-
+
+
+
-
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/x7-repository/x7-repository.iml b/x7-repository/x7-repository.iml
index cf61cde0..bbc452b1 100644
--- a/x7-repository/x7-repository.iml
+++ b/x7-repository/x7-repository.iml
@@ -17,71 +17,83 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/x7-reyc/src/main/java/io/xream/x7/reyc/ReyClient.java b/x7-reyc/src/main/java/io/xream/x7/reyc/ReyClient.java
index fb2fa3db..38603eb7 100644
--- a/x7-reyc/src/main/java/io/xream/x7/reyc/ReyClient.java
+++ b/x7-reyc/src/main/java/io/xream/x7/reyc/ReyClient.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package io.xream.x7.reyc;
import java.lang.annotation.*;
@@ -10,4 +26,5 @@
String value() default "";
String circuitBreaker() default "none";
+
}
diff --git a/x7-reyc/src/main/java/io/xream/x7/reyc/ReyClientConfig.java b/x7-reyc/src/main/java/io/xream/x7/reyc/ReyClientConfig.java
index 84d47b42..e97b7045 100644
--- a/x7-reyc/src/main/java/io/xream/x7/reyc/ReyClientConfig.java
+++ b/x7-reyc/src/main/java/io/xream/x7/reyc/ReyClientConfig.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package io.xream.x7.reyc;
import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry;
diff --git a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/ClientParsed.java b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/ClientParsed.java
index 1a1a4fb1..6ae7b77e 100644
--- a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/ClientParsed.java
+++ b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/ClientParsed.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package io.xream.x7.reyc.internal;
import java.util.HashMap;
diff --git a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/ClientParser.java b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/ClientParser.java
index f62b29b5..ceaed5dc 100644
--- a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/ClientParser.java
+++ b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/ClientParser.java
@@ -1,12 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package io.xream.x7.reyc.internal;
import io.xream.x7.reyc.ReyClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import x7.core.bean.KV;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
public class ClientParser {
@@ -65,10 +84,22 @@ public static void parse(Class> clz) {
rm = rmArr[0];
}
+ List hearderList = null;
+ String[] headers = requestMapping.headers();
+ if (headers != null && headers.length > 0){
+ hearderList = new ArrayList<>();
+ for (String header : headers){
+ String[] headerArr = header.split("=");
+ KV kv = new KV(headerArr[0],headerArr[1]);
+ hearderList.add(kv);
+ }
+ }
+
MethodParsed methodParsed = new MethodParsed();
methodParsed.setRequestMapping(mapping);
methodParsed.setReturnType(returnType);
methodParsed.setRequestMethod(rm);
+ methodParsed.setHeaderList(hearderList);
parsed.getMap().put(methodName,methodParsed);
}
diff --git a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/ClientResolver.java b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/ClientResolver.java
index f297f494..fa894e6e 100644
--- a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/ClientResolver.java
+++ b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/ClientResolver.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package io.xream.x7.reyc.internal;
import io.github.resilience4j.circuitbreaker.CircuitBreaker;
@@ -22,12 +38,12 @@ public class ClientResolver {
private static CircuitBreakerRegistry circuitBreakerRegistry;
- private static HttpClientProperies _properies;
+ private static HttpClientProperies properies;
- public static void init(CircuitBreakerRegistry c,HttpClientProperies properies) {
+ public static void init(CircuitBreakerRegistry c,HttpClientProperies p) {
circuitBreakerRegistry = c;
- _properies = properies;
+ properies = p;
}
private static Pattern pattern = Pattern.compile("\\{[\\w]*\\}");
@@ -54,9 +70,9 @@ protected static Object resolve(String remoteIntfName, String methodName, Object
if (requestMethod == RequestMethod.POST) {
if (args != null && args.length > 0) {
- result = HttpClientUtil.post(url, args[0],_properies.getConnectTimeout(),_properies.getSocketTimeout());
+ result = HttpClientUtil.post(url, args[0],methodParsed.getHeaderList(),properies.getConnectTimeout(),properies.getSocketTimeout());
} else {
- result = HttpClientUtil.post(url, null, _properies.getConnectTimeout(),_properies.getSocketTimeout());
+ result = HttpClientUtil.post(url, null,methodParsed.getHeaderList(), properies.getConnectTimeout(),properies.getSocketTimeout());
}
} else {
List regExList = StringUtil.listByRegEx(url, pattern);
@@ -64,7 +80,7 @@ protected static Object resolve(String remoteIntfName, String methodName, Object
for (int i = 0; i < size; i++) {
url = url.replaceAll(regExList.get(i), args[i].toString());
}
- result = HttpClientUtil.getUrl(url,_properies.getConnectTimeout(),_properies.getSocketTimeout());
+ result = HttpClientUtil.getUrl(url,methodParsed.getHeaderList(),properies.getConnectTimeout(),properies.getSocketTimeout());
}
if (StringUtil.isNullOrEmpty(result))
diff --git a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/HttpClientInvocationHandler.java b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/HttpClientInvocationHandler.java
index f158dd55..89b46365 100644
--- a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/HttpClientInvocationHandler.java
+++ b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/HttpClientInvocationHandler.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package io.xream.x7.reyc.internal;
import x7.core.util.ExceptionUtil;
diff --git a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/HttpClientProperies.java b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/HttpClientProperies.java
index e12d2ebc..6b6e08ef 100644
--- a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/HttpClientProperies.java
+++ b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/HttpClientProperies.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package io.xream.x7.reyc.internal;
import org.springframework.boot.context.properties.ConfigurationProperties;
diff --git a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/HttpClientProxy.java b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/HttpClientProxy.java
index a1e24a79..fefab08c 100644
--- a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/HttpClientProxy.java
+++ b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/HttpClientProxy.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package io.xream.x7.reyc.internal;
import org.springframework.beans.factory.FactoryBean;
diff --git a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/MethodParsed.java b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/MethodParsed.java
index d7a2db91..e3f5ee2d 100644
--- a/x7-reyc/src/main/java/io/xream/x7/reyc/internal/MethodParsed.java
+++ b/x7-reyc/src/main/java/io/xream/x7/reyc/internal/MethodParsed.java
@@ -1,6 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package io.xream.x7.reyc.internal;
import org.springframework.web.bind.annotation.RequestMethod;
+import x7.core.bean.KV;
+
+import java.util.List;
public class MethodParsed {
@@ -8,6 +27,8 @@ public class MethodParsed {
private RequestMethod requestMethod;
private Class> returnType;
+ private List headerList;
+
public String getRequestMapping() {
return requestMapping;
}
@@ -32,12 +53,21 @@ public void setReturnType(Class> returnType) {
this.returnType = returnType;
}
+ public List getHeaderList() {
+ return headerList;
+ }
+
+ public void setHeaderList(List headerList) {
+ this.headerList = headerList;
+ }
+
@Override
public String toString() {
return "MethodParsed{" +
"requestMapping='" + requestMapping + '\'' +
", requestMethod=" + requestMethod +
", returnType=" + returnType +
+ ", headerList=" + headerList +
'}';
}
}
diff --git a/x7-reyc/x7-reyc.iml b/x7-reyc/x7-reyc.iml
new file mode 100644
index 00000000..76f62b7c
--- /dev/null
+++ b/x7-reyc/x7-reyc.iml
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file