├── .gitignore ├── README.md ├── aggregate-framework-admin-web ├── .editorconfig ├── .gitignore ├── config │ ├── env.js │ ├── getHttpsConfig.js │ ├── jest │ │ ├── cssTransform.js │ │ └── fileTransform.js │ ├── modules.js │ ├── paths.js │ ├── pnpTs.js │ ├── webpack.config.js │ └── webpackDevServer.config.js ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt ├── scripts │ ├── build.js │ ├── start.js │ └── test.js ├── src │ ├── App.css │ ├── App.js │ ├── App.test.js │ ├── common │ │ ├── api.js │ │ ├── constants.js │ │ ├── http.js │ │ └── testData.js │ ├── index.css │ ├── index.js │ ├── layout │ │ ├── AggHeader.jsx │ │ └── AggLayout.jsx │ ├── logo.svg │ ├── pages │ │ └── agg │ │ │ ├── domain │ │ │ └── index.jsx │ │ │ ├── login │ │ │ └── index.jsx │ │ │ ├── task │ │ │ └── index.jsx │ │ │ ├── transaction │ │ │ ├── SearchBox.jsx │ │ │ ├── TableCard.jsx │ │ │ └── index.jsx │ │ │ └── welcome │ │ │ └── index.jsx │ ├── serviceWorker.js │ ├── setupProxy.js │ ├── setupTests.js │ └── store │ │ ├── actions │ │ └── domain.js │ │ ├── index.js │ │ └── reducers │ │ └── domain.js └── yarn.lock ├── aggregate-framework-bom └── pom.xml ├── aggregate-framework-core ├── pom.xml └── src │ └── main │ ├── dbscripts │ └── db.sql │ ├── java │ └── org │ │ └── aggregateframework │ │ ├── AbstractConfig.java │ │ ├── AggClient.java │ │ ├── AggServer.java │ │ ├── AggService.java │ │ ├── ClientConfig.java │ │ ├── ServerConfig.java │ │ ├── alert │ │ ├── AlertException.java │ │ ├── AlertManager.java │ │ └── ResponseCodeEnum.java │ │ ├── cache │ │ ├── AbstractRedisL2Cache.java │ │ ├── CaffeineL2Cache.java │ │ ├── IdentifiedEntityMap.java │ │ ├── JedisClusterL2Cache.java │ │ ├── JedisL2Cache.java │ │ ├── JodisClusterL2Cache.java │ │ ├── L2Cache.java │ │ ├── MultiLevelL2Cache.java │ │ ├── NoL2Cache.java │ │ ├── RedisTemplateL2Cache.java │ │ └── ShardJedisL2Cache.java │ │ ├── constants │ │ ├── MixAll.java │ │ └── RemotingServiceCode.java │ │ ├── dao │ │ ├── AggregateDao.java │ │ ├── AggregateRootDao.java │ │ ├── CollectiveAggregateRootDao.java │ │ ├── CollectiveDomainObjectDao.java │ │ └── DomainObjectDao.java │ │ ├── dashboard │ │ ├── dto │ │ │ ├── DomainStoreDto.java │ │ │ ├── DomainStoreRequestDto.java │ │ │ ├── ModifyCronDto.java │ │ │ ├── ResponseDto.java │ │ │ ├── TaskDto.java │ │ │ ├── TransactionDetailRequestDto.java │ │ │ ├── TransactionOperateRequestDto.java │ │ │ ├── TransactionPageDto.java │ │ │ ├── TransactionPageRequestDto.java │ │ │ └── TransactionStoreDto.java │ │ ├── enums │ │ │ └── ResponseCodeEnum.java │ │ ├── exception │ │ │ └── TransactionException.java │ │ └── service │ │ │ ├── DomainService.java │ │ │ ├── TaskService.java │ │ │ ├── TransactionService.java │ │ │ ├── TransactionStorageable.java │ │ │ └── impl │ │ │ ├── BaseDomainServiceImpl.java │ │ │ ├── BaseTaskServiceImpl.java │ │ │ └── BaseTransactionServiceImpl.java │ │ ├── discovery │ │ ├── loadbalance │ │ │ ├── AbstractLoadBalanceServcie.java │ │ │ ├── LoadBalanceFactory.java │ │ │ ├── LoadBalanceProvider.java │ │ │ ├── LoadBalanceServcie.java │ │ │ ├── LoadBalanceType.java │ │ │ ├── RandomLoadBalanceProvider.java │ │ │ ├── RandomLoadBalanceServcieImpl.java │ │ │ ├── RoundRobinLoadBalanceProvider.java │ │ │ └── RoundRobinLoadBalanceServcieImpl.java │ │ └── registry │ │ │ ├── AbstractRegistryService.java │ │ │ ├── ClientRegistryConfig.java │ │ │ ├── RegistryConfig.java │ │ │ ├── RegistryFactory.java │ │ │ ├── RegistryProvider.java │ │ │ ├── RegistryRole.java │ │ │ ├── RegistryService.java │ │ │ ├── RegistryType.java │ │ │ ├── ServerRegistryConfig.java │ │ │ ├── custom │ │ │ └── CustomRegistryProvider.java │ │ │ ├── direct │ │ │ ├── DirectRegistryProperties.java │ │ │ ├── DirectRegistryProvider.java │ │ │ └── DirectRegistryServiceImpl.java │ │ │ ├── nacos │ │ │ ├── NacosRegistryProperties.java │ │ │ ├── NacosRegistryServiceImpl.java │ │ │ └── NacosRegistryServiceProvider.java │ │ │ └── zookeeper │ │ │ ├── ZookeeperInstance.java │ │ │ ├── ZookeeperRegistryProperties.java │ │ │ ├── ZookeeperRegistryProvider.java │ │ │ └── ZookeeperRegistryServiceImpl.java │ │ ├── domainevent │ │ ├── EventMessage.java │ │ ├── MessageType.java │ │ └── SimpleEventMessage.java │ │ ├── entity │ │ ├── AbstractAggregateRoot.java │ │ ├── AbstractDomainObject.java │ │ ├── AbstractSimpleAggregateRoot.java │ │ ├── AbstractSimpleDomainObject.java │ │ ├── AggregateRoot.java │ │ ├── CompositeId.java │ │ ├── DaoAwareQuery.java │ │ ├── DomainObject.java │ │ ├── EventContainer.java │ │ └── Transient.java │ │ ├── eventbus │ │ ├── EventBus.java │ │ └── SimpleEventBus.java │ │ ├── eventhandling │ │ ├── AnnotationEventListenerAdapter.java │ │ ├── EventHandlerHook.java │ │ ├── EventHandlerListener.java │ │ ├── EventInvokerEntry.java │ │ ├── EventListener.java │ │ ├── SimpleEventListenerProxy.java │ │ ├── annotation │ │ │ ├── AsyncConfig.java │ │ │ ├── EventHandler.java │ │ │ ├── QueueFullPolicy.java │ │ │ └── TransactionCheck.java │ │ └── processor │ │ │ ├── AsyncMethodInvoker.java │ │ │ ├── EventHandlerProcessor.java │ │ │ ├── EventMethodInvoker.java │ │ │ └── async │ │ │ ├── AsyncBatchEventHandler.java │ │ │ ├── AsyncDisruptor.java │ │ │ ├── AsyncEvent.java │ │ │ ├── AsyncEventFactory.java │ │ │ ├── AsyncEventHandler.java │ │ │ ├── AsyncEventTranslator.java │ │ │ ├── EventProcessDefaultExceptionHandler.java │ │ │ ├── EventProcessThread.java │ │ │ ├── EventProcessThreadFactory.java │ │ │ ├── RetryEvent.java │ │ │ └── RetryEventFactory.java │ │ ├── exception │ │ ├── CancellingException.java │ │ ├── ConfirmingException.java │ │ ├── DomainException.java │ │ ├── NoDaoDefinitionException.java │ │ ├── NoExistedTransactionException.java │ │ ├── OptimisticLockException.java │ │ ├── RegistryException.java │ │ └── SystemException.java │ │ ├── load │ │ ├── LoadInfo.java │ │ └── LoadUtils.java │ │ ├── monitor │ │ └── ServerFlowMonitor.java │ │ ├── persistent │ │ └── redis │ │ │ ├── CommandCallback.java │ │ │ ├── JedisCallback.java │ │ │ ├── JedisClusterCommands.java │ │ │ ├── JedisCommands.java │ │ │ ├── PipelineCommands.java │ │ │ ├── RedisCommands.java │ │ │ ├── RedisTemplateCommands.java │ │ │ ├── ShardJedisCommands.java │ │ │ ├── ShardedJedisCallback.java │ │ │ └── ShardedPipelineCommand.java │ │ ├── processor │ │ ├── ClientRecoveryExecutor.java │ │ ├── ClientRecoveryProcessor.java │ │ ├── ServerRecoveryExecutor.java │ │ └── ServerRequestProcessor.java │ │ ├── properties │ │ ├── RecoveryProperties.java │ │ ├── registry │ │ │ ├── ClientRegistryProperties.java │ │ │ ├── RegistryProperties.java │ │ │ └── ServerRegistryProperties.java │ │ ├── remoting │ │ │ ├── NettyClientProperties.java │ │ │ ├── NettyProperties.java │ │ │ └── NettyServerProperties.java │ │ └── store │ │ │ ├── AbstractJedisStoreProperties.java │ │ │ ├── DLedgerProperties.java │ │ │ ├── HostAndPort.java │ │ │ ├── JdbcStoreProperties.java │ │ │ ├── RedisClusterStoreProperties.java │ │ │ ├── RedisStoreProperties.java │ │ │ ├── ShardRedisStoreProperties.java │ │ │ └── StoreProperties.java │ │ ├── recovery │ │ ├── QuartzRecoveryTask.java │ │ ├── RecoveryConfig.java │ │ ├── RecoveryExecutor.java │ │ ├── RecoveryScheduler.java │ │ ├── ReusableConnectionProvider.java │ │ ├── ReusableThreadPool.java │ │ └── TransactionStoreRecovery.java │ │ ├── remoting │ │ ├── RemotingClient.java │ │ ├── RemotingServer.java │ │ ├── RemotingService.java │ │ ├── RequestProcessor.java │ │ ├── codec │ │ │ ├── NettyDecoder.java │ │ │ └── NettyEncoder.java │ │ ├── exception │ │ │ ├── RemotingCommandException.java │ │ │ ├── RemotingConnectException.java │ │ │ ├── RemotingException.java │ │ │ ├── RemotingSendRequestException.java │ │ │ └── RemotingTimeoutException.java │ │ ├── netty │ │ │ ├── AbstractNettyRemoting.java │ │ │ ├── ChannelGroupMap.java │ │ │ ├── HeartBeatReqHandler.java │ │ │ ├── HeartBeatRespHandler.java │ │ │ ├── NettyClientConfig.java │ │ │ ├── NettyConfig.java │ │ │ ├── NettyPooledFactory.java │ │ │ ├── NettyRemotingClient.java │ │ │ ├── NettyRemotingServer.java │ │ │ ├── NettyServerConfig.java │ │ │ ├── RemotingResponseCallback.java │ │ │ ├── ResponseFuture.java │ │ │ └── ServerAddressLoader.java │ │ └── protocol │ │ │ ├── RemotingCommand.java │ │ │ └── RemotingCommandCode.java │ │ ├── repository │ │ ├── AbstractAggregateRepository.java │ │ ├── AggreateDaoFactory.java │ │ ├── AggregateRepository.java │ │ ├── CrudRepository.java │ │ ├── DaoAwareAggregateRepository.java │ │ ├── Repository.java │ │ ├── SaveAggregateCallback.java │ │ └── TraversalAggregateRepository.java │ │ ├── retry │ │ ├── BinaryExceptionClassifier.java │ │ ├── Classifier.java │ │ ├── RecoveryCallback.java │ │ ├── RetryCallback.java │ │ ├── RetryContext.java │ │ ├── RetryOperations.java │ │ ├── RetryPolicy.java │ │ ├── RetryTemplate.java │ │ ├── SimpleRecoveryCallback.java │ │ ├── SimpleRetryContext.java │ │ ├── SimpleRetryPolicy.java │ │ ├── SubclassClassifier.java │ │ └── backoff │ │ │ ├── BackOffContext.java │ │ │ ├── BackOffPolicy.java │ │ │ ├── ExponentialBackOffPolicy.java │ │ │ ├── ExponentialRandomBackOffPolicy.java │ │ │ ├── FixedBackOffPolicy.java │ │ │ ├── NoBackOffPolicy.java │ │ │ ├── Sleeper.java │ │ │ ├── SleepingBackOffPolicy.java │ │ │ ├── ThreadWaitSleeper.java │ │ │ └── UniformRandomBackOffPolicy.java │ │ ├── serializer │ │ ├── JdkSerializationSerializer.java │ │ ├── KryoPoolSerializer.java │ │ ├── ObjectSerializer.java │ │ └── RegisterableKryoSerializer.java │ │ ├── session │ │ ├── AbstractClientSession.java │ │ ├── AggregateContext.java │ │ ├── AggregateEntry.java │ │ ├── ClientSession.java │ │ ├── LocalSessionFactory.java │ │ ├── SessionFactory.java │ │ ├── SessionFactoryHelper.java │ │ └── UnitOfWork.java │ │ ├── storage │ │ ├── AbstractKVTransactionStorage.java │ │ ├── AbstractRedisTransactionStorage.java │ │ ├── AbstractTransactionStorage.java │ │ ├── DLedgerTransactionStorage.java │ │ ├── JdbcTransactionStorage.java │ │ ├── JedisClusterTransactionStorage.java │ │ ├── MemoryTransactionStorage.java │ │ ├── Page.java │ │ ├── RedisTransactionStorage.java │ │ ├── RemotingTransactionStorage.java │ │ ├── RetryableTransactionStorage.java │ │ ├── RocksDbTransactionStorage.java │ │ ├── ShardJedisTransactionStorage.java │ │ ├── StorageRecoverable.java │ │ ├── StorageType.java │ │ ├── StoreConfig.java │ │ ├── TransactionIOException.java │ │ ├── TransactionOptimisticLockException.java │ │ ├── TransactionStorage.java │ │ ├── TransactionStorageFactory.java │ │ ├── TransactionStore.java │ │ ├── domain │ │ │ ├── AlertType.java │ │ │ └── DomainStore.java │ │ └── helper │ │ │ ├── RedisHelper.java │ │ │ ├── ShardHolder.java │ │ │ └── ShardOffset.java │ │ ├── support │ │ ├── BeanFactory.java │ │ └── FactoryBuilder.java │ │ ├── threadcontext │ │ ├── EmptyThreadContextSynchronization.java │ │ ├── ThreadContextSynchronization.java │ │ └── ThreadContextSynchronizationManager.java │ │ ├── transaction │ │ ├── Invocation.java │ │ ├── LocalTransactionExecutor.java │ │ ├── LocalTransactionState.java │ │ ├── Participant.java │ │ ├── Transaction.java │ │ ├── repository │ │ │ ├── DefaultTransactionRepository.java │ │ │ ├── TransactionConvertor.java │ │ │ └── TransactionRepository.java │ │ └── serializer │ │ │ ├── DefaultRemotingCommandSerializer.java │ │ │ ├── DefaultTransactionStoreSerializer.java │ │ │ ├── DomainStoreMapSerializer.java │ │ │ ├── RemotingCommandSerializer.java │ │ │ ├── SerializerType.java │ │ │ ├── TransactionSerializer.java │ │ │ ├── TransactionStoreMapSerializer.java │ │ │ ├── TransactionStoreSerializer.java │ │ │ ├── json │ │ │ ├── FastjsonTransactionSerializer.java │ │ │ ├── JacksonDomainStoreSerializer.java │ │ │ └── JacksonTransactionSerializer.java │ │ │ └── kryo │ │ │ ├── KryoTransactionSerializer.java │ │ │ ├── RegisterableKryoRemotingCommandSerializer.java │ │ │ ├── RegisterableKryoSerializer.java │ │ │ └── RegisterableKryoTransactionSerializer.java │ │ ├── utils │ │ ├── AggDateFormatUtils.java │ │ ├── AlertUtils.java │ │ ├── AnnotationUtils.java │ │ ├── Assert.java │ │ ├── ByteUtils.java │ │ ├── CollectionUtils.java │ │ ├── DomainObjectUtils.java │ │ ├── EventHandlerUtils.java │ │ ├── NetUtils.java │ │ ├── ObjectUtils.java │ │ ├── ReflectionUtils.java │ │ └── StopUtils.java │ │ └── xid │ │ ├── TransactionXid.java │ │ ├── UUIDGenerator.java │ │ └── Xid.java │ └── resources │ └── META-INF │ └── services │ ├── org.aggregateframework.discovery.loadbalance.LoadBalanceProvider │ └── org.aggregateframework.discovery.registry.RegistryProvider ├── aggregate-framework-dashboard ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── aggregateframework │ │ ├── dashboard │ │ ├── AggregateFrameworkDashboardApplication.java │ │ ├── config │ │ │ ├── DashboardConfig.java │ │ │ └── DashboardProperties.java │ │ ├── constants │ │ │ └── DashboardConstant.java │ │ ├── controller │ │ │ ├── DomainController.java │ │ │ ├── TaskController.java │ │ │ ├── TransactionController.java │ │ │ └── UserController.java │ │ ├── enums │ │ │ └── ConnectionMode.java │ │ ├── exceptionhandler │ │ │ └── ControllerExceptionHandler.java │ │ ├── model │ │ │ ├── LoginDto.java │ │ │ └── SystemUser.java │ │ ├── security │ │ │ ├── AggAccessDeniedHandler.java │ │ │ ├── AggAuthenticationEntryPoint.java │ │ │ ├── JwtAuthFilter.java │ │ │ ├── SecurityConfig.java │ │ │ └── UserService.java │ │ ├── service │ │ │ ├── condition │ │ │ │ ├── AggServerStorageCondition.java │ │ │ │ ├── BaseStorageCondition.java │ │ │ │ └── LocalStorageCondition.java │ │ │ └── impl │ │ │ │ ├── aggserver │ │ │ │ ├── AggServerDomainServiceImpl.java │ │ │ │ ├── AggServerFeignClient.java │ │ │ │ ├── AggServerTaskServiceImpl.java │ │ │ │ └── AggServerTransactionServiceImpl.java │ │ │ │ └── local │ │ │ │ ├── LocalDomainServiceImpl.java │ │ │ │ ├── LocalTaskServiceImpl.java │ │ │ │ └── LocalTransactionServiceImpl.java │ │ └── utils │ │ │ └── JwtUtil.java │ │ └── ribbon │ │ ├── AggFeignClientConfig.java │ │ └── AggServerList.java │ └── resources │ ├── application-dev.yaml │ ├── application-embedded.yaml │ ├── application-server.yaml │ ├── application.yaml │ └── templates │ ├── asset-manifest.json │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ ├── precache-manifest.2707a861fce65e0ea4a57437e31cd76c.js │ ├── robots.txt │ ├── service-worker.js │ └── static │ ├── css │ ├── 2.4f57d18e.chunk.css │ ├── 2.4f57d18e.chunk.css.map │ ├── main.013a3909.chunk.css │ └── main.013a3909.chunk.css.map │ └── js │ ├── 2.ed2ac97b.chunk.js │ ├── 2.ed2ac97b.chunk.js.LICENSE.txt │ ├── 2.ed2ac97b.chunk.js.map │ ├── main.7496146c.chunk.js │ ├── main.7496146c.chunk.js.map │ ├── runtime-main.f35c6c1a.js │ └── runtime-main.f35c6c1a.js.map ├── aggregate-framework-dependencies └── pom.xml ├── aggregate-framework-distribution ├── dashboard │ ├── bin │ │ ├── shutdown.cmd │ │ ├── shutdown.sh │ │ ├── startup.cmd │ │ └── startup.sh │ └── conf │ │ └── logback.xml ├── pom.xml ├── release-dashboard.xml ├── release-server.xml └── server │ ├── bin │ ├── shutdown.cmd │ ├── shutdown.sh │ ├── startup.cmd │ └── startup.sh │ └── conf │ └── logback.xml ├── aggregate-framework-parent └── pom.xml ├── aggregate-framework-server ├── pom.xml └── src │ └── main │ ├── dbscripts │ └── db_init.sql │ ├── java │ └── org │ │ └── aggregateframework │ │ └── server │ │ ├── AggregateFrameworkServerApplication.java │ │ ├── config │ │ ├── AppConfig.java │ │ └── ServerEnvironmentPostProcessor.java │ │ ├── controller │ │ ├── DomainController.java │ │ ├── RecoveryController.java │ │ └── TransactionController.java │ │ └── service │ │ ├── DomainServiceImpl.java │ │ └── TransactionServiceImpl.java │ └── resources │ ├── application-dev.yml │ ├── application.yaml │ └── schema.sql ├── aggregate-framework-spring-boot-starter ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── aggregateframework │ │ └── spring │ │ ├── AggFrameworkAutoConfiguration.java │ │ └── AggFrameworkConfigurationFilter.java │ └── resources │ └── META-INF │ └── spring.factories ├── aggregate-framework-spring ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── aggregateframework │ │ └── spring │ │ ├── annotation │ │ ├── EnableSpringIntegration.java │ │ └── SpringIntegrationConfigurationSelector.java │ │ ├── datasource │ │ ├── SessionDataSourceTransactionManager.java │ │ ├── SessionTransactionSynchronizationAdapter.java │ │ ├── TransactionManagerAutoProxyCreator.java │ │ └── TransactionManagerInterceptor.java │ │ ├── eventhandling │ │ └── AnnotationEventListenerBeanPostProcessor.java │ │ ├── factory │ │ └── SpringBeanFactory.java │ │ ├── support │ │ └── SpringIntegrationConfiguration.java │ │ ├── xid │ │ ├── DefaultUUIDGenerator.java │ │ └── SimpleWorkerIdAssigner.java │ │ └── xml │ │ ├── AggConfigNamespaceHandlerSupport.java │ │ ├── SpringIntegrationByConfigDefinitionParser.java │ │ └── SpringIntegrationByRegisterDefinitionParser.java │ └── resources │ ├── META-INF │ ├── spring.handlers │ └── spring.schemas │ ├── aggregateframework-1.1.xsd │ └── config │ └── spring │ └── common │ └── aggregate-framework-context.xml ├── aggregate-framework-tutorial-sample ├── aggregate-framework-basic-usage │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── aggregateframework │ │ │ └── basic │ │ │ └── usage │ │ │ ├── BasicUsageApplication.java │ │ │ ├── controller │ │ │ └── AccountController.java │ │ │ ├── dao │ │ │ ├── AccountDao.java │ │ │ └── SubAccountDao.java │ │ │ ├── entity │ │ │ ├── Account.java │ │ │ └── SubAccount.java │ │ │ ├── event │ │ │ ├── AccountCreateEvent.java │ │ │ └── AccountEventHandler.java │ │ │ └── repository │ │ │ └── AccountRepository.java │ │ └── resources │ │ ├── application-local.yaml │ │ ├── application-server.yaml │ │ ├── application.yaml │ │ ├── mapping │ │ ├── AccountMapper.xml │ │ └── SubAccountMapper.xml │ │ └── schema.sql ├── aggregate-framework-sample │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── aggregateframework │ │ │ │ └── sample │ │ │ │ ├── AggregateFrameworkSampleApplication.java │ │ │ │ ├── complexmodel │ │ │ │ └── command │ │ │ │ │ ├── domain │ │ │ │ │ ├── entity │ │ │ │ │ │ ├── BookingOrder.java │ │ │ │ │ │ ├── BookingPayment.java │ │ │ │ │ │ ├── SeatAvailability.java │ │ │ │ │ │ └── UserShardingId.java │ │ │ │ │ ├── event │ │ │ │ │ │ ├── OrderCreatedEvent.java │ │ │ │ │ │ ├── OrderUpdatedEvent.java │ │ │ │ │ │ └── SeatAvailabilityRemovedEvent.java │ │ │ │ │ └── repository │ │ │ │ │ │ └── JpaOrderRepository.java │ │ │ │ │ ├── eventhandler │ │ │ │ │ └── BookingOrderHandler.java │ │ │ │ │ ├── infrastructure │ │ │ │ │ └── dao │ │ │ │ │ │ ├── BookingOrderDao.java │ │ │ │ │ │ ├── BookingPaymentDao.java │ │ │ │ │ │ └── SeatAvailabilityDao.java │ │ │ │ │ └── service │ │ │ │ │ ├── OrderService.java │ │ │ │ │ └── OrderServiceImpl.java │ │ │ │ ├── hierarchicalmodel │ │ │ │ └── command │ │ │ │ │ ├── domain │ │ │ │ │ ├── entity │ │ │ │ │ │ ├── DeliveryOrder.java │ │ │ │ │ │ ├── DeliveryOrderInfo.java │ │ │ │ │ │ ├── HierarchicalOrder.java │ │ │ │ │ │ ├── JobOrder.java │ │ │ │ │ │ ├── JobOrderInfo.java │ │ │ │ │ │ └── OrderInfo.java │ │ │ │ │ └── repository │ │ │ │ │ │ ├── DeliveryOrderRepository.java │ │ │ │ │ │ └── JobOrderRepository.java │ │ │ │ │ └── infrastructure │ │ │ │ │ └── dao │ │ │ │ │ ├── HierarchicalOrderDao.java │ │ │ │ │ └── OrderInfoDao.java │ │ │ │ ├── quickstart │ │ │ │ ├── command │ │ │ │ │ ├── domain │ │ │ │ │ │ ├── entity │ │ │ │ │ │ │ ├── OrderLine.java │ │ │ │ │ │ │ ├── Payment.java │ │ │ │ │ │ │ └── PricedOrder.java │ │ │ │ │ │ ├── event │ │ │ │ │ │ │ ├── OrderConfirmedEvent.java │ │ │ │ │ │ │ ├── OrderPlacedEvent.java │ │ │ │ │ │ │ └── PaymentConfirmedEvent.java │ │ │ │ │ │ ├── factory │ │ │ │ │ │ │ ├── OrderFactory.java │ │ │ │ │ │ │ └── PaymentFactory.java │ │ │ │ │ │ └── repository │ │ │ │ │ │ │ ├── OrderRepository.java │ │ │ │ │ │ │ └── PaymentRepository.java │ │ │ │ │ ├── eventhandler │ │ │ │ │ │ ├── OrderHandler.java │ │ │ │ │ │ └── PaymentHandler.java │ │ │ │ │ ├── infrastructure │ │ │ │ │ │ ├── cache │ │ │ │ │ │ │ └── PricedOrderL2Cache.java │ │ │ │ │ │ └── dao │ │ │ │ │ │ │ ├── OrderDao.java │ │ │ │ │ │ │ ├── OrderLineDao.java │ │ │ │ │ │ │ └── PaymentDao.java │ │ │ │ │ └── service │ │ │ │ │ │ └── OrderService.java │ │ │ │ └── config │ │ │ │ │ └── AppConfig.java │ │ │ │ ├── threadcontext │ │ │ │ └── TestThreadContextSynchronization.java │ │ │ │ └── web │ │ │ │ └── controller │ │ │ │ └── BenchmarkController.java │ │ └── resources │ │ │ ├── META-INF │ │ │ └── services │ │ │ │ └── org.aggregateframework.threadcontext.ThreadContextSynchronization │ │ │ ├── application-dev.yaml │ │ │ ├── application.yaml │ │ │ ├── config │ │ │ ├── spring │ │ │ │ └── local │ │ │ │ │ ├── appcontext-service-aggregate.xml │ │ │ │ │ ├── appcontext-service-cache.xml │ │ │ │ │ ├── appcontext-service-common.xml │ │ │ │ │ ├── appcontext-service-complex-dao.xml │ │ │ │ │ ├── appcontext-service-hierarchical-dao.xml │ │ │ │ │ └── appcontext-service-quickstart-dao.xml │ │ │ └── sqlmap │ │ │ │ ├── main │ │ │ │ ├── mybatis-complex-order.xml │ │ │ │ ├── mybatis-complex-payment.xml │ │ │ │ ├── mybatis-complex-seatAvailability.xml │ │ │ │ ├── mybatis-hierarchical-order.xml │ │ │ │ ├── mybatis-hierarchical-orderInfo.xml │ │ │ │ ├── mybatis-quickstart-order.xml │ │ │ │ ├── mybatis-quickstart-orderline.xml │ │ │ │ └── mybatis-quickstart-payment.xml │ │ │ │ └── sqlmap-config.xml │ │ │ ├── h2.sql │ │ │ ├── jdbc.properties │ │ │ ├── log4j2.xml │ │ │ ├── redis.properties │ │ │ └── zk.properties │ │ └── test │ │ └── java │ │ └── org │ │ └── aggregateframework │ │ └── sample │ │ ├── AbstractTestCase.java │ │ ├── asynctest │ │ ├── RingBufferEvent.java │ │ ├── RingBufferLogEventHandler.java │ │ └── RingBufferLogEventTranslator.java │ │ ├── cacheintegration │ │ ├── CaffeinelL2CacheTest.java │ │ └── RepositoryCacheTest.java │ │ ├── complexmodel │ │ ├── OrderTestCase.java │ │ └── domain │ │ │ └── repositorytest │ │ │ └── PricedOrderRepositoryTest.java │ │ ├── hierarchymodel │ │ ├── domain │ │ │ └── repository │ │ │ │ └── DeliveryBookingPricedOrderRepositoryTest.java │ │ └── infrastructure │ │ │ └── dao │ │ │ └── HierarchyPricedOrderDaoTest.java │ │ ├── performancetest │ │ └── PerformanceTest.java │ │ ├── quickstart │ │ └── service │ │ │ └── SimpleOrderServiceTest.java │ │ ├── repository │ │ └── RocksDbTest.java │ │ ├── serializer │ │ └── SerializerTest.java │ │ ├── threadcontext │ │ └── ThreadContextTest.java │ │ └── transactionmessage │ │ └── PricedOrderServiceTest.java └── pom.xml ├── doc ├── AggregateFamework Reference.docx └── AggregateFamework Reference.pdf └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | # maven ignore 2 | target/ 3 | *.jar 4 | *.war 5 | *.zip 6 | *.tar 7 | *.tar.gz 8 | .flattened-pom.xml 9 | 10 | # eclipse ignore 11 | .settings/ 12 | .project 13 | .classpath 14 | 15 | # idea ignore 16 | .idea/ 17 | *.ipr 18 | *.iml 19 | *.iws 20 | 21 | # temp ignore 22 | *.log 23 | *.cache 24 | *.diff 25 | *.patch 26 | *.tmp 27 | 28 | # system ignore 29 | .DS_Store 30 | Thumbs.db -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | AGGREGATE-FRAMEWORK是一款基于DDD和CQRS思想开发的领域驱动框架。内置了DomainObiect、AggregateRoot、Repository、DomainEvent、EventHandler等DDD基础构建块的实现。同时也提供了基于乐观锁的并发控制和可靠事件机制,用于满足分布式环境下的数据一致性需求。 2 | 3 | 主要目标是方便开发人员运用DDD和CQRS思想来构建复杂的、可扩展的应用系统。 4 | 5 | 详细介绍: 6 | https://changmingxie.github.io/zh-cn/aggdocs/what-is-aggregateframework.html 7 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/.editorconfig: -------------------------------------------------------------------------------- 1 | # 🎨 editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | 7 | charset = utf-8 8 | 9 | indent_style = space 10 | 11 | end_of_line = lf 12 | 13 | # [*.{js, jsx, ts, tsx, vue}] 14 | 15 | indent_size = 2 16 | 17 | insert_final_newline = true 18 | 19 | trim_trailing_whitespace = true 20 | 21 | [*.{md, json}] 22 | 23 | trim_trailing_whitespace = false 24 | 25 | 26 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .idea 16 | .DS_Store 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | 26 | dist 27 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/config/jest/cssTransform.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // This is a custom Jest transformer turning style imports into empty objects. 4 | // http://facebook.github.io/jest/docs/en/webpack.html 5 | 6 | module.exports = { 7 | process() { 8 | return 'module.exports = {};'; 9 | }, 10 | getCacheKey() { 11 | // The output is always the same. 12 | return 'cssTransform'; 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/config/pnpTs.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const {resolveModuleName} = require('ts-pnp'); 4 | 5 | exports.resolveModuleName = ( 6 | typescript, 7 | moduleName, 8 | containingFile, 9 | compilerOptions, 10 | resolutionHost 11 | ) => { 12 | return resolveModuleName( 13 | moduleName, 14 | containingFile, 15 | compilerOptions, 16 | resolutionHost, 17 | typescript.resolveModuleName 18 | ); 19 | }; 20 | 21 | exports.resolveTypeReferenceDirective = ( 22 | typescript, 23 | moduleName, 24 | containingFile, 25 | compilerOptions, 26 | resolutionHost 27 | ) => { 28 | return resolveModuleName( 29 | moduleName, 30 | containingFile, 31 | compilerOptions, 32 | resolutionHost, 33 | typescript.resolveTypeReferenceDirective 34 | ); 35 | }; 36 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changmingxie/aggregate-framework/9e6cc6fec81dc927145e87fcc0a28b9c77b9f51a/aggregate-framework-admin-web/public/favicon.ico -------------------------------------------------------------------------------- /aggregate-framework-admin-web/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changmingxie/aggregate-framework/9e6cc6fec81dc927145e87fcc0a28b9c77b9f51a/aggregate-framework-admin-web/public/logo192.png -------------------------------------------------------------------------------- /aggregate-framework-admin-web/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changmingxie/aggregate-framework/9e6cc6fec81dc927145e87fcc0a28b9c77b9f51a/aggregate-framework-admin-web/public/logo512.png -------------------------------------------------------------------------------- /aggregate-framework-admin-web/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/src/App.css: -------------------------------------------------------------------------------- 1 | .search-box { 2 | display: flex; 3 | flex-direction: row; 4 | } 5 | 6 | .search-box .ant-btn { 7 | margin-left: 8px; 8 | } 9 | 10 | .site-layout-content { 11 | padding: 12px; 12 | overflow: scroll; 13 | max-height: 48rem; 14 | } 15 | 16 | .tab-3-body { 17 | background-color: #fff; 18 | padding-top: 20px; 19 | padding-left: 24px; 20 | padding-right: 24px; 21 | padding-bottom: 1px; 22 | } 23 | 24 | .tab-3-row { 25 | padding: 6px; 26 | } 27 | 28 | .tab-3-switch-label { 29 | padding-left: 12px; 30 | } 31 | 32 | #root { 33 | height: 100%; 34 | } 35 | 36 | .layout { 37 | height: 100%; 38 | } 39 | 40 | .login-container { 41 | min-height: 100%; 42 | width: 100%; 43 | background-color: #2d3a4b; 44 | overflow: hidden; 45 | } 46 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {Provider} from 'react-redux'; 3 | import {HashRouter as Router, Redirect, Route, Switch} from 'react-router-dom'; 4 | import 'antd/dist/antd.css'; 5 | import './App.css'; 6 | 7 | import Login from './pages/agg/login/index'; 8 | import Welcome from './pages/agg/welcome/index'; 9 | import Domain from './pages/agg/domain/index'; 10 | import Transaction from './pages/agg/transaction/index'; 11 | import Task from "./pages/agg/task/index"; 12 | 13 | import store from './store'; 14 | import AggLayout from "./layout/AggLayout"; 15 | 16 | function App(props) { 17 | return ( 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 29 | }> 30 | 31 | 32 | 33 | 34 | 35 | ); 36 | 37 | } 38 | 39 | export default App; 40 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/src/App.test.js: -------------------------------------------------------------------------------- 1 | import {render} from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | const {getByText} = render(); 6 | const linkElement = getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import * as serviceWorker from './serviceWorker'; 5 | import App from "./App"; 6 | 7 | 8 | ReactDOM.render( 9 | , 10 | document.getElementById('root') 11 | ); 12 | 13 | // If you want your app to work offline and load faster, you can change 14 | // unregister() to register() below. Note this comes with some pitfalls. 15 | // Learn more about service workers: https://bit.ly/CRA-PWA 16 | serviceWorker.unregister(); 17 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/src/pages/agg/welcome/index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const page = () => { 4 | return ( 5 |
6 |

欢迎来到AGG管理后台

7 |
8 | ) 9 | } 10 | 11 | 12 | export default page; 13 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/src/setupProxy.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | const {createProxyMiddleware} = require('http-proxy-middleware'); 3 | 4 | module.exports = function (app) { 5 | let env = ''; 6 | 7 | switch (process.env.REACT_APP_ENV) { 8 | case 'test': 9 | case 'uat': 10 | env = process.env.REACT_APP_ENV; 11 | break; 12 | default: 13 | break; 14 | } 15 | 16 | // app.use( 17 | // createProxyMiddleware( 18 | // [ 19 | // '/aggregate-framework-dashboard', 20 | // ], 21 | // { 22 | // target: 'http://localhost:8888/', 23 | // changeOrigin: true, 24 | // } 25 | // ) 26 | // ); 27 | }; 28 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/src/store/actions/domain.js: -------------------------------------------------------------------------------- 1 | // export enum Domain { 2 | // UPDATE_DOMAIN_DATA = 'UPDATE_DOMAIN_DATA', 3 | // UPDATE_CURRENT_DOMAIN = 'UPDATE_CURRENT_DOMAIN', 4 | // } 5 | 6 | export const Domain = { 7 | UPDATE_DOMAIN_DATA: 'UPDATE_DOMAIN_DATA', 8 | UPDATE_CURRENT_DOMAIN: 'UPDATE_CURRENT_DOMAIN', 9 | }; 10 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/src/store/index.js: -------------------------------------------------------------------------------- 1 | import {combineReducers, createStore} from 'redux'; 2 | import {composeWithDevTools} from 'redux-devtools-extension'; 3 | import domain from './reducers/domain'; 4 | 5 | const store = createStore( 6 | combineReducers({domain}), 7 | composeWithDevTools(), 8 | ); 9 | 10 | export default store; 11 | -------------------------------------------------------------------------------- /aggregate-framework-admin-web/src/store/reducers/domain.js: -------------------------------------------------------------------------------- 1 | import {Domain} from '../actions/domain'; 2 | // import {CommonAction} from 'app-common'; 3 | 4 | // export interface DomainState { 5 | // domainData: any; 6 | // currentDomain: string; 7 | // } 8 | 9 | const defaultState = { 10 | domainData: [], 11 | currentDomain: '', 12 | xidString: null, 13 | refresh: 0, 14 | }; 15 | 16 | export default function domain(state = defaultState, {type, payload}) { 17 | switch (type) { 18 | case Domain.UPDATE_DOMAIN_DATA: 19 | return {...state, domainData: payload}; 20 | case Domain.UPDATE_CURRENT_DOMAIN: 21 | // console.log("UPDATE_CURRENT_DOMAIN", state); 22 | return {...state, currentDomain: payload.domain, xidString: payload.xidString, refresh: state.refresh + 1}; 23 | default: 24 | return state; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/dbscripts/db.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `AGG` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci'; 2 | 3 | USE `AGG`; 4 | 5 | CREATE TABLE IF NOT EXISTS `AGGREGATE_FRAMEWORK` ( 6 | `ID` bigint NOT NULL AUTO_INCREMENT, 7 | `DOMAIN` varchar(100) DEFAULT NULL, 8 | `XID` varchar(64) NOT NULL, 9 | `CONTENT` varbinary(8000) DEFAULT NULL, 10 | `RETRIED_COUNT` int(11) DEFAULT NULL, 11 | `REQUEST_ID` int(11) DEFAULT NULL, 12 | `IS_DELETE` tinyint(1) DEFAULT 0 NOT NULL, 13 | `CREATE_TIME` datetime DEFAULT NULL, 14 | `LAST_UPDATE_TIME` datetime DEFAULT NULL, 15 | `VERSION` int(11) DEFAULT NULL, 16 | PRIMARY KEY (`ID`), 17 | UNIQUE KEY `UX_XID` (`XID`) 18 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; 19 | 20 | CREATE TABLE IF NOT EXISTS `AGG_DOMAIN` ( 21 | `ID` bigint NOT NULL AUTO_INCREMENT, 22 | `DOMAIN` varchar(100) NOT NULL, 23 | `MAX_RETRY_COUNT` integer DEFAULT 3, 24 | `PHONE_NUMBERS` varchar(250), 25 | `ALERT_TYPE` varchar(10), 26 | `THRESHOLD` integer DEFAULT 0, 27 | `INTERVAL_MINUTES` integer DEFAULT 0, 28 | `LAST_ALERT_TIME` datetime DEFAULT NULL, 29 | `DING_ROBOT_URL` varchar(250) DEFAULT NULL, 30 | `CREATE_TIME` datetime DEFAULT NULL, 31 | `LAST_UPDATE_TIME` datetime DEFAULT NULL, 32 | `VERSION` int(11) DEFAULT NULL, 33 | PRIMARY KEY (`ID`), 34 | UNIQUE KEY `UX_DOMAIN` (`DOMAIN`) 35 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; 36 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/AggService.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework; 2 | 3 | import org.aggregateframework.recovery.TransactionStoreRecovery; 4 | 5 | public interface AggService { 6 | 7 | void start() throws Exception; 8 | 9 | void shutdown() throws Exception; 10 | 11 | TransactionStoreRecovery getTransactionStoreRecovery(); 12 | } 13 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/alert/AlertException.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.alert; 2 | 3 | /** 4 | * @Author huabao.fang 5 | * @Date 2022/6/7 00:28 6 | * 命名需要调整 TODO 7 | **/ 8 | public class AlertException extends RuntimeException { 9 | 10 | private final String errorCode; 11 | private final String errorMessage; 12 | 13 | public AlertException(String errorCode, String errorMessage) { 14 | super(errorMessage); 15 | this.errorCode = errorCode; 16 | this.errorMessage = errorMessage; 17 | } 18 | 19 | public AlertException(ResponseCodeEnum responseCodeEnum) { 20 | this(responseCodeEnum.getCode(), responseCodeEnum.getMessage()); 21 | } 22 | 23 | public String getErrorCode() { 24 | return errorCode; 25 | } 26 | 27 | public String getErrorMessage() { 28 | return errorMessage; 29 | } 30 | 31 | @Override 32 | public String getMessage() { 33 | return this.errorCode + "-" + this.errorMessage; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/cache/JedisClusterL2Cache.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.cache; 2 | 3 | import org.aggregateframework.entity.AggregateRoot; 4 | import org.aggregateframework.persistent.redis.JedisClusterCommands; 5 | import org.aggregateframework.persistent.redis.RedisCommands; 6 | import redis.clients.jedis.JedisCluster; 7 | 8 | import java.io.Serializable; 9 | 10 | public class JedisClusterL2Cache, ID extends Serializable> extends AbstractRedisL2Cache { 11 | 12 | private JedisCluster jedisCluster; 13 | 14 | @Override 15 | public RedisCommands getRedisCommands() { 16 | return new JedisClusterCommands(jedisCluster); 17 | } 18 | 19 | public JedisCluster getJedisCluster() { 20 | return jedisCluster; 21 | } 22 | 23 | public void setJedisCluster(JedisCluster jedisCluster) { 24 | this.jedisCluster = jedisCluster; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/cache/JedisL2Cache.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.cache; 2 | 3 | import org.aggregateframework.entity.AggregateRoot; 4 | import org.aggregateframework.persistent.redis.JedisCommands; 5 | import org.aggregateframework.persistent.redis.RedisCommands; 6 | import redis.clients.jedis.JedisPool; 7 | 8 | import java.io.Serializable; 9 | 10 | public class JedisL2Cache, ID extends Serializable> extends AbstractRedisL2Cache { 11 | 12 | private JedisPool jedisPool; 13 | 14 | public JedisPool getJedisPool() { 15 | return jedisPool; 16 | } 17 | 18 | public void setJedisPool(JedisPool jedisPool) { 19 | this.jedisPool = jedisPool; 20 | } 21 | 22 | @Override 23 | public RedisCommands getRedisCommands() { 24 | return new JedisCommands(jedisPool.getResource()); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/cache/JodisClusterL2Cache.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.cache; 2 | 3 | import io.codis.jodis.JedisResourcePool; 4 | import org.aggregateframework.entity.AggregateRoot; 5 | import org.aggregateframework.persistent.redis.JedisCommands; 6 | import org.aggregateframework.persistent.redis.RedisCommands; 7 | 8 | import java.io.Serializable; 9 | 10 | public class JodisClusterL2Cache, ID extends Serializable> extends AbstractRedisL2Cache { 11 | 12 | private JedisResourcePool jedisPool; 13 | 14 | @Override 15 | public RedisCommands getRedisCommands() { 16 | return new JedisCommands(jedisPool.getResource()); 17 | } 18 | 19 | public void setJedisPool(JedisResourcePool jedisPool) { 20 | this.jedisPool = jedisPool; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/cache/L2Cache.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.cache; 2 | 3 | import org.aggregateframework.entity.AggregateRoot; 4 | 5 | import java.io.Serializable; 6 | import java.util.Collection; 7 | 8 | /** 9 | * Created by changming.xie on 9/14/17. 10 | */ 11 | public interface L2Cache, ID extends Serializable> { 12 | 13 | void remove(Collection entities); 14 | 15 | void write(Collection entities); 16 | 17 | T findOne(Class clazz, ID id); 18 | 19 | Collection findAll(Class aggregateType, Collection ids); 20 | } 21 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/cache/NoL2Cache.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.cache; 2 | 3 | import org.aggregateframework.entity.AggregateRoot; 4 | 5 | import java.io.Serializable; 6 | import java.util.ArrayList; 7 | import java.util.Collection; 8 | 9 | /** 10 | * Created by changming.xie on 9/17/17. 11 | */ 12 | public class NoL2Cache, ID extends Serializable> implements L2Cache { 13 | 14 | public static NoL2Cache INSTANCE = new NoL2Cache(); 15 | 16 | @Override 17 | public void remove(Collection entities) { 18 | 19 | } 20 | 21 | @Override 22 | public void write(Collection entities) { 23 | 24 | } 25 | 26 | @Override 27 | public T findOne(Class clazz, ID id) { 28 | return null; 29 | } 30 | 31 | @Override 32 | public Collection findAll(Class aggregateType, Collection ids) { 33 | return new ArrayList(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/cache/RedisTemplateL2Cache.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.cache; 2 | 3 | import org.aggregateframework.entity.AggregateRoot; 4 | import org.aggregateframework.persistent.redis.RedisCommands; 5 | import org.aggregateframework.persistent.redis.RedisTemplateCommands; 6 | import org.springframework.data.redis.core.RedisTemplate; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * Created by changming.xie on 9/17/17. 12 | */ 13 | public class RedisTemplateL2Cache, ID extends Serializable> extends AbstractRedisL2Cache { 14 | 15 | private RedisTemplate redisTemplate; 16 | 17 | @Override 18 | public RedisCommands getRedisCommands() { 19 | return new RedisTemplateCommands(redisTemplate); 20 | } 21 | 22 | public void setRedisTemplate(RedisTemplate redisTemplate) { 23 | this.redisTemplate = redisTemplate; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/cache/ShardJedisL2Cache.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.cache; 2 | 3 | import org.aggregateframework.entity.AggregateRoot; 4 | import org.aggregateframework.persistent.redis.RedisCommands; 5 | import org.aggregateframework.persistent.redis.ShardJedisCommands; 6 | import redis.clients.jedis.ShardedJedisPool; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * Created by changming.xie on 9/17/17. 12 | */ 13 | public class ShardJedisL2Cache, ID extends Serializable> extends AbstractRedisL2Cache { 14 | 15 | private ShardedJedisPool shardedJedisPool; 16 | 17 | @Override 18 | public RedisCommands getRedisCommands() { 19 | return new ShardJedisCommands(shardedJedisPool.getResource()); 20 | } 21 | 22 | public void setShardedJedisPool(ShardedJedisPool shardedJedisPool) { 23 | this.shardedJedisPool = shardedJedisPool; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/constants/MixAll.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.constants; 2 | 3 | public class MixAll { 4 | 5 | public static final String DOMAIN = "DOMAIN"; 6 | 7 | private MixAll() { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/constants/RemotingServiceCode.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.constants; 2 | 3 | public class RemotingServiceCode { 4 | public static final int CREATE = 1; 5 | public static final int UPDATE = 2; 6 | public static final int DELETE = 3; 7 | public static final int FIND = 4; 8 | public static final int RECOVER = 5; 9 | public static final int REGISTER = 7; 10 | public static final int DESERIALIZE_TRANSACTION = 8; 11 | 12 | private RemotingServiceCode() { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dao/AggregateDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dao; 2 | 3 | import org.aggregateframework.entity.DomainObject; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Created by changming.xie on 10/28/16. 12 | */ 13 | @Target(ElementType.TYPE) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface AggregateDao { 16 | Class value(); 17 | } 18 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dao/AggregateRootDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dao; 2 | 3 | import org.aggregateframework.entity.AggregateRoot; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * User: changming.xie 10 | * Date: 14-6-26 11 | * Time: 上午10:14 12 | */ 13 | public interface AggregateRootDao, ID extends Serializable> extends DomainObjectDao { 14 | 15 | List findAll(); 16 | 17 | long count(); 18 | } 19 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dao/CollectiveAggregateRootDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dao; 2 | 3 | import org.aggregateframework.entity.AggregateRoot; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by changmingxie on 1/21/16. 9 | */ 10 | public interface CollectiveAggregateRootDao, ID extends Serializable> extends CollectiveDomainObjectDao, AggregateRootDao { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dao/CollectiveDomainObjectDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dao; 2 | 3 | import org.aggregateframework.entity.DomainObject; 4 | 5 | import java.io.Serializable; 6 | import java.util.Collection; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by changmingxie on 1/21/16. 11 | */ 12 | public interface CollectiveDomainObjectDao, ID extends Serializable> extends DomainObjectDao { 13 | 14 | int insertAll(Collection entities); 15 | 16 | int deleteAll(Collection entities); 17 | 18 | int updateAll(Collection entities); 19 | 20 | List findByIds(Collection ids); 21 | } 22 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dao/DomainObjectDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dao; 2 | 3 | import org.aggregateframework.entity.DomainObject; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author changming.xie 9 | */ 10 | public interface DomainObjectDao, ID extends Serializable> { 11 | 12 | int insert(T entity); 13 | 14 | int delete(T entity); 15 | 16 | int update(T entity); 17 | 18 | T findById(ID id); 19 | } 20 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dashboard/dto/ModifyCronDto.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.dto; 2 | 3 | /** 4 | * @Author huabao.fang 5 | * @Date 2022/5/26 16:31 6 | **/ 7 | public class ModifyCronDto { 8 | 9 | private String domain; 10 | 11 | private String cronExpression; 12 | 13 | public String getDomain() { 14 | return domain; 15 | } 16 | 17 | public void setDomain(String domain) { 18 | this.domain = domain; 19 | } 20 | 21 | public String getCronExpression() { 22 | return cronExpression; 23 | } 24 | 25 | public void setCronExpression(String cronExpression) { 26 | this.cronExpression = cronExpression; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dashboard/dto/TransactionDetailRequestDto.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.dto; 2 | 3 | /** 4 | * @Author huabao.fang 5 | * @Date 2022/5/30 14:31 6 | **/ 7 | public class TransactionDetailRequestDto { 8 | 9 | private String domain; 10 | 11 | private String xidString; 12 | 13 | public String getDomain() { 14 | return domain; 15 | } 16 | 17 | public void setDomain(String domain) { 18 | this.domain = domain; 19 | } 20 | 21 | public String getXidString() { 22 | return xidString; 23 | } 24 | 25 | public void setXidString(String xidString) { 26 | this.xidString = xidString; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dashboard/dto/TransactionOperateRequestDto.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.dto; 2 | 3 | /** 4 | * @Author huabao.fang 5 | * @Date 2022/5/19 20:30 6 | **/ 7 | public class TransactionOperateRequestDto { 8 | private String domain; 9 | private String xidString; 10 | 11 | public String getDomain() { 12 | return domain; 13 | } 14 | 15 | public void setDomain(String domain) { 16 | this.domain = domain; 17 | } 18 | 19 | public String getXidString() { 20 | return xidString; 21 | } 22 | 23 | public void setXidString(String xidString) { 24 | this.xidString = xidString; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dashboard/dto/TransactionPageDto.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.dto; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @Author huabao.fang 7 | * @Date 2022/5/23 07:13 8 | **/ 9 | public class TransactionPageDto { 10 | private String nextOffset; 11 | private List items; 12 | 13 | private int total; 14 | 15 | public String getNextOffset() { 16 | return nextOffset; 17 | } 18 | 19 | public void setNextOffset(String nextOffset) { 20 | this.nextOffset = nextOffset; 21 | } 22 | 23 | public List getItems() { 24 | return items; 25 | } 26 | 27 | public void setItems(List items) { 28 | this.items = items; 29 | } 30 | 31 | public int getTotal() { 32 | return total; 33 | } 34 | 35 | public void setTotal(int total) { 36 | this.total = total; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dashboard/exception/TransactionException.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.exception; 2 | 3 | import org.aggregateframework.alert.ResponseCodeEnum; 4 | 5 | /** 6 | * @Author huabao.fang 7 | * @Date 2022/6/7 00:28 8 | * 命名需要调整 TODO 9 | **/ 10 | public class TransactionException extends RuntimeException { 11 | 12 | private final String errorCode; 13 | private final String errorMessage; 14 | 15 | public TransactionException(String errorCode, String errorMessage) { 16 | super(errorMessage); 17 | this.errorCode = errorCode; 18 | this.errorMessage = errorMessage; 19 | } 20 | 21 | public TransactionException(ResponseCodeEnum responseCodeEnum) { 22 | this(responseCodeEnum.getCode(), responseCodeEnum.getMessage()); 23 | } 24 | 25 | public String getErrorCode() { 26 | return errorCode; 27 | } 28 | 29 | public String getErrorMessage() { 30 | return errorMessage; 31 | } 32 | 33 | @Override 34 | public String getMessage() { 35 | return this.errorCode + "-" + this.errorMessage; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dashboard/service/DomainService.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.service; 2 | 3 | 4 | import org.aggregateframework.dashboard.dto.DomainStoreDto; 5 | import org.aggregateframework.dashboard.dto.DomainStoreRequestDto; 6 | import org.aggregateframework.dashboard.dto.ResponseDto; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @Author huabao.fang 12 | * @Date 2022/5/30 10:09 13 | **/ 14 | public interface DomainService extends TransactionStorageable { 15 | 16 | ResponseDto> getAllDomainKeys(); 17 | 18 | ResponseDto> getAllDomains(); 19 | 20 | ResponseDto create(DomainStoreRequestDto requestDto); 21 | 22 | ResponseDto modify(DomainStoreRequestDto requestDto); 23 | 24 | ResponseDto delete(DomainStoreRequestDto requestDto); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dashboard/service/TaskService.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.service; 2 | 3 | import org.aggregateframework.dashboard.dto.ModifyCronDto; 4 | import org.aggregateframework.dashboard.dto.ResponseDto; 5 | import org.aggregateframework.dashboard.dto.TaskDto; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @Author huabao.fang 11 | * @Date 2022/5/30 10:08 12 | **/ 13 | public interface TaskService { 14 | 15 | /** 16 | * 所有任务 17 | * 18 | * @return 19 | */ 20 | ResponseDto> all(); 21 | 22 | /** 23 | * 暂停任务 24 | * 25 | * @param domain 26 | * @return 27 | */ 28 | ResponseDto pause(String domain); 29 | 30 | /** 31 | * 恢复任务 32 | * 33 | * @param domain 34 | * @return 35 | */ 36 | ResponseDto resume(String domain); 37 | 38 | /** 39 | * 修改任务cron表达式 40 | * 41 | * @param requestDto 42 | * @return 43 | */ 44 | ResponseDto modifyCron(ModifyCronDto requestDto); 45 | 46 | /** 47 | * 删除任务 48 | * 49 | * @param domain 50 | * @return 51 | */ 52 | ResponseDto delete(String domain); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dashboard/service/TransactionService.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.service; 2 | 3 | import org.aggregateframework.dashboard.dto.*; 4 | 5 | /** 6 | * @Author huabao.fang 7 | * @Date 2022/5/30 10:08 8 | **/ 9 | public interface TransactionService extends TransactionStorageable { 10 | 11 | /** 12 | * 事件分页查询 13 | * 14 | * @param requestDto 15 | * @return 16 | */ 17 | ResponseDto list(TransactionPageRequestDto requestDto); 18 | 19 | ResponseDto detail(TransactionDetailRequestDto requestDto); 20 | 21 | ResponseDto reset(TransactionOperateRequestDto requestDto); 22 | 23 | ResponseDto markDeleted(TransactionOperateRequestDto requestDto); 24 | 25 | ResponseDto restore(TransactionOperateRequestDto requestDto); 26 | 27 | ResponseDto delete(TransactionOperateRequestDto requestDto); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/dashboard/service/TransactionStorageable.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.service; 2 | 3 | import org.aggregateframework.storage.TransactionStorage; 4 | 5 | /** 6 | * @Author huabao.fang 7 | * @Date 2022/6/17 15:34 8 | **/ 9 | public interface TransactionStorageable { 10 | 11 | TransactionStorage getTransactionStorage(); 12 | } 13 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/loadbalance/AbstractLoadBalanceServcie.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.loadbalance; 2 | 3 | import org.aggregateframework.utils.CollectionUtils; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author Nervose.Wu 9 | * @date 2022/5/12 16:42 10 | */ 11 | public abstract class AbstractLoadBalanceServcie implements LoadBalanceServcie { 12 | 13 | @Override 14 | public T select(List invokers) { 15 | if (CollectionUtils.isEmpty(invokers)) { 16 | return null; 17 | } 18 | if (invokers.size() == 1) { 19 | return invokers.get(0); 20 | } 21 | return doSelect(invokers); 22 | } 23 | 24 | protected abstract T doSelect(List invokers); 25 | } 26 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/loadbalance/LoadBalanceFactory.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.loadbalance; 2 | 3 | import org.aggregateframework.discovery.registry.ClientRegistryConfig; 4 | import org.aggregateframework.load.LoadUtils; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | import java.util.ServiceLoader; 9 | 10 | /** 11 | * @author Nervose.Wu 12 | * @date 2022/5/12 17:18 13 | */ 14 | public class LoadBalanceFactory { 15 | 16 | private static final Map CANDIDATE_LOAD_BALANCES = new HashMap<>(); 17 | 18 | static { 19 | ServiceLoader.load(LoadBalanceProvider.class) 20 | .forEach(each -> CANDIDATE_LOAD_BALANCES.put(LoadUtils.getServiceName(each.getClass()), each)); 21 | } 22 | 23 | private LoadBalanceFactory() { 24 | } 25 | 26 | public static LoadBalanceServcie getInstance(ClientRegistryConfig clientRegistryConfig) { 27 | String loadBalanceType = clientRegistryConfig.getLoadBalanceType(); 28 | if (!CANDIDATE_LOAD_BALANCES.containsKey(loadBalanceType)) { 29 | throw new IllegalArgumentException("invalid loadBalanceType: " + loadBalanceType); 30 | } 31 | return CANDIDATE_LOAD_BALANCES.get(loadBalanceType).provide(); 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/loadbalance/LoadBalanceProvider.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.loadbalance; 2 | 3 | /** 4 | * @author Nervose.Wu 5 | * @date 2022/5/19 14:47 6 | */ 7 | public interface LoadBalanceProvider { 8 | 9 | LoadBalanceServcie provide(); 10 | } 11 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/loadbalance/LoadBalanceServcie.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.loadbalance; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author Nervose.Wu 7 | * @date 2022/5/12 16:39 8 | */ 9 | public interface LoadBalanceServcie { 10 | 11 | T select(List invokers); 12 | } 13 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/loadbalance/LoadBalanceType.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.loadbalance; 2 | 3 | /** 4 | * @author Nervose.Wu 5 | * @date 2022/5/12 18:39 6 | */ 7 | public enum LoadBalanceType { 8 | Random, 9 | RoundRobin, 10 | ; 11 | } 12 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/loadbalance/RandomLoadBalanceProvider.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.loadbalance; 2 | 3 | import org.aggregateframework.load.LoadInfo; 4 | 5 | /** 6 | * @author Nervose.Wu 7 | * @date 2022/5/19 14:48 8 | */ 9 | @LoadInfo(name = "Random") 10 | public class RandomLoadBalanceProvider implements LoadBalanceProvider { 11 | 12 | @Override 13 | public LoadBalanceServcie provide() { 14 | return new RandomLoadBalanceServcieImpl(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/loadbalance/RandomLoadBalanceServcieImpl.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.loadbalance; 2 | 3 | import java.util.List; 4 | import java.util.concurrent.ThreadLocalRandom; 5 | 6 | /** 7 | * @author Nervose.Wu 8 | * @date 2022/5/12 16:43 9 | */ 10 | public class RandomLoadBalanceServcieImpl extends AbstractLoadBalanceServcie { 11 | 12 | @Override 13 | protected T doSelect(List invokers) { 14 | int length = invokers.size(); 15 | return invokers.get(ThreadLocalRandom.current().nextInt(length)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/loadbalance/RoundRobinLoadBalanceProvider.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.loadbalance; 2 | 3 | import org.aggregateframework.load.LoadInfo; 4 | 5 | /** 6 | * @author Nervose.Wu 7 | * @date 2022/5/19 14:50 8 | */ 9 | @LoadInfo(name = "RoundRobin") 10 | public class RoundRobinLoadBalanceProvider implements LoadBalanceProvider { 11 | @Override 12 | public LoadBalanceServcie provide() { 13 | return new RoundRobinLoadBalanceServcieImpl(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/loadbalance/RoundRobinLoadBalanceServcieImpl.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.loadbalance; 2 | 3 | import java.util.List; 4 | import java.util.concurrent.atomic.AtomicInteger; 5 | 6 | /** 7 | * @author Nervose.Wu 8 | * @date 2022/5/12 16:41 9 | */ 10 | public class RoundRobinLoadBalanceServcieImpl extends AbstractLoadBalanceServcie { 11 | 12 | private final AtomicInteger sequence = new AtomicInteger(); 13 | 14 | @Override 15 | protected T doSelect(List invokers) { 16 | return invokers.get(getPositiveSequence() % invokers.size()); 17 | } 18 | 19 | private int getPositiveSequence() { 20 | for (; ; ) { 21 | int current = sequence.get(); 22 | int next = current == Integer.MAX_VALUE ? 0 : current + 1; 23 | if (sequence.compareAndSet(current, next)) { 24 | return current; 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/registry/ClientRegistryConfig.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.registry; 2 | 3 | /** 4 | * @author Nervose.Wu 5 | * @date 2022/7/7 17:34 6 | */ 7 | public interface ClientRegistryConfig extends RegistryConfig { 8 | 9 | RegistryRole getRegistryRole(); 10 | 11 | String getLoadBalanceType(); 12 | } 13 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/registry/RegistryConfig.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.registry; 2 | 3 | import org.aggregateframework.discovery.registry.nacos.NacosRegistryProperties; 4 | import org.aggregateframework.discovery.registry.direct.DirectRegistryProperties; 5 | import org.aggregateframework.discovery.registry.zookeeper.ZookeeperRegistryProperties; 6 | 7 | /** 8 | * @author Nervose.Wu 9 | * @date 2022/5/12 18:03 10 | */ 11 | public interface RegistryConfig { 12 | 13 | String getClusterName(); 14 | 15 | ZookeeperRegistryProperties getZookeeperRegistryProperties(); 16 | 17 | NacosRegistryProperties getNacosRegistryProperties(); 18 | 19 | DirectRegistryProperties getDirectRegistryProperties(); 20 | 21 | RegistryType getRegistryType(); 22 | 23 | String getCustomRegistryName(); 24 | } 25 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/registry/RegistryFactory.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.registry; 2 | 3 | import org.aggregateframework.load.LoadUtils; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import java.util.ServiceLoader; 8 | 9 | /** 10 | * @author Nervose.Wu 11 | * @date 2022/5/12 17:58 12 | */ 13 | public class RegistryFactory { 14 | 15 | private static final Map CANDIDATE_REGISTRY_PROVIDERS = new HashMap<>(); 16 | 17 | static { 18 | ServiceLoader.load(RegistryProvider.class).forEach(each -> CANDIDATE_REGISTRY_PROVIDERS.put(LoadUtils.getServiceName(each.getClass()), each)); 19 | } 20 | 21 | private RegistryFactory() { 22 | } 23 | 24 | public static RegistryService getInstance(RegistryConfig registryConfig) { 25 | return CANDIDATE_REGISTRY_PROVIDERS.get(registryConfig.getRegistryType().name()).provide(registryConfig); 26 | } 27 | 28 | public static RegistryProvider findRegistryProviderByName(String name) { 29 | return CANDIDATE_REGISTRY_PROVIDERS.get(name); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/registry/RegistryProvider.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.registry; 2 | 3 | /** 4 | * @author Nervose.Wu 5 | * @date 2022/5/12 17:24 6 | */ 7 | public interface RegistryProvider { 8 | 9 | RegistryService provide(RegistryConfig registryConfig); 10 | } 11 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/registry/RegistryRole.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.registry; 2 | 3 | /** 4 | * @author Nervose.Wu 5 | * @date 2022/5/12 17:55 6 | */ 7 | 8 | public enum RegistryRole { 9 | CLIENT, 10 | DASHBOARD; 11 | 12 | public static RegistryRole getType(String name) { 13 | for (RegistryRole registryRole : RegistryRole.values()) { 14 | if (registryRole.name().equalsIgnoreCase(name)) { 15 | return registryRole; 16 | } 17 | } 18 | throw new IllegalArgumentException("not support registry role: " + name); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/registry/RegistryService.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.registry; 2 | 3 | import java.net.InetSocketAddress; 4 | import java.util.List; 5 | 6 | /** 7 | * @author Nervose.Wu 8 | * @date 2022/5/12 16:27 9 | */ 10 | public interface RegistryService { 11 | 12 | void start(); 13 | 14 | void register(InetSocketAddress addressForClient, InetSocketAddress addressForDashboard); 15 | 16 | void subscribe(boolean forDashboard); 17 | 18 | List lookup(boolean forDashboard); 19 | 20 | void close(); 21 | } 22 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/registry/RegistryType.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.registry; 2 | 3 | /** 4 | * @author Nervose.Wu 5 | * @date 2022/5/12 17:55 6 | */ 7 | 8 | public enum RegistryType { 9 | zookeeper, 10 | nacos, 11 | direct, 12 | custom; 13 | 14 | public static RegistryType getType(String name) { 15 | for (RegistryType registryType : RegistryType.values()) { 16 | if (registryType.name().equalsIgnoreCase(name)) { 17 | return registryType; 18 | } 19 | } 20 | throw new IllegalArgumentException("not support registry type: " + name); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/registry/ServerRegistryConfig.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.registry; 2 | 3 | /** 4 | * @author Nervose.Wu 5 | * @date 2022/7/7 17:34 6 | */ 7 | public interface ServerRegistryConfig extends RegistryConfig { 8 | 9 | String getRegistryAddress(); 10 | 11 | int getRegistryPortForDashboard(); 12 | 13 | String getRegistryAddressForDashboard(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/registry/direct/DirectRegistryProperties.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.registry.direct; 2 | 3 | /** 4 | * @author Nervose.Wu 5 | * @date 2022/5/18 17:00 6 | */ 7 | public class DirectRegistryProperties { 8 | 9 | private String addressesForClient = "127.0.0.1:2332"; 10 | 11 | private String addressesForDashboard = "127.0.0.1:12332"; 12 | 13 | public String getAddressesForClient() { 14 | return addressesForClient; 15 | } 16 | 17 | public void setAddressesForClient(String addressesForClient) { 18 | this.addressesForClient = addressesForClient; 19 | } 20 | 21 | public String getAddressesForDashboard() { 22 | return addressesForDashboard; 23 | } 24 | 25 | public void setAddressesForDashboard(String addressesForDashboard) { 26 | this.addressesForDashboard = addressesForDashboard; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/registry/direct/DirectRegistryProvider.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.registry.direct; 2 | 3 | import org.aggregateframework.discovery.registry.RegistryConfig; 4 | import org.aggregateframework.discovery.registry.RegistryProvider; 5 | import org.aggregateframework.discovery.registry.RegistryService; 6 | import org.aggregateframework.load.LoadInfo; 7 | 8 | /** 9 | * @author Nervose.Wu 10 | * @date 2022/5/18 17:11 11 | */ 12 | @LoadInfo(name = "direct") 13 | public class DirectRegistryProvider implements RegistryProvider { 14 | @Override 15 | public RegistryService provide(RegistryConfig registryConfig) { 16 | return new DirectRegistryServiceImpl(registryConfig); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/registry/nacos/NacosRegistryServiceProvider.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.registry.nacos; 2 | 3 | import org.aggregateframework.discovery.registry.RegistryConfig; 4 | import org.aggregateframework.discovery.registry.RegistryProvider; 5 | import org.aggregateframework.discovery.registry.RegistryService; 6 | import org.aggregateframework.load.LoadInfo; 7 | 8 | /** 9 | * @author Nervose.Wu 10 | * @date 2022/5/12 17:29 11 | */ 12 | @LoadInfo(name = "nacos") 13 | public class NacosRegistryServiceProvider implements RegistryProvider { 14 | @Override 15 | public RegistryService provide(RegistryConfig registryConfig) { 16 | return new NacosRegistryServiceImpl(registryConfig); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/discovery/registry/zookeeper/ZookeeperRegistryProvider.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.discovery.registry.zookeeper; 2 | 3 | import org.aggregateframework.discovery.registry.RegistryConfig; 4 | import org.aggregateframework.discovery.registry.RegistryProvider; 5 | import org.aggregateframework.discovery.registry.RegistryService; 6 | import org.aggregateframework.load.LoadInfo; 7 | 8 | /** 9 | * @author Nervose.Wu 10 | * @date 2022/5/12 17:27 11 | */ 12 | @LoadInfo(name = "zookeeper") 13 | public class ZookeeperRegistryProvider implements RegistryProvider { 14 | @Override 15 | public RegistryService provide(RegistryConfig registryConfig) { 16 | return new ZookeeperRegistryServiceImpl(registryConfig); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/domainevent/EventMessage.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.domainevent; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * User: changming.xie 7 | * Date: 14-7-3 8 | * Time: 上午9:01 9 | */ 10 | public interface EventMessage extends Serializable { 11 | 12 | Class getPayloadType(); 13 | 14 | Object getPayload(); 15 | 16 | MessageType getMessageType(); 17 | } 18 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/domainevent/MessageType.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.domainevent; 2 | 3 | /** 4 | * Created by changmingxie on 8/25/15. 5 | */ 6 | public enum MessageType { 7 | 8 | DOMAIN_EVENT, 9 | APPLICATION_EVENT 10 | } 11 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/entity/AbstractSimpleAggregateRoot.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.entity; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | /** 7 | * @author changming.xie 8 | */ 9 | public abstract class AbstractSimpleAggregateRoot extends AbstractAggregateRoot { 10 | 11 | private static final long serialVersionUID = 5687124586118075949L; 12 | 13 | private Long version = 1L; 14 | 15 | private Date createTime; 16 | 17 | private Date lastUpdateTime; 18 | 19 | @Override 20 | public long getVersion() { 21 | return version; 22 | } 23 | 24 | 25 | @Override 26 | public Date getCreateTime() { 27 | return createTime; 28 | } 29 | 30 | @Override 31 | public Date getLastUpdateTime() { 32 | return lastUpdateTime; 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/entity/AbstractSimpleDomainObject.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.entity; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | /** 7 | * @author changming.xie 8 | */ 9 | public abstract class AbstractSimpleDomainObject extends AbstractDomainObject { 10 | 11 | private static final long serialVersionUID = 5891480982236336994L; 12 | 13 | private Date createTime; 14 | 15 | private Date lastUpdateTime; 16 | 17 | @Override 18 | public Date getCreateTime() { 19 | return createTime; 20 | } 21 | 22 | @Override 23 | public Date getLastUpdateTime() { 24 | return lastUpdateTime; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/entity/AggregateRoot.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.entity; 2 | 3 | import org.aggregateframework.domainevent.EventMessage; 4 | 5 | import java.io.Serializable; 6 | import java.util.Collection; 7 | 8 | /** 9 | * User: changming.xie 10 | * Date: 14-6-25 11 | * Time: 下午1:34 12 | */ 13 | public interface AggregateRoot extends DomainObject { 14 | 15 | Collection getUncommittedDomainEvents(); 16 | 17 | long getVersion(); 18 | 19 | boolean isDeleted(); 20 | 21 | void commitDomainEvents(); 22 | 23 | void clearDomainEvents(); 24 | } 25 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/entity/CompositeId.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by changmingxie on 11/30/15. 7 | */ 8 | public interface CompositeId extends Serializable { 9 | 10 | boolean isNewId(); 11 | } 12 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/entity/DaoAwareQuery.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.entity; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.Target; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 8 | 9 | /** 10 | * User: changming.xie 11 | * Date: 14-6-23 12 | * Time: 下午2:46 13 | */ 14 | @Target({FIELD}) 15 | @Retention(RUNTIME) 16 | public @interface DaoAwareQuery { 17 | 18 | public String mappedBy(); 19 | 20 | public String select(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/entity/DomainObject.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.entity; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | /** 7 | * User: changming.xie 8 | * Date: 14-6-25 9 | * Time: 下午6:57 10 | */ 11 | public interface DomainObject extends Serializable { 12 | 13 | ID getId(); 14 | 15 | void setId(ID id); 16 | 17 | boolean isNew(); 18 | 19 | Date getCreateTime(); 20 | 21 | Date getLastUpdateTime(); 22 | } -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/entity/EventContainer.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.entity; 2 | 3 | 4 | import org.aggregateframework.domainevent.EventMessage; 5 | import org.aggregateframework.domainevent.SimpleEventMessage; 6 | 7 | import java.io.Serializable; 8 | import java.util.Collection; 9 | import java.util.LinkedHashMap; 10 | import java.util.Map; 11 | 12 | /** 13 | * User: changming.xie 14 | * Date: 14-7-2 15 | * Time: 下午7:33 16 | */ 17 | public class EventContainer implements Serializable { 18 | 19 | private final Map eventMessageMap = new LinkedHashMap(); 20 | 21 | public void addEvent(T payload) { 22 | 23 | if (!eventMessageMap.containsKey(payload)) { 24 | EventMessage eventMessage = new SimpleEventMessage(payload); 25 | eventMessageMap.put(payload, eventMessage); 26 | } 27 | } 28 | 29 | public Collection getEvents() { 30 | return eventMessageMap.values(); 31 | } 32 | 33 | public void commit() { 34 | eventMessageMap.clear(); 35 | } 36 | 37 | public void clear() { 38 | eventMessageMap.clear(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/entity/Transient.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.entity; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.Target; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.ElementType.METHOD; 8 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 9 | 10 | /** 11 | * User: changming.xie 12 | * Date: 2014-09-29 13 | * Time: 15:49 14 | */ 15 | @Target({METHOD, FIELD}) 16 | @Retention(RUNTIME) 17 | public @interface Transient { 18 | } 19 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/eventbus/EventBus.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.eventbus; 2 | 3 | import org.aggregateframework.domainevent.EventMessage; 4 | import org.aggregateframework.eventhandling.EventListener; 5 | import org.aggregateframework.transaction.LocalTransactionExecutor; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * User: changming.xie 11 | * Date: 14-7-10 12 | * Time: 下午5:14 13 | */ 14 | public interface EventBus { 15 | 16 | public void subscribe(EventListener eventListener); 17 | 18 | void publishInTransaction(List messages, LocalTransactionExecutor localTransactionExecutor); 19 | } 20 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/eventhandling/EventHandlerListener.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.eventhandling; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | public interface EventHandlerListener { 6 | void before(Object target, Method method, Object[] params) throws Exception; 7 | 8 | void after(Object target, Method method, Object[] params, Exception e) throws Exception; 9 | 10 | boolean isActive(); 11 | } 12 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/eventhandling/EventListener.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.eventhandling; 2 | 3 | import org.aggregateframework.domainevent.EventMessage; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * User: changming.xie 9 | * Date: 14-7-10 10 | * Time: 下午1:10 11 | */ 12 | public interface EventListener { 13 | 14 | List matchHandler(List event); 15 | } 16 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/eventhandling/SimpleEventListenerProxy.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.eventhandling; 2 | 3 | /** 4 | * User: changming.xie 5 | * Date: 14-7-10 6 | * Time: 下午1:40 7 | */ 8 | public interface SimpleEventListenerProxy extends EventListener { 9 | Class getTargetType(); 10 | } 11 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/eventhandling/annotation/AsyncConfig.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.eventhandling.annotation; 2 | 3 | /** 4 | * Created by changming.xie on 12/19/17. 5 | */ 6 | public @interface AsyncConfig { 7 | 8 | QueueFullPolicy queueFullPolicy() default QueueFullPolicy.SYNCHRONOUS; 9 | 10 | int ringBufferSize() default 4096; 11 | 12 | int workPoolSize() default 24; 13 | 14 | int maxBatchSize() default 1024; 15 | } 16 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/eventhandling/annotation/EventHandler.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.eventhandling.annotation; 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 | /** 9 | * User: changming.xie 10 | * Date: 14-7-10 11 | * Time: 下午4:39 12 | */ 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Target(ElementType.METHOD) 15 | public @interface EventHandler { 16 | 17 | boolean asynchronous() default false; 18 | 19 | AsyncConfig asyncConfig() default @AsyncConfig(); 20 | 21 | boolean postAfterTransaction() default false; 22 | 23 | boolean isTransactionMessage() default false; 24 | 25 | int order() default Order.HIGHEST_PRECEDENCE; 26 | 27 | TransactionCheck transactionCheck() default @TransactionCheck(); 28 | 29 | interface Order { 30 | /** 31 | * Useful constant for the highest precedence value. 32 | * 33 | * @see java.lang.Integer#MIN_VALUE 34 | */ 35 | int HIGHEST_PRECEDENCE = Integer.MIN_VALUE; 36 | 37 | /** 38 | * Useful constant for the lowest precedence value. 39 | * 40 | * @see java.lang.Integer#MAX_VALUE 41 | */ 42 | int LOWEST_PRECEDENCE = Integer.MAX_VALUE; 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/eventhandling/annotation/QueueFullPolicy.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.eventhandling.annotation; 2 | 3 | public enum QueueFullPolicy { 4 | SYNCHRONOUS, 5 | ENQUEUE, 6 | DISCARD; 7 | } 8 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/eventhandling/annotation/TransactionCheck.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.eventhandling.annotation; 2 | 3 | /** 4 | * Created by changming.xie on 12/19/17. 5 | */ 6 | public @interface TransactionCheck { 7 | 8 | String checkTransactionStatusMethod() default ""; 9 | } 10 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/eventhandling/processor/EventHandlerProcessor.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.eventhandling.processor; 2 | 3 | import org.aggregateframework.eventhandling.EventInvokerEntry; 4 | import org.aggregateframework.eventhandling.annotation.EventHandler; 5 | import org.aggregateframework.utils.ReflectionUtils; 6 | 7 | /** 8 | * Created by changmingxie on 12/2/15. 9 | */ 10 | public class EventHandlerProcessor { 11 | 12 | public static void proceed(EventInvokerEntry eventInvokerEntry) { 13 | 14 | EventHandler eventHandler = ReflectionUtils.getAnnotation(eventInvokerEntry.getMethod(), EventHandler.class); 15 | if (eventHandler.asynchronous()) { 16 | AsyncMethodInvoker.getInstance().invoke(eventInvokerEntry); 17 | } else { 18 | EventMethodInvoker.getInstance().invoke(eventInvokerEntry); 19 | } 20 | } 21 | 22 | public static void prepare(EventInvokerEntry entry) { 23 | EventMethodInvoker.getInstance().preInvoke(entry); 24 | } 25 | 26 | public static void cancel(EventInvokerEntry entry) { 27 | EventMethodInvoker.getInstance().cancelInvoke(entry); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/eventhandling/processor/async/AsyncEvent.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.eventhandling.processor.async; 2 | 3 | import org.aggregateframework.eventhandling.EventInvokerEntry; 4 | 5 | /** 6 | * Created by changmingxie on 12/2/15. 7 | */ 8 | public class AsyncEvent { 9 | 10 | public static final AsyncEventFactory FACTORY = new AsyncEventFactory(); 11 | 12 | private EventInvokerEntry eventInvokerEntry; 13 | private String threadContext; 14 | 15 | public void reset(EventInvokerEntry eventInvokerEntry, String threadContext) { 16 | this.eventInvokerEntry = eventInvokerEntry; 17 | this.threadContext = threadContext; 18 | } 19 | 20 | public EventInvokerEntry getEventInvokerEntry() { 21 | return eventInvokerEntry; 22 | } 23 | 24 | public String getThreadContext() { 25 | return threadContext; 26 | } 27 | 28 | public void clear() { 29 | eventInvokerEntry = null; 30 | threadContext = null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/eventhandling/processor/async/AsyncEventFactory.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.eventhandling.processor.async; 2 | 3 | import com.lmax.disruptor.EventFactory; 4 | 5 | /** 6 | * Created by changmingxie on 12/2/15. 7 | */ 8 | public class AsyncEventFactory implements EventFactory { 9 | @Override 10 | public AsyncEvent newInstance() { 11 | return new AsyncEvent(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/eventhandling/processor/async/AsyncEventTranslator.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.eventhandling.processor.async; 2 | 3 | import com.lmax.disruptor.EventTranslator; 4 | import org.aggregateframework.eventhandling.EventInvokerEntry; 5 | 6 | /** 7 | * Created by changming.xie on 11/24/17. 8 | */ 9 | public class AsyncEventTranslator implements EventTranslator, AutoCloseable { 10 | 11 | private EventInvokerEntry eventInvokerEntry; 12 | private String threadContext; 13 | 14 | @Override 15 | public void translateTo(AsyncEvent event, long sequence) { 16 | event.reset(eventInvokerEntry, threadContext); 17 | } 18 | 19 | public void reset(EventInvokerEntry eventInvokerEntry, String threadContext) { 20 | this.eventInvokerEntry = eventInvokerEntry; 21 | this.threadContext = threadContext; 22 | } 23 | 24 | public EventInvokerEntry getEventInvokerEntry() { 25 | return eventInvokerEntry; 26 | } 27 | 28 | @Override 29 | public void close() throws Exception { 30 | this.eventInvokerEntry = null; 31 | this.threadContext = null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/eventhandling/processor/async/RetryEventFactory.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.eventhandling.processor.async; 2 | 3 | import com.lmax.disruptor.EventFactory; 4 | 5 | /** 6 | * Created by changming.xie on 2/1/16. 7 | */ 8 | public class RetryEventFactory implements EventFactory { 9 | @Override 10 | public RetryEvent newInstance() { 11 | return new RetryEvent(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/exception/CancellingException.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.exception; 2 | 3 | /** 4 | * Created by changming.xie on 7/21/16. 5 | */ 6 | public class CancellingException extends RuntimeException { 7 | 8 | 9 | private static final long serialVersionUID = -1250722688869888254L; 10 | 11 | public CancellingException(Throwable cause) { 12 | super(cause); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/exception/ConfirmingException.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.exception; 2 | 3 | /** 4 | * Created by changming.xie on 7/21/16. 5 | */ 6 | public class ConfirmingException extends RuntimeException { 7 | 8 | public ConfirmingException(Throwable cause) { 9 | super(cause); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/exception/DomainException.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.exception; 2 | 3 | /** 4 | * @author changming.xie 5 | */ 6 | public class DomainException extends RuntimeException { 7 | 8 | /** 9 | * 10 | */ 11 | private static final long serialVersionUID = 4950403241947582586L; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/exception/NoDaoDefinitionException.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.exception; 2 | 3 | /** 4 | * @author changming.xie 5 | */ 6 | public class NoDaoDefinitionException extends RuntimeException { 7 | 8 | /** 9 | * 10 | */ 11 | private static final long serialVersionUID = 9005161277240779449L; 12 | 13 | 14 | public NoDaoDefinitionException() { 15 | super(); 16 | } 17 | 18 | public NoDaoDefinitionException(String message) { 19 | super(message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/exception/NoExistedTransactionException.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.exception; 2 | 3 | /** 4 | * Created by changmingxie on 12/16/15. 5 | */ 6 | public class NoExistedTransactionException extends Exception { 7 | private static final long serialVersionUID = 1031919168789207713L; 8 | } 9 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/exception/OptimisticLockException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Project: ba-tgplatform-common 3 | *

4 | * File Created at Aug 5, 2013 5 | * $Id$ 6 | *

7 | * Copyright 2010 dianping.com. 8 | * All rights reserved. 9 | *

10 | * This software is the confidential and proprietary information of 11 | * Dianping Company. ("Confidential Information"). You shall not 12 | * disclose such Confidential Information and shall use it only in 13 | * accordance with the terms of the license agreement you entered into 14 | * with dianping.com. 15 | */ 16 | package org.aggregateframework.exception; 17 | 18 | /** 19 | * @author changming.xie 20 | */ 21 | public class OptimisticLockException extends DomainException { 22 | 23 | /** 24 | * 25 | */ 26 | private static final long serialVersionUID = -8667254382425959158L; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/exception/RegistryException.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.exception; 2 | 3 | /** 4 | * @author Nervose.Wu 5 | * @date 2022/5/13 14:19 6 | */ 7 | public class RegistryException extends RuntimeException { 8 | 9 | public RegistryException() { 10 | } 11 | 12 | public RegistryException(String message) { 13 | super(message); 14 | } 15 | 16 | public RegistryException(String message, Throwable cause) { 17 | super(message, cause); 18 | } 19 | 20 | public RegistryException(Throwable cause) { 21 | super(cause); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/exception/SystemException.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.exception; 2 | 3 | import java.lang.reflect.InvocationTargetException; 4 | 5 | /** 6 | * @author changming.xie 7 | */ 8 | public class SystemException extends RuntimeException { 9 | 10 | /** 11 | * 12 | */ 13 | private static final long serialVersionUID = -1168466835428095456L; 14 | 15 | public SystemException(String message) { 16 | super(message); 17 | } 18 | 19 | public SystemException(Throwable e) { 20 | super(e); 21 | } 22 | 23 | public SystemException(String message, Throwable e) { 24 | super(message, e); 25 | } 26 | 27 | public Throwable getOriginThrowable() { 28 | Throwable t = getCause(); 29 | if (t == null) { 30 | return null; 31 | } 32 | 33 | if (t instanceof InvocationTargetException) { 34 | return t.getCause(); 35 | } 36 | 37 | return t; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/load/LoadInfo.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.load; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author Nervose.Wu 7 | * @date 2022/5/12 19:17 8 | */ 9 | @Documented 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Target({ElementType.TYPE}) 12 | public @interface LoadInfo { 13 | String name(); 14 | } 15 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/load/LoadUtils.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.load; 2 | 3 | /** 4 | * @author Nervose.Wu 5 | * @date 2022/5/12 19:21 6 | */ 7 | public class LoadUtils { 8 | 9 | private LoadUtils() { 10 | } 11 | 12 | public static String getServiceName(Class clazz) { 13 | LoadInfo loadInfo = clazz.getAnnotation(LoadInfo.class); 14 | if (loadInfo == null) { 15 | throw new IllegalArgumentException("Failed to get loadInfo"); 16 | } 17 | return loadInfo.name(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/persistent/redis/CommandCallback.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.persistent.redis; 2 | 3 | public interface CommandCallback { 4 | T execute(RedisCommands commands); 5 | } 6 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/persistent/redis/JedisCallback.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.persistent.redis; 2 | 3 | import redis.clients.jedis.Jedis; 4 | 5 | /** 6 | * Created by changming.xie on 9/15/16. 7 | */ 8 | public interface JedisCallback { 9 | 10 | T doInJedis(Jedis jedis); 11 | } -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/persistent/redis/RedisCommands.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.persistent.redis; 2 | 3 | import java.io.Closeable; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | public interface RedisCommands extends Closeable { 8 | 9 | Object eval(byte[] scripts, List keys, List args); 10 | 11 | Long del(byte[] key); 12 | 13 | void set(byte[] key, byte[] value); 14 | 15 | byte[] get(byte[] key); 16 | 17 | Map hgetAll(byte[] key); 18 | 19 | void hset(byte[] key, byte[] field, byte[] value); 20 | 21 | void hdel(byte[] key, byte[] field); 22 | 23 | void expire(byte[] key, int expireTime); 24 | 25 | List executePipelined(CommandCallback> commandCallback); 26 | 27 | Long renamenx(byte[] oldkey, byte[] newkey); 28 | } 29 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/persistent/redis/ShardedJedisCallback.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.persistent.redis; 2 | 3 | import redis.clients.jedis.ShardedJedis; 4 | 5 | public interface ShardedJedisCallback { 6 | public T doInJedis(ShardedJedis jedis); 7 | } 8 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/properties/registry/ClientRegistryProperties.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.properties.registry; 2 | 3 | import org.aggregateframework.discovery.loadbalance.LoadBalanceType; 4 | import org.aggregateframework.discovery.registry.ClientRegistryConfig; 5 | import org.aggregateframework.discovery.registry.RegistryRole; 6 | 7 | /** 8 | * @author Nervose.Wu 9 | * @date 2022/7/7 17:38 10 | */ 11 | public class ClientRegistryProperties extends RegistryProperties implements ClientRegistryConfig { 12 | 13 | private String loadBalanceType = LoadBalanceType.RoundRobin.name(); 14 | 15 | private RegistryRole registryRole = RegistryRole.CLIENT; 16 | 17 | @Override 18 | public RegistryRole getRegistryRole() { 19 | return registryRole; 20 | } 21 | 22 | public void setRegistryRole(RegistryRole registryRole) { 23 | this.registryRole = registryRole; 24 | } 25 | 26 | @Override 27 | public String getLoadBalanceType() { 28 | return loadBalanceType; 29 | } 30 | 31 | public void setLoadBalanceType(String loadBalanceType) { 32 | this.loadBalanceType = loadBalanceType; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/recovery/QuartzRecoveryTask.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.recovery; 2 | 3 | import org.aggregateframework.AggService; 4 | import org.aggregateframework.constants.MixAll; 5 | import org.aggregateframework.support.FactoryBuilder; 6 | import org.quartz.DisallowConcurrentExecution; 7 | import org.quartz.Job; 8 | import org.quartz.JobExecutionContext; 9 | import org.quartz.JobExecutionException; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | @DisallowConcurrentExecution 14 | public class QuartzRecoveryTask implements Job { 15 | 16 | static final Logger logger = LoggerFactory.getLogger(QuartzRecoveryTask.class.getSimpleName()); 17 | 18 | @Override 19 | public void execute(JobExecutionContext context) throws JobExecutionException { 20 | String domain = context.getJobDetail().getJobDataMap().getString(MixAll.DOMAIN); 21 | logger.info("start recovery {}", domain); 22 | FactoryBuilder.factoryOf(AggService.class).getInstance().getTransactionStoreRecovery().startRecover(domain); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/recovery/RecoveryConfig.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.recovery; 2 | 3 | 4 | import java.util.Map; 5 | 6 | /** 7 | * Created by changming.xie on 6/1/16. 8 | */ 9 | public interface RecoveryConfig { 10 | 11 | boolean isRecoveryEnabled(); 12 | 13 | int getMaxRetryCount(); 14 | 15 | int getRecoverDuration(); 16 | 17 | String getCronExpression(); 18 | 19 | int getConcurrentRecoveryThreadCount(); 20 | 21 | int getFetchPageSize(); 22 | 23 | boolean isUpdateJobForcibly(); 24 | 25 | String getQuartzDataSourceDriver(); 26 | 27 | String getQuartzDataSourceUrl(); 28 | 29 | String getQuartzDataSourceUser(); 30 | 31 | String getQuartzDataSourcePassword(); 32 | 33 | String getQuartzDataSourceValidationQuery(); 34 | 35 | int getQuartzDataSourceCheckoutTimeout(); 36 | 37 | int getQuartzDataSourceInitialPoolSize(); 38 | 39 | int getQuartzDataSourceMinPoolSize(); 40 | 41 | int getQuartzDataSourceMaxPoolSize(); 42 | 43 | int getQuartzThreadPoolThreadCount(); 44 | 45 | boolean isQuartzClustered(); 46 | 47 | String getCustomConnectionProviderClassName(); 48 | 49 | Map getCustomConnectionProviderProperties(); 50 | } 51 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/recovery/RecoveryExecutor.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.recovery; 2 | 3 | import org.aggregateframework.storage.TransactionStore; 4 | 5 | public interface RecoveryExecutor { 6 | 7 | void recover(TransactionStore transactionStore); 8 | 9 | byte[] transactionVisualize(String domain, byte[] content); 10 | } 11 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/RemotingClient.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.remoting; 2 | 3 | import org.aggregateframework.remoting.protocol.RemotingCommand; 4 | 5 | public interface RemotingClient extends RemotingService { 6 | 7 | RemotingCommand invokeSync(final RemotingCommand request, final long timeoutMillis); 8 | 9 | RemotingCommand invokeSync(final String address, final RemotingCommand request, final long timeoutMillis); 10 | 11 | void invokeOneway(final RemotingCommand request, final long timeoutMillis); 12 | 13 | 14 | void invokeOneway(final String address, final RemotingCommand request, final long timeoutMillis); 15 | } 16 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/RemotingServer.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.remoting; 2 | 3 | import org.aggregateframework.remoting.protocol.RemotingCommand; 4 | 5 | public interface RemotingServer extends RemotingService { 6 | RemotingCommand invokeSync(final String key, final RemotingCommand request, final long timeoutMillis); 7 | } 8 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/RemotingService.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.remoting; 2 | 3 | import io.netty.channel.ChannelHandler; 4 | 5 | import java.util.concurrent.ExecutorService; 6 | 7 | public interface RemotingService { 8 | 9 | void start(); 10 | 11 | void shutdown(); 12 | 13 | void registerDefaultProcessor(final RequestProcessor processor, final ExecutorService executor); 14 | 15 | void registerChannelHandlers(ChannelHandler... channelHandlers); 16 | } 17 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/RequestProcessor.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.remoting; 2 | 3 | import org.aggregateframework.remoting.protocol.RemotingCommand; 4 | 5 | public interface RequestProcessor { 6 | 7 | RemotingCommand processRequest(T context, RemotingCommand request); 8 | } 9 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/codec/NettyDecoder.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.remoting.codec; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.channel.ChannelHandlerContext; 5 | import io.netty.handler.codec.ByteToMessageDecoder; 6 | import org.aggregateframework.transaction.serializer.RemotingCommandSerializer; 7 | 8 | import java.util.List; 9 | 10 | public class NettyDecoder extends ByteToMessageDecoder { 11 | 12 | RemotingCommandSerializer serializer; 13 | 14 | public NettyDecoder(RemotingCommandSerializer serializer) { 15 | this.serializer = serializer; 16 | } 17 | 18 | @Override 19 | protected void decode(ChannelHandlerContext ctx, ByteBuf in, 20 | List out) throws Exception { 21 | 22 | byte[] bytes = new byte[in.capacity()]; 23 | in.readBytes(bytes, 0, in.capacity()); 24 | out.add(serializer.deserialize(bytes)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/codec/NettyEncoder.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.remoting.codec; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.channel.ChannelHandlerContext; 5 | import io.netty.handler.codec.MessageToByteEncoder; 6 | import org.aggregateframework.remoting.protocol.RemotingCommand; 7 | import org.aggregateframework.transaction.serializer.RemotingCommandSerializer; 8 | 9 | public class NettyEncoder extends MessageToByteEncoder { 10 | 11 | RemotingCommandSerializer serializer; 12 | 13 | public NettyEncoder(RemotingCommandSerializer serializer) { 14 | this.serializer = serializer; 15 | } 16 | 17 | @Override 18 | protected void encode(ChannelHandlerContext ctx, RemotingCommand message, 19 | ByteBuf out) throws Exception { 20 | out.writeBytes(serializer.serialize(message)); 21 | ctx.flush(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/exception/RemotingCommandException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.aggregateframework.remoting.exception; 18 | 19 | public class RemotingCommandException extends RemotingException { 20 | 21 | public RemotingCommandException(String message) { 22 | super(message, null); 23 | } 24 | 25 | public RemotingCommandException(String message, Throwable cause) { 26 | super(message, cause); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/exception/RemotingConnectException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.aggregateframework.remoting.exception; 18 | 19 | public class RemotingConnectException extends RemotingException { 20 | 21 | public RemotingConnectException(String addr) { 22 | this(addr, null); 23 | } 24 | 25 | public RemotingConnectException(String addr, Throwable cause) { 26 | super("connect to " + addr + " failed", cause); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/exception/RemotingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.aggregateframework.remoting.exception; 18 | 19 | import org.aggregateframework.exception.SystemException; 20 | 21 | public class RemotingException extends SystemException { 22 | 23 | public RemotingException(String message) { 24 | super(message); 25 | } 26 | 27 | public RemotingException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/exception/RemotingSendRequestException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.aggregateframework.remoting.exception; 18 | 19 | public class RemotingSendRequestException extends RemotingException { 20 | 21 | public RemotingSendRequestException(String addr) { 22 | this(addr, null); 23 | } 24 | 25 | public RemotingSendRequestException(String addr, Throwable cause) { 26 | super("send request to <" + addr + "> failed", cause); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/netty/ChannelGroupMap.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.remoting.netty; 2 | 3 | import io.netty.channel.Channel; 4 | import io.netty.channel.group.ChannelGroup; 5 | import io.netty.channel.group.DefaultChannelGroup; 6 | import io.netty.util.concurrent.GlobalEventExecutor; 7 | 8 | import java.util.Set; 9 | import java.util.concurrent.ConcurrentHashMap; 10 | import java.util.concurrent.ConcurrentMap; 11 | 12 | public class ChannelGroupMap { 13 | 14 | private ConcurrentMap channelGroup = new ConcurrentHashMap<>(); 15 | 16 | public ChannelGroupMap() { 17 | 18 | } 19 | 20 | public void registerChannel(String key, Channel channel) { 21 | channelGroup.computeIfAbsent(key, key0 -> new DefaultChannelGroup(key0, GlobalEventExecutor.INSTANCE)).add(channel); 22 | } 23 | 24 | public Channel getChannel(String key) { 25 | Set channels = channelGroup.get(key); 26 | if (channels != null && !channels.isEmpty()) { 27 | return channels.iterator().next(); 28 | } 29 | return null; 30 | } 31 | 32 | public Set getAllChannels(String key) { 33 | return channelGroup.get(key); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/netty/NettyClientConfig.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.remoting.netty; 2 | 3 | public interface NettyClientConfig extends NettyConfig { 4 | 5 | long getConnectTimeoutMillis(); 6 | 7 | int getChannelPoolMaxTotal(); 8 | 9 | int getChannelPoolMaxIdlePerKey(); 10 | 11 | int getChannelPoolMaxTotalPerKey(); 12 | 13 | int getChannelPoolMinIdlePerKey(); 14 | 15 | long getChannelPoolMaxWaitMillis(); 16 | 17 | long getChannelPoolTimeBetweenEvictionRunsMillis(); 18 | 19 | long getChannelPoolSoftMinEvictableIdleTimeMillis(); 20 | 21 | int getNumTestsPerEvictionRun(); 22 | 23 | int getChannelMaxIdleTimeSeconds(); 24 | 25 | int getReconnectIntervalSeconds(); 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/netty/NettyConfig.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.remoting.netty; 2 | 3 | public interface NettyConfig { 4 | 5 | int getWorkSelectorThreadSize(); 6 | 7 | int getWorkerThreadSize(); 8 | 9 | int getSocketBacklog(); 10 | 11 | int getSocketRcvBufSize(); 12 | 13 | int getSocketSndBufSize(); 14 | 15 | int getFrameMaxLength(); 16 | 17 | int getRequestProcessThreadSize(); 18 | 19 | int getRequestProcessThreadQueueCapacity(); 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/netty/NettyServerConfig.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.remoting.netty; 2 | 3 | public interface NettyServerConfig extends NettyConfig { 4 | 5 | int getListenPort(); 6 | 7 | int getChannelIdleTimeoutSeconds(); 8 | 9 | int getFlowMonitorPrintIntervalMinutes(); 10 | } 11 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/netty/RemotingResponseCallback.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.remoting.netty; 2 | 3 | import org.aggregateframework.remoting.protocol.RemotingCommand; 4 | 5 | public interface RemotingResponseCallback { 6 | 7 | void callback(RemotingCommand response); 8 | } 9 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/remoting/netty/ServerAddressLoader.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.remoting.netty; 2 | 3 | import java.util.List; 4 | 5 | public interface ServerAddressLoader { 6 | String selectOneAvailableAddress(); 7 | 8 | List getAllAvailableAddresses(); 9 | 10 | boolean isAvailableAddress(String address); 11 | } 12 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/repository/AggregateRepository.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.repository; 2 | 3 | import org.aggregateframework.entity.AggregateRoot; 4 | 5 | import java.io.Serializable; 6 | import java.util.Collection; 7 | import java.util.List; 8 | 9 | /** 10 | * User: changming.xie 11 | * Date: 14-6-25 12 | * Time: 下午1:31 13 | */ 14 | public interface AggregateRepository, ID extends Serializable> extends CrudRepository { 15 | 16 | List save(Collection entities); 17 | 18 | List findAll(); 19 | 20 | List findAll(Collection ids); 21 | 22 | public void flush(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/repository/CrudRepository.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.repository; 2 | 3 | import java.io.Serializable; 4 | import java.util.Collection; 5 | 6 | /** 7 | * User: changming.xie 8 | * Date: 14-6-25 9 | * Time: 上午10:14 10 | */ 11 | public interface CrudRepository extends Repository { 12 | 13 | T save(T entity); 14 | 15 | Collection save(Collection entities); 16 | 17 | T findOne(ID id); 18 | 19 | boolean exists(ID id); 20 | 21 | Collection findAll(); 22 | 23 | Collection findAll(Collection ids); 24 | 25 | long count(); 26 | 27 | void delete(ID id); 28 | 29 | void delete(T entity); 30 | 31 | void delete(Collection entities); 32 | 33 | void deleteAll(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/repository/Repository.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.repository; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * User: changming.xie 7 | * Date: 14-6-25 8 | * Time: 上午10:12 9 | */ 10 | public interface Repository { 11 | } 12 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/repository/SaveAggregateCallback.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.repository; 2 | 3 | import java.util.Collection; 4 | 5 | /** 6 | * User: changming.xie 7 | * Date: 14-7-25 8 | * Time: 下午2:43 9 | */ 10 | public interface SaveAggregateCallback { 11 | public void save(final Collection aggregate); 12 | } 13 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/retry/Classifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2007 the original author or 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 org.aggregateframework.retry; 18 | 19 | 20 | public interface Classifier { 21 | 22 | T classify(C classifiable); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/retry/RecoveryCallback.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.retry; 2 | 3 | /** 4 | * Created by changming.xie on 2/2/16. 5 | */ 6 | public interface RecoveryCallback { 7 | 8 | T recover(RetryContext context); 9 | 10 | } -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/retry/RetryCallback.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.retry; 2 | 3 | /** 4 | * Created by changming.xie on 2/2/16. 5 | */ 6 | public interface RetryCallback { 7 | 8 | T doWithRetry(RetryContext context); 9 | } 10 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/retry/RetryContext.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.retry; 2 | 3 | /** 4 | * Created by changming.xie on 2/2/16. 5 | */ 6 | public interface RetryContext { 7 | 8 | int getRetryCount(); 9 | 10 | Throwable getLastThrowable(); 11 | 12 | public void registerThrowable(Throwable throwable); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/retry/RetryOperations.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.retry; 2 | 3 | /** 4 | * Created by changming.xie on 2/2/16. 5 | */ 6 | public interface RetryOperations { 7 | 8 | T execute(RetryContext context, RetryCallback retryCallback); 9 | 10 | T execute(RetryContext context, RetryCallback retryCallback, RecoveryCallback recoveryCallback); 11 | } 12 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/retry/RetryPolicy.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.retry; 2 | 3 | /** 4 | * Created by changming.xie on 2/2/16. 5 | */ 6 | public interface RetryPolicy { 7 | 8 | boolean canRetry(RetryContext context); 9 | 10 | void registerThrowable(RetryContext context, Throwable e); 11 | 12 | RetryContext requireRetryContext(); 13 | } 14 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/retry/SimpleRetryContext.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.retry; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | /** 6 | * Created by changming.xie on 2/2/16. 7 | */ 8 | public class SimpleRetryContext implements RetryContext { 9 | 10 | private volatile AtomicInteger count = new AtomicInteger(0); 11 | 12 | private volatile Throwable lastException; 13 | 14 | @Override 15 | public int getRetryCount() { 16 | return count.get(); 17 | } 18 | 19 | @Override 20 | public Throwable getLastThrowable() { 21 | return lastException; 22 | } 23 | 24 | @Override 25 | public void registerThrowable(Throwable throwable) { 26 | this.lastException = throwable; 27 | if (throwable != null) 28 | count.incrementAndGet(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/retry/backoff/BackOffContext.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.retry.backoff; 2 | 3 | /** 4 | * Created by changming.xie on 2/2/16. 5 | */ 6 | public interface BackOffContext { 7 | } 8 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/retry/backoff/BackOffPolicy.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.retry.backoff; 2 | 3 | import org.aggregateframework.retry.RetryContext; 4 | 5 | /** 6 | * Created by changming.xie on 2/2/16. 7 | */ 8 | 9 | public interface BackOffPolicy { 10 | 11 | BackOffContext start(RetryContext context); 12 | 13 | void backOff(BackOffContext backOffContext); 14 | 15 | } -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/retry/backoff/NoBackOffPolicy.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.retry.backoff; 2 | 3 | import org.aggregateframework.retry.RetryContext; 4 | 5 | /** 6 | * Created by changming.xie on 2/2/16. 7 | */ 8 | public class NoBackOffPolicy implements BackOffPolicy { 9 | 10 | 11 | @Override 12 | public BackOffContext start(RetryContext context) { 13 | return null; 14 | } 15 | 16 | @Override 17 | public void backOff(BackOffContext backOffContext) { 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/retry/backoff/Sleeper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2007 the original author or 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 org.aggregateframework.retry.backoff; 17 | 18 | /** 19 | * Created by changming.xie on 2/1/16. 20 | * part of the source code come from open source:spring-retry. 21 | *

22 | * Strategy interface for backoff policies to delegate the pausing of execution. 23 | */ 24 | public interface Sleeper { 25 | 26 | /** 27 | * Pause for the specified period using whatever means available. 28 | * 29 | * @param backOffPeriod 30 | */ 31 | void sleep(long backOffPeriod) throws InterruptedException; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/retry/backoff/SleepingBackOffPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2007 the original author or 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 org.aggregateframework.retry.backoff; 18 | 19 | /** 20 | * Created by changming.xie on 2/1/16. 21 | * part of the source code come from open source:spring-retry. 22 | */ 23 | public interface SleepingBackOffPolicy> extends BackOffPolicy { 24 | /** 25 | * Clone the policy and return a new policy which uses the passed sleeper. 26 | * 27 | * @param sleeper Target to be invoked any time the backoff policy sleeps 28 | * @return a clone of this policy which will have all of its backoff sleeps 29 | * routed into the passed sleeper 30 | */ 31 | T withSleeper(Sleeper sleeper); 32 | } 33 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/retry/backoff/ThreadWaitSleeper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or 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 org.aggregateframework.retry.backoff; 18 | 19 | /** 20 | * Created by changming.xie on 2/1/16. 21 | * part of the source code come from open source:spring-retry. 22 | */ 23 | public class ThreadWaitSleeper implements Sleeper { 24 | 25 | @Override 26 | public void sleep(long backOffPeriod) throws InterruptedException { 27 | Thread.sleep(backOffPeriod); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/serializer/JdkSerializationSerializer.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.serializer; 2 | 3 | import org.apache.commons.lang3.SerializationUtils; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by changming.xie on 7/22/16. 9 | */ 10 | public class JdkSerializationSerializer implements ObjectSerializer { 11 | 12 | @Override 13 | public byte[] serialize(T object) { 14 | return SerializationUtils.serialize(object); 15 | } 16 | 17 | @Override 18 | public T deserialize(byte[] bytes) { 19 | if (bytes == null) { 20 | return null; 21 | } else { 22 | return (T) SerializationUtils.deserialize(bytes); 23 | } 24 | } 25 | 26 | @Override 27 | public T clone(T object) { 28 | return SerializationUtils.clone(object); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/serializer/ObjectSerializer.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.serializer; 2 | 3 | /** 4 | * Created by changming.xie on 7/22/16. 5 | */ 6 | public interface ObjectSerializer { 7 | 8 | /** 9 | * Serialize the given object to binary data. 10 | * 11 | * @param t object to serialize 12 | * @return the equivalent binary data 13 | */ 14 | byte[] serialize(T t); 15 | 16 | /** 17 | * Deserialize an object from the given binary data. 18 | * 19 | * @param bytes object binary representation 20 | * @return the equivalent object instance 21 | */ 22 | T deserialize(byte[] bytes); 23 | 24 | 25 | T clone(T object); 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/session/AggregateContext.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.session; 2 | 3 | import org.aggregateframework.cache.IdentifiedEntityMap; 4 | 5 | /** 6 | * Created by changmingxie on 7/17/15. 7 | */ 8 | public class AggregateContext { 9 | 10 | private IdentifiedEntityMap entityMap = new IdentifiedEntityMap(); 11 | private boolean isAggregateChanged; 12 | 13 | public IdentifiedEntityMap getEntityMap() { 14 | return entityMap; 15 | } 16 | 17 | public boolean isAggregateChanged() { 18 | return isAggregateChanged; 19 | } 20 | 21 | public void setAggregateChanged(boolean isAggregateDirty) { 22 | this.isAggregateChanged = isAggregateDirty; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/session/SessionFactory.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.session; 2 | 3 | /** 4 | * User: changming.xie 5 | * Date: 14-7-29 6 | * Time: 下午4:58 7 | */ 8 | public interface SessionFactory { 9 | 10 | ClientSession requireClientSession(); 11 | 12 | void closeClientSession(); 13 | 14 | void registerNewClientSession(); 15 | 16 | boolean registerClientSessionIfAbsent(); 17 | 18 | boolean hasClientSessions(); 19 | 20 | int clientSessionCount(); 21 | } 22 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/session/UnitOfWork.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.session; 2 | 3 | import org.aggregateframework.entity.AggregateRoot; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * User: changming.xie 9 | * Date: 14-8-19 10 | * Time: 下午4:30 11 | */ 12 | public class UnitOfWork extends AbstractClientSession { 13 | 14 | @Override 15 | public , ID extends Serializable> void registerAggregate(AggregateEntry aggregateEntry) { 16 | currentAggregateQueue.add(aggregateEntry); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/storage/Page.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.storage; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Page { 7 | 8 | private String nextOffset; 9 | 10 | private List data = new ArrayList<>(); 11 | 12 | private Object attachment; 13 | 14 | public Page() { 15 | 16 | } 17 | 18 | public Page(String nextOffset, List data) { 19 | this.nextOffset = nextOffset; 20 | this.data.addAll(data); 21 | } 22 | 23 | public String getNextOffset() { 24 | return nextOffset; 25 | } 26 | 27 | public void setNextOffset(String nextOffset) { 28 | this.nextOffset = nextOffset; 29 | } 30 | 31 | public List getData() { 32 | return data; 33 | } 34 | 35 | public void setData(List data) { 36 | this.data.clear(); 37 | 38 | if (data != null) { 39 | this.data.addAll(data); 40 | } 41 | } 42 | 43 | public Object getAttachment() { 44 | return attachment; 45 | } 46 | 47 | public void setAttachment(Object attachment) { 48 | this.attachment = attachment; 49 | } 50 | } -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/storage/StorageRecoverable.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.storage; 2 | 3 | import org.aggregateframework.storage.domain.DomainStore; 4 | 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | public interface StorageRecoverable { 9 | 10 | Page findAllUnmodifiedSince(String domain, Date date, String offset, int pageSize); 11 | 12 | Page findAllDeletedSince(String domain, Date date, String offset, int pageSize); 13 | 14 | int count(String domain, boolean isMarkDeleted); 15 | 16 | void registerDomain(DomainStore domainStore); 17 | 18 | void updateDomain(DomainStore domainStore); 19 | 20 | void removeDomain(String domain); 21 | 22 | DomainStore findDomain(String domain); 23 | 24 | List getAllDomains(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/storage/StoreConfig.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.storage; 2 | 3 | import io.openmessaging.storage.dledger.proxy.DLedgerProxy; 4 | import org.aggregateframework.transaction.serializer.SerializerType; 5 | import redis.clients.jedis.JedisCluster; 6 | import redis.clients.jedis.JedisPool; 7 | import redis.clients.jedis.ShardedJedisPool; 8 | 9 | import javax.sql.DataSource; 10 | import java.util.Map; 11 | 12 | public interface StoreConfig { 13 | 14 | StorageType getStorageType(); 15 | 16 | String getDomain(); 17 | 18 | String getTransactionStorageClass(); 19 | 20 | long getRequestTimeoutMillis(); 21 | 22 | String getLocation(); 23 | 24 | JedisPool getJedisPool(); 25 | 26 | ShardedJedisPool getShardedJedisPool(); 27 | 28 | JedisCluster getJedisCluster(); 29 | 30 | DLedgerProxy getDLedgerProxy(); 31 | 32 | String getRemoteCluster(); 33 | 34 | String getTbSuffix(); 35 | 36 | DataSource getDataSource(); 37 | 38 | SerializerType getSerializerType(); 39 | 40 | String getTransactionSerializerClassName(); 41 | 42 | int getKryoPoolSize(); 43 | 44 | int getMaxTransactionSize(); 45 | 46 | int getMaxAttempts(); 47 | 48 | Map getCustomStorageProperties(); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/storage/TransactionIOException.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.storage; 2 | 3 | /** 4 | * Created by hongyuan.wang on 2016/1/26. 5 | */ 6 | public class TransactionIOException extends RuntimeException { 7 | 8 | private static final long serialVersionUID = 6508064607297986329L; 9 | 10 | public TransactionIOException(String message) { 11 | super(message); 12 | } 13 | 14 | public TransactionIOException(Throwable e) { 15 | super(e); 16 | } 17 | 18 | public TransactionIOException() { 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/storage/TransactionOptimisticLockException.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.storage; 2 | 3 | /** 4 | * Created by changming.xie on 7/21/16. 5 | */ 6 | public class TransactionOptimisticLockException extends TransactionIOException { 7 | 8 | public TransactionOptimisticLockException() { 9 | } 10 | 11 | public TransactionOptimisticLockException(String message) { 12 | super(message); 13 | } 14 | 15 | public TransactionOptimisticLockException(Throwable e) { 16 | super(e); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/storage/TransactionStorage.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.storage; 2 | 3 | import org.aggregateframework.xid.Xid; 4 | 5 | import java.io.Closeable; 6 | 7 | /** 8 | * Created by changmingxie on 11/12/15. 9 | */ 10 | public interface TransactionStorage extends Closeable { 11 | 12 | int create(TransactionStore transactionStore); 13 | 14 | int update(TransactionStore transactionStore); 15 | 16 | int delete(TransactionStore transactionStore); 17 | 18 | TransactionStore findByXid(String domain, Xid xid); 19 | 20 | TransactionStore findMarkDeletedByXid(String domain, Xid xid); 21 | 22 | int markDeleted(TransactionStore transactionStore); 23 | 24 | int restore(TransactionStore transactionStore); 25 | 26 | // completely delete for mark deleted transaction 27 | int completelyDelete(TransactionStore transactionStore); 28 | 29 | boolean supportStorageRecoverable(); 30 | 31 | @Override 32 | default void close() { 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/storage/domain/AlertType.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.storage.domain; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * @Author huabao.fang 8 | * @Date 2022/6/13 22:54 9 | **/ 10 | public enum AlertType { 11 | 12 | // 钉钉告警 13 | DING, 14 | // 短信告警 15 | SMS, 16 | // 电话告警 17 | PHONE; 18 | 19 | private static Map alertTypeMap = new HashMap<>(3); 20 | 21 | static { 22 | for (AlertType alertType : AlertType.values()) { 23 | alertTypeMap.put(alertType.name(), alertType); 24 | } 25 | } 26 | 27 | public static AlertType nameOf(String name) { 28 | return alertTypeMap.get(name); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/storage/helper/ShardHolder.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.storage.helper; 2 | 3 | import java.io.Closeable; 4 | import java.util.List; 5 | 6 | public interface ShardHolder extends Closeable { 7 | List getAllShards(); 8 | } 9 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/support/BeanFactory.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.support; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Created by changmingxie on 11/20/15. 7 | */ 8 | public interface BeanFactory { 9 | 10 | T getBean(Class clazz); 11 | 12 | boolean isFactoryOf(Class clazz); 13 | 14 | Map getBeansOfType(Class clazz); 15 | 16 | Class getTargetClass(Object target); 17 | } 18 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/threadcontext/EmptyThreadContextSynchronization.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.threadcontext; 2 | 3 | public class EmptyThreadContextSynchronization implements ThreadContextSynchronization { 4 | 5 | @Override 6 | public String getCurrentThreadContext() { 7 | return null; 8 | } 9 | 10 | @Override 11 | public void setThreadContext(String threadContext) { 12 | 13 | } 14 | 15 | @Override 16 | public void clear() { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/threadcontext/ThreadContextSynchronization.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.threadcontext; 2 | 3 | public interface ThreadContextSynchronization { 4 | 5 | public String getCurrentThreadContext(); 6 | 7 | public void setThreadContext(String threadContext); 8 | 9 | public void clear(); 10 | } 11 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/transaction/LocalTransactionExecutor.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.transaction; 2 | 3 | import org.aggregateframework.domainevent.EventMessage; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by changming.xie on 12/20/17. 9 | */ 10 | public interface LocalTransactionExecutor { 11 | 12 | public LocalTransactionState executeLocalTransactionBranch(List events); 13 | } 14 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/transaction/LocalTransactionState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.aggregateframework.transaction; 18 | 19 | public enum LocalTransactionState { 20 | COMMIT_MESSAGE, 21 | ROLLBACK_MESSAGE, 22 | UNKNOW, 23 | } 24 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/transaction/Participant.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.transaction; 2 | 3 | import org.aggregateframework.xid.TransactionXid; 4 | 5 | /** 6 | * Created by changming.xie on 8/23/17. 7 | */ 8 | public class Participant { 9 | 10 | private static final long serialVersionUID = 2869353273179002268L; 11 | 12 | private TransactionXid xid; 13 | 14 | private Invocation invocation; 15 | 16 | public Participant(Invocation invocation) { 17 | this.xid = new TransactionXid(); 18 | this.invocation = invocation; 19 | } 20 | 21 | public Participant getParent() { 22 | return null; 23 | } 24 | 25 | public void proceed() { 26 | this.invocation.proceed(); 27 | } 28 | 29 | public TransactionXid getXid() { 30 | return xid; 31 | } 32 | 33 | public void setXid(TransactionXid xid) { 34 | this.xid = xid; 35 | } 36 | 37 | public Invocation getInvocation() { 38 | return invocation; 39 | } 40 | 41 | public void setInvocation(Invocation invocation) { 42 | this.invocation = invocation; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/transaction/repository/TransactionRepository.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.transaction.repository; 2 | 3 | import org.aggregateframework.transaction.Transaction; 4 | import org.aggregateframework.storage.Page; 5 | import org.aggregateframework.xid.Xid; 6 | 7 | import java.io.Closeable; 8 | import java.util.Date; 9 | 10 | /** 11 | * Created by changmingxie on 11/12/15. 12 | */ 13 | public interface TransactionRepository extends Closeable { 14 | 15 | String getDomain(); 16 | 17 | int create(Transaction transaction); 18 | 19 | int update(Transaction transaction); 20 | 21 | int delete(Transaction transaction); 22 | 23 | Transaction findByXid(Xid xid); 24 | 25 | boolean supportRecovery(); 26 | 27 | Page findAllUnmodifiedSince(Date date, String offset, int pageSize); 28 | 29 | @Override 30 | default void close() { 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/transaction/serializer/RemotingCommandSerializer.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.transaction.serializer; 2 | 3 | 4 | import org.aggregateframework.remoting.protocol.RemotingCommand; 5 | import org.aggregateframework.serializer.ObjectSerializer; 6 | 7 | public interface RemotingCommandSerializer extends ObjectSerializer { 8 | } 9 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/transaction/serializer/SerializerType.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.transaction.serializer; 2 | 3 | /** 4 | * @author Nervose.Wu 5 | * @date 2022/6/21 16:16 6 | */ 7 | public enum SerializerType { 8 | KRYO, 9 | FASTJSON, 10 | CUSTOMIZED, 11 | ; 12 | } -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/transaction/serializer/TransactionSerializer.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.transaction.serializer; 2 | 3 | 4 | import org.aggregateframework.serializer.ObjectSerializer; 5 | import org.aggregateframework.transaction.Transaction; 6 | 7 | /** 8 | * Created by changming.xie on 09/12/19. 9 | */ 10 | public interface TransactionSerializer extends ObjectSerializer { 11 | } 12 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/transaction/serializer/TransactionStoreSerializer.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.transaction.serializer; 2 | 3 | import org.aggregateframework.serializer.ObjectSerializer; 4 | import org.aggregateframework.storage.TransactionStore; 5 | 6 | public interface TransactionStoreSerializer extends ObjectSerializer { 7 | } -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/transaction/serializer/kryo/KryoTransactionSerializer.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.transaction.serializer.kryo; 2 | 3 | 4 | import org.aggregateframework.serializer.KryoPoolSerializer; 5 | import org.aggregateframework.transaction.Transaction; 6 | import org.aggregateframework.transaction.serializer.TransactionSerializer; 7 | 8 | /** 9 | * Created by changming.xie on 9/18/17. 10 | */ 11 | public class KryoTransactionSerializer extends KryoPoolSerializer implements TransactionSerializer { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/utils/AggDateFormatUtils.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.utils; 2 | 3 | import org.apache.commons.lang3.time.DateFormatUtils; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @Author huabao.fang 9 | * @Date 2022/6/15 15:45 10 | **/ 11 | public class AggDateFormatUtils { 12 | 13 | private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; 14 | 15 | private AggDateFormatUtils(){ 16 | } 17 | 18 | public static String formatDate(Date date) { 19 | if (date == null) { 20 | return null; 21 | } 22 | return DateFormatUtils.format(date, DATE_FORMAT); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/utils/Assert.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.utils; 2 | 3 | import org.aggregateframework.exception.SystemException; 4 | 5 | /** 6 | * @author changming.xie 7 | */ 8 | public class Assert { 9 | public static void notNull(Object object, String message) { 10 | 11 | if (object == null) { 12 | throw new SystemException(message); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/utils/ByteUtils.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.utils; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | /** 6 | * Created by changming.xie on 2/14/16. 7 | */ 8 | public class ByteUtils { 9 | 10 | public static final byte[] TRUE; 11 | public static final byte[] FALSE; 12 | 13 | static { 14 | TRUE = bool2bytes(true); 15 | FALSE = bool2bytes(false); 16 | } 17 | 18 | 19 | public static byte[] longToBytes(long num) { 20 | return String.valueOf(num).getBytes(); 21 | } 22 | 23 | public static long bytesToLong(byte[] bytes) { 24 | return Long.valueOf(new String(bytes)); 25 | } 26 | 27 | public static byte[] intToBytes(int num) { 28 | return String.valueOf(num).getBytes(); 29 | } 30 | 31 | public static int bytesToInt(byte[] bytes) { 32 | return Integer.valueOf(new String(bytes)); 33 | } 34 | 35 | /** 36 | * @param i boolean 37 | * @return byte[] 38 | */ 39 | public static byte[] bool2bytes(boolean i) { 40 | ByteBuffer allocate = ByteBuffer.allocate(4); 41 | allocate.putInt(i ? 1 : 0); 42 | return allocate.array(); 43 | } 44 | 45 | public static boolean bytes2bool(byte[] bytes) { 46 | ByteBuffer allocate = ByteBuffer.wrap(bytes); 47 | return allocate.getInt() != 0; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/utils/StopUtils.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.utils; 2 | 3 | /** 4 | * @author Nervose.Wu 5 | * @date 2022/7/7 16:39 6 | */ 7 | public class StopUtils { 8 | 9 | private StopUtils() { 10 | } 11 | 12 | /** 13 | * call exit in a new thread to avoid potential dead lock 14 | */ 15 | public static void stop() { 16 | new Thread(() -> System.exit(1)).start(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/xid/UUIDGenerator.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.xid; 2 | 3 | public interface UUIDGenerator { 4 | String generate(); 5 | } 6 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/java/org/aggregateframework/xid/Xid.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.xid; 2 | 3 | public interface Xid { 4 | int AUTO = 1; 5 | int CUSTOMIZED = 2; 6 | 7 | int getFormatId(); 8 | 9 | String getXid(); 10 | } 11 | -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/resources/META-INF/services/org.aggregateframework.discovery.loadbalance.LoadBalanceProvider: -------------------------------------------------------------------------------- 1 | org.aggregateframework.discovery.loadbalance.RandomLoadBalanceProvider 2 | org.aggregateframework.discovery.loadbalance.RoundRobinLoadBalanceProvider -------------------------------------------------------------------------------- /aggregate-framework-core/src/main/resources/META-INF/services/org.aggregateframework.discovery.registry.RegistryProvider: -------------------------------------------------------------------------------- 1 | org.aggregateframework.discovery.registry.nacos.NacosRegistryServiceProvider 2 | org.aggregateframework.discovery.registry.zookeeper.ZookeeperRegistryProvider 3 | org.aggregateframework.discovery.registry.direct.DirectRegistryProvider 4 | org.aggregateframework.discovery.registry.custom.CustomRegistryProvider -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/java/org/aggregateframework/dashboard/AggregateFrameworkDashboardApplication.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard; 2 | 3 | import org.aggregateframework.dashboard.constants.DashboardConstant; 4 | import org.aggregateframework.ribbon.AggFeignClientConfig; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 8 | import org.springframework.cloud.netflix.ribbon.RibbonClient; 9 | import org.springframework.cloud.netflix.ribbon.RibbonClients; 10 | import org.springframework.cloud.openfeign.EnableFeignClients; 11 | 12 | /** 13 | * Created by Lee on 2020/4/8 12:56. 14 | */ 15 | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) 16 | @EnableFeignClients 17 | @RibbonClients(value = {@RibbonClient(name = DashboardConstant.AGG_SERVER_GROUP, configuration = AggFeignClientConfig.class)}) 18 | public class AggregateFrameworkDashboardApplication { 19 | 20 | public static void main(String[] args) { 21 | SpringApplication.run(AggregateFrameworkDashboardApplication.class, args); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/java/org/aggregateframework/dashboard/config/DashboardConfig.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.client.RestTemplate; 8 | 9 | /** 10 | * @Author huabao.fang 11 | * @Date 2022/6/12 00:46 12 | **/ 13 | @EnableConfigurationProperties 14 | @Configuration 15 | public class DashboardConfig { 16 | 17 | @Bean 18 | @ConfigurationProperties("spring.agg.dashboard") 19 | public DashboardProperties dashboardProperties() { 20 | return new DashboardProperties(); 21 | } 22 | 23 | @Bean 24 | public RestTemplate restTemplate() { 25 | return new RestTemplate(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/java/org/aggregateframework/dashboard/config/DashboardProperties.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.config; 2 | 3 | 4 | import org.aggregateframework.dashboard.enums.ConnectionMode; 5 | import org.aggregateframework.properties.registry.RegistryProperties; 6 | 7 | /** 8 | * @Author huabao.fang 9 | * @Date 2022/6/12 00:32 10 | **/ 11 | public class DashboardProperties { 12 | private String userName = "admin"; 13 | private String password = "123456"; 14 | private ConnectionMode connectionMode; 15 | 16 | public DashboardProperties() { 17 | } 18 | 19 | public String getUserName() { 20 | return userName; 21 | } 22 | 23 | public void setUserName(String userName) { 24 | this.userName = userName; 25 | } 26 | 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | 35 | public ConnectionMode getConnectionMode() { 36 | return connectionMode; 37 | } 38 | 39 | public void setConnectionMode(ConnectionMode connectionMode) { 40 | this.connectionMode = connectionMode; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/java/org/aggregateframework/dashboard/constants/DashboardConstant.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.constants; 2 | 3 | /** 4 | * @Author huabao.fang 5 | * @Date 2022/6/7 10:07 6 | **/ 7 | public interface DashboardConstant { 8 | 9 | // security 10 | String SECURITY_JWT_PREFIX = "Bearer "; 11 | String SECURITY_HEADER_AUTHORIZATION = "Authorization"; 12 | 13 | String AGG_SERVER_GROUP = "aggregate-framework-server"; 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/java/org/aggregateframework/dashboard/enums/ConnectionMode.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.enums; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * @Author huabao.fang 8 | * @Date 2022/6/9 20:52 9 | * 存储链接模式 10 | **/ 11 | public enum ConnectionMode { 12 | EMBEDDED,// 嵌入模式 13 | SERVER // server模式 14 | ; 15 | 16 | private static Map connectionModeMap = new HashMap<>(); 17 | 18 | static { 19 | for (ConnectionMode connectionMode : ConnectionMode.values()) { 20 | connectionModeMap.put(connectionMode.name(), connectionMode); 21 | } 22 | } 23 | 24 | public static ConnectionMode nameOf(String connectionModeName) { 25 | return connectionModeMap.get(connectionModeName); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/java/org/aggregateframework/dashboard/model/LoginDto.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.model; 2 | 3 | /** 4 | * @Author huabao.fang 5 | * @Date 2022/6/6 18:40 6 | **/ 7 | public class LoginDto { 8 | 9 | private String username; 10 | 11 | private String password; 12 | 13 | public String getUsername() { 14 | return username; 15 | } 16 | 17 | public void setUsername(String username) { 18 | this.username = username; 19 | } 20 | 21 | public String getPassword() { 22 | return password; 23 | } 24 | 25 | public void setPassword(String password) { 26 | this.password = password; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/java/org/aggregateframework/dashboard/security/AggAccessDeniedHandler.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.security; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.security.access.AccessDeniedException; 6 | import org.springframework.security.web.access.AccessDeniedHandler; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | /** 14 | * @Author huabao.fang 15 | * @Date 2022/6/8 11:49 16 | **/ 17 | public class AggAccessDeniedHandler implements AccessDeniedHandler { 18 | private Logger logger = LoggerFactory.getLogger(AggAccessDeniedHandler.class); 19 | 20 | @Override 21 | public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { 22 | logger.error("Responding with unauthorized error. Message:{}, url:{}", accessDeniedException.getMessage(), request.getRequestURI()); 23 | response.sendError(HttpServletResponse.SC_FORBIDDEN, "FORBIDDEN"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/java/org/aggregateframework/dashboard/security/AggAuthenticationEntryPoint.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.security; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.security.core.AuthenticationException; 6 | import org.springframework.security.web.AuthenticationEntryPoint; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | /** 14 | * @Author huabao.fang 15 | * @Date 2022/6/8 10:38 16 | **/ 17 | public class AggAuthenticationEntryPoint implements AuthenticationEntryPoint { 18 | 19 | private Logger logger = LoggerFactory.getLogger(AggAuthenticationEntryPoint.class); 20 | 21 | @Override 22 | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { 23 | logger.error("Responding with unauthorized error. Message:{}, url:{}", authException.getMessage(), request.getRequestURI()); 24 | response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/java/org/aggregateframework/dashboard/service/condition/AggServerStorageCondition.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.service.condition; 2 | 3 | import org.aggregateframework.dashboard.enums.ConnectionMode; 4 | import org.springframework.util.StringUtils; 5 | 6 | /** 7 | * @Author huabao.fang 8 | * @Date 2022/5/30 11:56 9 | **/ 10 | public class AggServerStorageCondition extends BaseStorageCondition { 11 | @Override 12 | boolean match(String connectionModeValue, String storageTypeVaule) { 13 | 14 | if (connectionModeValue.equalsIgnoreCase(ConnectionMode.SERVER.name())) { 15 | if (!StringUtils.isEmpty(storageTypeVaule)) { 16 | throw new IllegalArgumentException("storageType must null, when connectionMode is " + ConnectionMode.SERVER.name()); 17 | } 18 | return true; 19 | } 20 | 21 | return false; 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/java/org/aggregateframework/dashboard/service/impl/local/LocalDomainServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.service.impl.local; 2 | 3 | 4 | import org.aggregateframework.AggClient; 5 | import org.aggregateframework.dashboard.service.condition.LocalStorageCondition; 6 | import org.aggregateframework.dashboard.service.impl.BaseDomainServiceImpl; 7 | import org.aggregateframework.storage.TransactionStorage; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.context.annotation.Conditional; 10 | import org.springframework.stereotype.Service; 11 | 12 | /** 13 | * @Author huabao.fang 14 | * @Date 2022/6/9 17:03 15 | **/ 16 | @Conditional(LocalStorageCondition.class) 17 | @Service 18 | public class LocalDomainServiceImpl extends BaseDomainServiceImpl { 19 | 20 | @Autowired 21 | private AggClient aggClient; 22 | 23 | @Override 24 | public TransactionStorage getTransactionStorage() { 25 | return aggClient.getTransactionStorage(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/java/org/aggregateframework/dashboard/service/impl/local/LocalTaskServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.service.impl.local; 2 | 3 | 4 | import org.aggregateframework.dashboard.service.condition.LocalStorageCondition; 5 | import org.aggregateframework.dashboard.service.impl.BaseTaskServiceImpl; 6 | import org.springframework.context.annotation.Conditional; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @Author huabao.fang 11 | * @Date 2022/6/9 17:03 12 | **/ 13 | @Conditional(LocalStorageCondition.class) 14 | @Service 15 | public class LocalTaskServiceImpl extends BaseTaskServiceImpl { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/java/org/aggregateframework/dashboard/service/impl/local/LocalTransactionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.dashboard.service.impl.local; 2 | 3 | 4 | import org.aggregateframework.AggClient; 5 | import org.aggregateframework.dashboard.service.condition.LocalStorageCondition; 6 | import org.aggregateframework.dashboard.service.impl.BaseTransactionServiceImpl; 7 | import org.aggregateframework.storage.TransactionStorage; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.context.annotation.Conditional; 10 | import org.springframework.stereotype.Service; 11 | 12 | /** 13 | * @Author huabao.fang 14 | * @Date 2022/6/9 16:27 15 | **/ 16 | @Conditional(LocalStorageCondition.class) 17 | @Service 18 | public class LocalTransactionServiceImpl extends BaseTransactionServiceImpl { 19 | 20 | @Autowired 21 | private AggClient aggClient; 22 | 23 | @Override 24 | public TransactionStorage getTransactionStorage() { 25 | return aggClient.getTransactionStorage(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/java/org/aggregateframework/ribbon/AggFeignClientConfig.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.ribbon; 2 | 3 | import com.netflix.loadbalancer.Server; 4 | import com.netflix.loadbalancer.ServerList; 5 | import org.aggregateframework.AggClient; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | /** 11 | * @author Nervose.Wu 12 | * @date 2023/2/8 16:48 13 | */ 14 | @Configuration 15 | public class AggFeignClientConfig { 16 | 17 | @Autowired 18 | private AggClient aggClient; 19 | 20 | @Bean 21 | ServerList aggServerList(AggClient aggClient) { 22 | return new AggServerList<>(aggClient.getRegistryService()); 23 | } 24 | } -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/resources/application-server.yaml: -------------------------------------------------------------------------------- 1 | # dashbaord aggserver模式专项配置 2 | server: 3 | servlet: 4 | context-path: /aggregate-framework-dashboard 5 | port: 22332 6 | 7 | logging: 8 | level: 9 | root: info 10 | spring: 11 | application: 12 | name: aggregate-framework-dashboard 13 | resources: 14 | static-locations: classpath:templates/ 15 | chain: 16 | cache: false 17 | freemarker: 18 | enabled: true 19 | cache: false 20 | charset: UTF-8 21 | suffix: .html 22 | check-template-location: true 23 | template-loader-path: classpath:/templates/ 24 | agg: 25 | dashboard: 26 | userName: admin 27 | password: 123456 28 | connection-mode: server 29 | registry: 30 | registry-type: direct # 切换agg-server注册中心 31 | registry-role: dashboard 32 | direct: 33 | addresses-for-dashboard: localhost:12332 34 | nacos: 35 | server-addr: localhost:8848 36 | zookeeper: 37 | connect-string: localhost:2181 38 | feign: 39 | path: /aggregate-framework-server -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/resources/templates/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changmingxie/aggregate-framework/9e6cc6fec81dc927145e87fcc0a28b9c77b9f51a/aggregate-framework-dashboard/src/main/resources/templates/favicon.ico -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/resources/templates/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changmingxie/aggregate-framework/9e6cc6fec81dc927145e87fcc0a28b9c77b9f51a/aggregate-framework-dashboard/src/main/resources/templates/logo192.png -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/resources/templates/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changmingxie/aggregate-framework/9e6cc6fec81dc927145e87fcc0a28b9c77b9f51a/aggregate-framework-dashboard/src/main/resources/templates/logo512.png -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/resources/templates/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/resources/templates/precache-manifest.2707a861fce65e0ea4a57437e31cd76c.js: -------------------------------------------------------------------------------- 1 | self.__precacheManifest = (self.__precacheManifest || []).concat([ 2 | { 3 | "revision": "d3df90d57c6eecb456383330ea8d28ce", 4 | "url": "/aggregate-framework-dashboard/index.html" 5 | }, 6 | { 7 | "revision": "ef9868135a98c2f2af39", 8 | "url": "/aggregate-framework-dashboard/static/css/2.4f57d18e.chunk.css" 9 | }, 10 | { 11 | "revision": "82936d2f17b835cc79fd", 12 | "url": "/aggregate-framework-dashboard/static/css/main.013a3909.chunk.css" 13 | }, 14 | { 15 | "revision": "ef9868135a98c2f2af39", 16 | "url": "/aggregate-framework-dashboard/static/js/2.ed2ac97b.chunk.js" 17 | }, 18 | { 19 | "revision": "c87e50d81cc7b5311525cc6fd5482ea5", 20 | "url": "/aggregate-framework-dashboard/static/js/2.ed2ac97b.chunk.js.LICENSE.txt" 21 | }, 22 | { 23 | "revision": "82936d2f17b835cc79fd", 24 | "url": "/aggregate-framework-dashboard/static/js/main.7496146c.chunk.js" 25 | }, 26 | { 27 | "revision": "61e5459726f9f138dc5a", 28 | "url": "/aggregate-framework-dashboard/static/js/runtime-main.f35c6c1a.js" 29 | } 30 | ]); -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/resources/templates/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/resources/templates/static/css/main.013a3909.chunk.css: -------------------------------------------------------------------------------- 1 | body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}code{font-family:source-code-pro,Menlo,Monaco,Consolas,"Courier New",monospace}.search-box{display:-webkit-flex;display:flex;-webkit-flex-direction:row;flex-direction:row}.search-box .ant-btn{margin-left:8px}.site-layout-content{padding:12px;overflow:scroll;max-height:48rem}.tab-3-body{background-color:#fff;padding:20px 24px 1px}.tab-3-row{padding:6px}.tab-3-switch-label{padding-left:12px}#root,.layout{height:100%}.login-container{min-height:100%;width:100%;background-color:#2d3a4b;overflow:hidden} 2 | /*# sourceMappingURL=main.013a3909.chunk.css.map */ -------------------------------------------------------------------------------- /aggregate-framework-dashboard/src/main/resources/templates/static/js/2.ed2ac97b.chunk.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | object-assign 3 | (c) Sindre Sorhus 4 | @license MIT 5 | */ 6 | 7 | /*! 8 | Copyright (c) 2018 Jed Watson. 9 | Licensed under the MIT License (MIT), see 10 | http://jedwatson.github.io/classnames 11 | */ 12 | 13 | /** @license React v0.19.1 14 | * scheduler.production.min.js 15 | * 16 | * Copyright (c) Facebook, Inc. and its affiliates. 17 | * 18 | * This source code is licensed under the MIT license found in the 19 | * LICENSE file in the root directory of this source tree. 20 | */ 21 | 22 | /** @license React v16.13.1 23 | * react-is.production.min.js 24 | * 25 | * Copyright (c) Facebook, Inc. and its affiliates. 26 | * 27 | * This source code is licensed under the MIT license found in the 28 | * LICENSE file in the root directory of this source tree. 29 | */ 30 | 31 | /** @license React v16.14.0 32 | * react-dom.production.min.js 33 | * 34 | * Copyright (c) Facebook, Inc. and its affiliates. 35 | * 36 | * This source code is licensed under the MIT license found in the 37 | * LICENSE file in the root directory of this source tree. 38 | */ 39 | 40 | /** @license React v16.14.0 41 | * react.production.min.js 42 | * 43 | * Copyright (c) Facebook, Inc. and its affiliates. 44 | * 45 | * This source code is licensed under the MIT license found in the 46 | * LICENSE file in the root directory of this source tree. 47 | */ 48 | -------------------------------------------------------------------------------- /aggregate-framework-distribution/dashboard/bin/shutdown.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if not exist "%JAVA_HOME%\bin\jps.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better! & EXIT /B 1 4 | 5 | setlocal 6 | 7 | set "PATH=%JAVA_HOME%\bin;%PATH%" 8 | 9 | echo killing aggregate-framework-dashboard 10 | 11 | for /f "tokens=1" %%i in ('jps -m ^| find "agg.dashboard"') do ( taskkill /F /PID %%i ) 12 | 13 | echo Done! 14 | -------------------------------------------------------------------------------- /aggregate-framework-distribution/dashboard/bin/shutdown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd `dirname $0`/../lib 4 | target_dir=`pwd` 5 | 6 | pid=`ps ax | grep -i 'agg.dashboard' | grep ${target_dir} | grep java | grep -v grep | awk '{print $1}'` 7 | if [ -z "$pid" ] ; then 8 | echo "No aggregate-framework-dashboard running." 9 | exit -1; 10 | fi 11 | 12 | echo "The aggregate-framework-dashboard(${pid}) is running..." 13 | 14 | kill ${pid} 15 | 16 | echo "Send shutdown request to aggregate-framework-dashboard(${pid}) OK" 17 | -------------------------------------------------------------------------------- /aggregate-framework-distribution/release-dashboard.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | dashboard-${project.version} 5 | false 6 | 7 | dir 8 | tar.gz 9 | zip 10 | 11 | 12 | 13 | dashboard/conf 14 | conf 15 | 16 | 17 | 18 | dashboard/bin 19 | bin 20 | 0755 21 | 22 | 23 | 24 | 25 | ../aggregate-framework-dashboard/target/classes/application.yaml 26 | conf 27 | 28 | 29 | ../aggregate-framework-dashboard/target/aggregate-framework-dashboard-exec.jar 30 | lib 31 | aggregate-framework-dashboard.jar 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /aggregate-framework-distribution/release-server.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | server-${project.version} 5 | false 6 | 7 | dir 8 | tar.gz 9 | zip 10 | 11 | 12 | 13 | server/conf 14 | conf 15 | 16 | 17 | 18 | server/bin 19 | bin 20 | 0755 21 | 22 | 23 | 24 | 25 | ../aggregate-framework-server/target/classes/application.yaml 26 | conf 27 | 28 | 29 | ../aggregate-framework-server/target/aggregate-framework-server-exec.jar 30 | lib 31 | aggregate-framework-server.jar 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /aggregate-framework-distribution/server/bin/shutdown.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if not exist "%JAVA_HOME%\bin\jps.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better! & EXIT /B 1 4 | 5 | setlocal 6 | 7 | set "PATH=%JAVA_HOME%\bin;%PATH%" 8 | 9 | echo killing aggregate-framework-server 10 | 11 | for /f "tokens=1" %%i in ('jps -m ^| find "agg.server"') do ( taskkill /F /PID %%i ) 12 | 13 | echo Done! 14 | -------------------------------------------------------------------------------- /aggregate-framework-distribution/server/bin/shutdown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd `dirname $0`/../lib 4 | target_dir=`pwd` 5 | 6 | pid=`ps ax | grep -i 'agg.server' | grep ${target_dir} | grep java | grep -v grep | awk '{print $1}'` 7 | if [ -z "$pid" ] ; then 8 | echo "No aggregate-framework-server running." 9 | exit -1; 10 | fi 11 | 12 | echo "The aggregate-framework-server(${pid}) is running..." 13 | 14 | kill ${pid} 15 | 16 | echo "Send shutdown request to aggregate-framework-server(${pid}) OK" 17 | -------------------------------------------------------------------------------- /aggregate-framework-server/src/main/java/org/aggregateframework/server/AggregateFrameworkServerApplication.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.server; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; 6 | import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration; 7 | 8 | @SpringBootApplication(exclude = {QuartzAutoConfiguration.class, 9 | DataSourceTransactionManagerAutoConfiguration.class}) 10 | public class AggregateFrameworkServerApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(AggregateFrameworkServerApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /aggregate-framework-server/src/main/java/org/aggregateframework/server/controller/RecoveryController.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.server.controller; 2 | 3 | import org.aggregateframework.AggServer; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | @RestController 11 | @RequestMapping("recover") 12 | public class RecoveryController { 13 | 14 | @Autowired 15 | private AggServer aggServer; 16 | 17 | @RequestMapping("/start/{domain}") 18 | @ResponseBody 19 | public String startRecover(@PathVariable("domain") String domain) { 20 | aggServer.getTransactionStoreRecovery().startRecover(domain); 21 | return "triggered"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /aggregate-framework-server/src/main/java/org/aggregateframework/server/service/DomainServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.server.service; 2 | 3 | import org.aggregateframework.AggServer; 4 | import org.aggregateframework.dashboard.service.impl.BaseDomainServiceImpl; 5 | import org.aggregateframework.storage.TransactionStorage; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @Author huabao.fang 11 | * @Date 2022/6/14 12:18 12 | **/ 13 | @Service 14 | public class DomainServiceImpl extends BaseDomainServiceImpl { 15 | 16 | @Autowired 17 | private AggServer aggServer; 18 | 19 | 20 | @Override 21 | public TransactionStorage getTransactionStorage() { 22 | return aggServer.getTransactionStorage(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /aggregate-framework-server/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 12332 3 | servlet: 4 | context-path: /${spring.application.name} 5 | spring: 6 | application: 7 | name: aggregate-framework-server 8 | datasource: 9 | url: jdbc:h2:mem:quartz;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MySQL 10 | username: root 11 | password: welcome1 12 | driver-class-name: org.h2.Driver 13 | schema: classpath:schema.sql 14 | h2: 15 | console: 16 | enabled: true 17 | path: /h2 18 | agg: 19 | storage: 20 | storage-type: redis 21 | redis: 22 | host: 127.0.0.1 23 | port: 6379 24 | database: 0 25 | pool-config: 26 | max-total: 100 27 | max-idle: 100 28 | min-idle: 10 29 | max-wait-millis: 300 30 | recovery: 31 | quartz-clustered: true 32 | quartz-data-source-url: jdbc:h2:mem:quartz 33 | quartz-data-source-driver: org.h2.Driver 34 | quartz-data-source-user: root 35 | quartz-data-source-password: welcome1 36 | registry: 37 | registry-type: direct 38 | cluster-name: default 39 | remoting: 40 | listen-port: 2332 41 | logging: 42 | level: 43 | root: info -------------------------------------------------------------------------------- /aggregate-framework-spring-boot-starter/src/main/java/org/aggregateframework/spring/AggFrameworkConfigurationFilter.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.spring; 2 | 3 | import org.springframework.boot.autoconfigure.AutoConfigurationImportFilter; 4 | import org.springframework.boot.autoconfigure.AutoConfigurationMetadata; 5 | 6 | import java.util.Collections; 7 | import java.util.HashSet; 8 | import java.util.Set; 9 | 10 | /** 11 | * @author Nervose.Wu 12 | * @date 2022/7/6 14:04 13 | */ 14 | public class AggFrameworkConfigurationFilter implements AutoConfigurationImportFilter { 15 | 16 | @Override 17 | public boolean[] match(String[] classes, AutoConfigurationMetadata autoConfigurationMetadata) { 18 | Set skips = getSkips(); 19 | boolean[] matches = new boolean[classes.length]; 20 | for (int i = 0; i < classes.length; i++) { 21 | matches[i] = !skips.contains(classes[i]); 22 | } 23 | return matches; 24 | } 25 | 26 | private Set getSkips() { 27 | Set classes = new HashSet<>(); 28 | classes.add("org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration"); 29 | return Collections.unmodifiableSet(classes); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /aggregate-framework-spring-boot-starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | org.aggregateframework.spring.AggFrameworkAutoConfiguration 3 | org.springframework.boot.autoconfigure.AutoConfigurationImportFilter=\ 4 | org.aggregateframework.spring.AggFrameworkConfigurationFilter -------------------------------------------------------------------------------- /aggregate-framework-spring/src/main/java/org/aggregateframework/spring/annotation/EnableSpringIntegration.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.spring.annotation; 2 | 3 | import org.springframework.context.annotation.Import; 4 | 5 | import java.lang.annotation.*; 6 | 7 | @Target(ElementType.TYPE) 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Documented 10 | @Import(SpringIntegrationConfigurationSelector.class) 11 | public @interface EnableSpringIntegration { 12 | } 13 | -------------------------------------------------------------------------------- /aggregate-framework-spring/src/main/java/org/aggregateframework/spring/annotation/SpringIntegrationConfigurationSelector.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.spring.annotation; 2 | 3 | import org.aggregateframework.spring.support.SpringIntegrationConfiguration; 4 | import org.springframework.context.annotation.ImportSelector; 5 | import org.springframework.core.type.AnnotationMetadata; 6 | 7 | public class SpringIntegrationConfigurationSelector implements ImportSelector { 8 | @Override 9 | public String[] selectImports(AnnotationMetadata importingClassMetadata) { 10 | return new String[]{SpringIntegrationConfiguration.class.getName()}; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /aggregate-framework-spring/src/main/java/org/aggregateframework/spring/datasource/TransactionManagerAutoProxyCreator.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.spring.datasource; 2 | 3 | import org.springframework.aop.TargetSource; 4 | import org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator; 5 | import org.springframework.beans.BeansException; 6 | import org.springframework.transaction.PlatformTransactionManager; 7 | 8 | public class TransactionManagerAutoProxyCreator extends AbstractAutoProxyCreator { 9 | private static final long serialVersionUID = 7736935531455160187L; 10 | 11 | @Override 12 | protected Object[] getAdvicesAndAdvisorsForBean(Class beanClass, String beanName, TargetSource customTargetSource) throws BeansException { 13 | return isMatch(beanClass) ? PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS : DO_NOT_PROXY; 14 | } 15 | 16 | private boolean isMatch(Class clazz) { 17 | if (PlatformTransactionManager.class.isAssignableFrom(clazz) 18 | && !SessionDataSourceTransactionManager.class.isAssignableFrom(clazz)) { 19 | return true; 20 | } 21 | return false; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /aggregate-framework-spring/src/main/java/org/aggregateframework/spring/xid/DefaultUUIDGenerator.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.spring.xid; 2 | 3 | import com.xfvape.uid.UidGenerator; 4 | import org.aggregateframework.xid.UUIDGenerator; 5 | 6 | public class DefaultUUIDGenerator implements UUIDGenerator { 7 | private UidGenerator uidGenerator; 8 | 9 | public DefaultUUIDGenerator(UidGenerator uidGenerator) { 10 | this.uidGenerator = uidGenerator; 11 | } 12 | 13 | @Override 14 | public String generate() { 15 | long value = this.uidGenerator.getUID(); 16 | return Long.toHexString(value); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aggregate-framework-spring/src/main/java/org/aggregateframework/spring/xml/AggConfigNamespaceHandlerSupport.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.spring.xml; 2 | 3 | import org.springframework.beans.factory.xml.NamespaceHandlerSupport; 4 | 5 | public class AggConfigNamespaceHandlerSupport extends NamespaceHandlerSupport { 6 | @Override 7 | public void init() { 8 | registerBeanDefinitionParser("integration", new SpringIntegrationByRegisterDefinitionParser()); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aggregate-framework-spring/src/main/java/org/aggregateframework/spring/xml/SpringIntegrationByConfigDefinitionParser.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.spring.xml; 2 | 3 | import org.aggregateframework.spring.support.SpringIntegrationConfiguration; 4 | import org.springframework.beans.factory.support.BeanDefinitionBuilder; 5 | import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; 6 | import org.w3c.dom.Element; 7 | 8 | public class SpringIntegrationByConfigDefinitionParser extends AbstractSingleBeanDefinitionParser { 9 | 10 | protected Class getBeanClass(Element element) { 11 | return SpringIntegrationConfiguration.class; 12 | } 13 | 14 | protected boolean shouldGenerateIdAsFallback() { 15 | return true; 16 | } 17 | 18 | protected void doParse(Element element, BeanDefinitionBuilder builder) { 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /aggregate-framework-spring/src/main/resources/META-INF/spring.handlers: -------------------------------------------------------------------------------- 1 | http\://www.aggregateframework.org/schema/agg=org.aggregateframework.spring.xml.AggConfigNamespaceHandlerSupport -------------------------------------------------------------------------------- /aggregate-framework-spring/src/main/resources/META-INF/spring.schemas: -------------------------------------------------------------------------------- 1 | http\://www.aggregateframework.org/schema/agg.xsd=aggregateframework-1.1.xsd -------------------------------------------------------------------------------- /aggregate-framework-spring/src/main/resources/aggregateframework-1.1.xsd: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /aggregate-framework-spring/src/main/resources/config/spring/common/aggregate-framework-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | transactionManagerInterceptor 14 | 15 | 16 | 17 | 18 | 20 | 21 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-basic-usage/src/main/java/org/aggregateframework/basic/usage/BasicUsageApplication.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.basic.usage; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.mybatis.spring.annotation.MapperScan; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 9 | 10 | /** 11 | * @author Nervose.Wu 12 | * @date 2022/6/16 16:19 13 | */ 14 | @Slf4j 15 | @SpringBootApplication 16 | @MapperScan("org.aggregateframework.basic.usage.dao") 17 | @EnableAspectJAutoProxy(exposeProxy = true) 18 | public class BasicUsageApplication implements CommandLineRunner { 19 | public static void main(String[] args) { 20 | SpringApplication.run(BasicUsageApplication.class, args); 21 | } 22 | 23 | @Override 24 | public void run(String... args) { 25 | log.info("start"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-basic-usage/src/main/java/org/aggregateframework/basic/usage/dao/AccountDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.basic.usage.dao; 2 | 3 | 4 | import org.aggregateframework.basic.usage.entity.Account; 5 | import org.aggregateframework.dao.AggregateRootDao; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author Nervose.Wu 12 | * @date 2023/6/26 14:33 13 | */ 14 | 15 | public interface AccountDao extends AggregateRootDao { 16 | 17 | Account findByAccountId(@Param("accountId") String accountId); 18 | 19 | List findByAccountIds(List accountIds); 20 | } 21 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-basic-usage/src/main/java/org/aggregateframework/basic/usage/dao/SubAccountDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.basic.usage.dao; 2 | 3 | 4 | import org.aggregateframework.basic.usage.entity.SubAccount; 5 | import org.aggregateframework.dao.DomainObjectDao; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author Nervose.Wu 12 | * @date 2023/6/26 14:33 13 | */ 14 | public interface SubAccountDao extends DomainObjectDao { 15 | 16 | List findByParentId(@Param("parentId") Long parentId); 17 | } 18 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-basic-usage/src/main/java/org/aggregateframework/basic/usage/entity/Account.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.basic.usage.entity; 2 | 3 | 4 | import lombok.*; 5 | import org.aggregateframework.basic.usage.event.AccountCreateEvent; 6 | import org.aggregateframework.entity.AbstractSimpleAggregateRoot; 7 | import org.aggregateframework.entity.DaoAwareQuery; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * @author Nervose.Wu 14 | * @date 2023/6/26 14:11 15 | */ 16 | @Data 17 | @EqualsAndHashCode(callSuper = true) 18 | @Builder 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | public class Account extends AbstractSimpleAggregateRoot { 22 | 23 | private Long id; 24 | 25 | private String accountId; 26 | 27 | private Integer eventStatus; 28 | 29 | @DaoAwareQuery(mappedBy = "account", select = "findByParentId") 30 | private List subAccounts = new ArrayList<>(); 31 | 32 | public void applyAccountCreateEvent(){ 33 | apply(new AccountCreateEvent(accountId)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-basic-usage/src/main/java/org/aggregateframework/basic/usage/entity/SubAccount.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.basic.usage.entity; 2 | 3 | import lombok.*; 4 | import org.aggregateframework.entity.AbstractSimpleDomainObject; 5 | 6 | /** 7 | * @author Nervose.Wu 8 | * @date 2023/6/26 14:15 9 | */ 10 | @Data 11 | @EqualsAndHashCode(callSuper = true) 12 | @Builder 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class SubAccount extends AbstractSimpleDomainObject { 16 | 17 | private Long id; 18 | 19 | private String accountId; 20 | 21 | private Account account; 22 | 23 | private Integer eventStatus; 24 | } 25 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-basic-usage/src/main/java/org/aggregateframework/basic/usage/event/AccountCreateEvent.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.basic.usage.event; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author Nervose.Wu 9 | * @date 2023/6/26 16:42 10 | */ 11 | @Data 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | public class AccountCreateEvent { 15 | 16 | private String accountId; 17 | } 18 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-basic-usage/src/main/java/org/aggregateframework/basic/usage/repository/AccountRepository.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.basic.usage.repository; 2 | 3 | 4 | import org.aggregateframework.basic.usage.dao.AccountDao; 5 | import org.aggregateframework.basic.usage.entity.Account; 6 | import org.aggregateframework.repository.DaoAwareAggregateRepository; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author Nervose.Wu 14 | * @date 2023/6/26 14:43 15 | */ 16 | @Repository 17 | public class AccountRepository extends DaoAwareAggregateRepository { 18 | 19 | @Autowired 20 | private AccountDao accountDao; 21 | 22 | public AccountRepository() { 23 | super(Account.class); 24 | } 25 | 26 | public Account findByAccountId(String accountId) { 27 | return fetchAllComponents(accountDao.findByAccountId(accountId)); 28 | } 29 | 30 | public List findByAccountIds(List accountIds) { 31 | return fetchAllComponents(accountDao.findByAccountIds(accountIds)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-basic-usage/src/main/resources/application-local.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | agg: 3 | storage: 4 | storage-type: redis 5 | domain: "AGG:TEST:CLIENT:" 6 | serializer-type: kryo 7 | redis: 8 | host: 127.0.0.1 9 | port: 6379 10 | database: 0 11 | pool-config: 12 | max-total: 100 13 | max-idle: 100 14 | min-idle: 10 15 | max-wait-millis: 300 16 | recovery: 17 | recovery-enabled: true 18 | update-job-forcibly: false 19 | quartz-clustered: false 20 | recover-duration: 30 21 | max-retry-count: 3 22 | fetch-page-size: 200 23 | cron-expression: "0/30 * * * * ? " -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-basic-usage/src/main/resources/application-server.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | agg: 3 | storage: 4 | storage-type: remoting 5 | domain: "AGG:TEST:CLIENT:" 6 | serializer-type: kryo 7 | request-timeout-millis: 10000 8 | registry: 9 | cluster-name: default 10 | registry-type: direct 11 | direct: 12 | addresses-for-client: 127.0.0.1:2332 13 | 14 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-basic-usage/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | servlet: 4 | context-path: /${spring.application.name} 5 | spring: 6 | application: 7 | name: aggregate-framework-basic-usage 8 | profiles: 9 | active: server # Possible values: local, server 10 | datasource: 11 | driver-class-name: org.h2.Driver 12 | url: jdbc:h2:mem:AGG_TEST 13 | username: root 14 | password: welcome1 15 | initialization-mode: always 16 | schema: classpath:schema.sql 17 | # http://localhost:8080/aggregate-framework-basic-usage/h2-console 18 | h2: 19 | console: 20 | enabled: true 21 | settings: 22 | web-allow-others: true 23 | mybatis: 24 | mapper-locations: classpath:mapping/*.xml 25 | 26 | logging: 27 | level: 28 | root: info -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-basic-usage/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `ACCOUNT`; 2 | CREATE TABLE `ACCOUNT` 3 | ( 4 | `ID` bigint(20) NOT NULL AUTO_INCREMENT, 5 | `ACCOUNT_ID` varchar(40) NOT NULL COMMENT '账户id', 6 | `EVENT_STATUS` bigint(20) NOT NULL DEFAULT 0 COMMENT '状态(测试agg事件)', 7 | `CREATE_TIME` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 8 | `LAST_UPDATE_TIME` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '最近更新时间', 9 | `VERSION` int(11) DEFAULT '1' COMMENT '版本号', 10 | PRIMARY KEY (`ID`) 11 | ); 12 | 13 | CREATE UNIQUE INDEX ON ACCOUNT(ACCOUNT_ID); 14 | 15 | DROP TABLE IF EXISTS `SUB_ACCOUNT`; 16 | CREATE TABLE `SUB_ACCOUNT` 17 | ( 18 | `ID` bigint(20) NOT NULL AUTO_INCREMENT, 19 | `ACCOUNT_ID` varchar(40) NOT NULL COMMENT '子账户id', 20 | `PARENT_ID` varchar(40) NOT NULL COMMENT '主账户主键', 21 | `EVENT_STATUS` bigint(20) NOT NULL DEFAULT 0 COMMENT '状态(测试agg事件)', 22 | `CREATE_TIME` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 23 | `LAST_UPDATE_TIME` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '最近更新时间', 24 | PRIMARY KEY (`ID`) 25 | ); 26 | 27 | CREATE UNIQUE INDEX ON SUB_ACCOUNT(ACCOUNT_ID); 28 | CREATE INDEX ON SUB_ACCOUNT(PARENT_ID); -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/AggregateFrameworkSampleApplication.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ImportResource; 6 | 7 | @SpringBootApplication 8 | @ImportResource(locations = {"classpath:config/spring/local/*.xml"}) 9 | public class AggregateFrameworkSampleApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(AggregateFrameworkSampleApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/complexmodel/command/domain/entity/BookingPayment.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.complexmodel.command.domain.entity; 2 | 3 | import org.aggregateframework.entity.AbstractSimpleDomainObject; 4 | 5 | import java.math.BigDecimal; 6 | 7 | /** 8 | * User: changming.xie 9 | * Date: 14-6-20 10 | * Time: 下午6:46 11 | */ 12 | public class BookingPayment extends AbstractSimpleDomainObject { 13 | 14 | private static final long serialVersionUID = 6555609853935658453L; 15 | private BigDecimal amount; 16 | private Integer id; 17 | 18 | public BigDecimal getAmount() { 19 | return amount; 20 | } 21 | 22 | public void setAmount(BigDecimal amount) { 23 | this.amount = amount; 24 | } 25 | 26 | @Override 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | @Override 32 | public void setId(Integer id) { 33 | this.id = id; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/complexmodel/command/domain/event/OrderCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.complexmodel.command.domain.event; 2 | 3 | import org.aggregateframework.sample.complexmodel.command.domain.entity.BookingOrder; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created with IntelliJ IDEA. 9 | * User: Administrator 10 | * Date: 13-10-9 11 | * Time: 下午3:10 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class OrderCreatedEvent implements Serializable { 15 | 16 | private static final long serialVersionUID = 6310942080650856566L; 17 | private BookingOrder bookingOrder; 18 | 19 | public OrderCreatedEvent(BookingOrder bookingOrder) { 20 | this.bookingOrder = bookingOrder; 21 | } 22 | 23 | public BookingOrder getBookingOrder() { 24 | return bookingOrder; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/complexmodel/command/domain/event/OrderUpdatedEvent.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.complexmodel.command.domain.event; 2 | 3 | import org.aggregateframework.sample.complexmodel.command.domain.entity.UserShardingId; 4 | 5 | /** 6 | * Created with IntelliJ IDEA. 7 | * User: Administrator 8 | * Date: 13-10-9 9 | * Time: 下午3:56 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class OrderUpdatedEvent { 13 | 14 | private UserShardingId id; 15 | 16 | private String content; 17 | 18 | public OrderUpdatedEvent(UserShardingId id, String content) { 19 | this.id = id; 20 | this.content = content; 21 | } 22 | 23 | public String getContent() { 24 | return content; 25 | } 26 | 27 | public UserShardingId getId() { 28 | return id; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/complexmodel/command/domain/event/SeatAvailabilityRemovedEvent.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.complexmodel.command.domain.event; 2 | 3 | import org.aggregateframework.sample.complexmodel.command.domain.entity.BookingOrder; 4 | 5 | /** 6 | * Created by changming.xie on 2/4/16. 7 | */ 8 | public class SeatAvailabilityRemovedEvent { 9 | 10 | BookingOrder bookingOrder; 11 | 12 | public SeatAvailabilityRemovedEvent(BookingOrder bookingOrder) { 13 | this.bookingOrder = bookingOrder; 14 | } 15 | 16 | public BookingOrder getBookingOrder() { 17 | return bookingOrder; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/complexmodel/command/domain/repository/JpaOrderRepository.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.complexmodel.command.domain.repository; 2 | 3 | import org.aggregateframework.repository.DaoAwareAggregateRepository; 4 | import org.aggregateframework.sample.complexmodel.command.domain.entity.BookingOrder; 5 | import org.aggregateframework.sample.complexmodel.command.domain.entity.UserShardingId; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | public class JpaOrderRepository extends DaoAwareAggregateRepository { 10 | 11 | public JpaOrderRepository() { 12 | this(BookingOrder.class); 13 | } 14 | 15 | protected JpaOrderRepository(Class aggregateType) { 16 | super(aggregateType); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/complexmodel/command/infrastructure/dao/BookingOrderDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.complexmodel.command.infrastructure.dao; 2 | 3 | import org.aggregateframework.dao.CollectiveAggregateRootDao; 4 | import org.aggregateframework.sample.complexmodel.command.domain.entity.BookingOrder; 5 | import org.aggregateframework.sample.complexmodel.command.domain.entity.UserShardingId; 6 | 7 | /** 8 | * Created with IntelliJ IDEA. 9 | * User: Administrator 10 | * Date: 13-9-16 11 | * Time: 下午4:14 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public interface BookingOrderDao extends CollectiveAggregateRootDao { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/complexmodel/command/infrastructure/dao/BookingPaymentDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.complexmodel.command.infrastructure.dao; 2 | 3 | import org.aggregateframework.dao.CollectiveDomainObjectDao; 4 | import org.aggregateframework.sample.complexmodel.command.domain.entity.BookingPayment; 5 | 6 | /** 7 | * User: changming.xie 8 | * Date: 14-6-20 9 | * Time: 下午6:57 10 | */ 11 | public interface BookingPaymentDao extends CollectiveDomainObjectDao { 12 | } 13 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/complexmodel/command/infrastructure/dao/SeatAvailabilityDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.complexmodel.command.infrastructure.dao; 2 | 3 | import org.aggregateframework.dao.CollectiveDomainObjectDao; 4 | import org.aggregateframework.sample.complexmodel.command.domain.entity.SeatAvailability; 5 | import org.aggregateframework.sample.complexmodel.command.domain.entity.UserShardingId; 6 | 7 | import java.util.Collection; 8 | import java.util.List; 9 | 10 | /** 11 | * Created with IntelliJ IDEA. 12 | * User: Administrator 13 | * Date: 13-10-12 14 | * Time: 下午5:31 15 | * To change this template use File | Settings | File Templates. 16 | */ 17 | public interface SeatAvailabilityDao extends CollectiveDomainObjectDao { 18 | 19 | List findByOrderIds(Collection orderIds); 20 | 21 | List findByOrderId(UserShardingId orderId); 22 | } 23 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/complexmodel/command/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.complexmodel.command.service; 2 | 3 | import org.aggregateframework.sample.complexmodel.command.domain.entity.BookingOrder; 4 | 5 | /** 6 | * User: changming.xie 7 | * Date: 14-6-3 8 | * Time: 下午3:44 9 | */ 10 | public interface OrderService { 11 | 12 | public void add(BookingOrder bookingOrder); 13 | 14 | public void add2(String as); 15 | } 16 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/hierarchicalmodel/command/domain/entity/DeliveryOrder.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.hierarchicalmodel.command.domain.entity; 2 | 3 | /** 4 | * Created by changming.xie on 3/30/16. 5 | */ 6 | public class DeliveryOrder extends HierarchicalOrder { 7 | 8 | private static final long serialVersionUID = 2259054024797433038L; 9 | private String deliver; 10 | 11 | public DeliveryOrder() { 12 | this.setDtype("DeliveryOrder"); 13 | } 14 | 15 | public DeliveryOrderInfo getOrderInfo() { 16 | return (DeliveryOrderInfo) super.getOrderInfo(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/hierarchicalmodel/command/domain/entity/DeliveryOrderInfo.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.hierarchicalmodel.command.domain.entity; 2 | 3 | /** 4 | * Created by changming.xie on 3/30/16. 5 | */ 6 | public class DeliveryOrderInfo extends OrderInfo { 7 | 8 | private String deliveryInfo; 9 | 10 | public DeliveryOrderInfo() { 11 | this.setDtype("DeliveryOrderInfo"); 12 | } 13 | 14 | public String getDeliveryInfo() { 15 | return deliveryInfo; 16 | } 17 | 18 | public void setDeliveryInfo(String deliveryInfo) { 19 | this.deliveryInfo = deliveryInfo; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/hierarchicalmodel/command/domain/entity/HierarchicalOrder.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.hierarchicalmodel.command.domain.entity; 2 | 3 | import org.aggregateframework.entity.AbstractSimpleAggregateRoot; 4 | 5 | /** 6 | * Created by changming.xie on 3/30/16. 7 | */ 8 | public class HierarchicalOrder extends AbstractSimpleAggregateRoot { 9 | 10 | private static final long serialVersionUID = 2788858215657724845L; 11 | private String dtype; 12 | 13 | private String content; 14 | 15 | private OrderInfo orderInfo; 16 | private Integer id; 17 | 18 | public OrderInfo getOrderInfo() { 19 | return orderInfo; 20 | } 21 | 22 | public void setOrderInfo(OrderInfo orderInfo) { 23 | this.orderInfo = orderInfo; 24 | } 25 | 26 | @Override 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | @Override 32 | public void setId(Integer id) { 33 | this.id = id; 34 | } 35 | 36 | public String getDtype() { 37 | return dtype; 38 | } 39 | 40 | public void setDtype(String dtype) { 41 | this.dtype = dtype; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/hierarchicalmodel/command/domain/entity/JobOrder.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.hierarchicalmodel.command.domain.entity; 2 | 3 | /** 4 | * Created by changming.xie on 3/30/16. 5 | */ 6 | public class JobOrder extends HierarchicalOrder { 7 | 8 | private String job; 9 | 10 | public JobOrder() { 11 | this.setDtype("JobOrder"); 12 | } 13 | 14 | public JobOrderInfo getOrderInfo() { 15 | return (JobOrderInfo) super.getOrderInfo(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/hierarchicalmodel/command/domain/entity/JobOrderInfo.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.hierarchicalmodel.command.domain.entity; 2 | 3 | /** 4 | * Created by changming.xie on 3/30/16. 5 | */ 6 | public class JobOrderInfo extends OrderInfo { 7 | 8 | private String jobInfo; 9 | 10 | public JobOrderInfo() { 11 | this.setDtype("JobOrderInfo"); 12 | } 13 | 14 | public String getJobInfo() { 15 | return jobInfo; 16 | } 17 | 18 | public void setJobInfo(String jobInfo) { 19 | this.jobInfo = jobInfo; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/hierarchicalmodel/command/domain/entity/OrderInfo.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.hierarchicalmodel.command.domain.entity; 2 | 3 | import org.aggregateframework.entity.AbstractSimpleDomainObject; 4 | 5 | /** 6 | * Created by changming.xie on 3/30/16. 7 | */ 8 | public class OrderInfo extends AbstractSimpleDomainObject { 9 | 10 | private static final long serialVersionUID = -3404894128686039392L; 11 | private String name; 12 | 13 | private String dtype; 14 | 15 | private Integer id; 16 | 17 | @Override 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | @Override 23 | public void setId(Integer id) { 24 | this.id = id; 25 | } 26 | 27 | public String getDtype() { 28 | return dtype; 29 | } 30 | 31 | public void setDtype(String dtype) { 32 | this.dtype = dtype; 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/hierarchicalmodel/command/domain/repository/DeliveryOrderRepository.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.hierarchicalmodel.command.domain.repository; 2 | 3 | import org.aggregateframework.repository.DaoAwareAggregateRepository; 4 | import org.aggregateframework.sample.hierarchicalmodel.command.domain.entity.DeliveryOrder; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * Created by changming.xie on 3/30/16. 9 | */ 10 | @Repository 11 | public class DeliveryOrderRepository extends DaoAwareAggregateRepository { 12 | protected DeliveryOrderRepository(Class aggregateType) { 13 | super(aggregateType); 14 | } 15 | 16 | public DeliveryOrderRepository() { 17 | this(DeliveryOrder.class); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/hierarchicalmodel/command/domain/repository/JobOrderRepository.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.hierarchicalmodel.command.domain.repository; 2 | 3 | import org.aggregateframework.repository.DaoAwareAggregateRepository; 4 | import org.aggregateframework.sample.hierarchicalmodel.command.domain.entity.JobOrder; 5 | 6 | /** 7 | * Created by changming.xie on 3/30/16. 8 | */ 9 | public class JobOrderRepository extends DaoAwareAggregateRepository { 10 | protected JobOrderRepository(Class aggregateType) { 11 | super(aggregateType); 12 | } 13 | 14 | public JobOrderRepository() { 15 | this(JobOrder.class); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/hierarchicalmodel/command/infrastructure/dao/HierarchicalOrderDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.hierarchicalmodel.command.infrastructure.dao; 2 | 3 | import org.aggregateframework.dao.CollectiveAggregateRootDao; 4 | import org.aggregateframework.sample.hierarchicalmodel.command.domain.entity.HierarchicalOrder; 5 | 6 | /** 7 | * Created by changming.xie on 3/30/16. 8 | */ 9 | public interface HierarchicalOrderDao extends CollectiveAggregateRootDao { 10 | } 11 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/hierarchicalmodel/command/infrastructure/dao/OrderInfoDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.hierarchicalmodel.command.infrastructure.dao; 2 | 3 | import org.aggregateframework.dao.CollectiveDomainObjectDao; 4 | import org.aggregateframework.sample.hierarchicalmodel.command.domain.entity.OrderInfo; 5 | 6 | /** 7 | * Created by changming.xie on 3/30/16. 8 | */ 9 | public interface OrderInfoDao extends CollectiveDomainObjectDao { 10 | } 11 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/quickstart/command/domain/event/OrderConfirmedEvent.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.quickstart.command.domain.event; 2 | 3 | import org.aggregateframework.sample.quickstart.command.domain.entity.PricedOrder; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by changming.xie on 11/28/17. 9 | */ 10 | public class OrderConfirmedEvent implements Serializable { 11 | private static final long serialVersionUID = 5747983401748068456L; 12 | 13 | private String no; 14 | 15 | public OrderConfirmedEvent(PricedOrder pricedOrder) { 16 | 17 | this.no = pricedOrder.getMerchantOrderNo(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/quickstart/command/domain/event/OrderPlacedEvent.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.quickstart.command.domain.event; 2 | 3 | import org.aggregateframework.sample.quickstart.command.domain.entity.PricedOrder; 4 | 5 | /** 6 | * Created by changming.xie on 4/7/16. 7 | */ 8 | public class OrderPlacedEvent { 9 | 10 | private PricedOrder pricedOrder; 11 | 12 | // private String no; 13 | 14 | public OrderPlacedEvent(PricedOrder pricedOrder) { 15 | this.pricedOrder = pricedOrder; 16 | // this.no = pricedOrder.getMerchantOrderNo(); 17 | } 18 | 19 | public PricedOrder getPricedOrder() { 20 | return pricedOrder; 21 | } 22 | 23 | // public String getNo() { 24 | // return no; 25 | // } 26 | // 27 | // public void setNo(String no) { 28 | // this.no = no; 29 | // } 30 | } 31 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/quickstart/command/domain/event/PaymentConfirmedEvent.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.quickstart.command.domain.event; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by changming.xie on 4/13/16. 7 | */ 8 | public class PaymentConfirmedEvent implements Serializable { 9 | 10 | private static final long serialVersionUID = -5599479410994660047L; 11 | private String paymentNo; 12 | 13 | public PaymentConfirmedEvent(String paymentNo) { 14 | this.paymentNo = paymentNo; 15 | } 16 | 17 | public String getPaymentNo() { 18 | return paymentNo; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/quickstart/command/domain/factory/OrderFactory.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.quickstart.command.domain.factory; 2 | 3 | import org.aggregateframework.sample.quickstart.command.domain.entity.OrderLine; 4 | import org.aggregateframework.sample.quickstart.command.domain.entity.PricedOrder; 5 | 6 | import java.util.Random; 7 | import java.util.concurrent.ThreadLocalRandom; 8 | 9 | /** 10 | * Created by changming.xie on 4/7/16. 11 | */ 12 | public class OrderFactory { 13 | 14 | public static PricedOrder buildOrder(int productId, int price, int i) { 15 | 16 | PricedOrder pricedOrder = new PricedOrder(getNewMerchantOrderNo(i)); 17 | pricedOrder.addOrderLine(new OrderLine(productId, price, 1)); 18 | return pricedOrder; 19 | } 20 | 21 | private static String getNewMerchantOrderNo(int i) { 22 | 23 | return String.format("OR%s-%d", System.currentTimeMillis(), ThreadLocalRandom.current().nextLong()); 24 | // return String.format("OR%s-%d", String.valueOf(System.currentTimeMillis() / 1000 / 60), i); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/quickstart/command/domain/factory/PaymentFactory.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.quickstart.command.domain.factory; 2 | 3 | import org.aggregateframework.sample.quickstart.command.domain.entity.Payment; 4 | 5 | import java.math.BigDecimal; 6 | 7 | /** 8 | * Created by changming.xie on 4/13/16. 9 | */ 10 | public class PaymentFactory { 11 | 12 | 13 | public static Payment buildPayment(Long orderId, String paymentNo, BigDecimal totalAmount) { 14 | return new Payment(orderId, paymentNo, totalAmount); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/quickstart/command/infrastructure/dao/OrderDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.quickstart.command.infrastructure.dao; 2 | 3 | import org.aggregateframework.dao.CollectiveAggregateRootDao; 4 | import org.aggregateframework.sample.quickstart.command.domain.entity.PricedOrder; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by changming.xie on 4/8/16. 10 | */ 11 | public interface OrderDao extends CollectiveAggregateRootDao { 12 | List findByPrice(); 13 | 14 | PricedOrder findByNo(String no); 15 | } 16 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/quickstart/command/infrastructure/dao/OrderLineDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.quickstart.command.infrastructure.dao; 2 | 3 | import org.aggregateframework.dao.CollectiveDomainObjectDao; 4 | import org.aggregateframework.sample.quickstart.command.domain.entity.OrderLine; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by changming.xie on 4/8/16. 10 | */ 11 | public interface OrderLineDao extends CollectiveDomainObjectDao { 12 | 13 | public List findByOrderId(Long orderId); 14 | 15 | public List findAll(); 16 | } 17 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/quickstart/command/infrastructure/dao/PaymentDao.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.quickstart.command.infrastructure.dao; 2 | 3 | import org.aggregateframework.dao.CollectiveAggregateRootDao; 4 | import org.aggregateframework.sample.quickstart.command.domain.entity.Payment; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by changming.xie on 4/8/16. 10 | */ 11 | public interface PaymentDao extends CollectiveAggregateRootDao { 12 | 13 | Payment findByPaymentNo(String paymentNo); 14 | 15 | List findAll(); 16 | } 17 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/quickstart/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.quickstart.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | 5 | //@EnableSpringIntegration 6 | @Configuration 7 | public class AppConfig { 8 | } 9 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/java/org/aggregateframework/sample/threadcontext/TestThreadContextSynchronization.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.threadcontext; 2 | 3 | import org.aggregateframework.threadcontext.ThreadContextSynchronization; 4 | 5 | public class TestThreadContextSynchronization implements ThreadContextSynchronization { 6 | 7 | // private ThreadLocal threadContext = new ThreadLocal<>(); 8 | 9 | public volatile static String THREAD_CONTEXT = null; 10 | 11 | @Override 12 | public String getCurrentThreadContext() { 13 | return THREAD_CONTEXT; 14 | } 15 | 16 | @Override 17 | public void setThreadContext(String threadContext) { 18 | System.out.println("set thread context:" + threadContext); 19 | THREAD_CONTEXT = threadContext; 20 | } 21 | 22 | @Override 23 | public void clear() { 24 | THREAD_CONTEXT = null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/resources/META-INF/services/org.aggregateframework.threadcontext.ThreadContextSynchronization: -------------------------------------------------------------------------------- 1 | org.aggregateframework.sample.threadcontext.TestThreadContextSynchronization -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/resources/application-dev.yaml: -------------------------------------------------------------------------------- 1 | #SERVER模式 2 | spring: 3 | main: 4 | allow-bean-definition-overriding: true 5 | agg: 6 | storage: 7 | domain: AGG:UT 8 | storage-type: remoting 9 | # dledger: 10 | # configs: 11 | # - group: aaa 12 | registry: 13 | registry-type: nacos 14 | 15 | #EMBEDDED模式 16 | #spring: 17 | # main: 18 | # allow-bean-definition-overriding: true 19 | # agg: 20 | # storage: 21 | # domain: AGG:UT 22 | # storage-type: REDIS_CLUSTER 23 | # redis-cluster: 24 | # max-attempts: 5 25 | # so-timeout: 300 26 | # connection-timeout: 1000 27 | # nodes: 28 | # - host: 192.168.75.140 29 | # port: 6379 30 | # - host: 192.168.75.140 31 | # port: 6380 32 | # - host: 192.168.75.140 33 | # port: 6381 34 | # - host: 192.168.75.140 35 | # port: 6382 36 | # - host: 192.168.75.140 37 | # port: 6383 38 | # - host: 192.168.75.140 39 | # port: 6384 40 | # recovery: 41 | # fetch-page-size: 200 42 | # cron-expression: "0/30 * * * * ? " 43 | # max-retry-count: 5 44 | # recover-duration: 30 45 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | main: 3 | allow-bean-definition-overriding: true 4 | agg: 5 | storage: 6 | domain: AGG:UT 7 | storage-type: remoting 8 | registry: 9 | registry-type: direct 10 | direct: 11 | addresses-for-client: 127.0.0.1:2332 12 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/resources/config/spring/local/appcontext-service-hierarchical-dao.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/resources/config/sqlmap/sqlmap-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/resources/jdbc.properties: -------------------------------------------------------------------------------- 1 | jdbc.driverClassName=com.mysql.jdbc.Driver 2 | jdbc.url=jdbc:mysql://127.0.0.1:3306/DEMO?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&connectionTimeout=1000&socketTimeout=5000 3 | jdbc.username=root 4 | jdbc.password=welcome1 5 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/resources/redis.properties: -------------------------------------------------------------------------------- 1 | singleredis.host=127.0.0.1 2 | singleredis.port=6379 3 | shardredis1.host=127.0.0.1 4 | shardredis1.port=6379 5 | shardredis2.host=127.0.0.1 6 | shardredis2.port=6380 7 | clusterredis1.host=127.0.0.1 8 | clusterredis1.port=7001 9 | clusterredis2.host=127.0.0.1 10 | clusterredis2.port=7002 11 | clusterredis3.host=127.0.0.1 12 | clusterredis3.port=7003 13 | clusterredis.password=123456 14 | redis.connectionTimeout=1000 15 | redis.soTimeout=500 16 | redis.pool.maxTotal=100 17 | redis.pool.maxIdle=100 18 | redis.pool.minIdle=10 19 | redis.pool.maxWaitMillis=300 20 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/main/resources/zk.properties: -------------------------------------------------------------------------------- 1 | zk.sessionTimeout=8000 2 | zk.connectTimeout=2000 3 | zk.digest= 4 | zk.baseSleepMs=1000 5 | zk.maxRetries=10 6 | zk.address=127.0.0.1:2181 7 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/test/java/org/aggregateframework/sample/AbstractTestCase.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.springframework.test.context.ContextConfiguration; 5 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 6 | 7 | /** 8 | * User: changming.xie 9 | * Date: 14-6-27 10 | * Time: 下午5:58 11 | */ 12 | @RunWith(SpringJUnit4ClassRunner.class) 13 | @ContextConfiguration(locations = { 14 | // "classpath*:/config/spring/common/aggregate-framework-*.xml", 15 | "classpath*:/config/spring/local/appcontext-service-*.xml"}) 16 | public abstract class AbstractTestCase { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/test/java/org/aggregateframework/sample/asynctest/RingBufferEvent.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.asynctest; 2 | 3 | import com.lmax.disruptor.EventFactory; 4 | 5 | /** 6 | * Created by changming.xie on 11/23/17. 7 | */ 8 | public class RingBufferEvent { 9 | 10 | public static final Factory FACTORY = new Factory(); 11 | 12 | int i; 13 | 14 | public void execute(boolean endOfBatch) { 15 | 16 | System.out.println("async call, i:" + i); 17 | 18 | if (i == 100) { 19 | try { 20 | Thread.sleep(100 * 1000l); 21 | } catch (InterruptedException e) { 22 | e.printStackTrace(); 23 | } 24 | } 25 | 26 | i = 0; 27 | } 28 | 29 | public void clear() { 30 | 31 | } 32 | 33 | public void set(int i) { 34 | this.i = i; 35 | } 36 | 37 | private static class Factory implements EventFactory { 38 | 39 | @Override 40 | public RingBufferEvent newInstance() { 41 | final RingBufferEvent result = new RingBufferEvent(); 42 | return result; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /aggregate-framework-tutorial-sample/aggregate-framework-sample/src/test/java/org/aggregateframework/sample/asynctest/RingBufferLogEventTranslator.java: -------------------------------------------------------------------------------- 1 | package org.aggregateframework.sample.asynctest; 2 | 3 | import com.lmax.disruptor.EventTranslator; 4 | 5 | /** 6 | * Created by changming.xie on 11/23/17. 7 | */ 8 | public class RingBufferLogEventTranslator implements EventTranslator { 9 | int i; 10 | 11 | @Override 12 | public void translateTo(RingBufferEvent event, long sequence) { 13 | event.set(i); 14 | } 15 | 16 | public void setIndex(int i) { 17 | this.i = i; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /doc/AggregateFamework Reference.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changmingxie/aggregate-framework/9e6cc6fec81dc927145e87fcc0a28b9c77b9f51a/doc/AggregateFamework Reference.docx -------------------------------------------------------------------------------- /doc/AggregateFamework Reference.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changmingxie/aggregate-framework/9e6cc6fec81dc927145e87fcc0a28b9c77b9f51a/doc/AggregateFamework Reference.pdf --------------------------------------------------------------------------------