This commit is contained in:
qaiu
2023-04-21 01:21:56 +08:00
parent 1579da797b
commit 2c010f9321
59 changed files with 128 additions and 694 deletions

View File

@@ -1,10 +1,10 @@
package cn.com.yhinfo.core;
package cn.qaiu.vx.core;
import cn.com.yhinfo.core.util.ConfigUtil;
import cn.com.yhinfo.core.util.VertxHolder;
import cn.com.yhinfo.core.verticle.ReverseProxyVerticle;
import cn.com.yhinfo.core.verticle.ServiceVerticle;
import cn.com.yhinfo.core.verticle.RouterVerticle;
import cn.qaiu.vx.core.util.ConfigUtil;
import cn.qaiu.vx.core.util.VertxHolder;
import cn.qaiu.vx.core.verticle.ReverseProxyVerticle;
import cn.qaiu.vx.core.verticle.ServiceVerticle;
import cn.qaiu.vx.core.verticle.RouterVerticle;
import io.vertx.core.*;
import io.vertx.core.json.JsonObject;
import io.vertx.core.shareddata.LocalMap;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.annotaions;
package cn.qaiu.vx.core.annotaions;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.annotaions;
package cn.qaiu.vx.core.annotaions;
import java.lang.annotation.*;

View File

@@ -1,7 +1,7 @@
package cn.com.yhinfo.core.annotaions;
package cn.qaiu.vx.core.annotaions;
import cn.com.yhinfo.core.enums.MIMEType;
import cn.com.yhinfo.core.enums.RouteMethod;
import cn.qaiu.vx.core.enums.MIMEType;
import cn.qaiu.vx.core.enums.RouteMethod;
import java.lang.annotation.*;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.annotaions;
package cn.qaiu.vx.core.annotaions;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.annotaions;
package cn.qaiu.vx.core.annotaions;
import java.lang.annotation.*;

View File

@@ -1,6 +1,6 @@
package cn.com.yhinfo.core.base;
package cn.qaiu.vx.core.base;
import cn.com.yhinfo.core.util.CastUtil;
import cn.qaiu.vx.core.util.CastUtil;
import java.util.Arrays;
@@ -36,4 +36,4 @@ public interface BaseAsyncService {
}
return clazz;
}
}
}

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.base;
package cn.qaiu.vx.core.base;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.RoutingContext;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.enums;
package cn.qaiu.vx.core.enums;
/**
* MIMEType: request or response head

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.enums;
package cn.qaiu.vx.core.enums;
/**
* Router API 请求处理方式枚举

View File

@@ -1,13 +1,13 @@
package cn.com.yhinfo.core.handlerfactory;
package cn.qaiu.vx.core.handlerfactory;
import cn.com.yhinfo.core.annotaions.DateFormat;
import cn.com.yhinfo.core.annotaions.RouteHandler;
import cn.com.yhinfo.core.annotaions.RouteMapping;
import cn.com.yhinfo.core.annotaions.SockRouteMapper;
import cn.com.yhinfo.core.base.BaseHttpApi;
import cn.com.yhinfo.core.enums.MIMEType;
import cn.com.yhinfo.core.model.JsonResult;
import cn.com.yhinfo.core.util.*;
import cn.qaiu.vx.core.annotaions.DateFormat;
import cn.qaiu.vx.core.annotaions.RouteHandler;
import cn.qaiu.vx.core.annotaions.RouteMapping;
import cn.qaiu.vx.core.annotaions.SockRouteMapper;
import cn.qaiu.vx.core.enums.MIMEType;
import cn.qaiu.vx.core.model.JsonResult;
import cn.qaiu.vx.core.base.BaseHttpApi;
import cn.qaiu.vx.core.util.*;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.MultiMap;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.interceptor;
package cn.qaiu.vx.core.interceptor;
import io.vertx.core.Handler;
import io.vertx.ext.web.RoutingContext;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.model;
package cn.qaiu.vx.core.model;
import org.apache.commons.lang3.StringUtils;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.util;
package cn.qaiu.vx.core.util;
import io.vertx.core.Vertx;
import io.vertx.serviceproxy.ServiceProxyBuilder;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.util;
package cn.qaiu.vx.core.util;
/**
* 转换为任意类型 旨在消除泛型转换时的异常
@@ -15,4 +15,4 @@ public interface CastUtil {
static <T> T cast(Object object) {
return (T) object;
}
}
}

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.util;
package cn.qaiu.vx.core.util;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonObject;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.util;
package cn.qaiu.vx.core.util;
import io.vertx.config.ConfigRetriever;
import io.vertx.config.ConfigRetrieverOptions;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.util;
package cn.qaiu.vx.core.util;
import java.util.HashMap;
import java.util.Map;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.util;
package cn.qaiu.vx.core.util;
import io.vertx.core.MultiMap;
import org.apache.commons.beanutils.BeanUtils;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.util;
package cn.qaiu.vx.core.util;
import javassist.*;
import javassist.bytecode.AccessFlag;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.util;
package cn.qaiu.vx.core.util;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.util;
package cn.qaiu.vx.core.util;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.util;
package cn.qaiu.vx.core.util;
import org.apache.commons.lang3.StringUtils;
@@ -107,4 +107,4 @@ public class StringCase {
System.out.println(toUnderlineUpperCase("__my_nameQaiu___"));
}
}
}

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.core.util;
package cn.qaiu.vx.core.util;
import io.vertx.core.Vertx;

View File

@@ -1,9 +1,9 @@
package cn.com.yhinfo.core.verticle;
package cn.qaiu.vx.core.verticle;
import cn.com.yhinfo.core.util.CastUtil;
import cn.com.yhinfo.core.util.ConfigUtil;
import cn.com.yhinfo.core.util.SharedDataUtil;
import cn.com.yhinfo.core.util.VertxHolder;
import cn.qaiu.vx.core.util.CastUtil;
import cn.qaiu.vx.core.util.ConfigUtil;
import cn.qaiu.vx.core.util.SharedDataUtil;
import cn.qaiu.vx.core.util.VertxHolder;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.Promise;

View File

@@ -1,16 +1,13 @@
package cn.com.yhinfo.core.verticle;
package cn.qaiu.vx.core.verticle;
import cn.com.yhinfo.core.handlerfactory.RouterHandlerFactory;
import cn.com.yhinfo.core.util.CommonUtil;
import cn.com.yhinfo.core.util.SharedDataUtil;
import cn.qaiu.vx.core.handlerfactory.RouterHandlerFactory;
import cn.qaiu.vx.core.util.CommonUtil;
import cn.qaiu.vx.core.util.SharedDataUtil;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.stomp.StompServer;
import io.vertx.ext.stomp.StompServerHandler;
import io.vertx.ext.stomp.StompServerOptions;
import io.vertx.ext.web.Router;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@@ -1,9 +1,9 @@
package cn.com.yhinfo.core.verticle;
package cn.qaiu.vx.core.verticle;
import cn.com.yhinfo.core.annotaions.Service;
import cn.com.yhinfo.core.base.BaseAsyncService;
import cn.com.yhinfo.core.util.ReflectionUtil;
import cn.com.yhinfo.core.util.SharedDataUtil;
import cn.qaiu.vx.core.annotaions.Service;
import cn.qaiu.vx.core.base.BaseAsyncService;
import cn.qaiu.vx.core.util.ReflectionUtil;
import cn.qaiu.vx.core.util.SharedDataUtil;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.serviceproxy.ServiceBinder;
@@ -17,7 +17,7 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
* 服务注册到EventBus
* <br>Create date 2021-05-07 10:26:54
*
*
* @author <a href="https://qaiu.top">QAIU</a>
*/
public class ServiceVerticle extends AbstractVerticle {

View File

@@ -97,7 +97,7 @@
<!--jar包不包含唯一版本标识-->
<useUniqueVersions>false</useUniqueVersions>
<!--指定入口类-->
<mainClass>cn.com.yhinfo.real.AppMain</mainClass>
<mainClass>cn.qaiu.lz.AppMain</mainClass>
</manifest>
<manifestEntries>
<!--MANIFEST.MF 中 Class-Path 加入资源文件目录-->

View File

@@ -1,28 +0,0 @@
package cn.com.yhinfo.real.common.model;
/**
* Mapper for {@link MyData}.
* NOTE: This class has been automatically generated from the {@link MyData} original class using Vert.x codegen.
*/
@io.vertx.codegen.annotations.VertxGen
public interface MyDataParametersMapper extends io.vertx.sqlclient.templates.TupleMapper<MyData> {
MyDataParametersMapper INSTANCE = new MyDataParametersMapper() {};
default io.vertx.sqlclient.Tuple map(java.util.function.Function<Integer, String> mapping, int size, MyData params) {
java.util.Map<String, Object> args = map(params);
Object[] array = new Object[size];
for (int i = 0;i < array.length;i++) {
String column = mapping.apply(i);
array[i] = args.get(column);
}
return io.vertx.sqlclient.Tuple.wrap(array);
}
default java.util.Map<String, Object> map(MyData obj) {
java.util.Map<String, Object> params = new java.util.HashMap<>();
params.put("id", obj.getId());
params.put("max_size", obj.getMaxSize());
return params;
}
}

View File

@@ -1,29 +0,0 @@
package cn.com.yhinfo.real.common.model;
/**
* Mapper for {@link MyData}.
* NOTE: This class has been automatically generated from the {@link MyData} original class using Vert.x codegen.
*/
@io.vertx.codegen.annotations.VertxGen
public interface MyDataRowMapper extends io.vertx.sqlclient.templates.RowMapper<MyData> {
@io.vertx.codegen.annotations.GenIgnore
MyDataRowMapper INSTANCE = new MyDataRowMapper() { };
@io.vertx.codegen.annotations.GenIgnore
java.util.stream.Collector<io.vertx.sqlclient.Row, ?, java.util.List<MyData>> COLLECTOR = java.util.stream.Collectors.mapping(INSTANCE::map, java.util.stream.Collectors.toList());
@io.vertx.codegen.annotations.GenIgnore
default MyData map(io.vertx.sqlclient.Row row) {
MyData obj = new MyData();
Object val;
int idx;
if ((idx = row.getColumnIndex("id")) != -1 && (val = row.getString(idx)) != null) {
obj.setId((java.lang.String)val);
}
if ((idx = row.getColumnIndex("max_size")) != -1 && (val = row.getString(idx)) != null) {
obj.setMaxSize((java.lang.String)val);
}
return obj;
}
}

View File

@@ -1,30 +0,0 @@
package cn.com.yhinfo.real.common.model;
/**
* Mapper for {@link UserInfo}.
* NOTE: This class has been automatically generated from the {@link UserInfo} original class using Vert.x codegen.
*/
@io.vertx.codegen.annotations.VertxGen
public interface UserInfoParametersMapper extends io.vertx.sqlclient.templates.TupleMapper<UserInfo> {
UserInfoParametersMapper INSTANCE = new UserInfoParametersMapper() {};
default io.vertx.sqlclient.Tuple map(java.util.function.Function<Integer, String> mapping, int size, UserInfo params) {
java.util.Map<String, Object> args = map(params);
Object[] array = new Object[size];
for (int i = 0;i < array.length;i++) {
String column = mapping.apply(i);
array[i] = args.get(column);
}
return io.vertx.sqlclient.Tuple.wrap(array);
}
default java.util.Map<String, Object> map(UserInfo obj) {
java.util.Map<String, Object> params = new java.util.HashMap<>();
params.put("permission", obj.getPermission());
params.put("pwd_crc32", obj.getPwdCrc32());
params.put("username", obj.getUsername());
params.put("uuid", obj.getUuid());
return params;
}
}

View File

@@ -1,35 +0,0 @@
package cn.com.yhinfo.real.common.model;
/**
* Mapper for {@link UserInfo}.
* NOTE: This class has been automatically generated from the {@link UserInfo} original class using Vert.x codegen.
*/
@io.vertx.codegen.annotations.VertxGen
public interface UserInfoRowMapper extends io.vertx.sqlclient.templates.RowMapper<UserInfo> {
@io.vertx.codegen.annotations.GenIgnore
UserInfoRowMapper INSTANCE = new UserInfoRowMapper() { };
@io.vertx.codegen.annotations.GenIgnore
java.util.stream.Collector<io.vertx.sqlclient.Row, ?, java.util.List<UserInfo>> COLLECTOR = java.util.stream.Collectors.mapping(INSTANCE::map, java.util.stream.Collectors.toList());
@io.vertx.codegen.annotations.GenIgnore
default UserInfo map(io.vertx.sqlclient.Row row) {
UserInfo obj = new UserInfo();
Object val;
int idx;
if ((idx = row.getColumnIndex("permission")) != -1 && (val = row.getString(idx)) != null) {
obj.setPermission((java.lang.String)val);
}
if ((idx = row.getColumnIndex("pwd_crc32")) != -1 && (val = row.getString(idx)) != null) {
obj.setPwdCrc32((java.lang.String)val);
}
if ((idx = row.getColumnIndex("username")) != -1 && (val = row.getString(idx)) != null) {
obj.setUsername((java.lang.String)val);
}
if ((idx = row.getColumnIndex("uuid")) != -1 && (val = row.getString(idx)) != null) {
obj.setUuid((java.lang.String)val);
}
return obj;
}
}

View File

@@ -1,89 +0,0 @@
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat 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 cn.com.yhinfo.real.web.service;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.Vertx;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.function.Function;
import io.vertx.serviceproxy.ServiceException;
import io.vertx.serviceproxy.ServiceExceptionMessageCodec;
import io.vertx.serviceproxy.ProxyUtils;
import cn.com.yhinfo.real.common.model.UserInfo;
import cn.com.yhinfo.core.base.BaseAsyncService;
import io.vertx.core.Future;
/*
Generated Proxy code - DO NOT EDIT
@author Roger the Robot
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class DbServiceVertxEBProxy implements DbService {
private Vertx _vertx;
private String _address;
private DeliveryOptions _options;
private boolean closed;
public DbServiceVertxEBProxy(Vertx vertx, String address) {
this(vertx, address, null);
}
public DbServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) {
this._vertx = vertx;
this._address = address;
this._options = options;
try {
this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec());
} catch (IllegalStateException ex) {
}
}
@Override
public Future<JsonObject> sayOk(String data){
if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed");
JsonObject _json = new JsonObject();
_json.put("data", data);
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "sayOk");
return _vertx.eventBus().<JsonObject>request(_address, _json, _deliveryOptions).map(msg -> {
return msg.body();
});
}
@Override
public Future<JsonObject> sayOk2(String data, UserInfo holder){
if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed");
JsonObject _json = new JsonObject();
_json.put("data", data);
_json.put("holder", holder != null ? holder.toJson() : null);
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "sayOk2");
return _vertx.eventBus().<JsonObject>request(_address, _json, _deliveryOptions).map(msg -> {
return msg.body();
});
}
}

View File

@@ -1,140 +0,0 @@
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat 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 cn.com.yhinfo.real.web.service;
import cn.com.yhinfo.real.web.service.DbService;
import io.vertx.core.Vertx;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.eventbus.EventBus;
import io.vertx.core.eventbus.Message;
import io.vertx.core.eventbus.MessageConsumer;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.eventbus.ReplyException;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import java.util.Collection;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import io.vertx.serviceproxy.ProxyHandler;
import io.vertx.serviceproxy.ServiceException;
import io.vertx.serviceproxy.ServiceExceptionMessageCodec;
import io.vertx.serviceproxy.HelperUtils;
import io.vertx.serviceproxy.ServiceBinder;
import cn.com.yhinfo.real.common.model.UserInfo;
import cn.com.yhinfo.core.base.BaseAsyncService;
import io.vertx.core.Future;
/*
Generated Proxy code - DO NOT EDIT
@author Roger the Robot
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class DbServiceVertxProxyHandler extends ProxyHandler {
public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes
private final Vertx vertx;
private final DbService service;
private final long timerID;
private long lastAccessed;
private final long timeoutSeconds;
private final boolean includeDebugInfo;
public DbServiceVertxProxyHandler(Vertx vertx, DbService service){
this(vertx, service, DEFAULT_CONNECTION_TIMEOUT);
}
public DbServiceVertxProxyHandler(Vertx vertx, DbService service, long timeoutInSecond){
this(vertx, service, true, timeoutInSecond);
}
public DbServiceVertxProxyHandler(Vertx vertx, DbService service, boolean topLevel, long timeoutInSecond){
this(vertx, service, true, timeoutInSecond, false);
}
public DbServiceVertxProxyHandler(Vertx vertx, DbService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) {
this.vertx = vertx;
this.service = service;
this.includeDebugInfo = includeDebugInfo;
this.timeoutSeconds = timeoutSeconds;
try {
this.vertx.eventBus().registerDefaultCodec(ServiceException.class,
new ServiceExceptionMessageCodec());
} catch (IllegalStateException ex) {}
if (timeoutSeconds != -1 && !topLevel) {
long period = timeoutSeconds * 1000 / 2;
if (period > 10000) {
period = 10000;
}
this.timerID = vertx.setPeriodic(period, this::checkTimedOut);
} else {
this.timerID = -1;
}
accessed();
}
private void checkTimedOut(long id) {
long now = System.nanoTime();
if (now - lastAccessed > timeoutSeconds * 1000000000) {
close();
}
}
@Override
public void close() {
if (timerID != -1) {
vertx.cancelTimer(timerID);
}
super.close();
}
private void accessed() {
this.lastAccessed = System.nanoTime();
}
public void handle(Message<JsonObject> msg) {
try{
JsonObject json = msg.body();
String action = msg.headers().get("action");
if (action == null) throw new IllegalStateException("action not specified");
accessed();
switch (action) {
case "sayOk": {
service.sayOk((java.lang.String)json.getValue("data")).onComplete(HelperUtils.createHandler(msg, includeDebugInfo));
break;
}
case "sayOk2": {
service.sayOk2((java.lang.String)json.getValue("data"),
json.getJsonObject("holder") != null ? new cn.com.yhinfo.real.common.model.UserInfo((JsonObject)json.getJsonObject("holder")) : null).onComplete(HelperUtils.createHandler(msg, includeDebugInfo));
break;
}
default: throw new IllegalStateException("Invalid action: " + action);
}
} catch (Throwable t) {
if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t)));
else msg.reply(new ServiceException(500, t.getMessage()));
throw t;
}
}
}

View File

@@ -1,76 +0,0 @@
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat 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 cn.com.yhinfo.real.web.service;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.Vertx;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.function.Function;
import io.vertx.serviceproxy.ServiceException;
import io.vertx.serviceproxy.ServiceExceptionMessageCodec;
import io.vertx.serviceproxy.ProxyUtils;
import cn.com.yhinfo.core.base.BaseAsyncService;
import cn.com.yhinfo.real.web.model.RealUser;
import io.vertx.core.Future;
/*
Generated Proxy code - DO NOT EDIT
@author Roger the Robot
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class UserServiceVertxEBProxy implements UserService {
private Vertx _vertx;
private String _address;
private DeliveryOptions _options;
private boolean closed;
public UserServiceVertxEBProxy(Vertx vertx, String address) {
this(vertx, address, null);
}
public UserServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) {
this._vertx = vertx;
this._address = address;
this._options = options;
try {
this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec());
} catch (IllegalStateException ex) {
}
}
@Override
public Future<String> login(RealUser user){
if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed");
JsonObject _json = new JsonObject();
_json.put("user", user != null ? user.toJson() : null);
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "login");
return _vertx.eventBus().<String>request(_address, _json, _deliveryOptions).map(msg -> {
return msg.body();
});
}
}

View File

@@ -1,135 +0,0 @@
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat 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 cn.com.yhinfo.real.web.service;
import cn.com.yhinfo.real.web.service.UserService;
import io.vertx.core.Vertx;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.eventbus.EventBus;
import io.vertx.core.eventbus.Message;
import io.vertx.core.eventbus.MessageConsumer;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.eventbus.ReplyException;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import java.util.Collection;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import io.vertx.serviceproxy.ProxyHandler;
import io.vertx.serviceproxy.ServiceException;
import io.vertx.serviceproxy.ServiceExceptionMessageCodec;
import io.vertx.serviceproxy.HelperUtils;
import io.vertx.serviceproxy.ServiceBinder;
import cn.com.yhinfo.core.base.BaseAsyncService;
import cn.com.yhinfo.real.web.model.RealUser;
import io.vertx.core.Future;
/*
Generated Proxy code - DO NOT EDIT
@author Roger the Robot
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class UserServiceVertxProxyHandler extends ProxyHandler {
public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes
private final Vertx vertx;
private final UserService service;
private final long timerID;
private long lastAccessed;
private final long timeoutSeconds;
private final boolean includeDebugInfo;
public UserServiceVertxProxyHandler(Vertx vertx, UserService service){
this(vertx, service, DEFAULT_CONNECTION_TIMEOUT);
}
public UserServiceVertxProxyHandler(Vertx vertx, UserService service, long timeoutInSecond){
this(vertx, service, true, timeoutInSecond);
}
public UserServiceVertxProxyHandler(Vertx vertx, UserService service, boolean topLevel, long timeoutInSecond){
this(vertx, service, true, timeoutInSecond, false);
}
public UserServiceVertxProxyHandler(Vertx vertx, UserService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) {
this.vertx = vertx;
this.service = service;
this.includeDebugInfo = includeDebugInfo;
this.timeoutSeconds = timeoutSeconds;
try {
this.vertx.eventBus().registerDefaultCodec(ServiceException.class,
new ServiceExceptionMessageCodec());
} catch (IllegalStateException ex) {}
if (timeoutSeconds != -1 && !topLevel) {
long period = timeoutSeconds * 1000 / 2;
if (period > 10000) {
period = 10000;
}
this.timerID = vertx.setPeriodic(period, this::checkTimedOut);
} else {
this.timerID = -1;
}
accessed();
}
private void checkTimedOut(long id) {
long now = System.nanoTime();
if (now - lastAccessed > timeoutSeconds * 1000000000) {
close();
}
}
@Override
public void close() {
if (timerID != -1) {
vertx.cancelTimer(timerID);
}
super.close();
}
private void accessed() {
this.lastAccessed = System.nanoTime();
}
public void handle(Message<JsonObject> msg) {
try{
JsonObject json = msg.body();
String action = msg.headers().get("action");
if (action == null) throw new IllegalStateException("action not specified");
accessed();
switch (action) {
case "login": {
service.login(json.getJsonObject("user") != null ? new cn.com.yhinfo.real.web.model.RealUser((JsonObject)json.getJsonObject("user")) : null).onComplete(HelperUtils.createHandler(msg, includeDebugInfo));
break;
}
default: throw new IllegalStateException("Invalid action: " + action);
}
} catch (Throwable t) {
if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t)));
else msg.reply(new ServiceException(500, t.getMessage()));
throw t;
}
}
}

View File

@@ -1,10 +0,0 @@
/**
* sinoreal2-web
* <br>Create date 2021/7/8 13:29
*
* @author <a href="https://qaiu.top">QAIU</a>
*/
@ModuleGen(name = "proxy", groupPackage = "cn.com.yhinfo.real", useFutures = true)
package cn.com.yhinfo.real;
import io.vertx.codegen.annotations.ModuleGen;

View File

@@ -1,6 +1,6 @@
package cn.com.yhinfo.real;
package cn.qaiu.lz;
import cn.com.yhinfo.core.Deploy;
import cn.qaiu.vx.core.Deploy;
import io.vertx.core.json.JsonObject;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.real.common;
package cn.qaiu.lz.common;
import io.vertx.core.json.JsonObject;

View File

@@ -1,11 +1,11 @@
package cn.com.yhinfo.real.common.interceptorImpl;
package cn.qaiu.lz.common.interceptorImpl;
import cn.com.yhinfo.core.base.BaseHttpApi;
import cn.com.yhinfo.core.interceptor.Interceptor;
import cn.com.yhinfo.core.model.JsonResult;
import cn.com.yhinfo.core.util.CommonUtil;
import cn.com.yhinfo.core.util.SharedDataUtil;
import cn.com.yhinfo.core.util.VertxHolder;
import cn.qaiu.vx.core.base.BaseHttpApi;
import cn.qaiu.vx.core.interceptor.Interceptor;
import cn.qaiu.vx.core.model.JsonResult;
import cn.qaiu.vx.core.util.CommonUtil;
import cn.qaiu.vx.core.util.SharedDataUtil;
import cn.qaiu.vx.core.util.VertxHolder;
import io.vertx.core.json.JsonArray;
import io.vertx.core.shareddata.LocalMap;
import io.vertx.ext.web.RoutingContext;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.real.common.model;
package cn.qaiu.lz.common.model;
import io.vertx.codegen.annotations.DataObject;
import io.vertx.codegen.format.SnakeCase;

View File

@@ -1,6 +1,6 @@
package cn.com.yhinfo.real.common.model;
package cn.qaiu.lz.common.model;
import cn.com.yhinfo.real.common.ToJson;
import cn.qaiu.lz.common.ToJson;
import io.vertx.codegen.annotations.DataObject;
import io.vertx.codegen.format.SnakeCase;
import io.vertx.core.json.JsonObject;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.real.common.util;
package cn.qaiu.lz.common.util;
public class ArrayUtil {

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.real.common.util;
package cn.qaiu.lz.common.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@@ -0,0 +1,10 @@
/**
* sinoreal2-web
* <br>Create date 2021/7/8 13:29
*
* @author <a href="https://qaiu.top">QAIU</a>
*/
@ModuleGen(name = "proxy", groupPackage = "cn.qaiu.lz", useFutures = true)
package cn.qaiu.lz;
import io.vertx.codegen.annotations.ModuleGen;

View File

@@ -1,21 +1,21 @@
package cn.com.yhinfo.real.web.http;
package cn.qaiu.lz.web.http;
import cn.com.yhinfo.core.annotaions.RouteHandler;
import cn.com.yhinfo.core.annotaions.RouteMapping;
import cn.com.yhinfo.core.annotaions.SockRouteMapper;
import cn.com.yhinfo.core.enums.RouteMethod;
import cn.com.yhinfo.core.model.JsonResult;
import cn.com.yhinfo.core.util.AsyncServiceUtil;
import cn.com.yhinfo.core.util.SnowflakeIdWorker;
import cn.com.yhinfo.core.util.VertxHolder;
import cn.com.yhinfo.real.web.model.RealUser;
import cn.com.yhinfo.real.web.service.UserService;
import cn.qaiu.lz.web.service.UserService;
import cn.qaiu.vx.core.annotaions.RouteHandler;
import cn.qaiu.vx.core.annotaions.RouteMapping;
import cn.qaiu.vx.core.annotaions.SockRouteMapper;
import cn.qaiu.vx.core.enums.RouteMethod;
import cn.qaiu.vx.core.model.JsonResult;
import cn.qaiu.vx.core.util.AsyncServiceUtil;
import cn.qaiu.vx.core.util.SnowflakeIdWorker;
import cn.qaiu.vx.core.util.VertxHolder;
import cn.qaiu.lz.web.model.RealUser;
import io.vertx.core.Future;
import io.vertx.ext.web.handler.sockjs.SockJSSocket;
import lombok.extern.slf4j.Slf4j;
/**
* 连接服务API
* 服务API
* <br>Create date 2021/4/28 9:15
*
* @author <a href="https://qaiu.top">QAIU</a>

View File

@@ -1,6 +1,6 @@
package cn.com.yhinfo.real.web.model;
package cn.qaiu.lz.web.model;
import cn.com.yhinfo.real.common.ToJson;
import cn.qaiu.lz.common.ToJson;
import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.json.JsonObject;
import lombok.AllArgsConstructor;

View File

@@ -1,7 +1,7 @@
package cn.com.yhinfo.real.web.service;
package cn.qaiu.lz.web.service;
import cn.com.yhinfo.core.base.BaseAsyncService;
import cn.com.yhinfo.real.common.model.UserInfo;
import cn.qaiu.lz.common.model.UserInfo;
import cn.qaiu.vx.core.base.BaseAsyncService;
import io.vertx.codegen.annotations.ProxyGen;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;

View File

@@ -1,6 +1,6 @@
package cn.com.yhinfo.real.web.service;
package cn.qaiu.lz.web.service;
import cn.com.yhinfo.core.util.CastUtil;
import cn.qaiu.vx.core.util.CastUtil;
import java.lang.reflect.Proxy;
@@ -15,4 +15,4 @@ public class JdkProxyFactory {
new ServiceJdkProxy<>(target))
);
}
}
}

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.real.web.service;
package cn.qaiu.lz.web.service;
import lombok.extern.slf4j.Slf4j;

View File

@@ -1,7 +1,7 @@
package cn.com.yhinfo.real.web.service;
package cn.qaiu.lz.web.service;
import cn.com.yhinfo.core.base.BaseAsyncService;
import cn.com.yhinfo.real.web.model.RealUser;
import cn.qaiu.vx.core.base.BaseAsyncService;
import cn.qaiu.lz.web.model.RealUser;
import io.vertx.codegen.annotations.ProxyGen;
import io.vertx.core.Future;

View File

@@ -1,9 +1,9 @@
package cn.com.yhinfo.real.web.service.impl;
package cn.qaiu.lz.web.service.impl;
import cn.com.yhinfo.core.annotaions.Service;
import cn.com.yhinfo.core.model.JsonResult;
import cn.com.yhinfo.real.common.model.UserInfo;
import cn.com.yhinfo.real.web.service.DbService;
import cn.qaiu.lz.common.model.UserInfo;
import cn.qaiu.lz.web.service.DbService;
import cn.qaiu.vx.core.annotaions.Service;
import cn.qaiu.vx.core.model.JsonResult;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import lombok.extern.slf4j.Slf4j;

View File

@@ -1,8 +1,8 @@
package cn.com.yhinfo.real.web.service.impl;
package cn.qaiu.lz.web.service.impl;
import cn.com.yhinfo.core.annotaions.Service;
import cn.com.yhinfo.real.web.model.RealUser;
import cn.com.yhinfo.real.web.service.UserService;
import cn.qaiu.lz.web.model.RealUser;
import cn.qaiu.lz.web.service.UserService;
import cn.qaiu.vx.core.annotaions.Service;
import io.vertx.core.Future;
/**

View File

@@ -12,15 +12,14 @@ vertx:
workerPoolSize: 20
custom:
asyncServiceInstances: 8
routerLocations: cn.com.yhinfo.real.web.http
interceptorClassPath: cn.com.yhinfo.real.common.interceptorImpl.DefaultInterceptor
handlerLocations: cn.com.yhinfo.real.web.service
routerLocations: cn.qaiu.lz.web.http
interceptorClassPath: cn.qaiu.lz.common.interceptorImpl.DefaultInterceptor
handlerLocations: cn.qaiu.lz.web.service
ignoresReg:
- .*/login$
- .*/test.*$
entityPackagesReg:
- ^cn\.com\.yhinfo\.real\.web\.model\..*
- ^sinereal\.core\..*
- ^cn\.qaiu\.lz\.web\.model\..*
otherConfig:
- dictionaries.json
errorPage404: /index.html

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.test;
package cn.qaiu.web.test;
import io.vertx.core.Future;
import io.vertx.core.Vertx;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.test;
package cn.qaiu.web.test;
import io.vertx.ext.web.RoutingContext;
import lombok.extern.slf4j.Slf4j;

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.test;
package cn.qaiu.web.test;
import javassist.ClassPool;
import javassist.CtClass;
@@ -82,4 +82,4 @@ public class Test02 {
System.out.println(map);
}
}
}

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.test;
package cn.qaiu.web.test;
import java.io.*;
import java.net.InetAddress;
@@ -158,4 +158,4 @@ public class TestOS {
// new TestOS().showURL();
System.out.println(File.separator);
}
}
}

View File

@@ -1,4 +1,4 @@
package cn.com.yhinfo.test;
package cn.qaiu.web.test;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpClient;