├── _config.yml ├── docs ├── _config.yml └── index.md ├── .settings └── .gitignore ├── gamioo-event ├── .settings │ └── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── gamioo │ │ │ └── event │ │ │ ├── package-info.java │ │ │ └── EventService.java │ └── test │ │ ├── resources │ │ ├── log4j2.component.properties │ │ └── log4j2.xml │ │ └── java │ │ └── io │ │ └── gamioo │ │ └── event │ │ └── guava │ │ ├── MainT.java │ │ ├── UserLoginEvent.java │ │ ├── StageEventHandler.java │ │ ├── UserEventHandler.java │ │ └── BaseEvent.java └── build.gradle ├── gamioo-game ├── .settings │ └── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── gamioo │ │ │ └── game │ │ │ ├── activity │ │ │ └── package-info.java │ │ │ ├── Main.java │ │ │ └── word │ │ │ └── DirtyWordUnit.java │ └── test │ │ ├── resources │ │ └── log4j2.component.properties │ │ └── java │ │ └── io │ │ └── gamioo │ │ └── game │ │ └── DeviationDTO.java └── build.gradle ├── gamioo-ioc ├── .settings │ └── .gitignore ├── build.gradle └── src │ ├── test │ ├── resources │ │ ├── log4j2.component.properties │ │ ├── junit-platform.properties │ │ ├── ioc.xml │ │ ├── gate-config.xml │ │ └── log4j2.xml │ └── java │ │ └── io │ │ └── gamioo │ │ └── ioc │ │ ├── map │ │ ├── Command.java │ │ ├── AddRmbCommand.java │ │ ├── AddItemCommand.java │ │ └── AddMoneyCommand.java │ │ ├── SkillService.java │ │ ├── skill │ │ ├── AbstractSkill.java │ │ ├── SkillA.java │ │ └── SkillB.java │ │ ├── DebugService.java │ │ ├── action │ │ └── UserController.java │ │ ├── RoleService.java │ │ ├── entity │ │ ├── DB.java │ │ ├── Cache.java │ │ └── Server.java │ │ ├── MapTest.java │ │ └── XmlBeanFactoryTest.java │ └── main │ └── java │ └── io │ └── gamioo │ └── ioc │ ├── stereotype │ ├── Repository.java │ ├── package-info.java │ ├── Resource.java │ ├── Service.java │ ├── Component.java │ └── Controller.java │ ├── definition │ ├── ResourceBeanDefinition.java │ ├── MapFieldDefinition.java │ ├── ListFieldDefinition.java │ ├── FieldDefinition.java │ ├── Definition.java │ ├── MethodDefinition.java │ ├── BeanDefinition.java │ ├── GenericFieldDefinition.java │ └── ControllerBeanDefinition.java │ ├── annotation │ ├── Value.java │ ├── Scheduled.java │ ├── Bean.java │ ├── Subscribe.java │ ├── Mapping.java │ ├── Attribute.java │ ├── Configuration.java │ ├── CommandMapping.java │ ├── RequestMapping.java │ └── AnnotationBeanDefinitionReader.java │ ├── io │ ├── ResourceCallback.java │ ├── UrlFileResource.java │ ├── Resource.java │ ├── ResourceLoader.java │ ├── JarClassResource.java │ ├── FileClassResource.java │ └── AbstractResource.java │ ├── type │ ├── AnnotationMetadata.java │ ├── AnnotatedTypeMetadata.java │ ├── classreading │ │ ├── MetadataReader.java │ │ └── AnnotationMetadataReadingVisitor.java │ └── MethodMetadata.java │ ├── factory │ ├── support │ │ ├── BeanDefinitionReader.java │ │ ├── DefaultListableBeanFactory.java │ │ └── AbstractBeanDefinitionReader.java │ ├── annotation │ │ └── Autowired.java │ ├── ObjectFactory.java │ ├── BeanFactory.java │ └── xml │ │ └── XmlResourceLoader.java │ ├── config │ ├── BeanFactoryPostProcessor.java │ ├── BeanPostProcessor.java │ └── BeanReference.java │ ├── context │ └── ApplicationContext.java │ ├── PropertyValue.java │ ├── PropertyValues.java │ └── wrapper │ ├── BeanWrapper.java │ ├── Command.java │ └── MethodWrapper.java ├── gamioo-log ├── .settings │ └── .gitignore ├── src │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── gamioo │ │ │ │ └── log │ │ │ │ ├── package-info.java │ │ │ │ └── MainT.java │ │ └── resources │ │ │ ├── log4j2.component.properties │ │ │ └── log4j2.xml │ └── test │ │ ├── java │ │ └── io │ │ │ └── gamioo │ │ │ └── log │ │ │ └── Main.java │ │ └── resources │ │ └── log4j2.xml └── build.gradle ├── gamioo-network ├── .settings │ └── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── gamioo │ │ │ └── network │ │ │ └── package-info.java │ └── test │ │ └── java │ │ └── io │ │ └── gamioo │ │ └── network │ │ └── MainT.java └── build.gradle ├── gamioo-orm ├── .settings │ └── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── gamioo │ │ │ └── orm │ │ │ ├── package-info.java │ │ │ └── OrmService.java │ └── test │ │ └── java │ │ └── io │ │ └── gamioo │ │ └── orm │ │ └── MainT.java └── build.gradle ├── gamioo-redis ├── .settings │ └── .gitignore ├── build.gradle └── src │ ├── main │ └── java │ │ └── io │ │ └── gamioo │ │ └── redis │ │ └── zset │ │ ├── generic │ │ ├── ZScoreRangeSpec.java │ │ ├── Entry.java │ │ ├── ScoreHandler.java │ │ └── ScoreRangeSpec.java │ │ ├── object2long │ │ ├── ZLongScoreRangeSpec.java │ │ ├── Object2LongEntry.java │ │ ├── LongScoreHandler.java │ │ ├── LongScoreRangeSpec.java │ │ └── LongScoreHandlers.java │ │ └── long2object │ │ └── Long2ObjectEntry.java │ └── test │ └── java │ └── io │ └── gamioo │ └── redis │ └── zset │ └── object2long │ └── Object2LongZSetTest.java ├── gamioo-protocol ├── .settings │ └── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── gamioo │ │ │ └── protocol │ │ │ ├── package-info.java │ │ │ └── ProtocolService.java │ └── test │ │ └── java │ │ └── io │ │ └── gamioo │ │ └── protocol │ │ └── MainT.java └── build.gradle ├── version.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gamioo-navigation ├── src │ ├── main │ │ ├── resources │ │ │ ├── recast.dll │ │ │ ├── recast.so │ │ │ └── solo_navmesh.bin │ │ └── java │ │ │ └── io │ │ │ └── gamioo │ │ │ └── nav │ │ │ ├── Main.java │ │ │ └── INav.java │ ├── jmh │ │ └── resources │ │ │ └── solo_navmesh.bin │ └── test │ │ └── resources │ │ └── solo_navmesh.bin └── build.gradle ├── .gitattributes ├── gamioo-sandbox ├── src │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── gamioo │ │ │ └── sandbox │ │ │ ├── LoginGame_S2C_Msg.java │ │ │ ├── SkillCategory.java │ │ │ ├── SerializingUtil.java │ │ │ ├── HarmDTO.java │ │ │ └── SkillFire_S2C_Msg.java │ ├── jmh │ │ ├── resources │ │ │ └── message.txt │ │ └── java │ │ │ └── io │ │ │ └── gamioo │ │ │ └── sandbox │ │ │ ├── AsymmetricBenchMark.java │ │ │ ├── SymmetricBenchmark.java │ │ │ └── InterruptBenchmark.java │ └── test │ │ ├── resources │ │ └── message.txt │ │ └── java │ │ └── io │ │ └── gamioo │ │ └── sandbox │ │ ├── Base64Test.java │ │ ├── AnsibleTest.java │ │ ├── CryptoTest.java │ │ └── BitMapTest.java └── build.gradle ├── gamioo-compress ├── src │ ├── jmh │ │ └── resources │ │ │ ├── mini.txt │ │ │ ├── short.txt │ │ │ └── message.txt │ └── main │ │ ├── java │ │ └── io │ │ │ └── gamioo │ │ │ └── compress │ │ │ └── Main.java │ │ └── resources │ │ └── message.txt └── build.gradle ├── gamioo-common ├── src │ ├── test │ │ ├── resources │ │ │ ├── log4j2.component.properties │ │ │ ├── junit-platform.properties │ │ │ ├── gate-config.xml │ │ │ └── log4j2.xml │ │ └── java │ │ │ └── io │ │ │ └── gamioo │ │ │ ├── MainT.java │ │ │ └── JsonXmlUtilTest.java │ └── main │ │ └── java │ │ └── io │ │ └── gamioo │ │ └── common │ │ ├── constant │ │ ├── CacheConstant.java │ │ ├── Describe.java │ │ ├── TimeConstant.java │ │ └── ModuleConstant.java │ │ ├── util │ │ ├── JVMUtil.java │ │ ├── JSONUtils.java │ │ ├── NativeUtils.java │ │ ├── CharsetUtils.java │ │ ├── AnnotationUtils.java │ │ ├── ByteArrayUtils.java │ │ └── ThreadUtils.java │ │ ├── shape │ │ ├── Shape.java │ │ └── AABB.java │ │ ├── exception │ │ ├── NoPublicFieldException.java │ │ ├── BeansException.java │ │ ├── NoPublicMethodException.java │ │ ├── ServiceException.java │ │ ├── ServerBootstrapException.java │ │ └── NestedIOException.java │ │ ├── vector │ │ └── Vector3f.java │ │ ├── http │ │ └── RequestMethod.java │ │ ├── concurrent │ │ ├── NameableThreadFactory.java │ │ └── Group.java │ │ └── lang │ │ ├── ServerInfo.java │ │ └── Cache.java └── build.gradle ├── gamioo-cache └── build.gradle ├── settings.gradle ├── gamioo-config └── build.gradle ├── .github ├── FUNDING.yml └── workflows │ ├── gradle.yml │ └── gradle-publish.yml ├── .gitignore └── README.md /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect -------------------------------------------------------------------------------- /.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.buildship.core.prefs 2 | -------------------------------------------------------------------------------- /gamioo-event/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.buildship.core.prefs 2 | -------------------------------------------------------------------------------- /gamioo-game/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.buildship.core.prefs 2 | -------------------------------------------------------------------------------- /gamioo-ioc/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.buildship.core.prefs 2 | -------------------------------------------------------------------------------- /gamioo-log/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.buildship.core.prefs 2 | -------------------------------------------------------------------------------- /gamioo-network/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.buildship.core.prefs 2 | -------------------------------------------------------------------------------- /gamioo-orm/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.buildship.core.prefs 2 | -------------------------------------------------------------------------------- /gamioo-redis/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.buildship.core.prefs 2 | -------------------------------------------------------------------------------- /gamioo-orm/src/main/java/io/gamioo/orm/package-info.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.orm; -------------------------------------------------------------------------------- /gamioo-protocol/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.buildship.core.prefs 2 | -------------------------------------------------------------------------------- /gamioo-event/src/main/java/io/gamioo/event/package-info.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.event; -------------------------------------------------------------------------------- /gamioo-network/src/main/java/io/gamioo/network/package-info.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.network; -------------------------------------------------------------------------------- /gamioo-orm/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':gamioo-common'); 3 | } -------------------------------------------------------------------------------- /gamioo-protocol/src/main/java/io/gamioo/protocol/package-info.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.protocol; -------------------------------------------------------------------------------- /gamioo-event/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':gamioo-common'); 3 | 4 | } -------------------------------------------------------------------------------- /version.properties: -------------------------------------------------------------------------------- 1 | #version info 2 | #Fri Mar 10 20:15:12 CST 2023 3 | release=18 4 | date=20230310 5 | -------------------------------------------------------------------------------- /gamioo-log/src/main/java/io/gamioo/log/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 日志库. 3 | */ 4 | package io.gamioo.log; -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangguilong2000/gamioo/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gamioo-navigation/src/main/resources/recast.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangguilong2000/gamioo/HEAD/gamioo-navigation/src/main/resources/recast.dll -------------------------------------------------------------------------------- /gamioo-navigation/src/main/resources/recast.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangguilong2000/gamioo/HEAD/gamioo-navigation/src/main/resources/recast.so -------------------------------------------------------------------------------- /gamioo-navigation/src/jmh/resources/solo_navmesh.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangguilong2000/gamioo/HEAD/gamioo-navigation/src/jmh/resources/solo_navmesh.bin -------------------------------------------------------------------------------- /gamioo-navigation/src/main/resources/solo_navmesh.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangguilong2000/gamioo/HEAD/gamioo-navigation/src/main/resources/solo_navmesh.bin -------------------------------------------------------------------------------- /gamioo-navigation/src/test/resources/solo_navmesh.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangguilong2000/gamioo/HEAD/gamioo-navigation/src/test/resources/solo_navmesh.bin -------------------------------------------------------------------------------- /gamioo-orm/src/main/java/io/gamioo/orm/OrmService.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.orm; 2 | 3 | /** 4 | * @author Allen Jiang 5 | */ 6 | public class OrmService { 7 | } 8 | -------------------------------------------------------------------------------- /gamioo-event/src/main/java/io/gamioo/event/EventService.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.event; 2 | 3 | /** 4 | * @author Allen Jiang 5 | */ 6 | public class EventService { 7 | } 8 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /gamioo-protocol/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':gamioo-common'); 3 | implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.16.3'; 4 | } -------------------------------------------------------------------------------- /gamioo-protocol/src/main/java/io/gamioo/protocol/ProtocolService.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.protocol; 2 | 3 | /** 4 | * @author Allen Jiang 5 | */ 6 | public class ProtocolService { 7 | } 8 | -------------------------------------------------------------------------------- /gamioo-ioc/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':gamioo-common'); 3 | // implementation group: 'org.jenkins-ci.plugins', name: 'plugin', version: '4.33' 4 | } 5 | 6 | -------------------------------------------------------------------------------- /gamioo-sandbox/src/main/java/io/gamioo/sandbox/LoginGame_S2C_Msg.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.sandbox; 2 | 3 | /** 4 | * @author Allen Jiang 5 | */ 6 | public class LoginGame_S2C_Msg { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /gamioo-compress/src/jmh/resources/mini.txt: -------------------------------------------------------------------------------- 1 | {code { 2 | flag: 1 3 | id: 1 4 | } 5 | tableId: 936940 6 | ownerId: 143566 7 | createId: 143566 8 | roomTemplateId: 4 9 | configTemplateId: 1101 10 | } -------------------------------------------------------------------------------- /gamioo-game/src/main/java/io/gamioo/game/activity/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * some description 3 | * 4 | * @author Allen Jiang 5 | * @since 1.0.0 6 | */ 7 | package io.gamioo.game.activity; 8 | /**活动系统*/ -------------------------------------------------------------------------------- /gamioo-event/src/test/resources/log4j2.component.properties: -------------------------------------------------------------------------------- 1 | Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector 2 | # default values is 256*1024 3 | AsyncLogger.RingBufferSize=131072 -------------------------------------------------------------------------------- /gamioo-game/src/test/resources/log4j2.component.properties: -------------------------------------------------------------------------------- 1 | Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector 2 | # default values is 256*1024 3 | AsyncLogger.RingBufferSize=131072 -------------------------------------------------------------------------------- /gamioo-ioc/src/test/resources/log4j2.component.properties: -------------------------------------------------------------------------------- 1 | Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector 2 | # default values is 256*1024 3 | AsyncLogger.RingBufferSize=131072 -------------------------------------------------------------------------------- /gamioo-log/src/test/java/io/gamioo/log/Main.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.log; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | System.out.println(); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /gamioo-common/src/test/resources/log4j2.component.properties: -------------------------------------------------------------------------------- 1 | Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector 2 | # default values is 256*1024 3 | AsyncLogger.RingBufferSize=131072 -------------------------------------------------------------------------------- /gamioo-log/src/main/java/io/gamioo/log/MainT.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.log; 2 | 3 | public class MainT { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("hello ketty"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /gamioo-network/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':gamioo-common'); 3 | implementation project(':gamioo-protocol'); 4 | api group: 'io.netty', name: 'netty-all', version: '4.1.89.Final'; 5 | } -------------------------------------------------------------------------------- /gamioo-orm/src/test/java/io/gamioo/orm/MainT.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.orm; 2 | 3 | public class MainT { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("hello ketty11"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /gamioo-game/src/main/java/io/gamioo/game/Main.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.game; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("hello,soyabean"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /gamioo-network/src/test/java/io/gamioo/network/MainT.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.network; 2 | 3 | public class MainT { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("hello ketty11"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /gamioo-protocol/src/test/java/io/gamioo/protocol/MainT.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.protocol; 2 | 3 | public class MainT { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("hello ketty11"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /gamioo-log/src/main/resources/log4j2.component.properties: -------------------------------------------------------------------------------- 1 | Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector 2 | # default values is 256*1024 3 | AsyncLogger.RingBufferSize=131072 4 | isThreadContextMapInheritable=false -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/constant/CacheConstant.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.constant; 2 | 3 | /** 4 | * @author Allen Jiang 5 | */ 6 | public class CacheConstant { 7 | public static final String RECORD = "record"; 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/map/Command.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.map; 2 | 3 | /** 4 | * some description 5 | * 6 | * @author Allen Jiang 7 | * @since 1.0.0 8 | */ 9 | public interface Command { 10 | 11 | void execute(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /gamioo-redis/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':gamioo-common'); 3 | implementation 'it.unimi.dsi:fastutil:8.3.0' 4 | implementation 'redis.clients:jedis:3.3.0'; 5 | implementation group: 'io.lettuce', name: 'lettuce-core', version: '6.2.3.RELEASE'; 6 | } -------------------------------------------------------------------------------- /gamioo-event/src/test/java/io/gamioo/event/guava/MainT.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.event.guava; 2 | 3 | public class MainT { 4 | 5 | public static void main(String[] args) { 6 | UserLoginEvent event=new UserLoginEvent(); 7 | event.subscribe(); 8 | event.publish("Allen"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /gamioo-navigation/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':gamioo-common'); 3 | // implementation 'com.github.silencesu:Easy3dNav:1.1.0'; 4 | implementation('com.github.silencesu:Easy3dNav:1.1.0') { 5 | exclude group: "ch.qos.logback", module: "logback-classic" 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /gamioo-cache/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api project(':gamioo-log'); 3 | api group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '2.8.5' 4 | api group: 'com.google.guava', name: 'guava', version: '31.1-jre' 5 | api group: 'org.apache.commons', name: 'commons-lang3', version: '3.11' 6 | 7 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | org.gradle.jvmargs=-Dfile.encoding=UTF-8 7 | systemProp.org.gradle.internal.publish.checksums.insecure=true -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'gamioo'; 2 | 3 | // 基础模块 4 | include 'gamioo-common', 'gamioo-navigation', "gamioo-cache", "gamioo-compress", 'gamioo-config', "gamioo-protocol", "gamioo-network", "gamioo-event", "gamioo-orm", "gamioo-ioc", "gamioo-redis", "gamioo-log"; 5 | //测试沙箱模块 6 | include 'gamioo-sandbox' 7 | // 游戏服务器 8 | include "gamioo-game"; 9 | 10 | -------------------------------------------------------------------------------- /gamioo-game/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':gamioo-network'); 3 | implementation project(':gamioo-common'); 4 | implementation project(':gamioo-compress'); 5 | 6 | // testImplementation project(':gamioo-orm'); 7 | // testImplementation "com.alibaba:druid:1.0.27"; 8 | // testImplementation "mysql:mysql-connector-java:5.1.40"; 9 | } -------------------------------------------------------------------------------- /gamioo-config/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':gamioo-common'); 3 | implementation project(':gamioo-network'); 4 | implementation group: 'com.alibaba.nacos', name: 'nacos-client', version: '2.2.1-RC'; 5 | implementation group: 'org.yaml', name: 'snakeyaml', version: '2.0' 6 | // jetcd 7 | implementation 'io.etcd:jetcd-core:0.7.5' 8 | 9 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/stereotype/Repository.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.stereotype; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * Repository注解用来标识一个数据库处理类. 7 | * 8 | * @author Allen Jiang 9 | * @since 1.0.0 10 | */ 11 | 12 | @Component 13 | @Documented 14 | @Target(ElementType.TYPE) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | public @interface Repository { 17 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/definition/ResourceBeanDefinition.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.definition; 2 | 3 | import java.lang.annotation.Annotation; 4 | 5 | /** 6 | * 资源解析管理器的定义 7 | * 8 | * @author Allen Jiang 9 | * @since 1.0.0 10 | */ 11 | public class ResourceBeanDefinition extends GenericBeanDefinition{ 12 | public ResourceBeanDefinition(Class clazz, Annotation annotation) { 13 | super(clazz, annotation); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /gamioo-compress/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api project(':gamioo-common'); 3 | api group: 'com.github.luben', name: 'zstd-jni', version: '1.5.4-2'; 4 | api group: 'org.apache.commons', name: 'commons-compress', version: '1.21'; 5 | api group: 'commons-io', name: 'commons-io', version: '2.7'; 6 | api group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'; 7 | api group: 'info.debatty', name: 'java-string-similarity', version: '2.0.0' 8 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/annotation/Value.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * 注入配置文件中的属性. 7 | * 8 | * @author Allen Jiang 9 | * @since 1.0.0 10 | */ 11 | @Documented 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Target({ElementType.FIELD}) 14 | 15 | public @interface Value { 16 | 17 | /** 18 | * 属性配置文件中的配置键值. 19 | * 20 | * @return Key. 21 | */ 22 | String value(); 23 | } -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/constant/Describe.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.constant; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.FIELD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface Describe { 11 | 12 | String name(); 13 | 14 | //是否展示出来 15 | String description(); 16 | } 17 | -------------------------------------------------------------------------------- /gamioo-sandbox/src/jmh/resources/message.txt: -------------------------------------------------------------------------------- 1 | {"attackerId":2013850838,"harmList":[{"curHp":1061639.1,"dead":true,"maxHp":972081.06,"real":36249,"targetId":1711281434,"type":84,"value":18168.72},{"curHp":836323.44,"dead":true,"maxHp":8546706.0,"real":91675,"targetId":1527336063,"type":22,"value":30714.76},{"curHp":2022717.6,"dead":true,"maxHp":8923567.0,"real":74008,"targetId":1684460215,"type":67,"value":93250.83}],"index":37,"param1":[7153337,1918282,5243103,1985757,7515730],"skillCategory":"ATTACK_PASSIVE"} 2 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/util/JVMUtil.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.util; 2 | 3 | import java.lang.management.ManagementFactory; 4 | import java.util.List; 5 | 6 | /** 7 | * @author Allen Jiang 8 | */ 9 | public class JVMUtil { 10 | 11 | public static String getStartArgs() { 12 | String ret = ""; 13 | List list = ManagementFactory.getRuntimeMXBean().getInputArguments(); 14 | for (String e : list) { 15 | ret += e + " "; 16 | } 17 | return ret; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gamioo-sandbox/src/test/resources/message.txt: -------------------------------------------------------------------------------- 1 | {"attackerId":2013850838,"harmList":[{"curHp":1061639.1,"dead":true,"maxHp":972081.06,"real":36249,"targetId":1711281434,"type":84,"value":18168.72},{"curHp":836323.44,"dead":true,"maxHp":8546706.0,"real":91675,"targetId":1527336063,"type":22,"value":30714.76},{"curHp":2022717.6,"dead":true,"maxHp":8923567.0,"real":74008,"targetId":1684460215,"type":67,"value":93250.83}],"index":37,"param1":[7153337,1918282,5243103,1985757,7515730],"skillCategory":"ATTACK_PASSIVE"} 2 | -------------------------------------------------------------------------------- /gamioo-common/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | #\u7c7b\u5185\u90e8\u65b9\u6cd5\u5e76\u884c 3 | junit.jupiter.execution.parallel.mode.default = concurrent 4 | #\u7c7b\u4e4b\u95f4\u4e32\u884c 5 | junit.jupiter.execution.parallel.mode.classes.default = same_thread 6 | # the maximum pool size can be configured using a ParallelExecutionConfigurationStrategy 7 | junit.jupiter.execution.parallel.config.strategy=fixed 8 | junit.jupiter.execution.parallel.config.fixed.parallelism=8 -------------------------------------------------------------------------------- /gamioo-ioc/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled=true 2 | #\u7c7b\u5185\u90e8\u65b9\u6cd5\u5e76\u884c 3 | junit.jupiter.execution.parallel.mode.default = concurrent 4 | #\u7c7b\u4e4b\u95f4\u4e32\u884c 5 | junit.jupiter.execution.parallel.mode.classes.default = same_thread 6 | # the maximum pool size can be configured using a ParallelExecutionConfigurationStrategy 7 | junit.jupiter.execution.parallel.config.strategy=fixed 8 | junit.jupiter.execution.parallel.config.fixed.parallelism=8 -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/shape/Shape.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.shape; 2 | 3 | 4 | public interface Shape { 5 | /** 6 | * 是否包含指定的点 7 | * 8 | * @param x 点x 9 | * @param y 点y 10 | * 11 | * @return true:包含 12 | */ 13 | boolean containsPoint(long x, long y); 14 | 15 | /** 16 | * 获取aabb包围盒 17 | * 18 | * @return 包围盒 19 | */ 20 | AABB getAABB(); 21 | 22 | /** 23 | * 获取图形内随机一个点 24 | * 25 | * @return 点 26 | */ 27 | Point getRandomPoint(); 28 | } 29 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/SkillService.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc; 2 | 3 | import io.gamioo.ioc.factory.annotation.Autowired; 4 | import io.gamioo.ioc.skill.AbstractSkill; 5 | import io.gamioo.ioc.stereotype.Service; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * some description 11 | * 12 | * @author Allen Jiang 13 | * @since 1.0.0 14 | */ 15 | @Service 16 | public class SkillService { 17 | 18 | @Autowired 19 | private List skillList; 20 | 21 | public List getSkillList() { 22 | return skillList; 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /gamioo-common/src/test/java/io/gamioo/MainT.java: -------------------------------------------------------------------------------- 1 | package io.gamioo; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | 6 | import java.util.Arrays; 7 | 8 | public class MainT { 9 | private static final Logger logger = LogManager.getLogger(MainT.class); 10 | 11 | public static void main(String[] args) { 12 | String packager = MainT.class.getPackage().getName(); 13 | String[] packages = Arrays.asList(packager, "io.gamioo").toArray(new String[]{}); 14 | logger.debug("init ioc, packages={}", packager); 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /gamioo-compress/src/jmh/resources/short.txt: -------------------------------------------------------------------------------- 1 | {code { 2 | flag: 1 3 | id: 1 4 | } 5 | tableId: 936940 6 | ownerId: 143566 7 | createId: 143566 8 | roomTemplateId: 4 9 | configTemplateId: 1101 10 | entryDTO { 11 | key: 1 12 | value: 3 13 | } 14 | entryDTO { 15 | key: 201 16 | value: 0 17 | } 18 | entryDTO { 19 | key: 202 20 | value: 0 21 | } 22 | entryDTO { 23 | key: 204 24 | value: 1 25 | } 26 | entryDTO { 27 | key: 4 28 | value: 6 29 | } 30 | entryDTO { 31 | key: 203 32 | value: 0 33 | } 34 | clubId: 0 35 | status: 0 36 | sitDownPosition: 0 37 | kingBormPokerDTO { 38 | id: 143566 39 | } 40 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/skill/AbstractSkill.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.skill; 2 | 3 | 4 | import org.apache.commons.lang3.builder.ToStringBuilder; 5 | import org.apache.commons.lang3.builder.ToStringStyle; 6 | 7 | /** 8 | * some description 9 | * 10 | * @author Allen Jiang 11 | * @since 1.0.0 12 | */ 13 | public abstract class AbstractSkill { 14 | 15 | public abstract void init(); 16 | 17 | public abstract void handle(); 18 | 19 | public String toString(){ 20 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /gamioo-compress/src/main/java/io/gamioo/compress/Main.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.compress; 2 | 3 | import io.gamioo.common.util.FileUtils; 4 | import org.apache.logging.log4j.LogManager; 5 | import org.apache.logging.log4j.Logger; 6 | 7 | import java.io.IOException; 8 | 9 | /** 10 | * @author Allen Jiang 11 | */ 12 | public class Main { 13 | private static final Logger logger = LogManager.getLogger(Main.class); 14 | 15 | public static void main(String[] args) throws IOException { 16 | byte[] array = FileUtils.getByteArrayFromFile("message.txt"); 17 | logger.debug("size:{}", array.length); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/map/AddRmbCommand.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.map; 2 | 3 | import io.gamioo.ioc.stereotype.Component; 4 | import org.apache.logging.log4j.LogManager; 5 | import org.apache.logging.log4j.Logger; 6 | 7 | /** 8 | * some description 9 | * 10 | * @author Allen Jiang 11 | * @since 1.0.0 12 | */ 13 | @Component(name="-- add rmb") 14 | public class AddRmbCommand implements Command { 15 | private static final Logger logger = LogManager.getLogger(AddRmbCommand.class); 16 | @Override 17 | public void execute() { 18 | logger.debug("{} execute",this.getClass().getSimpleName()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/map/AddItemCommand.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.map; 2 | 3 | import io.gamioo.ioc.stereotype.Component; 4 | import org.apache.logging.log4j.LogManager; 5 | import org.apache.logging.log4j.Logger; 6 | 7 | /** 8 | * some description 9 | * 10 | * @author Allen Jiang 11 | * @since 1.0.0 12 | */ 13 | @Component(name="-- add item") 14 | public class AddItemCommand implements Command { 15 | private static final Logger logger = LogManager.getLogger(AddItemCommand.class); 16 | @Override 17 | public void execute() { 18 | logger.debug("{} execute",this.getClass().getSimpleName()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/map/AddMoneyCommand.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.map; 2 | 3 | import io.gamioo.ioc.stereotype.Component; 4 | import org.apache.logging.log4j.LogManager; 5 | import org.apache.logging.log4j.Logger; 6 | 7 | /** 8 | * some description 9 | * 10 | * @author Allen Jiang 11 | * @since 1.0.0 12 | */ 13 | @Component(name="-- add money") 14 | public class AddMoneyCommand implements Command { 15 | private static final Logger logger = LogManager.getLogger(AddMoneyCommand.class); 16 | 17 | @Override 18 | public void execute() { 19 | logger.debug("{} execute",this.getClass().getSimpleName()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/definition/MapFieldDefinition.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.definition; 2 | 3 | import java.lang.reflect.Field; 4 | import java.lang.reflect.ParameterizedType; 5 | 6 | /** 7 | * Map类型的属性注入 8 | * 9 | * @author Allen Jiang 10 | * @since 1.0.0 11 | */ 12 | public class MapFieldDefinition extends GenericFieldDefinition { 13 | 14 | 15 | public MapFieldDefinition(Field field) { 16 | super(field); 17 | } 18 | 19 | @Override 20 | public Class getClazz() { 21 | Class ret = (Class) ((ParameterizedType) this.getField().getGenericType()).getActualTypeArguments()[1]; 22 | return ret; 23 | } 24 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/definition/ListFieldDefinition.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.definition; 2 | 3 | import java.lang.reflect.Field; 4 | import java.lang.reflect.ParameterizedType; 5 | 6 | /** 7 | * 所有实现此接口或继承此类的 8 | * 9 | * @author Allen Jiang 10 | * @since 1.0.0 11 | */ 12 | public class ListFieldDefinition extends GenericFieldDefinition { 13 | 14 | 15 | public ListFieldDefinition(Field field) { 16 | super(field); 17 | } 18 | 19 | @Override 20 | public Class getClazz() { 21 | Class ret = (Class) ((ParameterizedType) this.getField().getGenericType()).getActualTypeArguments()[0]; 22 | return ret; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/DebugService.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc; 2 | 3 | import io.gamioo.ioc.factory.annotation.Autowired; 4 | import io.gamioo.ioc.map.Command; 5 | import io.gamioo.ioc.stereotype.Service; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * some description 11 | * 12 | * @author Allen Jiang 13 | * @since 1.0.0 14 | */ 15 | @Service 16 | public class DebugService { 17 | 18 | @Autowired 19 | private Map commandStore; 20 | 21 | 22 | public void handle(String value){ 23 | Command command=commandStore.get(value); 24 | if(command!=null){ 25 | command.execute(); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /gamioo-sandbox/src/main/java/io/gamioo/sandbox/SkillCategory.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.sandbox; 2 | 3 | /** 4 | * @author Allen Jiang 5 | */ 6 | 7 | public enum SkillCategory { 8 | ATTACKED_PASSIVE(1," 受创时被动触发技能"), 9 | ACTIVE(2,"主动"), 10 | ATTACK_PASSIVE(3,"攻击时被动触发技能"), 11 | ATTRIBUTE_ATTRIBUTE(4,"属性技能"); 12 | 13 | private final int id; 14 | 15 | 16 | private final String message; 17 | 18 | SkillCategory(int id, String message) { 19 | this.id = id; 20 | 21 | this.message = message; 22 | } 23 | 24 | public int getId() { 25 | return id; 26 | } 27 | 28 | public String getMessage() { 29 | return message; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/exception/NoPublicFieldException.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.exception; 2 | 3 | /** 4 | * 在找不到指定Public属性时抛出. 5 | * 6 | * @author 小流氓[176543888@qq.com] 7 | * @since 3.3.6 8 | */ 9 | public class NoPublicFieldException extends ServiceException { 10 | 11 | 12 | public NoPublicFieldException(String message,Object... params) { 13 | super(message, params); 14 | } 15 | 16 | public NoPublicFieldException(String message, Throwable cause) { 17 | super(message, cause); 18 | } 19 | 20 | 21 | public NoPublicFieldException(Throwable cause, String message, Object... params) { 22 | super(cause, message, params); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gamioo-event/src/test/java/io/gamioo/event/guava/UserLoginEvent.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.event.guava; 2 | 3 | public class UserLoginEvent extends BaseEvent{ 4 | 5 | private String name; 6 | 7 | public String getName() { 8 | return name; 9 | } 10 | 11 | public void setName(String name) { 12 | this.name = name; 13 | } 14 | 15 | @Override 16 | public void subscribe() { 17 | this.eventBus.register(UserEventHandler.getInstance()); 18 | this.asyncEventBus.register(StageEventHandler.getInstance()); 19 | } 20 | public void publish(String name) { 21 | UserLoginEvent event=new UserLoginEvent(); 22 | event.setName(name); 23 | this.eventBus.post(event);//同步推送 24 | this.asyncEventBus.post(event);//异步推送 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gamioo-navigation/src/main/java/io/gamioo/nav/Main.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.nav; 2 | 3 | import java.io.IOException; 4 | 5 | public class Main { 6 | 7 | 8 | public static void main(String[] args) throws IOException { 9 | float[] extents = {1.f, 1.f, 1.f}; 10 | String navFilePath = "solo_navmesh.bin"; 11 | //初始化寻路对象 12 | Easy3dNav easyNav = new Easy3dNav(); 13 | //默认为true,可以忽略 14 | easyNav.setUseU3dData(false); 15 | //默认为false,查看需要设置为true 16 | easyNav.setPrintMeshInfo(false); 17 | easyNav.setExtents(extents); 18 | // File file = FileUtils.getFile(navFilePath); 19 | // assert file != null; 20 | easyNav.init(navFilePath); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/util/JSONUtils.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.util; 2 | 3 | import com.alibaba.fastjson2.JSONObject; 4 | import io.gamioo.common.exception.ServiceException; 5 | import org.dom4j.Document; 6 | import org.dom4j.Element; 7 | 8 | /** 9 | * some description 10 | * 11 | * @author Allen Jiang 12 | * @since 1.0.0 13 | */ 14 | public class JSONUtils { 15 | 16 | public static JSONObject loadFromXMLFile(String fileName) throws ServiceException { 17 | JSONObject ret = new JSONObject(); 18 | Document document = XMLUtil.loadFromFile(fileName); 19 | Element root = document.getRootElement(); 20 | JsonXmlUtil.xml2Json(root, ret); 21 | return ret; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/action/UserController.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.action; 2 | 3 | import io.gamioo.ioc.annotation.CommandMapping; 4 | import io.gamioo.ioc.stereotype.Controller; 5 | import org.apache.logging.log4j.LogManager; 6 | import org.apache.logging.log4j.Logger; 7 | 8 | /** 9 | * some description 10 | * 11 | * @author Allen Jiang 12 | * @since 1.0.0 13 | */ 14 | @Controller 15 | public class UserController { 16 | private static final Logger logger = LogManager.getLogger(UserController.class); 17 | @CommandMapping(code=10001,cross = true,print = false,login = false) 18 | public void login(Object session,String message){ 19 | logger.debug("object={},message={}",session,message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gamioo-log/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.1'; 3 | api group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.1'; 4 | api group: 'org.apache.logging.log4j', name: 'log4j-web', version: '2.17.1'; 5 | //桥接:告诉Slf4j使用Log4j2 6 | api group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.17.1'; 7 | //桥接:告诉commons logging使用 Log4j2 8 | api group: 'org.apache.logging.log4j', name: 'log4j-jcl', version: '2.17.1'; 9 | api group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'; 10 | // api group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.30'; 11 | api group: 'com.lmax', name: 'disruptor', version: '3.4.2'; 12 | } -------------------------------------------------------------------------------- /gamioo-event/src/test/java/io/gamioo/event/guava/StageEventHandler.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.event.guava; 2 | 3 | import com.google.common.eventbus.Subscribe; 4 | import org.apache.logging.log4j.LogManager; 5 | import org.apache.logging.log4j.Logger; 6 | 7 | public class StageEventHandler { 8 | private static final Logger logger = LogManager.getLogger(StageEventHandler.class); 9 | 10 | private static StageEventHandler instance; 11 | 12 | public static StageEventHandler getInstance() { 13 | if(instance==null) { 14 | instance=new StageEventHandler(); 15 | } 16 | return instance; 17 | } 18 | 19 | @Subscribe 20 | public void handle(UserLoginEvent event) { 21 | logger.debug("StageEventHandler.handle(UserLoginEvent event)"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/constant/TimeConstant.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.constant; 2 | 3 | import java.util.Date; 4 | 5 | public class TimeConstant { 6 | /** 7 | * 2020-01-01 00:00:00 8 | */ 9 | public static final long LONG_AGO = 1577808000000l; 10 | 11 | /** 12 | * 2020-01-01 00:00:00 13 | */ 14 | public static final Date DATE_LONG_AGO = new Date(LONG_AGO); 15 | /** 16 | * 一周毫秒时间 17 | */ 18 | public static final int ONE_WEEK_MS = 7 * 24 * 60 * 60 * 1000; 19 | 20 | public static void main(String[] args) { 21 | //68719476735 22 | 23 | //System.out.println(2051193600000l-1577808000000l); 24 | 25 | //System.out.println(TimeUtil.parse("2035-01-01","yyyy-MM-dd").getTime()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /gamioo-redis/src/main/java/io/gamioo/redis/zset/generic/ZScoreRangeSpec.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.redis.zset.generic; 2 | 3 | /** 4 | * {@link GenericZSet}中“score”范围描述信息 - specification模式 5 | */ 6 | public class ZScoreRangeSpec { 7 | /** 8 | * 最低分数 9 | */ 10 | public final S min; 11 | /** 12 | * 是否去除最低分 13 | * exclusive 14 | */ 15 | public final boolean minex; 16 | /** 17 | * 最高分数 18 | */ 19 | public final S max; 20 | /** 21 | * 是否去除最高分 22 | * exclusive 23 | */ 24 | public final boolean maxex; 25 | 26 | public ZScoreRangeSpec(S min, boolean minex, S max, boolean maxex) { 27 | this.min = min; 28 | this.minex = minex; 29 | this.max = max; 30 | this.maxex = maxex; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /gamioo-redis/src/main/java/io/gamioo/redis/zset/object2long/ZLongScoreRangeSpec.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.redis.zset.object2long; 2 | 3 | /** 4 | * {@link Object2LongZSet}中“score”范围描述信息 - specification模式 5 | */ 6 | public final class ZLongScoreRangeSpec { 7 | /** 8 | * 最低分数 9 | */ 10 | final long min; 11 | /** 12 | * 是否去除下限 13 | * exclusive 14 | */ 15 | final boolean minex; 16 | /** 17 | * 最高分数 18 | */ 19 | final long max; 20 | /** 21 | * 是否去除上限 22 | * exclusive 23 | */ 24 | final boolean maxex; 25 | 26 | public ZLongScoreRangeSpec(long min, boolean minex, long max, boolean maxex) { 27 | this.min = min; 28 | this.max = max; 29 | this.minex = minex; 30 | this.maxex = maxex; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/skill/SkillA.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.skill; 2 | 3 | import io.gamioo.ioc.stereotype.Component; 4 | import org.apache.logging.log4j.LogManager; 5 | import org.apache.logging.log4j.Logger; 6 | 7 | import javax.annotation.PostConstruct; 8 | 9 | /** 10 | * some description 11 | * 12 | * @author Allen Jiang 13 | * @since 1.0.0 14 | */ 15 | @Component(name="A") 16 | public class SkillA extends AbstractSkill{ 17 | private static final Logger logger = LogManager.getLogger(SkillA.class); 18 | 19 | @PostConstruct 20 | public void init() { 21 | logger.debug("{} init",this.getClass().getSimpleName()); 22 | } 23 | 24 | @Override 25 | public void handle() { 26 | logger.debug("{} handle",this.getClass().getSimpleName()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /gamioo-sandbox/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':gamioo-common'); 3 | implementation 'org.furyio:fury-core:0.1.0' 4 | implementation group: 'io.protostuff', name: 'protostuff-core', version: '1.8.0' 5 | implementation group: 'io.protostuff', name: 'protostuff-runtime', version: '1.8.0' 6 | implementation group: 'com.carrotsearch', name: 'java-sizeof', version: '0.0.5' 7 | testImplementation group: 'org.springframework.security', name: 'spring-security-crypto', version: '5.8.2' 8 | testImplementation 'org.tmatesoft.svnkit:svnkit:1.10.11' 9 | implementation 'com.github.houbb:data-factory-core:1.2.0' 10 | testImplementation('com.github.woostju:ansible-client:1.0.0-RELEASE') { 11 | exclude group: "ch.qos.logback", module: "logback-classic" 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/skill/SkillB.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.skill; 2 | 3 | import io.gamioo.ioc.stereotype.Component; 4 | import org.apache.logging.log4j.LogManager; 5 | import org.apache.logging.log4j.Logger; 6 | 7 | import javax.annotation.PostConstruct; 8 | 9 | /** 10 | * some description 11 | * 12 | * @author Allen Jiang 13 | * @since 1.0.0 14 | */ 15 | @Component(name="B") 16 | public class SkillB extends AbstractSkill{ 17 | private static final Logger logger = LogManager.getLogger(SkillB.class); 18 | @Override 19 | @PostConstruct 20 | public void init() { 21 | logger.debug("{} init",this.getClass().getSimpleName()); 22 | } 23 | 24 | @Override 25 | public void handle() { 26 | logger.debug("{} handle",this.getClass().getSimpleName()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/RoleService.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc; 2 | 3 | import io.gamioo.ioc.annotation.Subscribe; 4 | import io.gamioo.ioc.factory.annotation.Autowired; 5 | import io.gamioo.ioc.skill.AbstractSkill; 6 | import io.gamioo.ioc.stereotype.Service; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * some description 12 | * 13 | * @author Allen Jiang 14 | * @since 1.0.0 15 | */ 16 | @Service 17 | public class RoleService { 18 | 19 | @Autowired 20 | private SkillService skillService; 21 | @Autowired 22 | private DebugService debugService; 23 | 24 | public void handleCommand(String value) { 25 | debugService.handle(value); 26 | } 27 | 28 | 29 | 30 | public List getSkillList() { 31 | return skillService.getSkillList(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/stereotype/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * 一些关键的注解 19 | * 20 | * @author Allen Jiang 21 | * @since 1.0.0 22 | */ 23 | package io.gamioo.ioc.stereotype; -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/entity/DB.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.entity; 2 | 3 | /** 4 | * some description 5 | * 6 | * @author Allen Jiang 7 | * @since 1.0.0 8 | */ 9 | public class DB { 10 | private String jdbcUser; 11 | private String jdbcUrl; 12 | private String jdbcPassword; 13 | 14 | public String getJdbcUser() { 15 | return jdbcUser; 16 | } 17 | 18 | public void setJdbcUser(String jdbcUser) { 19 | this.jdbcUser = jdbcUser; 20 | } 21 | 22 | public String getJdbcUrl() { 23 | return jdbcUrl; 24 | } 25 | 26 | public void setJdbcUrl(String jdbcUrl) { 27 | this.jdbcUrl = jdbcUrl; 28 | } 29 | 30 | public String getJdbcPassword() { 31 | return jdbcPassword; 32 | } 33 | 34 | public void setJdbcPassword(String jdbcPassword) { 35 | this.jdbcPassword = jdbcPassword; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /gamioo-event/src/test/java/io/gamioo/event/guava/UserEventHandler.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.event.guava; 2 | 3 | import com.google.common.eventbus.Subscribe; 4 | import org.apache.logging.log4j.LogManager; 5 | import org.apache.logging.log4j.Logger; 6 | 7 | public class UserEventHandler { 8 | private static final Logger logger = LogManager.getLogger(UserEventHandler.class); 9 | private static UserEventHandler instance; 10 | 11 | public static UserEventHandler getInstance() { 12 | if(instance==null) { 13 | instance=new UserEventHandler(); 14 | } 15 | return instance; 16 | } 17 | 18 | @Subscribe 19 | public void handle(UserLoginEvent event) { 20 | logger.debug("UserEventHandler.handle(UserLoginEvent event)"); 21 | } 22 | 23 | 24 | //可以监听到父类事件 25 | @Subscribe 26 | public void handle(BaseEvent event) { 27 | logger.debug("UserEventHandler.handle(BaseEvent event)"); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /gamioo-redis/src/main/java/io/gamioo/redis/zset/generic/Entry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 wjybxx 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to iBn writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.redis.zset.generic; 18 | 19 | /** 20 | * zset中单个成员信息 21 | */ 22 | public interface Entry { 23 | 24 | K getMember(); 25 | 26 | S getScore(); 27 | 28 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/io/ResourceCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.io; 18 | 19 | /** 20 | * some description 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public interface ResourceCallback { 26 | void handle(); 27 | } 28 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/vector/Vector3f.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.vector; 2 | 3 | /** 4 | * 向量 5 | * 6 | * @author Allen Jiang 7 | */ 8 | public class Vector3f implements Cloneable { 9 | private float x; 10 | private float y; 11 | private float z; 12 | 13 | 14 | public Vector3f() { 15 | } 16 | 17 | public Vector3f(float x, float y, float z) { 18 | this.x = x; 19 | this.y = y; 20 | this.z = z; 21 | } 22 | 23 | 24 | public float getX() { 25 | return x; 26 | } 27 | 28 | public void setX(float x) { 29 | this.x = x; 30 | } 31 | 32 | public float getY() { 33 | return y; 34 | } 35 | 36 | public void setY(float y) { 37 | this.y = y; 38 | } 39 | 40 | public float getZ() { 41 | return z; 42 | } 43 | 44 | public void setZ(float z) { 45 | this.z = z; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/type/AnnotationMetadata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.type; 18 | 19 | /** 20 | * some description 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public interface AnnotationMetadata extends ClassMetadata, AnnotatedTypeMetadata{ 26 | 27 | } 28 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/exception/BeansException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.common.exception; 18 | 19 | /** 20 | * some description 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public abstract class BeansException extends ServiceException { 26 | 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/http/RequestMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.common.http; 18 | 19 | /** 20 | * some description 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public enum RequestMethod { 26 | 27 | GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE 28 | 29 | } -------------------------------------------------------------------------------- /gamioo-game/src/test/java/io/gamioo/game/DeviationDTO.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.game; 2 | 3 | import org.apache.commons.lang3.builder.ToStringBuilder; 4 | import org.apache.commons.lang3.builder.ToStringStyle; 5 | 6 | /** 7 | * some description 8 | * 9 | * @author Allen Jiang 10 | * @since 1.0.0 11 | */ 12 | public class DeviationDTO { 13 | private int value; 14 | private String ratio; 15 | 16 | public void increase() { 17 | value++; 18 | } 19 | 20 | public int getValue() { 21 | return value; 22 | } 23 | 24 | public void setValue(int value) { 25 | this.value = value; 26 | } 27 | 28 | public String getRatio() { 29 | return ratio; 30 | } 31 | 32 | public void setRatio(String ratio) { 33 | this.ratio = ratio; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/factory/support/BeanDefinitionReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.factory.support; 18 | 19 | /** 20 | * 读取器,从XML或者注解 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public interface BeanDefinitionReader { 26 | //void analysisResourceList(String location) throws IOException; 27 | } 28 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/config/BeanFactoryPostProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.config; 18 | 19 | /** 20 | * 用于修改一些bean的定义和值 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public interface BeanFactoryPostProcessor { 26 | // void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws ServiceException; 27 | } 28 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/io/UrlFileResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.io; 18 | 19 | 20 | /** 21 | * some description 22 | * 23 | * @author Allen Jiang 24 | * @since 1.0.0 25 | */ 26 | public class UrlFileResource extends AbstractResource { 27 | 28 | 29 | public UrlFileResource(String uri) { 30 | super(uri); 31 | } 32 | 33 | } 34 | 35 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/resources/ioc.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/io/Resource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.io; 18 | 19 | /** 20 | * some description 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public interface Resource { 26 | 27 | /** 28 | * 获得资源的名称. 29 | * 30 | * @return 资源的名称 31 | */ 32 | String getName(); 33 | 34 | /***/ 35 | String getClassName(); 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/stereotype/Resource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.stereotype; 18 | 19 | import java.lang.annotation.*; 20 | 21 | /** 22 | * 资源管理类 23 | * 24 | * @author Allen Jiang 25 | * @since 1.0.0 26 | */ 27 | @Target({ElementType.TYPE}) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Documented 30 | @Component 31 | public @interface Resource { 32 | String value() default ""; 33 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/annotation/Scheduled.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | 25 | @Target({ ElementType.METHOD }) 26 | @Retention(RetentionPolicy.RUNTIME) 27 | public @interface Scheduled { 28 | int type(); 29 | } 30 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/stereotype/Service.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.stereotype; 18 | 19 | import java.lang.annotation.*; 20 | 21 | /** 22 | * some description 23 | * 24 | * @author Allen Jiang 25 | * @since 1.0.0 26 | */ 27 | @Target({ElementType.TYPE}) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Documented 30 | @Component 31 | public @interface Service { 32 | 33 | 34 | String value() default ""; 35 | 36 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/annotation/Bean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.annotation; 18 | 19 | import java.lang.annotation.*; 20 | 21 | /** 22 | * 申明一个IOC容器接管的JavaBean. 23 | *

24 | * 只有当在{@link Configuration}注解所标识的类中才会生效. 25 | * 26 | * @author Allen Jiang 27 | * @since 1.0.0 28 | */ 29 | @Documented 30 | @Target({ElementType.FIELD}) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface Bean { 33 | String value(); 34 | } -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/exception/NoPublicMethodException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gamioo.common.exception; 17 | 18 | /** 19 | * 在找不到指定Public方法时抛出. 20 | * 21 | * @author Allen Jiang 22 | * @since 1.0.0 23 | */ 24 | public class NoPublicMethodException extends RuntimeException { 25 | private static final long serialVersionUID = -4256184544259394170L; 26 | 27 | public NoPublicMethodException(String msg) { 28 | super(msg); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /gamioo-redis/src/main/java/io/gamioo/redis/zset/object2long/Object2LongEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 wjybxx 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to iBn writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.redis.zset.object2long; 18 | 19 | 20 | import io.gamioo.redis.zset.generic.Entry; 21 | 22 | public interface Object2LongEntry extends Entry { 23 | 24 | @Override 25 | K getMember(); 26 | 27 | long getLongScore(); 28 | 29 | @Deprecated 30 | @Override 31 | default Long getScore() { 32 | return getLongScore(); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/definition/FieldDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.definition; 18 | 19 | import java.lang.reflect.Field; 20 | 21 | /** 22 | * 一个字段定义 23 | * 24 | * @author Allen Jiang 25 | * @since 1.0.0 26 | */ 27 | public interface FieldDefinition extends Definition{ 28 | /** 29 | * 注入对象. 30 | * 31 | * @param instance 宿主对象 32 | */ 33 | void inject(Object instance,Object value); 34 | 35 | Field getField(); 36 | } 37 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/exception/ServiceException.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.exception; 2 | 3 | import io.gamioo.common.util.StringUtils; 4 | 5 | /** 6 | * 框架异常类 7 | * 8 | * @author Allen Jiang 9 | * @since 1.0 10 | */ 11 | public class ServiceException extends RuntimeException { 12 | 13 | /** 14 | * 15 | */ 16 | private static final long serialVersionUID = -3287463281746412649L; 17 | //private int errorCode; 18 | 19 | public ServiceException() { 20 | super(); 21 | } 22 | public ServiceException(int code) { 23 | super(String.valueOf(code)); 24 | } 25 | 26 | public ServiceException(Throwable cause,String message,Object... params){ 27 | super(StringUtils.format(message, params),cause); 28 | } 29 | 30 | public ServiceException(String message) { 31 | super(message); 32 | } 33 | public ServiceException(String message,Object... params){ 34 | super(StringUtils.format(message, params)); 35 | } 36 | 37 | public ServiceException(String message, Throwable cause) { 38 | super(message, cause); 39 | } 40 | 41 | public ServiceException(Throwable cause) { 42 | super(cause); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/annotation/Subscribe.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * some description 26 | * 27 | * @author Allen Jiang 28 | * @since 1.0.0 29 | */ 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Target(ElementType.METHOD) 32 | public @interface Subscribe {} -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/config/BeanPostProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.config; 18 | 19 | import io.gamioo.common.exception.BeansException; 20 | 21 | /** 22 | * some description 23 | * 24 | * @author Allen Jiang 25 | * @since 1.0.0 26 | */ 27 | public interface BeanPostProcessor { 28 | Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException; 29 | Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException; 30 | } 31 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/io/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.io; 18 | 19 | 20 | import java.io.IOException; 21 | import java.util.List; 22 | 23 | /** 24 | * some description 25 | * 26 | * @author Allen Jiang 27 | * @since 1.0.0 28 | */ 29 | public interface ResourceLoader { 30 | 31 | // public String getLocation(); 32 | 33 | List getResourceList(String location) throws IOException; 34 | 35 | // Resource getResource(String location); 36 | 37 | 38 | } 39 | 40 | -------------------------------------------------------------------------------- /gamioo-redis/src/main/java/io/gamioo/redis/zset/long2object/Long2ObjectEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 wjybxx 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to iBn writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.redis.zset.long2object; 18 | 19 | 20 | import io.gamioo.redis.zset.generic.Entry; 21 | 22 | /** 23 | * zset中单个成员信息 24 | */ 25 | public interface Long2ObjectEntry extends Entry { 26 | 27 | @Deprecated 28 | @Override 29 | default Long getMember() { 30 | return getLongMember(); 31 | } 32 | 33 | long getLongMember(); 34 | 35 | @Override 36 | S getScore(); 37 | 38 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/annotation/Mapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * some description 26 | * 27 | * @author Allen Jiang 28 | * @since 1.0.0 29 | */ 30 | @Target({ElementType.ANNOTATION_TYPE}) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface Mapping { 33 | 34 | } 35 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/context/ApplicationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.context; 18 | 19 | import io.gamioo.ioc.factory.support.DefaultListableBeanFactory; 20 | 21 | /** 22 | * some description 23 | * 24 | * @author Allen Jiang 25 | * @since 1.0.0 26 | */ 27 | public interface ApplicationContext{ 28 | 29 | DefaultListableBeanFactory createBeanFactory(); 30 | 31 | void loadBeanDefinitions(DefaultListableBeanFactory beanFactory); 32 | 33 | public T getBean(Class requiredType); 34 | } 35 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/stereotype/Component.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.stereotype; 18 | 19 | import java.lang.annotation.*; 20 | 21 | /** 22 | * some description 23 | * 24 | * @author Allen Jiang 25 | * @since 1.0.0 26 | */ 27 | @Target(ElementType.TYPE) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Documented 30 | public @interface Component { 31 | /** 32 | * 这个类的唯一名称. 33 | *

主要用于Map注入的KEY

34 | * 35 | * @return 名称 36 | */ 37 | String[] name() default {}; 38 | } -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/concurrent/NameableThreadFactory.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.concurrent; 2 | 3 | import java.util.concurrent.ThreadFactory; 4 | import java.util.concurrent.atomic.AtomicInteger; 5 | 6 | /** 7 | * 线程工厂,可以设置别名 8 | * 9 | * @author Allen Jiang[41157121@qq.com] 10 | * @since 1.0 11 | */ 12 | public class NameableThreadFactory implements ThreadFactory { 13 | private final String name; 14 | private final AtomicInteger threadCounter = new AtomicInteger(0); 15 | 16 | @Override 17 | public Thread newThread(Runnable runnable) { 18 | StringBuilder threadName = new StringBuilder(name); 19 | threadName.append("-").append(threadCounter.getAndIncrement()); 20 | Thread thread = new Thread(group, runnable, threadName.toString()); 21 | return thread; 22 | } 23 | 24 | final ThreadGroup group; 25 | 26 | public NameableThreadFactory(String name) { 27 | SecurityManager securitymanager = System.getSecurityManager(); 28 | this.group = securitymanager == null ? Thread.currentThread().getThreadGroup() : securitymanager.getThreadGroup(); 29 | this.name = name; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/annotation/Attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * some description 26 | * 27 | * @author Allen Jiang 28 | * @since 1.0.0 29 | */ 30 | @Target({ ElementType.FIELD }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface Attribute { 33 | String value(); 34 | } 35 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/entity/Cache.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.entity; 2 | 3 | /** 4 | * some description 5 | * 6 | * @author Allen Jiang 7 | * @since 1.0.0 8 | */ 9 | public class Cache { 10 | private int type; 11 | private String ip; 12 | private int port; 13 | private int index; 14 | private String password; 15 | 16 | public int getType() { 17 | return type; 18 | } 19 | 20 | public void setType(int type) { 21 | this.type = type; 22 | } 23 | 24 | public String getIp() { 25 | return ip; 26 | } 27 | 28 | public void setIp(String ip) { 29 | this.ip = ip; 30 | } 31 | 32 | public int getPort() { 33 | return port; 34 | } 35 | 36 | public void setPort(int port) { 37 | this.port = port; 38 | } 39 | 40 | public int getIndex() { 41 | return index; 42 | } 43 | 44 | public void setIndex(int index) { 45 | this.index = index; 46 | } 47 | 48 | public String getPassword() { 49 | return password; 50 | } 51 | 52 | public void setPassword(String password) { 53 | this.password = password; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/util/NativeUtils.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.util; 2 | 3 | 4 | import org.apache.commons.lang3.SystemUtils; 5 | 6 | import java.io.*; 7 | 8 | /** 9 | * 用于加载native dll的工具类 10 | */ 11 | public class NativeUtils { 12 | public static void loadLibrary(String name) throws IOException { 13 | String suffix = ""; 14 | //TODO 暂时只为两种系统服务 15 | if (SystemUtils.IS_OS_LINUX) { 16 | suffix += ".so"; 17 | } else { 18 | suffix += ".dll"; 19 | } 20 | try (InputStream inputStream = FileUtils.getInputStream(name + suffix); ByteArrayOutputStream out = new ByteArrayOutputStream()) { 21 | byte[] buffer = new byte[1024]; 22 | int n = 0; 23 | while (-1 != (n = inputStream.read(buffer))) { 24 | out.write(buffer, 0, n); 25 | } 26 | File file = File.createTempFile(name, suffix); 27 | try (FileOutputStream fileOutputStream = new FileOutputStream(file)) { 28 | fileOutputStream.write(out.toByteArray()); 29 | } 30 | System.load(file.getAbsolutePath()); 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/io/JarClassResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.io; 18 | 19 | /** 20 | * some description 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public class JarClassResource extends AbstractResource { 26 | public JarClassResource(String path) { 27 | super(path); 28 | } 29 | 30 | @Override 31 | public String getClassName() { 32 | // io/gamioo/ioc/AnnotationBeanFactoryTest.class 33 | return name.substring(0, name.length() - 6).replace("/","."); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/lang/ServerInfo.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.lang; 2 | 3 | import org.apache.commons.lang3.builder.ToStringBuilder; 4 | import org.apache.commons.lang3.builder.ToStringStyle; 5 | 6 | import java.util.Date; 7 | 8 | public class ServerInfo { 9 | private int id; 10 | private String name; 11 | private int times; 12 | private Date addTime; 13 | 14 | public int getId() { 15 | return id; 16 | } 17 | 18 | public void setId(int id) { 19 | this.id = id; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | public int getTimes() { 31 | return times; 32 | } 33 | 34 | public void setTimes(int times) { 35 | this.times = times; 36 | } 37 | 38 | public Date getAddTime() { 39 | return addTime; 40 | } 41 | 42 | public void setAddTime(Date addTime) { 43 | this.addTime = addTime; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/annotation/Configuration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.annotation; 18 | 19 | import io.gamioo.ioc.stereotype.Component; 20 | 21 | import java.lang.annotation.*; 22 | 23 | 24 | 25 | /** 26 | * 用来标识一个配置文件类. 27 | *

28 | * 可与{@link Attribute}来实现注入配置参数.
29 | * 这种类也是只在启动时有用,相当于启动配置文件的作用. 30 | * 31 | * @author Allen Jiang 32 | * @since 1.0.0 33 | */ 34 | @Component 35 | @Documented 36 | @Target({ElementType.TYPE}) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | public @interface Configuration { 39 | String value(); 40 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/factory/annotation/Autowired.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.factory.annotation; 18 | 19 | import java.lang.annotation.*; 20 | 21 | /** 22 | * some description 23 | * 24 | * @author Allen Jiang 25 | * @since 1.0.0 26 | */ 27 | @Target(ElementType.FIELD) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Documented 30 | public @interface Autowired { 31 | 32 | /** 33 | * Declares whether the annotated dependency is required. 34 | *

Defaults to {@code true}. 35 | */ 36 | boolean required() default true; 37 | 38 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/entity/Server.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.entity; 2 | 3 | /** 4 | * some description 5 | * 6 | * @author Allen Jiang 7 | * @since 1.0.0 8 | */ 9 | public class Server { 10 | private int tcpPort; 11 | private String name; 12 | private int id; 13 | private String externalIp; 14 | private int webPort; 15 | 16 | public int getTcpPort() { 17 | return tcpPort; 18 | } 19 | 20 | public void setTcpPort(int tcpPort) { 21 | this.tcpPort = tcpPort; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | public int getId() { 33 | return id; 34 | } 35 | 36 | public void setId(int id) { 37 | this.id = id; 38 | } 39 | 40 | public String getExternalIp() { 41 | return externalIp; 42 | } 43 | 44 | public void setExternalIp(String externalIp) { 45 | this.externalIp = externalIp; 46 | } 47 | 48 | public int getWebPort() { 49 | return webPort; 50 | } 51 | 52 | public void setWebPort(int webPort) { 53 | this.webPort = webPort; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /gamioo-common/src/test/resources/gate-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/resources/gate-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/PropertyValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc; 18 | 19 | /** 20 | * some description 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public class PropertyValue { 26 | 27 | private final String name; 28 | 29 | private final Object value; 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public Object getValue() { 36 | return value; 37 | } 38 | 39 | 40 | public PropertyValue(String name, Object value) { 41 | this.name = name; 42 | this.value = value; 43 | } 44 | } -------------------------------------------------------------------------------- /gamioo-compress/src/jmh/resources/message.txt: -------------------------------------------------------------------------------- 1 | {code { 2 | flag: 1 3 | id: 1 4 | } 5 | tableId: 936940 6 | ownerId: 143566 7 | createId: 143566 8 | roomTemplateId: 4 9 | configTemplateId: 1101 10 | entryDTO { 11 | key: 1 12 | value: 3 13 | } 14 | entryDTO { 15 | key: 201 16 | value: 0 17 | } 18 | entryDTO { 19 | key: 202 20 | value: 0 21 | } 22 | entryDTO { 23 | key: 204 24 | value: 1 25 | } 26 | entryDTO { 27 | key: 4 28 | value: 6 29 | } 30 | entryDTO { 31 | key: 203 32 | value: 0 33 | } 34 | playerDTO { 35 | playerDTO { 36 | id: 143566 37 | name: "King\345\274\272" 38 | gender: 1 39 | icon: "http://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLLMzUbUh9ic7fQlhibCCLnibAIAP838Xge2cmFcStdEaWLL4UdLrgzhZsxrcsYxgJLsDR39vPsfjLibw/132" 40 | city: "\345\256\201\346\263\242\345\270\202" 41 | ip: "39.188.248.167" 42 | longitude: "0.0" 43 | latitude: "0.0" 44 | position: 0 45 | ready: false 46 | online: true 47 | totalPoint: 0.0 48 | lastEnterTime: 1595855143603 49 | win: 0 50 | lose: 0 51 | type: 1 52 | } 53 | sitDownPosition: 0 54 | remain: 0 55 | score: 0 56 | daoNum: 0.0 57 | totalDaoNum: 0.0 58 | rank: 0 59 | } 60 | clubId: 0 61 | status: 0 62 | sitDownPosition: 0 63 | kingBormPokerDTO { 64 | id: 143566 65 | } 66 | } -------------------------------------------------------------------------------- /gamioo-compress/src/main/resources/message.txt: -------------------------------------------------------------------------------- 1 | {code { 2 | flag: 1 3 | id: 1 4 | } 5 | tableId: 936940 6 | ownerId: 143566 7 | createId: 143566 8 | roomTemplateId: 4 9 | configTemplateId: 1101 10 | entryDTO { 11 | key: 1 12 | value: 3 13 | } 14 | entryDTO { 15 | key: 201 16 | value: 0 17 | } 18 | entryDTO { 19 | key: 202 20 | value: 0 21 | } 22 | entryDTO { 23 | key: 204 24 | value: 1 25 | } 26 | entryDTO { 27 | key: 4 28 | value: 6 29 | } 30 | entryDTO { 31 | key: 203 32 | value: 0 33 | } 34 | playerDTO { 35 | playerDTO { 36 | id: 143566 37 | name: "King\345\274\272" 38 | gender: 1 39 | icon: "http://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLLMzUbUh9ic7fQlhibCCLnibAIAP838Xge2cmFcStdEaWLL4UdLrgzhZsxrcsYxgJLsDR39vPsfjLibw/132" 40 | city: "\345\256\201\346\263\242\345\270\202" 41 | ip: "39.188.248.167" 42 | longitude: "0.0" 43 | latitude: "0.0" 44 | position: 0 45 | ready: false 46 | online: true 47 | totalPoint: 0.0 48 | lastEnterTime: 1595855143603 49 | win: 0 50 | lose: 0 51 | type: 1 52 | } 53 | sitDownPosition: 0 54 | remain: 0 55 | score: 0 56 | daoNum: 0.0 57 | totalDaoNum: 0.0 58 | rank: 0 59 | } 60 | clubId: 0 61 | status: 0 62 | sitDownPosition: 0 63 | kingBormPokerDTO { 64 | id: 143566 65 | } 66 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/PropertyValues.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | 23 | /** 24 | * some description 25 | * 26 | * @author Allen Jiang 27 | * @since 1.0.0 28 | */ 29 | public class PropertyValues { 30 | 31 | private final List propertyValueList = new ArrayList<>(); 32 | 33 | public PropertyValues() {} 34 | 35 | public void addPropertyValue(PropertyValue pv) { 36 | this.propertyValueList.add(pv); 37 | } 38 | 39 | public List getPropertyValues() { 40 | return this.propertyValueList; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/MapTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | /** 23 | * some description 24 | * 25 | * @author Allen Jiang 26 | * @since 1.0.0 27 | */ 28 | public class MapTest { 29 | public static void main(String[] args) { 30 | Map map=new HashMap<>(); 31 | Object obj= map.computeIfAbsent("a",key->new Object()); 32 | System.out.println(obj); 33 | Object d=map.putIfAbsent("d",new Object()); 34 | System.out.println(d); 35 | map.computeIfAbsent("a",key->new Object()); 36 | System.out.println(map); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | /.project 7 | /gamioo-log/.project 8 | /gamioo-log/.classpath 9 | /gamioo-ioc/.project 10 | /gamioo-ioc/.classpath 11 | /gamioo-game/.classpath 12 | /gamioo-game/.project 13 | /gamioo-compress/.classpath 14 | /gamioo-compress/.project 15 | /gamioo-compress/.settings/*.prefs 16 | /gamioo-cache/.classpath 17 | /gamioo-cache/.project 18 | /gamioo-cache/.settings/org.eclipse.buildship.core.prefs 19 | /测试结果 -BeanFactoryTest.html 20 | /gamioo-beans/.settings/*.prefs 21 | /.idea 22 | /gamioo-beans/.project 23 | /gamioo-beans/.classpath 24 | /gamioo-pomelo/out/production/classes/com/zvidia/pomelo/exception/*.class 25 | /gamioo-pomelo/out/production/classes/com/zvidia/pomelo/protobuf/*.class 26 | /gamioo-pomelo/out/production/classes/com/zvidia/pomelo/protocol/*.class 27 | /gamioo-pomelo/out/production/classes/com/zvidia/pomelo/utils/*.class 28 | /gamioo-pomelo/out/production/classes/com/zvidia/pomelo/websocket/*.class 29 | /gamioo-pomelo/out/production/classes/io/gamioo/pomelo/*.class 30 | /gamioo-pomelo/out/production/classes/org/java_websocket/drafts/*.class 31 | /gamioo-pomelo/out/production/resources/log4j2.component.properties 32 | /gamioo-pomelo/out/production/resources/log4j2.xml 33 | /gamioo-sandbox/src/jmh/generated 34 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/type/AnnotatedTypeMetadata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.type; 18 | 19 | /** 20 | * some description 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public interface AnnotatedTypeMetadata { 26 | /** 27 | * Determine whether the underlying element has an annotation or meta-annotation 28 | * of the given type defined. 29 | *

If this method returns {@code true}, then 30 | * @param annotationName the fully qualified class name of the annotation 31 | * type to look for 32 | * @return whether a matching annotation is defined 33 | */ 34 | boolean isAnnotated(String annotationName); 35 | } 36 | -------------------------------------------------------------------------------- /gamioo-event/src/test/java/io/gamioo/event/guava/BaseEvent.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.event.guava; 2 | 3 | import java.util.concurrent.Executor; 4 | import java.util.concurrent.Executors; 5 | 6 | import com.google.common.eventbus.AsyncEventBus; 7 | import com.google.common.eventbus.EventBus; 8 | import com.google.common.eventbus.SubscriberExceptionContext; 9 | import com.google.common.eventbus.SubscriberExceptionHandler; 10 | import org.apache.logging.log4j.LogManager; 11 | import org.apache.logging.log4j.Logger; 12 | 13 | public abstract class BaseEvent { 14 | private static final Logger logger = LogManager.getLogger(BaseEvent.class); 15 | private Executor executor = Executors.newCachedThreadPool(); 16 | protected AsyncEventBus asyncEventBus = new AsyncEventBus(executor,new SubscriberExceptionHandler() { 17 | 18 | @Override 19 | public void handleException(Throwable exception, SubscriberExceptionContext context) { 20 | logger.error(exception.getMessage(),exception); 21 | } 22 | 23 | 24 | }); 25 | protected EventBus eventBus = new EventBus(new SubscriberExceptionHandler() { 26 | 27 | @Override 28 | public void handleException(Throwable exception, SubscriberExceptionContext context) { 29 | logger.error(exception.getMessage(),exception); 30 | } 31 | 32 | 33 | }); 34 | 35 | 36 | public abstract void subscribe(); 37 | } 38 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/annotation/CommandMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * TCP 协议入口 26 | * 27 | * @author Allen Jiang 28 | * @since 1.0.0 29 | */ 30 | @Target(ElementType.METHOD) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface CommandMapping { 33 | int code() default 0; 34 | boolean cross() default false;//是否只跨服处理 35 | boolean print() default true;//是否要打印 36 | /** 是否要做登录验证 */ 37 | boolean login() default true; 38 | } 39 | -------------------------------------------------------------------------------- /gamioo-sandbox/src/test/java/io/gamioo/sandbox/Base64Test.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.sandbox; 2 | 3 | import com.github.woostju.ansible.AnsibleClient; 4 | import com.github.woostju.ansible.ReturnValue; 5 | import com.github.woostju.ansible.command.PingCommand; 6 | import com.github.woostju.ssh.SshClientConfig; 7 | import com.github.woostju.ssh.pool.SshClientsPool; 8 | import com.google.common.collect.Lists; 9 | import org.apache.logging.log4j.LogManager; 10 | import org.apache.logging.log4j.Logger; 11 | import org.junit.Assert; 12 | import org.junit.jupiter.api.*; 13 | 14 | import java.util.Base64; 15 | import java.util.Map; 16 | 17 | @DisplayName("crypto test") 18 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 19 | public class Base64Test { 20 | private static final Logger logger = LogManager.getLogger(Base64Test.class); 21 | 22 | 23 | @BeforeAll 24 | public static void beforeAll() { 25 | 26 | 27 | } 28 | 29 | @AfterAll 30 | public static void afterAll() { 31 | 32 | } 33 | 34 | @DisplayName("base64") 35 | @Test 36 | @Order(1) 37 | public void base64() { 38 | String ret= Base64.getEncoder().encodeToString("api_user:api_password".getBytes()); 39 | logger.debug("result:{}", ret); 40 | Assertions.assertEquals("YXBpX3VzZXI6YXBpX3Bhc3N3b3Jk", ret); 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/io/FileClassResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.io; 18 | 19 | import java.io.File; 20 | 21 | /** 22 | * some description 23 | * 24 | * @author Allen Jiang 25 | * @since 1.0.0 26 | */ 27 | public class FileClassResource extends AbstractResource { 28 | 29 | private final File file; 30 | public FileClassResource(String path, File file) { 31 | super(path + file.getName()); 32 | this.file=file; 33 | } 34 | 35 | @Override 36 | public String getClassName() { 37 | // io/gamioo/ioc/AnnotationBeanFactoryTest.class 38 | return name.substring(0, name.length() - 6).replace("/","."); 39 | } 40 | 41 | } 42 | 43 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/stereotype/Controller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.stereotype; 18 | 19 | import io.gamioo.common.concurrent.Group; 20 | 21 | import java.lang.annotation.*; 22 | 23 | /** 24 | * some description 25 | * 26 | * @author Allen Jiang 27 | * @since 1.0.0 28 | */ 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | @Component 33 | public @interface Controller { 34 | /**模块*/ 35 | String module() default ""; 36 | /** 37 | * 标识这个协议控制中的入口方法由哪个线程组调用. 38 | *

39 | * 默认转化为串型执行队列线程 40 | * 41 | * @return 执行线程组. 42 | */ 43 | Group group() default Group.QueueThreadGroup; 44 | 45 | 46 | 47 | } -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/exception/ServerBootstrapException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.common.exception; 18 | 19 | /** 20 | * some description 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public class ServerBootstrapException extends ServiceException{ 26 | 27 | 28 | public ServerBootstrapException(String message,Object... params) { 29 | super(message, params); 30 | } 31 | 32 | public ServerBootstrapException(String message, Throwable cause) { 33 | super(message, cause); 34 | } 35 | 36 | public ServerBootstrapException(Throwable cause, String message, Object... params) { 37 | super(cause, message, params); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /gamioo-game/src/main/java/io/gamioo/game/word/DirtyWordUnit.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.game.word; 2 | 3 | /** 4 | * some description 5 | * 6 | * @author Allen Jiang 7 | * @since 1.0.0 8 | */ 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | public class DirtyWordUnit { 13 | private final String source; 14 | private final String keyWord; 15 | private final List indexList = new ArrayList<>(); 16 | 17 | public DirtyWordUnit(String source,String word){ 18 | this.source = source; 19 | this.keyWord = word; 20 | } 21 | 22 | public void checkWordIndex(){ 23 | int index = 0; 24 | if(source.length() < keyWord.length()){ 25 | return ; 26 | } 27 | for (int i = 0,n=source.length(); i < n; i++) { 28 | if (keyWord.length() > index && source.charAt(i) == keyWord.charAt(index)) { 29 | indexList.add(index); 30 | index++; 31 | if(isGetTheWord()){ 32 | break; 33 | } 34 | } 35 | } 36 | } 37 | 38 | public boolean isGetTheWord(){ 39 | return this.indexList.size() == keyWord.length(); 40 | } 41 | 42 | public String getKeyWord() { 43 | return keyWord; 44 | } 45 | 46 | public List getIndexList() { 47 | return indexList; 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/config/BeanReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.config; 18 | 19 | 20 | /** 21 | * some description 22 | * 23 | * @author Allen Jiang 24 | * @since 1.0.0 25 | */ 26 | public class BeanReference { 27 | 28 | private String name; 29 | 30 | private Object bean; 31 | 32 | public BeanReference(String name) { 33 | this.name = name; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | 44 | public Object getBean() { 45 | return bean; 46 | } 47 | 48 | public void setBean(Object bean) { 49 | this.bean = bean; 50 | } 51 | } -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/constant/ModuleConstant.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.constant; 2 | 3 | import org.apache.commons.collections4.CollectionUtils; 4 | 5 | import java.lang.reflect.Field; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * @author Allen Jiang 11 | */ 12 | public class ModuleConstant { 13 | @Describe(name = "common", description = "通用模块") 14 | public static final int COMMON = 0; 15 | @Describe(name = "user", description = "用户模块") 16 | public static final int USER = 1; 17 | @Describe(name = "building", description = "建筑模块") 18 | public static final int BUILDING = 2; 19 | @Describe(name = "item", description = "道具模块") 20 | public static final int ITEM = 3; 21 | 22 | 23 | private static List moduleList = new ArrayList<>(); 24 | 25 | /** 26 | * 获取模块列表 27 | * 28 | * @return 返回模块列表 29 | */ 30 | public static List getModuleList() { 31 | if (CollectionUtils.isEmpty(moduleList)) { 32 | Field[] list = ModuleConstant.class.getDeclaredFields(); 33 | for (Field e : list) { 34 | Describe describe = e.getAnnotation(Describe.class); 35 | if (describe != null) { 36 | moduleList.add(describe.name()); 37 | } 38 | } 39 | } 40 | return moduleList; 41 | 42 | } 43 | } -------------------------------------------------------------------------------- /gamioo-navigation/src/main/java/io/gamioo/nav/INav.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.nav; 2 | 3 | import io.gamioo.common.vector.Vector3f; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 9 | */ 10 | public interface INav { 11 | 12 | 13 | /** 14 | * 寻找路径 15 | * 16 | * @param start 开始坐标点 17 | * @param end 结束坐标点 18 | * @return 路经典集合 19 | */ 20 | List find(float[] start, float[] end); 21 | 22 | List find(Vector3f start, Vector3f end); 23 | 24 | 25 | /** 26 | * 光线照射发,寻找可以支线通过的hit点,如果可通过则返回hit 27 | * 28 | * @param start 开始点 29 | * @param end 目标点 30 | * @return 光照可以达到的点 31 | */ 32 | float[] raycast(float[] start, float[] end); 33 | 34 | Vector3f raycast(Vector3f start, Vector3f end); 35 | 36 | 37 | /** 38 | * 获取指定点附近可行走的点 39 | * 40 | * @param point 当前验证点 41 | * @return 可以行走的点(如验证点不能行走 , 则返回可以行走的点) 42 | */ 43 | float[] findNearest(float[] point); 44 | 45 | Vector3f findNearest(Vector3f point); 46 | 47 | default float[] vector2Point(Vector3f vector3f) { 48 | float[] arr = new float[3]; 49 | arr[0] = vector3f.getX(); 50 | arr[1] = vector3f.getY(); 51 | arr[2] = vector3f.getZ(); 52 | return arr; 53 | } 54 | 55 | default Vector3f point2Vector(float[] point) { 56 | return new Vector3f(point[0], point[1], point[2]); 57 | } 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/definition/Definition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.definition; 18 | 19 | import java.lang.annotation.Annotation; 20 | 21 | /** 22 | * some description 23 | * 24 | * @author Allen Jiang 25 | * @since 1.0.0 26 | */ 27 | public interface Definition { 28 | 29 | Class getClazz(); 30 | 31 | String getName(); 32 | 33 | /** 34 | * 获取注解 35 | * 36 | * @return 返回注解 37 | */ 38 | T getAnnotation(); 39 | 40 | /** 41 | * 获取注解 42 | * 43 | * @return 返回注解类型 44 | */ 45 | Class getAnnotationType(); 46 | 47 | /** 48 | * 获取此方法的访问入口所对应的Index. 49 | * 50 | * @return 访问入口所对应的Index. 51 | */ 52 | int getIndex(); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/concurrent/Group.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.common.concurrent; 18 | 19 | /** 20 | * 执行线程组枚举类. 21 | *

22 | * 线程调度规则:N个线程 处理M个队列,哪个线程空闲了就去处理有任务的队列 23 | *

24 | * 25 | * @author Allen Jiang 26 | * @since 1.0.0 27 | */ 28 | public enum Group { 29 | /** 30 | * 以玩家ID划分的线程. 31 | *

32 | * 可以理解为一个玩家一个线程
33 | */ 34 | ModuleThreadGroup, 35 | 36 | /** 37 | * 以模块划分的线程. 38 | *

39 | * 可以理解为一个Controller一个线程
40 | * 如:登录,世界聊天,公会,排行榜 41 | */ 42 | NettyThreadGroup, 43 | 44 | /** 45 | * Netty本身的Work线程. 46 | *

47 | * 心跳,或完全没有IO操作的逻辑,直接交给Netty的Work线程处理掉 48 | */ 49 | PlayerThreadGroup, 50 | 51 | /** 52 | * 一种串行执行队列处理线程.只会有一根线程来处理, 53 | */ 54 | QueueThreadGroup; 55 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/definition/MethodDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.definition; 18 | 19 | import com.esotericsoftware.reflectasm.MethodAccess; 20 | import io.gamioo.ioc.wrapper.MethodWrapper; 21 | 22 | import java.lang.reflect.Parameter; 23 | 24 | /** 25 | * some description 26 | * 27 | * @author Allen Jiang 28 | * @since 1.0.0 29 | */ 30 | public interface MethodDefinition extends Definition{ 31 | 32 | 33 | /** 34 | * 获取此方法的访问入口. 35 | * 36 | * @return 访问入口 37 | */ 38 | MethodAccess getMethodAccess(); 39 | 40 | /** 41 | * 获取参数列表 42 | * 43 | * @return 参数 44 | */ 45 | Parameter[] getParameters(); 46 | 47 | Object invoke(Object instance,Object ...args); 48 | 49 | MethodWrapper getMethodWrapper(Object instance); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/io/AbstractResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.io; 18 | 19 | import org.apache.commons.lang3.NotImplementedException; 20 | 21 | /** 22 | * some description 23 | * 24 | * @author Allen Jiang 25 | * @since 1.0.0 26 | */ 27 | public abstract class AbstractResource implements Resource{ 28 | protected final String name; 29 | 30 | protected AbstractResource(String name) { 31 | this.name = name; 32 | } 33 | 34 | @Override 35 | public String getName() { 36 | return name; 37 | } 38 | @Override 39 | public String getClassName() { 40 | throw new NotImplementedException(this.getClass().getName()); 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "AbstractResource [name=" + name + "]"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /gamioo-sandbox/src/jmh/java/io/gamioo/sandbox/AsymmetricBenchMark.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.sandbox; 2 | 3 | 4 | import org.openjdk.jmh.annotations.*; 5 | import org.openjdk.jmh.runner.Runner; 6 | import org.openjdk.jmh.runner.RunnerException; 7 | import org.openjdk.jmh.runner.options.Options; 8 | import org.openjdk.jmh.runner.options.OptionsBuilder; 9 | 10 | import java.util.concurrent.TimeUnit; 11 | import java.util.concurrent.atomic.AtomicLong; 12 | 13 | /** 14 | * JMH测试15:官方Asymmetric样例 15 | * 16 | * @author Allen Jiang 17 | */ 18 | @Fork(1) 19 | @BenchmarkMode(Mode.AverageTime) 20 | @OutputTimeUnit(TimeUnit.MICROSECONDS) 21 | @Warmup(iterations = 5, time = 1) 22 | @Measurement(iterations = 5, time = 1) 23 | @State(Scope.Group) 24 | public class AsymmetricBenchMark { 25 | private AtomicLong counter; 26 | 27 | @Setup 28 | public void up() { 29 | counter = new AtomicLong(); 30 | } 31 | 32 | @Benchmark 33 | @Group("atomic") 34 | @GroupThreads(3) 35 | public long inc() { 36 | return counter.incrementAndGet(); 37 | } 38 | 39 | @Benchmark 40 | @Group("atomic") 41 | @GroupThreads(1) 42 | public long get() { 43 | return counter.get(); 44 | } 45 | 46 | public static void main(String[] args) throws RunnerException { 47 | Options opt = new OptionsBuilder() 48 | .include(AsymmetricBenchMark.class.getSimpleName()) 49 | .build(); 50 | 51 | new Runner(opt).run(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /gamioo-redis/src/main/java/io/gamioo/redis/zset/object2long/LongScoreHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 wjybxx 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to iBn writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.redis.zset.object2long; 18 | 19 | /** 20 | * long类型的score处理器 21 | * 22 | * @author wjybxx 23 | * @version 1.0 24 | * date - 2019/11/7 25 | */ 26 | public interface LongScoreHandler { 27 | 28 | /** 29 | * 比较两个分数的大小 30 | * Q: 为什么需要这个方法? 31 | * A: 想实现实现逆序 或 当你的score是由多个部分组合而成的时候,那么你就需要它。 32 | * 33 | * @param score1 分数1 34 | * @param score2 分数2 35 | * @return 返回比较值 36 | */ 37 | int compare(long score1, long score2); 38 | 39 | /** 40 | * 计算两个score的和 41 | * Q: 为什么需要这个方法? 42 | * A: 当你的score是由多个部分组合而成的时候,那么你就需要它。 43 | * 44 | * @param oldScore 当前分数 45 | * @param increment 自定义增量 46 | * @return sum 47 | */ 48 | long sum(long oldScore, long increment); 49 | } 50 | -------------------------------------------------------------------------------- /gamioo-sandbox/src/jmh/java/io/gamioo/sandbox/SymmetricBenchmark.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.sandbox; 2 | 3 | 4 | import org.openjdk.jmh.annotations.*; 5 | import org.openjdk.jmh.runner.Runner; 6 | import org.openjdk.jmh.runner.RunnerException; 7 | import org.openjdk.jmh.runner.options.Options; 8 | import org.openjdk.jmh.runner.options.OptionsBuilder; 9 | 10 | import java.util.concurrent.TimeUnit; 11 | import java.util.concurrent.atomic.AtomicLong; 12 | 13 | /** 14 | * JMH测试15:Asymmetric Benchmark样例 15 | * 16 | * @author Allen Jiang 17 | */ 18 | @BenchmarkMode(Mode.AverageTime) 19 | @Fork(1) 20 | @Warmup(iterations = 5, time = 1) 21 | @Measurement(iterations = 5, time = 1) 22 | @OutputTimeUnit(TimeUnit.MICROSECONDS) 23 | @State(Scope.Group) 24 | public class SymmetricBenchmark { 25 | private AtomicLong counter; 26 | 27 | @Setup 28 | public void init() { 29 | this.counter = new AtomicLong(); 30 | } 31 | 32 | @GroupThreads(5) 33 | @Group("atomic") 34 | @Benchmark 35 | public void inc() { 36 | this.counter.incrementAndGet(); 37 | } 38 | 39 | @GroupThreads(5) 40 | @Group("atomic") 41 | @Benchmark 42 | public long get() { 43 | return this.counter.get(); 44 | } 45 | 46 | public static void main(String[] args) throws RunnerException { 47 | Options opt = new OptionsBuilder() 48 | .include(SymmetricBenchmark.class.getSimpleName()) 49 | .build(); 50 | new Runner(opt).run(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /gamioo-common/src/test/java/io/gamioo/JsonXmlUtilTest.java: -------------------------------------------------------------------------------- 1 | package io.gamioo; 2 | 3 | import com.alibaba.fastjson2.JSONObject; 4 | import io.gamioo.common.util.JsonXmlUtil; 5 | import io.gamioo.common.util.XMLUtil; 6 | import org.apache.logging.log4j.LogManager; 7 | import org.apache.logging.log4j.Logger; 8 | import org.dom4j.Document; 9 | import org.dom4j.Element; 10 | import org.junit.jupiter.api.*; 11 | 12 | /** 13 | * some description 14 | * 15 | * @author Allen Jiang 16 | * @since 1.0.0 17 | */ 18 | 19 | @DisplayName("IOC测试") 20 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 21 | public class JsonXmlUtilTest { 22 | private static final Logger logger = LogManager.getLogger(JsonXmlUtilTest.class); 23 | //private final Benchmark benchmark=new Benchmark(10000); 24 | private static Element root; 25 | 26 | @BeforeAll 27 | public static void beforeAll() throws Exception { 28 | Document document = XMLUtil.loadFromFile("gate-config.xml"); 29 | root = document.getRootElement(); 30 | 31 | } 32 | 33 | @Test 34 | @Order(1) 35 | public void test() throws Exception { 36 | JSONObject obj = new JSONObject(); 37 | JsonXmlUtil.xml2Json(root, obj); 38 | logger.debug(obj); 39 | 40 | } 41 | 42 | 43 | @BeforeEach 44 | public void beforeEach() { 45 | 46 | } 47 | 48 | @AfterEach 49 | public void afterEach() { 50 | 51 | } 52 | 53 | 54 | @AfterAll 55 | public static void afterAll() { 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /gamioo-sandbox/src/test/java/io/gamioo/sandbox/AnsibleTest.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.sandbox; 2 | 3 | import com.github.woostju.ansible.AnsibleClient; 4 | import com.github.woostju.ansible.ReturnValue; 5 | import com.github.woostju.ansible.command.PingCommand; 6 | import com.github.woostju.ssh.SshClientConfig; 7 | import com.github.woostju.ssh.pool.SshClientsPool; 8 | import com.google.common.collect.Lists; 9 | import org.apache.logging.log4j.LogManager; 10 | import org.apache.logging.log4j.Logger; 11 | import org.junit.jupiter.api.*; 12 | 13 | import java.util.Map; 14 | 15 | @DisplayName("crypto test") 16 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 17 | public class AnsibleTest { 18 | private static final Logger logger = LogManager.getLogger(AnsibleTest.class); 19 | private static SshClientsPool pool = new SshClientsPool(); 20 | private static AnsibleClient client; 21 | 22 | @BeforeAll 23 | public static void beforeAll() { 24 | 25 | client = new AnsibleClient(new SshClientConfig("115.159.87.108", 3737, "root", "", null), pool); 26 | 27 | // client = new AnsibleClient(); 28 | 29 | } 30 | 31 | @AfterAll 32 | public static void afterAll() { 33 | 34 | } 35 | 36 | @DisplayName("ssh") 37 | @Test 38 | @Order(1) 39 | public void ssh() { 40 | Map result = client.execute(new PingCommand(Lists.newArrayList("106.53.236.196")), 1000); 41 | logger.debug("result", result); 42 | 43 | 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/type/classreading/MetadataReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.type.classreading; 18 | 19 | import io.gamioo.ioc.io.Resource; 20 | import io.gamioo.ioc.type.AnnotationMetadata; 21 | import io.gamioo.ioc.type.ClassMetadata; 22 | 23 | /** 24 | * some description 25 | * 26 | * @author Allen Jiang 27 | * @since 1.0.0 28 | */ 29 | public interface MetadataReader { 30 | /** 31 | * Return the resource reference for the class file. 32 | */ 33 | Resource getResource(); 34 | 35 | /** 36 | * Read basic class metadata for the underlying class. 37 | */ 38 | ClassMetadata getClassMetadata(); 39 | 40 | /** 41 | * Read full annotation metadata for the underlying class, 42 | * including metadata for annotated methods. 43 | */ 44 | AnnotationMetadata getAnnotationMetadata(); 45 | } 46 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/factory/ObjectFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.factory; 18 | 19 | import io.gamioo.common.exception.BeansException; 20 | 21 | 22 | 23 | /** 24 | * Defines a factory which can return an Object instance 25 | * (possibly shared or independent) when invoked. 26 | * 27 | *

This interface is typically used to encapsulate a generic factory which 28 | * returns a new instance (prototype) of some target object on each invocation. 29 | * 30 | * @author Allen Jiang 31 | * @since 1.0.0 32 | */ 33 | public interface ObjectFactory { 34 | 35 | /** 36 | * Return an instance (possibly shared or independent) 37 | * of the object managed by this factory. 38 | * @return the resulting instance 39 | * @throws BeansException in case of creation errors 40 | */ 41 | T getObject() throws BeansException; 42 | 43 | } -------------------------------------------------------------------------------- /gamioo-sandbox/src/test/java/io/gamioo/sandbox/CryptoTest.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.sandbox; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | import org.junit.jupiter.api.*; 6 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 7 | 8 | import java.io.IOException; 9 | 10 | @DisplayName("crypto test") 11 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 12 | public class CryptoTest { 13 | private static final Logger logger = LogManager.getLogger(CryptoTest.class); 14 | 15 | 16 | @BeforeAll 17 | public static void beforeAll() throws IOException { 18 | } 19 | 20 | @AfterAll 21 | public static void afterAll() { 22 | 23 | } 24 | 25 | @DisplayName("bCrypt") 26 | @Test 27 | @Order(1) 28 | public void bCrypt() { 29 | String password = "neil"; 30 | String encodedPwd = "$apr1$PjLB3DLO$J1zN2Bbit2A9e8FQdALjb0"; 31 | //密码加密 32 | BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); 33 | //加密 34 | String newPassword = passwordEncoder.encode(password); 35 | logger.debug("raw pwd:{},encoded pwd:{}", password, newPassword); 36 | 37 | //对比这两个密码是否是同一个密码 38 | logger.debug("compare {},{}", password, encodedPwd); 39 | boolean matches = passwordEncoder.matches(password, encodedPwd); 40 | if (matches) { 41 | logger.debug("match"); 42 | } else { 43 | logger.debug("diff"); 44 | } 45 | 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | ## Welcome to GitHub Pages 5 | 6 | You can use the [editor on GitHub](https://github.com/jiangguilong2000/gamioo/edit/master/docs/index.md) to maintain and preview the content for your website in Markdown files. 7 | 8 | Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files. 9 | 10 | ### Markdown 11 | 12 | Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for 13 | 14 | ```markdown 15 | Syntax highlighted code block 16 | 17 | # Header 1 18 | 19 | ## Header 2 20 | 21 | ### Header 3 22 | 23 | - Bulleted 24 | - List 25 | 26 | 1. Numbered 27 | 2. List 28 | 29 | **Bold** and _Italic_ and `Code` text 30 | 31 | [Link](url) and ![Image](src) 32 | ``` 33 | 34 | For more details see [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/). 35 | 36 | ### Jekyll Themes 37 | 38 | Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/jiangguilong2000/gamioo/settings). The name of this theme is 39 | saved in the Jekyll `_config.yml` configuration file. 40 | 41 | ### Support or Contact 42 | 43 | Having trouble with Pages? Check out our [documentation](https://docs.github.com/categories/github-pages-basics/) or [contact support](https://github.com/contact) and we’ll help you sort it out. 44 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/util/CharsetUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.common.util; 18 | 19 | import java.nio.charset.Charset; 20 | 21 | /** 22 | * 字符集工具类 23 | * 24 | * @author Allen Jiang 25 | * @since 1.0.0 26 | */ 27 | public class CharsetUtils { 28 | /** 29 | * ISO-8859-1 30 | */ 31 | public static final String ISO_8859_1 = "ISO-8859-1"; 32 | /** 33 | * UTF-8 34 | */ 35 | public static final String UTF_8 = "UTF-8"; 36 | /** 37 | * GBK 38 | */ 39 | public static final String GBK = "GBK"; 40 | /** 41 | * ISO-8859-1 42 | */ 43 | public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1); 44 | /** 45 | * UTF-8 46 | */ 47 | public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8); 48 | /** 49 | * GBK 50 | */ 51 | public static final Charset CHARSET_GBK = Charset.forName(GBK); 52 | } 53 | -------------------------------------------------------------------------------- /gamioo-redis/src/main/java/io/gamioo/redis/zset/generic/ScoreHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 wjybxx 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to iBn writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.redis.zset.generic; 18 | 19 | import java.util.Comparator; 20 | 21 | /** 22 | * 泛型化的分数处理器 23 | * 24 | * Note: 25 | * 1. score对象必须实现为不可变,一定不可以修改里面的内容。 26 | * 2. {@link #sum(Object, Object)}必须返回一个新对象。 27 | * 3. 不要在score对象中存储杂七杂八的属性,如果想存储一些额外的数据,请存储在key中。 28 | * 29 | * @param the type of score 30 | * @author wjybxx 31 | * @version 1.0 32 | * date - 2019/11/6 33 | */ 34 | public interface ScoreHandler extends Comparator { 35 | 36 | /** 37 | * 比较两个score的大小。 38 | * 39 | * @param o1 score 40 | * @param o2 score 41 | * @return 0表示相等 42 | */ 43 | @Override 44 | int compare(T o1, T o2); 45 | 46 | /** 47 | * 计算两个score的和 48 | * 49 | * @param oldScore 当前分数 50 | * @param increment 增量 51 | * @return newInstance 52 | */ 53 | T sum(T oldScore, T increment); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/wrapper/BeanWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.wrapper; 18 | 19 | /** 20 | * some description 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public class BeanWrapper { 26 | private Object object; 27 | 28 | public BeanWrapper(Object object) { 29 | this.object = object; 30 | } 31 | 32 | /** 33 | * Return the bean instance wrapped by this object, if any. 34 | * 35 | * @return the bean instance, or {@code null} if none set 36 | */ 37 | public Object getWrappedInstance() { 38 | return this.object; 39 | } 40 | 41 | /** 42 | * Return the type of the wrapped JavaBean object. 43 | * 44 | * @return the type of the wrapped bean instance, 45 | * or {@code null} if no wrapped object has been set 46 | */ 47 | public Class getWrappedClass() { 48 | return (this.object != null ? this.object.getClass() : null); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/factory/support/DefaultListableBeanFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.factory.support; 18 | 19 | import io.gamioo.ioc.annotation.CommandMapping; 20 | import io.gamioo.ioc.annotation.RequestMapping; 21 | import io.gamioo.ioc.definition.BeanDefinition; 22 | import io.gamioo.ioc.definition.MethodDefinition; 23 | import io.gamioo.ioc.stereotype.Controller; 24 | import io.gamioo.ioc.wrapper.Command; 25 | import io.gamioo.ioc.wrapper.MethodWrapper; 26 | 27 | import java.lang.annotation.Annotation; 28 | import java.util.Collection; 29 | import java.util.List; 30 | import java.util.Map; 31 | import java.util.concurrent.ConcurrentHashMap; 32 | 33 | /** 34 | * some description 35 | * 36 | * @author Allen Jiang 37 | * @since 1.0.0 38 | */ 39 | public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFactory { 40 | 41 | /** 42 | * 控制器的消息处理容器 43 | */ 44 | protected final Map commandStore = new ConcurrentHashMap<>(1024); 45 | 46 | 47 | 48 | 49 | } 50 | 51 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/factory/BeanFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.factory; 18 | 19 | import io.gamioo.common.exception.BeansException; 20 | import io.gamioo.ioc.definition.BeanDefinition; 21 | 22 | import java.lang.annotation.Annotation; 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | 27 | /** 28 | * some description 29 | * 30 | * @author Allen Jiang 31 | * @since 1.0.0 32 | */ 33 | 34 | public interface BeanFactory { 35 | 36 | public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition); 37 | 38 | public T getBean(Class requiredType); 39 | 40 | public Object getBean(String name) throws BeansException; 41 | 42 | public List getBeanListOfType(Class type); 43 | 44 | public List getBeanListOfAnnotation(Class type); 45 | 46 | public T getBean(String name, Class requiredType); 47 | 48 | public Map getBeanMapOfType(Class type); 49 | 50 | void preInstantiateSingletons(); 51 | 52 | } -------------------------------------------------------------------------------- /gamioo-event/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | event 6 | log 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time 6 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle 7 | 8 | name: build 9 | 10 | on: [ "push", "pull_request" ] 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout Code 17 | uses: actions/checkout@v3.3.0 18 | - name: Set up JDK 8 19 | uses: actions/setup-java@v3.10.0 20 | with: 21 | java-version: '8' 22 | distribution: 'temurin' 23 | - name: Run chmod to make gradlew executable 24 | run: chmod +x ./gradlew 25 | - name: Clean with Gradle 26 | uses: gradle/gradle-build-action@v2.4.0 27 | with: 28 | arguments: clean 29 | - name: Build with Gradle 30 | uses: gradle/gradle-build-action@v2.4.0 31 | with: 32 | arguments: build --scan 33 | - name: Coverage with Gradle 34 | uses: gradle/gradle-build-action@v2.4.0 35 | with: 36 | arguments: coverage 37 | - name: Upload coverage reports to Codecov 38 | uses: codecov/codecov-action@v3.1.1 39 | with: 40 | token: ${{ secrets.CODECOV_TOKEN }} 41 | finish: 42 | needs: build 43 | runs-on: ubuntu-latest 44 | if: ${{success()}} 45 | steps: 46 | - run: echo "Build successfully on branch ${{ github.actor }}" 47 | 48 | 49 | -------------------------------------------------------------------------------- /gamioo-common/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api project(':gamioo-log'); 3 | api group: 'com.google.guava', name: 'guava', version: '31.1-jre'; 4 | api group: 'com.esotericsoftware', name: 'reflectasm', version: '1.11.9'; 5 | api group: 'org.apache.commons', name: 'commons-lang3', version: '3.11'; 6 | api group: 'commons-io', name: 'commons-io', version: '2.8.0'; 7 | api group: 'org.ow2.asm', name: 'asm', version: '8.0.1'; 8 | api group: 'commons-net', name: 'commons-net', version: '3.9.0'; 9 | api group: 'commons-codec', name: 'commons-codec', version: '1.15' 10 | api group: 'org.dom4j', name: 'dom4j', version: '2.1.3'; 11 | api group: 'com.alibaba.fastjson2', name: 'fastjson2', version: '2.0.37'; 12 | api group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'; 13 | api group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'; 14 | // api group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.14.2' 15 | //任务调度 16 | api group: 'it.sauronsoftware.cron4j', name: 'cron4j', version: '2.2.5'; 17 | // api group: 'com.jfinal', name: 'jfinal', version: '5.0.8'; 18 | api group: 'org.jctools', name: 'jctools-core', version: '3.3.0'; 19 | // http 20 | api group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.14'; 21 | api group: 'org.apache.httpcomponents', name: 'fluent-hc', version: '4.5.14'; 22 | 23 | api group: 'jakarta.annotation', name: 'jakarta.annotation-api', version: '1.3.5'; 24 | api group: 'jakarta.servlet', name: 'jakarta.servlet-api', version: '4.0.4'; 25 | api group: 'org.reflections', name: 'reflections', version: '0.10.2'; 26 | api group: 'cn.hutool', name: 'hutool-core', version: '5.8.18'; 27 | 28 | } -------------------------------------------------------------------------------- /.github/workflows/gradle-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | # This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created 6 | # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle 7 | 8 | name: Gradle Package 9 | 10 | on: 11 | release: 12 | types: [created] 13 | 14 | jobs: 15 | build: 16 | 17 | runs-on: ubuntu-latest 18 | permissions: 19 | contents: read 20 | packages: write 21 | 22 | steps: 23 | - name: Checkout Code 24 | uses: actions/checkout@v3.3.0 25 | - name: Set up JDK 8 26 | uses: actions/setup-java@v3.10.0 27 | with: 28 | java-version: '8' 29 | distribution: 'temurin' 30 | server-id: github # Value of the distributionManagement/repository/id field of the pom.xml 31 | settings-path: ${{ github.workspace }} # location for the settings.xml file 32 | - name: Run chmod to make gradlew executable 33 | run: chmod +x ./gradlew 34 | - name: Build with Gradle 35 | uses: gradle/gradle-build-action@v2.4.0 36 | with: 37 | arguments: build 38 | 39 | # The USERNAME and TOKEN need to correspond to the credentials environment variables used in 40 | # the publishing section of your build.gradle 41 | - name: Publish to GitHub Packages 42 | uses: gradle/gradle-build-action@v2.4.0 43 | with: 44 | arguments: publish 45 | env: 46 | USERNAME: ${{ github.actor }} 47 | TOKEN: ${{ secrets.GITHUB_TOKEN }} 48 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/lang/Cache.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.lang; 2 | 3 | import org.apache.commons.lang3.builder.ToStringBuilder; 4 | import org.apache.commons.lang3.builder.ToStringStyle; 5 | 6 | /** 7 | * some description 8 | * 9 | * @author Allen Jiang 10 | * @since 1.0.0 11 | */ 12 | public class Cache { 13 | private int type; 14 | private String ip; 15 | private int port; 16 | private int index; 17 | private String password; 18 | 19 | public Cache(){ 20 | 21 | } 22 | public Cache(int type, String ip, int port, int index, String password) { 23 | this.type = type; 24 | this.ip = ip; 25 | this.port = port; 26 | this.index = index; 27 | this.password = password; 28 | } 29 | 30 | public int getType() { 31 | return type; 32 | } 33 | 34 | public void setType(int type) { 35 | this.type = type; 36 | } 37 | 38 | public String getIp() { 39 | return ip; 40 | } 41 | 42 | public void setIp(String ip) { 43 | this.ip = ip; 44 | } 45 | 46 | public int getPort() { 47 | return port; 48 | } 49 | 50 | public void setPort(int port) { 51 | this.port = port; 52 | } 53 | 54 | public int getIndex() { 55 | return index; 56 | } 57 | 58 | public void setIndex(int index) { 59 | this.index = index; 60 | } 61 | 62 | public String getPassword() { 63 | return password; 64 | } 65 | 66 | public void setPassword(String password) { 67 | this.password = password; 68 | } 69 | 70 | @Override 71 | public String toString() { 72 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/annotation/RequestMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.annotation; 18 | 19 | import io.gamioo.common.http.RequestMethod; 20 | 21 | import java.lang.annotation.*; 22 | 23 | /** 24 | * HTTP 协议入口 25 | * 26 | * @author Allen Jiang 27 | * @since 1.0.0 28 | */ 29 | @Target({ElementType.METHOD, ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | @Mapping 33 | public @interface RequestMapping { 34 | String name() default ""; 35 | 36 | String value() default ""; 37 | 38 | /** 39 | * The HTTP request methods to map to, narrowing the primary mapping: 40 | * GET, POST, HEAD, OPTIONS, PUT, PATCH, DELETE, TRACE. 41 | *

Supported at the type level as well as at the method level! 42 | * When used at the type level, all method-level mappings inherit 43 | * this HTTP method restriction (i.e. the type-level restriction 44 | * gets checked before the handler method is even resolved). 45 | *

Supported for Servlet environments as well as Portlet 2.0 environments. 46 | */ 47 | RequestMethod[] method() default {}; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/shape/AABB.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.common.shape; 2 | 3 | /** 4 | * @author Allen Jiang 5 | */ 6 | public class AABB implements Shape { 7 | private final int left; 8 | private final int top; 9 | private final int right; 10 | private final int bottom; 11 | 12 | 13 | public AABB(int left, int top, int right, int bottom) { 14 | this.left = left; 15 | this.top = top; 16 | this.right = right; 17 | this.bottom = bottom; 18 | } 19 | 20 | 21 | public int getLeft() { 22 | return left; 23 | } 24 | 25 | public int getTop() { 26 | return top; 27 | } 28 | 29 | public int getRight() { 30 | return right; 31 | } 32 | 33 | public int getBottom() { 34 | return bottom; 35 | } 36 | 37 | public int getCenterX() { 38 | return (left + right + 1) / 2; 39 | } 40 | 41 | public int getCenterY() { 42 | return (top + bottom + 1) / 2; 43 | } 44 | 45 | public int getWidth() { 46 | return right - left + 1; 47 | } 48 | 49 | public int getHeight() { 50 | return bottom - top + 1; 51 | } 52 | 53 | 54 | @Override 55 | public String toString() { 56 | return "AABB{" + 57 | "left=" + left + 58 | ", top=" + top + 59 | ", right=" + right + 60 | ", bottom=" + bottom + 61 | '}'; 62 | } 63 | 64 | @Override 65 | public boolean containsPoint(long x, long y) { 66 | return left <= x && x <= right && top <= y && y <= bottom; 67 | } 68 | 69 | @Override 70 | public AABB getAABB() { 71 | return this; 72 | } 73 | 74 | @Override 75 | public Point getRandomPoint() { 76 | return null; 77 | } 78 | } -------------------------------------------------------------------------------- /gamioo-sandbox/src/test/java/io/gamioo/sandbox/BitMapTest.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.sandbox; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | import org.junit.jupiter.api.*; 6 | 7 | import java.io.IOException; 8 | import java.util.BitSet; 9 | 10 | @DisplayName("BitMap test") 11 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 12 | public class BitMapTest { 13 | private static final Logger logger = LogManager.getLogger(BitMapTest.class); 14 | 15 | 16 | @BeforeAll 17 | public static void beforeAll() throws IOException { 18 | } 19 | 20 | @AfterAll 21 | public static void afterAll() { 22 | 23 | } 24 | 25 | @DisplayName("bitmap") 26 | @Test 27 | @Order(2) 28 | public void nativeFind() throws Exception { 29 | BitSet bit = new BitSet(); 30 | BitSet other = new BitSet(); 31 | logger.debug("size={}", bit.size()); 32 | int a[] = {2, 3, 14, 7, 0, 66}; 33 | 34 | //赋值 35 | for (int num : a) { 36 | //进入某层 37 | bit.set(num); 38 | 39 | } 40 | 41 | //离开某层 42 | // bit.clear(2); 43 | 44 | int b[] = {1, 4}; 45 | for (int num : b) { 46 | other.set(num, true); 47 | } 48 | 49 | logger.debug("size={}", bit.size()); 50 | //排序 51 | 52 | for (int i = 0; i < bit.size(); i++) { 53 | 54 | if (bit.get(i)) { 55 | logger.debug(i); 56 | } 57 | } 58 | if (bit.intersects(other)) { 59 | logger.debug("same layer"); 60 | } 61 | logger.debug("{}", bit.toByteArray()); 62 | logger.debug("{}", bit.toLongArray()); 63 | logger.debug("{}", bit.toString()); 64 | 65 | 66 | logger.debug("end"); 67 | } 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/util/AnnotationUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gamioo.common.util; 17 | 18 | import java.lang.annotation.Annotation; 19 | import java.lang.reflect.AnnotatedElement; 20 | 21 | 22 | /** 23 | * 注解工具类. 24 | * 25 | * @author Allen Jiang 26 | * @since 1.0.0 27 | */ 28 | 29 | public class AnnotationUtils { 30 | private AnnotationUtils() { 31 | } 32 | 33 | /** 34 | * 获取指定类型的注解或注解上有指定的注解. 35 | * 36 | * @param element 注解元素 37 | * @param annotationType 注解类型 38 | * @param 注解类型 39 | * @return 返回标识有指定注解的注解 40 | */ 41 | public static Annotation getAnnotation(AnnotatedElement element, Class annotationType) { 42 | A annotation = element.getAnnotation(annotationType); 43 | if (annotation == null) { 44 | for (Annotation metaAnn : element.getAnnotations()) { 45 | annotation = metaAnn.annotationType().getAnnotation(annotationType); 46 | if (annotation != null) { 47 | return metaAnn; 48 | } 49 | } 50 | } 51 | return annotation; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /gamioo-sandbox/src/main/java/io/gamioo/sandbox/SerializingUtil.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.sandbox; 2 | 3 | import io.protostuff.LinkedBuffer; 4 | import io.protostuff.ProtostuffIOUtil; 5 | import io.protostuff.runtime.RuntimeSchema; 6 | 7 | /** 8 | * 序列化和反序列化工具类 9 | * @author Allen Jiang 10 | */ 11 | public class SerializingUtil { 12 | 13 | /** 14 | * 将目标类序列化为byte数组 15 | * 16 | * @param source 17 | * @param 18 | * @return 19 | */ 20 | public static byte[] serialize(T source) { 21 | RuntimeSchema schema; 22 | LinkedBuffer buffer = null; 23 | byte[] result; 24 | try { 25 | schema = RuntimeSchema.createFrom((Class) source.getClass()); 26 | buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE); 27 | result = ProtostuffIOUtil.toByteArray(source, schema, buffer); 28 | } catch (Exception e) { 29 | throw new RuntimeException("serialize exception"); 30 | } finally { 31 | if (buffer != null) { 32 | buffer.clear(); 33 | } 34 | } 35 | 36 | return result; 37 | } 38 | 39 | /** 40 | * 将byte数组反序列化为目标类 41 | * 42 | * @param source 43 | * @param typeClass 44 | * @param 45 | * @return 46 | */ 47 | public static T deserialize(byte[] source, Class typeClass) { 48 | RuntimeSchema schema; 49 | T newInstance; 50 | try { 51 | schema = RuntimeSchema.createFrom(typeClass); 52 | newInstance = typeClass.newInstance(); 53 | ProtostuffIOUtil.mergeFrom(source, newInstance, schema); 54 | } catch (Exception e) { 55 | throw new RuntimeException("deserialize exception"); 56 | } 57 | 58 | return newInstance; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/util/ByteArrayUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.common.util; 18 | 19 | /** 20 | * 字节数组操作工具类. 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public class ByteArrayUtils { 26 | /** 27 | * 一个空的字节数组. 28 | */ 29 | public static final byte[] EMPTY_BYTE_ARRAY = {}; 30 | 31 | /** 32 | * 一个short类型的数字转化为2位byte数组 33 | * 34 | * @param a short类型的数字 35 | * @return byte数组 36 | */ 37 | public static byte[] toByteArray(short a) { 38 | return new byte[]{(byte) ((a >> 8) & 0xFF), (byte) (a & 0xFF)}; 39 | } 40 | 41 | /** 42 | * 一个int类型的数字转化为4位byte数组 43 | * 44 | * @param num int类型的数字 45 | * @return byte数组 46 | */ 47 | public static byte[] toByteArray(int num) { 48 | return new byte[]{(byte) ((num >> 24) & 0xFF), (byte) ((num >> 16) & 0xFF), (byte) ((num >> 8) & 0xFF), (byte) (num & 0xFF)}; 49 | } 50 | 51 | /** 52 | * 4位byte数组转化为一个int类型的数字 53 | * 54 | * @param bytes byte数组 55 | * @return int类型的数字 56 | */ 57 | public static int toInt(byte[] bytes) { 58 | return bytes[3] & 0xFF | (bytes[2] & 0xFF) << 8 | (bytes[1] & 0xFF) << 16 | (bytes[0] & 0xFF) << 24; 59 | } 60 | } -------------------------------------------------------------------------------- /gamioo-redis/src/main/java/io/gamioo/redis/zset/generic/ScoreRangeSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 wjybxx 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to iBn writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.redis.zset.generic; 18 | 19 | /** 20 | * Score范围区间 21 | * 22 | * @author wjybxx 23 | * @version 1.0 24 | * date - 2019/11/7 25 | */ 26 | public class ScoreRangeSpec { 27 | 28 | /** 29 | * 起始分数 - 最高分或最低分 30 | */ 31 | private final S start; 32 | /** 33 | * 是否去除起始分数 34 | * exclusive 35 | */ 36 | private final boolean startEx; 37 | /** 38 | * 截止分数 - 最高分或最低分 39 | */ 40 | private final S end; 41 | /** 42 | * 是否去除最高分 43 | * exclusive 44 | */ 45 | private final boolean endEx; 46 | 47 | public ScoreRangeSpec(S start, S end) { 48 | this(start, false, end, false); 49 | } 50 | 51 | public ScoreRangeSpec(S start, boolean startEx, S end, boolean endEx) { 52 | this.start = start; 53 | this.startEx = startEx; 54 | this.end = end; 55 | this.endEx = endEx; 56 | } 57 | 58 | 59 | public S getStart() { 60 | return start; 61 | } 62 | 63 | public boolean isStartEx() { 64 | return startEx; 65 | } 66 | 67 | public S getEnd() { 68 | return end; 69 | } 70 | 71 | public boolean isEndEx() { 72 | return endEx; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /gamioo-sandbox/src/jmh/java/io/gamioo/sandbox/InterruptBenchmark.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.sandbox; 2 | 3 | 4 | import org.openjdk.jmh.annotations.*; 5 | import org.openjdk.jmh.runner.Runner; 6 | import org.openjdk.jmh.runner.RunnerException; 7 | import org.openjdk.jmh.runner.options.Options; 8 | import org.openjdk.jmh.runner.options.OptionsBuilder; 9 | import org.openjdk.jmh.runner.options.TimeValue; 10 | 11 | import java.util.concurrent.ArrayBlockingQueue; 12 | import java.util.concurrent.BlockingQueue; 13 | import java.util.concurrent.TimeUnit; 14 | 15 | /** 16 | * JMH测试16:Interrupts Benchmark样例 17 | * 18 | * @author Allen Jiang 19 | */ 20 | @Fork(1) 21 | @BenchmarkMode(Mode.AverageTime) 22 | @OutputTimeUnit(TimeUnit.NANOSECONDS) 23 | @State(Scope.Group) 24 | public class InterruptBenchmark { 25 | private BlockingQueue queue; 26 | 27 | private final static int VALUE = Integer.MAX_VALUE; 28 | 29 | @Setup 30 | public void init() { 31 | this.queue = new ArrayBlockingQueue<>(10); 32 | } 33 | 34 | @GroupThreads(5) 35 | @Group("queue") 36 | @Warmup(iterations = 5, time = 1) 37 | @Measurement(iterations = 5, time = 1) 38 | @Benchmark 39 | public void put() 40 | throws InterruptedException { 41 | this.queue.put(VALUE); 42 | } 43 | 44 | @GroupThreads(5) 45 | @Group("queue") 46 | @Warmup(iterations = 5, time = 1) 47 | @Measurement(iterations = 5, time = 1) 48 | @Benchmark 49 | public int take() 50 | throws InterruptedException { 51 | return this.queue.take(); 52 | } 53 | 54 | public static void main(String[] args) throws RunnerException { 55 | Options opt = new OptionsBuilder() 56 | .include(InterruptBenchmark.class.getSimpleName()) 57 | // 将每个批次的超时时间设置为10秒 58 | .timeout(TimeValue.milliseconds(10000)) 59 | .build(); 60 | new Runner(opt).run(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/factory/support/AbstractBeanDefinitionReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.factory.support; 18 | 19 | 20 | import io.gamioo.ioc.factory.BeanFactory; 21 | 22 | /** 23 | * some description 24 | * 25 | * @author Allen Jiang 26 | * @since 1.0.0 27 | */ 28 | public abstract class AbstractBeanDefinitionReader implements BeanDefinitionReader { 29 | 30 | // private Map registry= new HashMap(); 31 | 32 | // private ResourceLoader resourceLoader; 33 | 34 | private BeanFactory beanFactory; 35 | 36 | public AbstractBeanDefinitionReader(BeanFactory beanFactory) { 37 | this.beanFactory = beanFactory; 38 | } 39 | 40 | public BeanFactory getBeanFactory() { 41 | return beanFactory; 42 | } 43 | 44 | public void setBeanFactory(BeanFactory beanFactory) { 45 | this.beanFactory = beanFactory; 46 | } 47 | 48 | // public Map getRegistry() { 49 | // return registry; 50 | // } 51 | 52 | // public void setResourceLoader(ResourceLoader resourceLoader) { 53 | // this.resourceLoader = resourceLoader; 54 | // } 55 | // 56 | // public ResourceLoader getResourceLoader() { 57 | // return resourceLoader; 58 | // } 59 | } -------------------------------------------------------------------------------- /gamioo-redis/src/main/java/io/gamioo/redis/zset/object2long/LongScoreRangeSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 wjybxx 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to iBn writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.redis.zset.object2long; 18 | 19 | /** 20 | * Score范围区间 21 | * 22 | * @author wjybxx 23 | * @version 1.0 24 | * date - 2019/11/7 25 | */ 26 | public class LongScoreRangeSpec { 27 | 28 | /** 29 | * 起始分数 - 最高分或最低分 30 | */ 31 | private final long start; 32 | /** 33 | * 是否去除起始分数 34 | * exclusive 35 | */ 36 | private final boolean startEx; 37 | /** 38 | * 截止分数 - 最高分或最低分 39 | */ 40 | private final long end; 41 | /** 42 | * 是否去除最高分 43 | * exclusive 44 | */ 45 | private final boolean endEx; 46 | 47 | public LongScoreRangeSpec(long start, long end) { 48 | this(start, false, end, false); 49 | } 50 | 51 | public LongScoreRangeSpec(long start, boolean startEx, long end, boolean endEx) { 52 | this.start = start; 53 | this.startEx = startEx; 54 | this.end = end; 55 | this.endEx = endEx; 56 | } 57 | 58 | 59 | public long getStart() { 60 | return start; 61 | } 62 | 63 | public boolean isStartEx() { 64 | return startEx; 65 | } 66 | 67 | public long getEnd() { 68 | return end; 69 | } 70 | 71 | public boolean isEndEx() { 72 | return endEx; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/factory/xml/XmlResourceLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.factory.xml; 18 | 19 | import io.gamioo.ioc.io.Resource; 20 | import io.gamioo.ioc.io.ResourceLoader; 21 | import io.gamioo.ioc.io.UrlFileResource; 22 | 23 | import java.io.IOException; 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | 27 | /** 28 | * some description 29 | * 30 | * @author Allen Jiang 31 | * @since 1.0.0 32 | */ 33 | public class XmlResourceLoader implements ResourceLoader { 34 | 35 | /** 36 | * Resolve the given location pattern into Resource objects. 37 | *

Overlapping resource entries that point to the same physical 38 | * resource should be avoided, as far as possible. The result should 39 | * have set semantics. 40 | * 41 | * @param location the location pattern to resolve 42 | * @return the corresponding Resource objects 43 | * @throws IOException in case of I/O errors 44 | */ 45 | @Override 46 | public List getResourceList(String location) throws IOException { 47 | List ret=new ArrayList<>(); 48 | // URL url = ClassUtils.getDefaultClassLoader().getResource(location); 49 | UrlFileResource resource=new UrlFileResource(location); 50 | ret.add(resource); 51 | return ret; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/wrapper/Command.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.wrapper; 2 | 3 | import io.gamioo.ioc.annotation.CommandMapping; 4 | import org.apache.commons.lang3.builder.ToStringBuilder; 5 | import org.apache.commons.lang3.builder.ToStringStyle; 6 | import org.apache.logging.log4j.LogManager; 7 | import org.apache.logging.log4j.Logger; 8 | 9 | import java.util.concurrent.atomic.LongAdder; 10 | 11 | /** 12 | * 指令包装类 13 | * 14 | * @author Allen Jiang 15 | * @since 1.0.0 16 | */ 17 | public class Command { 18 | private static final Logger logger = LogManager.getLogger(Command.class); 19 | private MethodWrapper wrapper; 20 | 21 | private final int code; 22 | private boolean valid; 23 | private final boolean print; 24 | private final boolean login; 25 | private final boolean cross; 26 | /** 27 | * 调用次数累加 28 | */ 29 | private final LongAdder number = new LongAdder(); 30 | 31 | public Command(MethodWrapper wrapper, CommandMapping mapping) { 32 | this.wrapper = wrapper; 33 | this.code = mapping.code(); 34 | this.print = mapping.print(); 35 | this.login = mapping.login(); 36 | this.cross = mapping.cross(); 37 | 38 | } 39 | 40 | public int getCode() { 41 | return code; 42 | } 43 | 44 | public boolean isValid() { 45 | return valid; 46 | } 47 | 48 | public void setValid(boolean valid) { 49 | this.valid = valid; 50 | } 51 | 52 | public boolean isPrint() { 53 | return print; 54 | } 55 | 56 | public boolean isLogin() { 57 | return login; 58 | } 59 | 60 | public boolean isCross() { 61 | return cross; 62 | } 63 | 64 | public void increase() { 65 | number.increment(); 66 | } 67 | 68 | 69 | public long getInvokeNumber() { 70 | return number.longValue(); 71 | } 72 | 73 | public String toString() { 74 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 75 | } 76 | 77 | } 78 | 79 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/type/MethodMetadata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.type; 18 | 19 | /** 20 | * some description 21 | * 22 | * @author Allen Jiang 23 | * @since 1.0.0 24 | */ 25 | public interface MethodMetadata extends AnnotatedTypeMetadata { 26 | 27 | /** 28 | * Return the name of the method. 29 | */ 30 | String getMethodName(); 31 | 32 | /** 33 | * Return the fully-qualified name of the class that declares this method. 34 | */ 35 | String getDeclaringClassName(); 36 | 37 | /** 38 | * Return the fully-qualified name of this method's declared return type. 39 | * 40 | */ 41 | String getReturnTypeName(); 42 | 43 | /** 44 | * Return whether the underlying method is effectively abstract: 45 | * i.e. marked as abstract on a class or declared as a regular, 46 | * non-default method in an interface. 47 | * 48 | * @since 4.2 49 | */ 50 | boolean isAbstract(); 51 | 52 | /** 53 | * Return whether the underlying method is declared as 'static'. 54 | */ 55 | boolean isStatic(); 56 | 57 | /** 58 | * Return whether the underlying method is marked as 'final'. 59 | */ 60 | boolean isFinal(); 61 | 62 | /** 63 | * Return whether the underlying method is overridable, 64 | * i.e. not marked as static, final or private. 65 | */ 66 | boolean isOverridable(); 67 | } 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 |

5 | Game , so easy. 6 |

7 | 8 |

9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | github star 32 | 33 |

34 | 35 | ##### 语言: 中文 | [English](README.en-US.md) 36 | 37 | ## 📌 简介 38 | 39 | Game server framework, based on this framework, you can quickly implement a highly available, easy to maintain, stable and high-performance game server. 40 | 41 | ## 🔧 功能特点 42 | 43 | ## 📄文件结构 44 | 45 | ## TODO list 46 | -------------------------------------------------------------------------------- /gamioo-log/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /gamioo-log/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/exception/NestedIOException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.common.exception; 18 | 19 | import java.io.IOException; 20 | 21 | /** 22 | * some description 23 | * 24 | * @author Allen Jiang 25 | * @since 1.0.0 26 | */ 27 | public class NestedIOException extends IOException { 28 | 29 | /** 30 | * Construct a {@code NestedIOException} with the specified detail message. 31 | * 32 | * @param msg the detail message 33 | */ 34 | public NestedIOException(String msg) { 35 | super(msg); 36 | } 37 | 38 | /** 39 | * Construct a {@code NestedIOException} with the specified detail message 40 | * and nested exception. 41 | * 42 | * @param msg the detail message 43 | * @param cause the nested exception 44 | */ 45 | public NestedIOException(String msg, Throwable cause) { 46 | super(msg, cause); 47 | } 48 | 49 | 50 | /** 51 | * Return the detail message, including the message from the nested exception 52 | * if there is one. 53 | */ 54 | @Override 55 | public String getMessage() { 56 | String message = super.getMessage(); 57 | if (getCause() != null) { 58 | StringBuilder sb = new StringBuilder(); 59 | if (message != null) { 60 | sb.append(message).append("; "); 61 | } 62 | sb.append("nested exception is ").append(getCause()); 63 | return sb.toString(); 64 | } else { 65 | return message; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /gamioo-sandbox/src/main/java/io/gamioo/sandbox/HarmDTO.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.sandbox; 2 | 3 | import com.github.houbb.data.factory.api.annotation.DataFactory; 4 | import org.apache.commons.lang3.builder.ToStringBuilder; 5 | import org.apache.commons.lang3.builder.ToStringStyle; 6 | 7 | /** 8 | * @author Allen Jiang 9 | */ 10 | public class HarmDTO { 11 | @DataFactory(min = 1000000000, max = Integer.MAX_VALUE) 12 | private Long targetId;//受伤者 13 | @DataFactory(min = 1, max = 100) 14 | private int type;// 伤害类型 15 | 16 | @DataFactory(min = 0, max = 99999) 17 | private float value;//伤害值 18 | private boolean dead; //是否致死 19 | @DataFactory(min = 0, max = 99999) 20 | private long real; //真实伤害 21 | @DataFactory(min = 0, max = 9999999) 22 | private float maxHp;//最大血量 23 | @DataFactory(min = 0, max = 9999999) 24 | private float curHp;//当前血量 25 | 26 | public Long getTargetId() { 27 | return targetId; 28 | } 29 | 30 | public void setTargetId(Long targetId) { 31 | this.targetId = targetId; 32 | } 33 | 34 | public int getType() { 35 | return type; 36 | } 37 | 38 | public void setType(int type) { 39 | this.type = type; 40 | } 41 | 42 | public float getValue() { 43 | return value; 44 | } 45 | 46 | public void setValue(float value) { 47 | this.value = value; 48 | } 49 | 50 | public boolean isDead() { 51 | return dead; 52 | } 53 | 54 | public void setDead(boolean dead) { 55 | this.dead = dead; 56 | } 57 | 58 | public long getReal() { 59 | return real; 60 | } 61 | 62 | public void setReal(long real) { 63 | this.real = real; 64 | } 65 | 66 | public float getMaxHp() { 67 | return maxHp; 68 | } 69 | 70 | public void setMaxHp(float maxHp) { 71 | this.maxHp = maxHp; 72 | } 73 | 74 | public float getCurHp() { 75 | return curHp; 76 | } 77 | 78 | public void setCurHp(float curHp) { 79 | this.curHp = curHp; 80 | } 81 | 82 | @Override 83 | public String toString() { 84 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/definition/BeanDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.definition; 18 | 19 | import java.lang.annotation.Annotation; 20 | import java.util.List; 21 | 22 | /** 23 | * some description 24 | * 25 | * @author Allen Jiang 26 | * @since 1.0.0 27 | */ 28 | public interface BeanDefinition extends Definition { 29 | 30 | List getFieldDefinitionList(Class clazz); 31 | 32 | List getMethodDefinitionList(Class clazz); 33 | // List getValueFieldDefinition(); 34 | 35 | Object newInstance(); 36 | 37 | /** 38 | * 解析方法 39 | */ 40 | void analysisMethodList(); 41 | 42 | /** 43 | * 解析字段 44 | */ 45 | void analysisFieldList(); 46 | 47 | /** 48 | * 解析实体对象 49 | * 50 | * @param instance 对象 51 | */ 52 | void analysisBean(Object instance); 53 | 54 | // /** 55 | // * 注入 56 | // */ 57 | // void inject(Object instance); 58 | 59 | MethodDefinition getInitMethodDefinition(); 60 | 61 | // void setInitMethodName(String initMethodName); 62 | // 63 | // String getDestroyMethodName(); 64 | // 65 | // void setDestroyMethodName(String destroyMethodName); 66 | 67 | // String getBeanClassName(); 68 | // 69 | // void setBeanClassName(String beanClassName); 70 | // 71 | // Class getBeanClass(); 72 | 73 | 74 | // void setBeanClass(Class beanClass); 75 | // 76 | // public PropertyValues getPropertyValues(); 77 | // 78 | // void setPropertyValues(PropertyValues propertyValues); 79 | 80 | } 81 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/annotation/AnnotationBeanDefinitionReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.annotation; 18 | 19 | import io.gamioo.ioc.context.ClassPathBeanDefinitionScanner; 20 | import io.gamioo.ioc.factory.support.AbstractBeanDefinitionReader; 21 | import io.gamioo.ioc.factory.support.DefaultListableBeanFactory; 22 | import org.apache.logging.log4j.LogManager; 23 | import org.apache.logging.log4j.Logger; 24 | 25 | /** 26 | * some description 27 | * 28 | * @author Allen Jiang 29 | * @since 1.0.0 30 | */ 31 | public class AnnotationBeanDefinitionReader extends AbstractBeanDefinitionReader { 32 | private static final Logger logger = LogManager.getLogger(AnnotationBeanDefinitionReader.class); 33 | public AnnotationBeanDefinitionReader(DefaultListableBeanFactory beanFactory) { 34 | super(beanFactory); 35 | } 36 | 37 | 38 | 39 | public void loadBeanDefinitions(String location){ 40 | 41 | // ResourceLoader resourceLoader=this.getResourceLoader(); 42 | ClassPathBeanDefinitionScanner scanner=new ClassPathBeanDefinitionScanner(this.getBeanFactory()); 43 | //扫描资源 44 | // Actually scan for bean definitions and register them. 45 | // this.getClass().getPackage(). 46 | scanner.doScan(location, "io.gamioo"); 47 | 48 | // this.scanPackage(resourceLoader.getLocation(), "io.gamioo"); 49 | 50 | } 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | // public Set doScan(String basePackage) { 61 | // List list= this.getResources(basePackage); 62 | // 63 | // 64 | // return null; 65 | // } 66 | } 67 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/type/classreading/AnnotationMetadataReadingVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.type.classreading; 18 | 19 | import io.gamioo.ioc.type.AnnotationMetadata; 20 | import io.gamioo.ioc.type.MethodMetadata; 21 | 22 | import java.util.LinkedHashMap; 23 | import java.util.LinkedHashSet; 24 | import java.util.Map; 25 | import java.util.Set; 26 | 27 | /** 28 | * some description 29 | * 30 | * @author Allen Jiang 31 | * @since 1.0.0 32 | */ 33 | public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor implements AnnotationMetadata { 34 | 35 | 36 | protected final ClassLoader classLoader; 37 | 38 | protected final Set annotationSet = new LinkedHashSet(4); 39 | 40 | protected final Map> metaAnnotationMap = new LinkedHashMap>(4); 41 | 42 | 43 | 44 | protected final Set methodMetadataSet = new LinkedHashSet(4); 45 | 46 | 47 | public AnnotationMetadataReadingVisitor(ClassLoader classLoader) { 48 | this.classLoader = classLoader; 49 | } 50 | 51 | 52 | public Set getAnnotationTypes() { 53 | return this.annotationSet; 54 | } 55 | 56 | public Set getMetaAnnotationTypes(String annotationName) { 57 | return this.metaAnnotationMap.get(annotationName); 58 | } 59 | 60 | 61 | public boolean hasAnnotation(String annotationName) { 62 | return this.annotationSet.contains(annotationName); 63 | } 64 | @Override 65 | public boolean isAnnotated(String annotationName) { 66 | return true; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /gamioo-sandbox/src/main/java/io/gamioo/sandbox/SkillFire_S2C_Msg.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.sandbox; 2 | 3 | import com.github.houbb.data.factory.api.annotation.DataFactory; 4 | import org.apache.commons.lang3.builder.ToStringBuilder; 5 | import org.apache.commons.lang3.builder.ToStringStyle; 6 | 7 | import java.util.ArrayList; 8 | import java.util.HashMap; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | /** 13 | * 技能回包 14 | * @author Allen Jiang 15 | */ 16 | public class SkillFire_S2C_Msg { 17 | @DataFactory(min = 1000000000, max = Integer.MAX_VALUE) 18 | private Long attackerId; 19 | private SkillCategory skillCategory;//技能类型(大类) 20 | @DataFactory(min = 0, max = 100) 21 | private int index;//设置连招索引 22 | @DataFactory(min = 0, max = 5) 23 | private List harmList=new ArrayList<>(); 24 | 25 | private List param1=new ArrayList<>(); 26 | 27 | // private Map store=new HashMap<>(); 28 | 29 | // public Map getStore() { 30 | // return store; 31 | // } 32 | // 33 | // public void setStore(Map store) { 34 | // this.store = store; 35 | // } 36 | 37 | public Long getAttackerId() { 38 | return attackerId; 39 | } 40 | 41 | public void setAttackerId(Long attackerId) { 42 | this.attackerId = attackerId; 43 | } 44 | 45 | public SkillCategory getSkillCategory() { 46 | return skillCategory; 47 | } 48 | 49 | public void setSkillCategory(SkillCategory skillCategory) { 50 | this.skillCategory = skillCategory; 51 | } 52 | 53 | public int getIndex() { 54 | return index; 55 | } 56 | 57 | public void setIndex(int index) { 58 | this.index = index; 59 | } 60 | 61 | public List getHarmList() { 62 | return harmList; 63 | } 64 | 65 | public void setHarmList(List harmList) { 66 | this.harmList = harmList; 67 | } 68 | 69 | public List getParam1() { 70 | return param1; 71 | } 72 | 73 | public void setParam1(List param1) { 74 | this.param1 = param1; 75 | } 76 | 77 | @Override 78 | public String toString() { 79 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /gamioo-common/src/main/java/io/gamioo/common/util/ThreadUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.common.util; 18 | 19 | import org.apache.logging.log4j.LogManager; 20 | import org.apache.logging.log4j.Logger; 21 | 22 | /** 23 | * 线程工具类. 24 | * 25 | * @author Allen Jiang 26 | * @since 1.0.0 27 | */ 28 | public class ThreadUtils { 29 | private static final Logger logger = LogManager.getLogger(ThreadUtils.class); 30 | 31 | /** 32 | * 暂停执行. 33 | *

34 | * 就是JDK的{@link Thread#sleep(long)}包装一下就不用管这个异常了.
35 | * 这个方法只用于写一些测试用例时使用... 36 | * 37 | * @param millis 暂停毫秒数 38 | */ 39 | public static void sleep(long millis) { 40 | try { 41 | if (millis > 0) { 42 | Thread.sleep(millis); 43 | } 44 | } catch (InterruptedException e) { 45 | throw new RuntimeException(e); 46 | } 47 | } 48 | 49 | /** 50 | * 输出当前线程正在运行的堆栈信息. 51 | * 52 | * @param thread 当前线程 53 | * @return 当前线程正在运行的堆栈信息 54 | */ 55 | public static String printStackTrace(Thread thread) { 56 | final StackTraceElement[] st = thread.getStackTrace(); 57 | StringBuffer sb = new StringBuffer(2048); 58 | sb.append("\n"); 59 | for (StackTraceElement e : st) { 60 | sb.append("\tat ").append(e).append("\n"); 61 | } 62 | return sb.toString(); 63 | } 64 | 65 | /** 66 | * 输出当前线程正在运行的堆栈信息. 67 | * 当前线程正在运行的堆栈信息 68 | */ 69 | public static void printStackTrace() { 70 | 71 | try { 72 | throw new Exception(); 73 | } catch (Exception e) { 74 | logger.error(e.getMessage(), e); 75 | } 76 | 77 | 78 | } 79 | } -------------------------------------------------------------------------------- /gamioo-ioc/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 1 6 | benchmark 7 | /data/log/${SERVER_NAME}/${SERVER_ID} 8 | /data/stat/gamioo/${SERVER_NAME}/${SERVER_ID} 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /gamioo-common/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 1 6 | benchmark 7 | /data/log/${SERVER_NAME}/${SERVER_ID} 8 | /data/stat/gamioo/${SERVER_NAME}/${SERVER_ID} 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /gamioo-redis/src/test/java/io/gamioo/redis/zset/object2long/Object2LongZSetTest.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.redis.zset.object2long; 2 | 3 | import java.util.concurrent.ThreadLocalRandom; 4 | import java.util.stream.LongStream; 5 | 6 | /** 7 | * {@link Object2LongZSet}的复杂score测试 8 | * 这里的score由vipLevel和level拼接而成,因此在比较时需要拆分。 9 | * 10 | * @author wjybxx 11 | * @version 1.0 12 | * date - 2019/11/7 13 | * github - https://github.com/hl845740757 14 | */ 15 | public class Object2LongZSetTest { 16 | 17 | private static final long MULTIPLE = 10000; 18 | 19 | public static void main(String[] args) { 20 | final Object2LongZSet zSet = Object2LongZSet.newLongKeyZSet(new ComplexScoreHandler()); 21 | 22 | // 插入数据 23 | LongStream.rangeClosed(1, 10000).forEach(playerId -> { 24 | zSet.zadd(randomScore(), playerId); 25 | }); 26 | 27 | // 覆盖数据 28 | LongStream.rangeClosed(1, 10000).forEach(playerId -> { 29 | zSet.zadd(randomScore(), playerId); 30 | }); 31 | 32 | System.out.println("------------------------- dump ----------------------"); 33 | System.out.println(zSet.dump()); 34 | System.out.println(); 35 | } 36 | 37 | private static long randomScore() { 38 | return composeToLong(ThreadLocalRandom.current().nextInt(0, 4), 39 | ThreadLocalRandom.current().nextInt(1, 101)); 40 | } 41 | 42 | private static long composeToLong(int a, int b) { 43 | return (long) a * MULTIPLE + b; 44 | } 45 | 46 | private static int vipLevel(long score) { 47 | return (int) (score / MULTIPLE); 48 | } 49 | 50 | private static int level(long score) { 51 | return (int) (score % MULTIPLE); 52 | } 53 | 54 | private static class ComplexScoreHandler implements LongScoreHandler { 55 | 56 | @Override 57 | public int compare(long o1, long o2) { 58 | // vip等级排序 - 等级高的排前面(逆序) 59 | final int vipLevelCompareR = Integer.compare(vipLevel(o2), vipLevel(o1)); 60 | if (vipLevelCompareR != 0) { 61 | return vipLevelCompareR; 62 | } 63 | // 普通等级排序 - 等级高的排前面(逆序) 64 | return Integer.compare(level(o2), level(o1)); 65 | } 66 | 67 | @Override 68 | public long sum(long oldScore, long increment) { 69 | throw new UnsupportedOperationException(); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/definition/GenericFieldDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc.definition; 18 | 19 | import io.gamioo.common.util.FieldUtils; 20 | 21 | import java.lang.annotation.Annotation; 22 | import java.lang.reflect.Field; 23 | 24 | /** 25 | * some description 26 | * 27 | * @author Allen Jiang 28 | * @since 1.0.0 29 | */ 30 | public class GenericFieldDefinition implements FieldDefinition { 31 | private Field field; 32 | 33 | 34 | public GenericFieldDefinition(Field field) { 35 | this.field = field; 36 | // this.field.setAccessible(true); 37 | } 38 | 39 | @Override 40 | public Annotation getAnnotation(){ 41 | return this.field.getDeclaredAnnotations()[0]; 42 | } 43 | 44 | 45 | @Override 46 | public Class getClazz() { 47 | Class clazz= field.getType().getClass(); 48 | return clazz; 49 | } 50 | 51 | @Override 52 | public Field getField() { 53 | return field; 54 | } 55 | 56 | 57 | @Override 58 | public String getName() { 59 | return this.field.getName(); 60 | } 61 | 62 | /** 63 | * 获取注解类型 64 | */ 65 | @Override 66 | public Class getAnnotationType() { 67 | return this.getAnnotation().annotationType(); 68 | } 69 | 70 | /** 71 | * 注入对象. 72 | * 73 | * @param instance 宿主对象 74 | */ 75 | @Override 76 | public void inject(Object instance,Object value) { 77 | 78 | //TODO ... 79 | 80 | FieldUtils.writeField(instance, field, value); 81 | } 82 | 83 | 84 | /** 85 | * 获取此方法的访问入口所对应的Index. 86 | * 87 | * @return 访问入口所对应的Index. 88 | */ 89 | @Override 90 | public int getIndex() { 91 | return 0; 92 | } 93 | 94 | 95 | } 96 | 97 | 98 | -------------------------------------------------------------------------------- /gamioo-redis/src/main/java/io/gamioo/redis/zset/object2long/LongScoreHandlers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 wjybxx 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to iBn writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.redis.zset.object2long; 18 | 19 | /** 20 | * 基础分数比较器 21 | * 22 | * @author wjybxx 23 | * @version 1.0 24 | * date - 2019/11/7 25 | */ 26 | public class LongScoreHandlers { 27 | 28 | private LongScoreHandlers() { 29 | 30 | } 31 | 32 | /** 33 | * @return Long类型的score处理器 34 | */ 35 | public static LongScoreHandler scoreHandler() { 36 | return scoreHandler(false); 37 | } 38 | 39 | 40 | /** 41 | * 获取一个分数比较器 42 | * 43 | * @param desc 是否降序 44 | * @return 分数比较器 45 | */ 46 | public static LongScoreHandler scoreHandler(boolean desc) { 47 | return desc ? DescScoreHandler.INSTANCE : AscScoreHandler.INSTANCE; 48 | } 49 | 50 | /** 51 | * 升序比较器 52 | */ 53 | private static class AscScoreHandler implements LongScoreHandler { 54 | 55 | private static AscScoreHandler INSTANCE = new AscScoreHandler(); 56 | 57 | @Override 58 | public int compare(long score1, long score2) { 59 | return Long.compare(score1, score2); 60 | } 61 | 62 | @Override 63 | public long sum(long oldScore, long increment) { 64 | return oldScore + increment; 65 | } 66 | } 67 | 68 | /** 69 | * 降序比较器 70 | */ 71 | private static class DescScoreHandler implements LongScoreHandler { 72 | 73 | private static DescScoreHandler INSTANCE = new DescScoreHandler(); 74 | 75 | @Override 76 | public int compare(long score1, long score2) { 77 | return Long.compare(score2, score1); 78 | } 79 | 80 | @Override 81 | public long sum(long oldScore, long increment) { 82 | return oldScore + increment; 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/definition/ControllerBeanDefinition.java: -------------------------------------------------------------------------------- 1 | package io.gamioo.ioc.definition; 2 | 3 | import io.gamioo.ioc.annotation.CommandMapping; 4 | import io.gamioo.ioc.annotation.RequestMapping; 5 | import io.gamioo.ioc.stereotype.Controller; 6 | import io.gamioo.ioc.wrapper.Command; 7 | import io.gamioo.ioc.wrapper.MethodWrapper; 8 | 9 | import java.lang.annotation.Annotation; 10 | import java.util.Collection; 11 | import java.util.List; 12 | import java.util.Map; 13 | import java.util.concurrent.ConcurrentHashMap; 14 | 15 | /** 16 | * 控制器入口的定义 17 | * 18 | * @author Allen Jiang 19 | * @since 1.0.0 20 | */ 21 | public class ControllerBeanDefinition extends GenericBeanDefinition{ 22 | /** 23 | * 控制器的消息处理容器 24 | */ 25 | protected final static Map commandStore = new ConcurrentHashMap<>(1024); 26 | public ControllerBeanDefinition(Class clazz, Annotation annotation) { 27 | super(clazz, annotation); 28 | } 29 | 30 | 31 | /** 32 | * 解析实体对象 33 | * 34 | * @param instance 35 | */ 36 | @Override 37 | public void analysisBean(Object instance) { 38 | //控制器入口有特殊的分析 39 | // Class type =this.getAnnotationType(); 40 | // // 控制器 41 | // //TODO ... 后续可以把这些解析放到 gamioo-game 中,开发者可以自定义注释,如何解析注释以及如何使用注释 42 | // if (type == Controller.class) { 43 | //@MessageMapping 44 | List methodList = this.getMethodDefinitionList(CommandMapping.class); 45 | for (MethodDefinition e : methodList) { 46 | CommandMapping mapping = e.getAnnotation(); 47 | MethodWrapper wrapper = e.getMethodWrapper(instance); 48 | Command command = new Command(wrapper, mapping); 49 | this.commandStore.put(command.getCode(), command); 50 | } 51 | //@RequestMapping 52 | methodList = this.getMethodDefinitionList(RequestMapping.class); 53 | for (MethodDefinition e : methodList) { 54 | RequestMapping mapping = e.getAnnotation(); 55 | //TODO ... 56 | } 57 | 58 | // 59 | // } else { 60 | // 61 | // } 62 | } 63 | 64 | /**根据指令调用*/ 65 | public static Command getCommand(int code) { 66 | return commandStore.get(code); 67 | } 68 | 69 | /**指令列表*/ 70 | public static Collection getCommandList(){ 71 | return commandStore.values(); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /gamioo-ioc/src/test/java/io/gamioo/ioc/XmlBeanFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.gamioo.ioc; 18 | 19 | import io.gamioo.ioc.factory.support.DefaultListableBeanFactory; 20 | import io.gamioo.ioc.factory.xml.XmlBeanDefinitionReader; 21 | import io.gamioo.ioc.factory.xml.XmlResourceLoader; 22 | import org.apache.logging.log4j.LogManager; 23 | import org.apache.logging.log4j.Logger; 24 | import org.junit.jupiter.api.*; 25 | 26 | 27 | /** 28 | * some description 29 | * 30 | * @author Allen Jiang 31 | * @since 1.0.0 32 | */ 33 | 34 | @DisplayName("IOC测试") 35 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 36 | public class XmlBeanFactoryTest { 37 | private static final Logger logger = LogManager.getLogger(XmlBeanFactoryTest.class); 38 | //private final Benchmark benchmark=new Benchmark(10000); 39 | private static XmlBeanDefinitionReader xmlBeanDefinitionReader; 40 | 41 | @BeforeAll 42 | public static void beforeAll() throws Exception { 43 | //初始化...... 44 | xmlBeanDefinitionReader = new XmlBeanDefinitionReader(new XmlResourceLoader()); 45 | xmlBeanDefinitionReader.analysisResourceList("ioc.xml"); 46 | 47 | } 48 | 49 | @Test 50 | @Order(1) 51 | @DisplayName("IOC2测试") 52 | public void test() throws Exception { 53 | DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); 54 | // for (Map.Entry beanDefinitionEntry : beanFactory.entrySet()) { 55 | // beanFactory.registerBeanDefinition(beanDefinitionEntry.getKey(), beanDefinitionEntry.getValue()); 56 | // } 57 | 58 | } 59 | 60 | 61 | @BeforeEach 62 | public void beforeEach() { 63 | 64 | } 65 | 66 | @AfterEach 67 | public void afterEach() { 68 | 69 | } 70 | 71 | 72 | @AfterAll 73 | public static void afterAll() { 74 | 75 | } 76 | 77 | 78 | } 79 | -------------------------------------------------------------------------------- /gamioo-ioc/src/main/java/io/gamioo/ioc/wrapper/MethodWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Gamioo Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.gamioo.ioc.wrapper; 17 | 18 | import com.esotericsoftware.reflectasm.MethodAccess; 19 | import org.apache.commons.lang3.builder.ToStringBuilder; 20 | import org.apache.commons.lang3.builder.ToStringStyle; 21 | 22 | import java.lang.reflect.Method; 23 | 24 | /** 25 | * 方法的包装类 26 | * 27 | * @author Allen Jiang 28 | * @since 1.0.0 29 | */ 30 | 31 | public class MethodWrapper { 32 | private MethodAccess access; 33 | private int index;// 方法索引 34 | private Object instance; 35 | private Class paramClazz;// 参数类型 36 | private String name; 37 | 38 | 39 | public MethodWrapper( Object instance,Method method,MethodAccess access,int index) { 40 | this.name = method.getName(); 41 | this.access = access; 42 | this.index = index; 43 | this.instance = instance; 44 | this.paramClazz = method.getParameterTypes()[0]; 45 | } 46 | 47 | public MethodWrapper(Method method, Object instance) { 48 | this.name = method.getName(); 49 | this.access = MethodAccess.get(instance.getClass()); 50 | this.index = access.getIndex(method.getName(), method.getParameterTypes()); 51 | this.instance = instance; 52 | this.paramClazz = method.getParameterTypes()[0]; 53 | } 54 | 55 | public Object invoke(Object... args) { 56 | Object ret = null; 57 | if (args == null) { 58 | // 无参数调用 59 | ret = access.invoke(instance, index); 60 | } else { 61 | // 有参数调用 62 | ret = access.invoke(instance, index, args); 63 | } 64 | return ret; 65 | } 66 | 67 | public String getName() { 68 | return name; 69 | } 70 | 71 | public void setName(String name) { 72 | this.name = name; 73 | } 74 | 75 | public Class getParamClazz() { 76 | return paramClazz; 77 | } 78 | 79 | public void setParamClazz(Class paramClazz) { 80 | this.paramClazz = paramClazz; 81 | } 82 | 83 | public String toString() { 84 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 85 | } 86 | } 87 | --------------------------------------------------------------------------------