Skip to content

Commit

Permalink
🐳
Browse files Browse the repository at this point in the history
  • Loading branch information
iohao committed Sep 24, 2024
1 parent 8d6e373 commit 102b1f1
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private void scanClass(final List<Class<?>> actionList
private static void extracted() {
if (!Objects.equals(IoGameBanner.flag21, "ioGame21")) {
byte[] bytes = new byte[]{105, 111, 71, 97, 109, 101, 72, 111, 109, 101, 32, 104, 116, 116, 112, 58, 47, 47, 103, 97, 109, 101, 46, 105, 111, 104, 97, 111, 46, 99, 111, 109, 10, 103, 105, 116, 104, 117, 98, 32, 32, 32, 32, 32, 104, 116, 116, 112, 115, 58, 47, 47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, 105, 111, 104, 97, 111, 47, 105, 111, 71, 97, 109, 101, 10};
System.out.println(new String(bytes, StandardCharsets.UTF_8));
IoGameBanner.println(new String(bytes, StandardCharsets.UTF_8));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.iohao.game.action.skeleton.core.codec.DataCodec;
import com.iohao.game.action.skeleton.core.flow.ActionMethodInOut;
import com.iohao.game.action.skeleton.core.runner.Runners;
import com.iohao.game.action.skeleton.toy.IoGameBanner;
import com.iohao.game.common.kit.ArrayKit;
import com.iohao.game.common.kit.StrKit;
import com.iohao.game.common.kit.exception.ThrowKit;
Expand Down Expand Up @@ -69,19 +70,19 @@ void print(BarSkeleton barSkeleton, BarSkeletonSetting setting) {
PrintActionKit.printActionCommand(barSkeleton.actionCommandRegions.actionCommands, setting.printActionShort);
}

System.out.println();
IoGameBanner.println();
}

private static void extractedRunners(BarSkeleton barSkeleton) {
Runners runners = barSkeleton.runners;
List<String> nameList = runners.listRunnerName();
String title = "@|CYAN ======================== Runners ========================= |@";
System.out.println(Ansi.ansi().render(title));
System.out.println("如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printRunners");
IoGameBanner.println(Ansi.ansi().render(title));
IoGameBanner.println("如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printRunners");

for (String name : nameList) {
String info = String.format("@|BLUE %s |@", name);
System.out.println(Ansi.ansi().render(info));
IoGameBanner.println(Ansi.ansi().render(info));
}
}

Expand All @@ -92,41 +93,41 @@ private static void extractedRunners(BarSkeleton barSkeleton) {
*/
void printInout(List<ActionMethodInOut> inOuts) {
String title = "@|CYAN ======================== InOut ========================= |@";
System.out.println(Ansi.ansi().render(title));
System.out.println("如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printInout");
IoGameBanner.println(Ansi.ansi().render(title));
IoGameBanner.println("如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printInout");

for (ActionMethodInOut inOut : inOuts) {
String info = String.format("@|BLUE %s |@", inOut.getClass());
System.out.println(Ansi.ansi().render(info));
IoGameBanner.println(Ansi.ansi().render(info));
}
}

void printHandler(List<Handler> handlers) {
String iohaoTitle = "@|CYAN ======================== 业务框架 iohao ========================= |@";
System.out.println(Ansi.ansi().render(iohaoTitle));
System.out.println(IoGameVersion.VERSION);
IoGameBanner.println(Ansi.ansi().render(iohaoTitle));
IoGameBanner.println(IoGameVersion.VERSION);
String colorStr = "@|BLACK BLACK|@ @|RED RED|@ @|GREEN GREEN|@ @|YELLOW YELLOW|@ @|BLUE BLUE|@ @|MAGENTA MAGENTA|@ @|CYAN CYAN|@ @|WHITE WHITE|@ @|DEFAULT DEFAULT|@";
System.out.println(Ansi.ansi().render(colorStr));
IoGameBanner.println(Ansi.ansi().render(colorStr));

String title = "@|CYAN ======================== Handler ========================= |@";
System.out.println(Ansi.ansi().render(title));
System.out.println("如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printHandler");
IoGameBanner.println(Ansi.ansi().render(title));
IoGameBanner.println("如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printHandler");

for (Handler handler : handlers) {
String info = String.format("@|BLUE %s |@", handler.getClass());
System.out.println(Ansi.ansi().render(info));
IoGameBanner.println(Ansi.ansi().render(info));
}
}

void printActionCommand(ActionCommand[][] behaviors, boolean shortName) {
String title = "@|CYAN ======================== action ========================= |@";
System.out.println(Ansi.ansi().render(title));
IoGameBanner.println(Ansi.ansi().render(title));

String tip = """
如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printAction;
如需要打印(class method params return)完整的包名, 查看 BarSkeletonBuilder#setting#printActionShort;
""";
System.out.print(tip);
IoGameBanner.print(tip);

for (int cmd = 0; cmd < behaviors.length; cmd++) {
ActionCommand[] subBehaviors = behaviors[cmd];
Expand Down Expand Up @@ -199,7 +200,7 @@ void printActionCommand(ActionCommand[][] behaviors, boolean shortName) {

String lineTemplate = "{routeCell} {actionCell} {actionNameCell}.{methodNameCell}({paramInfoCell}) {throwCell} --- return {returnValueCell} ~~~ see.({actionSimpleName}.java:{lineNumber})";
String text = StrKit.format(lineTemplate, params);
System.out.println(Ansi.ansi().render(text));
IoGameBanner.println(Ansi.ansi().render(text));
}
}
}
Expand All @@ -208,11 +209,11 @@ void printDataCodec() {
DataCodec dataCodec = DataCodecKit.dataCodec;

String title = "@|CYAN ======================== 当前使用的编解码器 ========================= |@";
System.out.println(Ansi.ansi().render(title));
System.out.println("如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printDataCodec");
IoGameBanner.println(Ansi.ansi().render(title));
IoGameBanner.println("如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printDataCodec");

String info = String.format("@|BLUE %s - %s |@", dataCodec.codecName(), dataCodec.getClass().getName());
System.out.println(Ansi.ansi().render(info));
IoGameBanner.println(Ansi.ansi().render(info));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.iohao.game.action.skeleton.protocol.HeadMetadata;
import com.iohao.game.action.skeleton.protocol.ResponseMessage;
import com.iohao.game.action.skeleton.protocol.wrapper.ByteValueList;
import com.iohao.game.action.skeleton.toy.IoGameBanner;
import com.iohao.game.common.kit.CollKit;
import com.iohao.game.common.kit.StrKit;
import lombok.Setter;
Expand Down Expand Up @@ -112,7 +113,7 @@ public final class DebugInOut implements ActionMethodInOut {
@Setter
BiConsumer<String, FlowContext> printConsumer = (message, flowContext) -> {
// 打印 message
System.out.println(message);
IoGameBanner.println(message);
};

public DebugInOut() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.esotericsoftware.reflectasm.MethodAccess;
import com.iohao.game.action.skeleton.core.IoGameCommonCoreConfig;
import com.iohao.game.action.skeleton.core.commumication.BrokerClientContext;
import com.iohao.game.action.skeleton.toy.IoGameBanner;
import com.iohao.game.common.kit.CollKit;
import com.iohao.game.common.kit.MoreKit;
import com.iohao.game.common.kit.collect.ListMultiMap;
Expand Down Expand Up @@ -780,7 +781,7 @@ private void extractedPrint(EventBusMessage eventBusMessage) {
log.info("远程逻辑服 : {}", eventBrokerClientMessage.getAppName());
}

System.out.println();
IoGameBanner.println();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import static java.lang.System.out;

/**
* ioGame Banner , 不提供关闭 Banner 的方法,让开发者含泪看完 Banner
*
Expand Down Expand Up @@ -97,6 +99,26 @@ public void ofRuntimeException(String message) {
render();
}

public static void println() {
out.println();
}

public static void print(String message) {
out.print(message);
}

public static void print(Object message) {
out.print(message);
}

public static void println(Object message) {
out.println(message);
}

public static void println(String message) {
out.println(message);
}

private void renderBanner() {
print.set(true);

Expand All @@ -106,7 +128,7 @@ private void renderBanner() {
if (Objects.nonNull(IoGameBanner.me().countDownLatch)) {
boolean r = IoGameBanner.me().countDownLatch.await(5, TimeUnit.SECONDS);
if (!r) {
System.out.println("countDownLatch await is false");
IoGameBanner.println("countDownLatch await is false");
}
}
} catch (InterruptedException e) {
Expand Down Expand Up @@ -141,7 +163,7 @@ private void renderBanner() {

clean();

System.out.println();
IoGameBanner.println();
};

TaskKit.execute(runnable);
Expand Down Expand Up @@ -175,21 +197,21 @@ private void extractedBreakingNews() {
System.out.printf("| News | %s%n", news);
}

System.out.println("+----------+--------------------------------------------------------------------------------------");
IoGameBanner.println("+----------+--------------------------------------------------------------------------------------");
}

private void extractedAdv() {
String s = BreakingNews.randomAdv().toString();
String builder = "| adv | %s - %s%n";
System.out.printf(builder, "启动项广告位招租", s);
System.out.println("+----------+--------------------------------------------------------------------------------------");
IoGameBanner.println("+----------+--------------------------------------------------------------------------------------");
}

private void extractedIoGameJavadocApi() {
String s = BreakingNews.randomMainNews().toString();
String builder = "| | %s%n";
System.out.printf(builder, s);
System.out.println("+----------+--------------------------------------------------------------------------------------");
IoGameBanner.println("+----------+--------------------------------------------------------------------------------------");
}

private void extractedErrorCount() {
Expand All @@ -199,7 +221,7 @@ private void extractedErrorCount() {

String builder = "| Error | error count : %s%n";
System.out.printf(builder, errorCount.get());
System.out.println("+----------+--------------------------------------------------------------------------------------");
IoGameBanner.println("+----------+--------------------------------------------------------------------------------------");
}

private void extractedMiss() {
Expand All @@ -210,7 +232,7 @@ private void extractedMiss() {
builder = "| | (%s)%n";
System.out.printf(builder, desc);

System.out.println("+----------+--------------------------------------------------------------------------------------");
IoGameBanner.println("+----------+--------------------------------------------------------------------------------------");
}

private void extractedPrint(ToyTable table) {
Expand All @@ -222,8 +244,8 @@ private void extractedPrint(ToyTable table) {
var anyFunction = new BannerColorStrategy().anyColorFun();
String anyBanner = anyFunction.apply(banner);

System.out.println();
System.out.println(anyBanner);
IoGameBanner.println();
IoGameBanner.println(anyBanner);
table.render();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void render() {

// table last
builder.append("+").append(this.lastLine);
System.out.println(builder);
IoGameBanner.println(builder);
}

void line(int keyMaxLen, int valueMaxLen) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.iohao.game.action.skeleton.core.action.ExampleActionCmd;
import com.iohao.game.action.skeleton.core.action.pojo.BeeApple;
import com.iohao.game.action.skeleton.core.data.TestDataKit;
import com.iohao.game.action.skeleton.toy.IoGameBanner;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -50,11 +51,11 @@ public void newBuilder() {

// 业务框架处理用户请求
barSkeleton.handle(flowContext);
System.out.println();
IoGameBanner.println();

// 业务框架处理用户请求
barSkeleton.handle(flowContext);
System.out.println();
IoGameBanner.println();
}

@Test
Expand All @@ -72,6 +73,6 @@ public void testVoid() {

// 业务框架处理用户请求
barSkeleton.handle(flowContext);
System.out.println();
IoGameBanner.println();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.iohao.game.action.skeleton.core.flow.ActionMethodInOut;
import com.iohao.game.action.skeleton.core.flow.FlowContext;
import com.iohao.game.action.skeleton.core.flow.attr.FlowOption;
import com.iohao.game.action.skeleton.toy.IoGameBanner;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Test;
Expand All @@ -28,17 +29,17 @@ public void test() {
inOutList.add(new B_ActionMethodInOut());
inOutList.add(new C_ActionMethodInOut());

System.out.println("------ 测试多个 inout ------");
IoGameBanner.println("------ 测试多个 inout ------");
extracted(InOutManager.ofAbcAbc(), "Ain Bin Cin Aout Bout Cout", inOutList);
extracted(InOutManager.ofPipeline(), "Ain Bin Cin Cout Bout Aout", inOutList);

// 测试单个 inout
System.out.println("------ 测试 1 个 inout ------");
IoGameBanner.println("------ 测试 1 个 inout ------");
extracted(InOutManager.ofAbcAbc(), "Ain Aout", List.of(new A_ActionMethodInOut()));
extracted(InOutManager.ofPipeline(), "Ain Aout", List.of(new A_ActionMethodInOut()));

// 测试 0 个 inout
System.out.println("------ 测试 0 个 inout ------");
IoGameBanner.println("------ 测试 0 个 inout ------");
extracted(InOutManager.ofAbcAbc(), "", Collections.emptyList());
extracted(InOutManager.ofPipeline(), "", Collections.emptyList());
}
Expand All @@ -57,7 +58,7 @@ private void extracted(InOutManager inOutManager, String result, List<ActionMeth
var line = String.join(" ", resultList);
Assert.assertEquals(line, result);

System.out.println();
IoGameBanner.println();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.iohao.game.action.skeleton.annotation.ActionController;
import com.iohao.game.action.skeleton.annotation.ActionMethod;
import com.iohao.game.action.skeleton.toy.IoGameBanner;
import lombok.extern.slf4j.Slf4j;

/**
Expand All @@ -31,6 +32,6 @@
public class SimpleWrapperAction {
@ActionMethod(ExampleActionCmd.SimpleWrapperActionActionCmd.testInt)
public void testInt(int age) {
System.out.println(age);
IoGameBanner.println(age);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.iohao.game.action.skeleton.core.flow.FlowContext;
import com.iohao.game.action.skeleton.core.flow.internal.DebugInOut;
import com.iohao.game.action.skeleton.protocol.RequestMessage;
import com.iohao.game.action.skeleton.toy.IoGameBanner;
import com.iohao.game.common.kit.ClassScanner;
import lombok.experimental.UtilityClass;

Expand All @@ -44,7 +45,7 @@ public BarSkeletonBuilder createBuilder(Predicate<Class<?>> appendPredicateFilte

builder.addInOut(new DebugInOut());

builder.setActionAfter(flowContext -> System.out.println());
builder.setActionAfter(flowContext -> IoGameBanner.println());

List<Class<?>> classList = getClasses(appendPredicateFilter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.iohao.game.action.skeleton.core.CmdInfo;
import com.iohao.game.action.skeleton.core.flow.FlowContext;
import com.iohao.game.action.skeleton.protocol.RequestMessage;
import com.iohao.game.action.skeleton.toy.IoGameBanner;
import com.iohao.game.common.kit.RandomKit;
import org.junit.Test;

Expand Down Expand Up @@ -31,7 +32,7 @@ public void testStatActionInOut() {
flowContext.setRequest(requestMessage);
extracted(region, flowContext);

region.stream().forEach(System.out::println);
region.stream().forEach(IoGameBanner::println);
}

private void setListener(StatActionInOut inOut) {
Expand Down
Loading

0 comments on commit 102b1f1

Please sign in to comment.