├── .editorconfig
├── .gitignore
├── LICENSE
├── README.md
├── basic
├── PrinciplesofComputerOrganization
│ └── README.md
├── README.md
└── pom.xml
├── bigdata
└── README.md
├── blog
└── 计算机组成名词缩写.md
├── database
├── mongodb
│ └── pom.xml
├── mysql
│ ├── pom.xml
│ ├── 从根儿上理解MySQL
│ │ ├── 01.重新认识MySQL.md
│ │ ├── 02.启动选项和系统变量.md
│ │ ├── 03.字符集和比较规则.md
│ │ ├── 04.InnoDB记录结构.md
│ │ ├── 05.InnoDB数据页结构.md
│ │ ├── 06.B+树索引.md
│ │ ├── 07.B+树索引的使用.md
│ │ ├── 08.MySQL的数据目录.md
│ │ ├── 09.InnoDB 的表空间.md
│ │ ├── 10.单表访问方法.md
│ │ └── 11.连接的原理.md
│ └── 使用
│ │ ├── 0.建表语句.md
│ │ ├── 1.基础查询.md
│ │ ├── 10.DML.md
│ │ ├── 11.DDL.md
│ │ ├── 12.数据类型.md
│ │ ├── 13.常见约束.md
│ │ ├── 14.标识列.md
│ │ ├── 15.事务.md
│ │ ├── 16.视图.md
│ │ ├── 17.变量.md
│ │ ├── 18.存储过程.md
│ │ ├── 19.自定义函数.md
│ │ ├── 2.条件查询.md
│ │ ├── 20.流程控制.md
│ │ ├── 21.MySQL基础架构.md
│ │ ├── 22.MySQL索引优化.md
│ │ ├── 23.MySql查询截取分析.md
│ │ ├── 24.MySql锁机制.md
│ │ ├── 3.排序查询.md
│ │ ├── 4.常见函数.md
│ │ ├── 5.分组查询.md
│ │ ├── 6.连接查询.md
│ │ ├── 7.子查询.md
│ │ ├── 8.分页查询.md
│ │ └── 9.联合查询.md
└── pom.xml
├── java
├── algorithm
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── zj
│ │ └── dreamly
│ │ └── algorithm
│ │ └── doc
│ │ ├── 1.复杂度.md
│ │ └── 2.动态数组.md
├── concurrent
│ ├── doc
│ │ ├── Executor框架详细介绍.md
│ │ ├── java并发知识总结.md
│ │ ├── 多线程设计模式.md
│ │ ├── 并发之原子类型.md
│ │ ├── 并发之工具包.md
│ │ └── 并发集合.md
│ ├── image
│ │ ├── 11.jpg
│ │ ├── 1537329735402.png
│ │ ├── 19.jpg
│ │ ├── 2.jpg
│ │ ├── 20180502173012969.png
│ │ ├── 201805051421294.png
│ │ ├── 24.png
│ │ ├── 25.png
│ │ ├── 26.png
│ │ ├── 27.png
│ │ ├── 325120-810222c987209828.jpg
│ │ ├── 325120-82daf8a71caae552.jpg
│ │ ├── 325120-bc5c8371e69048d4.jpg
│ │ └── 325120-eec3a6a29903a918.jpg
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── github
│ │ │ └── zj
│ │ │ └── dreamly
│ │ │ └── concurrent
│ │ │ ├── BooleanLock.java
│ │ │ ├── Lock.java
│ │ │ ├── ReadWriteLock.java
│ │ │ ├── SimpleThreadPool.java
│ │ │ ├── active
│ │ │ ├── ActivationQueue.java
│ │ │ ├── ActiveObject.java
│ │ │ ├── ActiveObjectFactory.java
│ │ │ ├── ActiveObjectProxy.java
│ │ │ ├── DisplayClientThread.java
│ │ │ ├── DisplayStringRequest.java
│ │ │ ├── FutureResult.java
│ │ │ ├── MakeStringRequest.java
│ │ │ ├── MakerClientThread.java
│ │ │ ├── MethodRequest.java
│ │ │ ├── RealResult.java
│ │ │ ├── Result.java
│ │ │ ├── SchedulerThread.java
│ │ │ ├── Servant.java
│ │ │ └── Test.java
│ │ │ ├── atomic
│ │ │ ├── AtomicIntegerArrayTest.java
│ │ │ ├── AtomicIntegerFieldUpdaterTest.java
│ │ │ ├── AtomicIntegerTest.java
│ │ │ ├── AtomicReferenceTest.java
│ │ │ ├── AtomicStampedReferenceTest.java
│ │ │ ├── CompareAndSetLock.java
│ │ │ ├── FailedAtomicIntegerFieldUpdaterTest.java
│ │ │ ├── GetLockException.java
│ │ │ ├── TestMe.java
│ │ │ └── UnsafeTest.java
│ │ │ ├── classloader
│ │ │ ├── DecryptClassLoader.java
│ │ │ ├── EncryptUtils.java
│ │ │ └── MyClassLoader.java
│ │ │ ├── collections
│ │ │ ├── CopyOnWriteMap.java
│ │ │ ├── LockFreeQueue.java
│ │ │ ├── LockFreeQueueTest.java
│ │ │ ├── MyQueue.java
│ │ │ ├── MyQueueTest.java
│ │ │ ├── SimpleSkipList.java
│ │ │ ├── blocking
│ │ │ │ ├── ArrayBlockingQueueTest.java
│ │ │ │ ├── DelayQueueTest.java
│ │ │ │ ├── LinkedBlockingDequeTest.java
│ │ │ │ ├── LinkedBlockingQueueTest.java
│ │ │ │ ├── LinkedTransferQueueTest.java
│ │ │ │ ├── PriorityBlockingQueueTest.java
│ │ │ │ └── SynchronousQueueTest.java
│ │ │ └── concurrent
│ │ │ │ └── ConcurrentSkipListMapTest.java
│ │ │ ├── executors
│ │ │ ├── CompletableFutureExample1.java
│ │ │ ├── CompletableFutureExample2.java
│ │ │ ├── CompletableFutureExample3.java
│ │ │ ├── CompletableFutureExample4.java
│ │ │ ├── CompletableFutureExample5.java
│ │ │ ├── CompletionServiceExample1.java
│ │ │ ├── CompletionServiceExample2.java
│ │ │ ├── ComplexExample.java
│ │ │ ├── ExecutorServiceExample1.java
│ │ │ ├── ExecutorServiceExample2.java
│ │ │ ├── ExecutorServiceExample3.java
│ │ │ ├── ExecutorServiceExample4.java
│ │ │ ├── FutureExample1.java
│ │ │ ├── FutureExample2.java
│ │ │ ├── ThreadPoolExecutorBuild.java
│ │ │ ├── ThreadPoolExecutorShutdown.java
│ │ │ ├── ThreadPoolExecutorTask.java
│ │ │ ├── factory
│ │ │ │ ├── CachedThreadPool.java
│ │ │ │ ├── FixedThreadPool.java
│ │ │ │ ├── SingleThreadExecutor.java
│ │ │ │ └── WorkStealingPool.java
│ │ │ └── scheduler
│ │ │ │ ├── ScheduledExecutorServiceExample1.java
│ │ │ │ ├── ScheduledExecutorServiceExample2.java
│ │ │ │ └── TimerScheduler.java
│ │ │ ├── future
│ │ │ ├── AsyncFuture.java
│ │ │ ├── Future.java
│ │ │ ├── FutureService.java
│ │ │ ├── FutureTask.java
│ │ │ └── FutureTest.java
│ │ │ ├── observer
│ │ │ ├── LifeCycleListener.java
│ │ │ ├── ObservableRunnable.java
│ │ │ ├── ThreadLifeCycleObserver.java
│ │ │ └── ThreadLifeCycleObserverTest.java
│ │ │ ├── semaphore
│ │ │ ├── SemaphoreExample1.java
│ │ │ ├── SemaphoreExample2.java
│ │ │ ├── SemaphoreExample3.java
│ │ │ ├── SemaphoreExample4.java
│ │ │ └── SemaphoreExample5.java
│ │ │ └── util
│ │ │ ├── condition
│ │ │ ├── ComBetweenThreads.java
│ │ │ ├── ConditionExample1.java
│ │ │ ├── ConditionExample2.java
│ │ │ └── ConditionExample3.java
│ │ │ ├── countdownlatch
│ │ │ ├── CountDownLatchExample1.java
│ │ │ ├── CountDownLatchExample2.java
│ │ │ ├── CountDownLatchExample3.java
│ │ │ └── CountDownLatchExample4.java
│ │ │ ├── cyclicbarrier
│ │ │ ├── CyclicBarrierExample1.java
│ │ │ ├── CyclicBarrierExample2.java
│ │ │ └── CyclicBarrierExample3.java
│ │ │ ├── exchanger
│ │ │ ├── ExchangerExample1.java
│ │ │ ├── ExchangerExample2.java
│ │ │ └── ExchangerExample3.java
│ │ │ ├── forkjoin
│ │ │ ├── ForkJoinRecursiveAction.java
│ │ │ └── ForkJoinRecursiveTask.java
│ │ │ ├── locks
│ │ │ ├── ReadWriteLockExample.java
│ │ │ ├── ReentrantLockExample.java
│ │ │ └── StampedLockExample.java
│ │ │ └── phaser
│ │ │ ├── ArriveAndAwaitAdvanceTest1.java
│ │ │ ├── ArriveAndAwaitAdvanceTest2.java
│ │ │ ├── ArriveAndDeregisterTest.java
│ │ │ ├── ArriveTest.java
│ │ │ ├── AwaitAdvanceInterruptiblyTest.java
│ │ │ ├── AwaitAdvanceTest.java
│ │ │ ├── ForceTerminationTest.java
│ │ │ └── OnAdvanceTest.java
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── zj
│ │ └── dreamly
│ │ └── concurrent
│ │ └── collections
│ │ └── blocking
│ │ └── ArrayBlockingQueueExampleTest.java
├── data-structure
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── github
│ │ │ └── zj
│ │ │ └── dreamly
│ │ │ └── datastructure
│ │ │ ├── array
│ │ │ ├── Array.java
│ │ │ └── ArrayTest.java
│ │ │ ├── hash
│ │ │ ├── HashTable.java
│ │ │ └── HashTableTest.java
│ │ │ ├── linkedlist
│ │ │ ├── LinkedList.java
│ │ │ └── LinkedListTest.java
│ │ │ ├── map
│ │ │ ├── BalanceBinaryMap.java
│ │ │ ├── BalanceBinarySet.java
│ │ │ ├── BinarySearchTreeMap.java
│ │ │ ├── LinkedListMap.java
│ │ │ ├── Map.java
│ │ │ └── MapTest.java
│ │ │ ├── maxheap
│ │ │ ├── MaxHeap.java
│ │ │ └── MaxHeapTest.java
│ │ │ ├── queue
│ │ │ ├── LinkedListQueue.java
│ │ │ ├── PriorityQueue.java
│ │ │ ├── Queue.java
│ │ │ ├── QueueTest.java
│ │ │ ├── array
│ │ │ │ ├── ArrayQueue.java
│ │ │ │ └── ArrayQueueTest.java
│ │ │ ├── delay
│ │ │ │ ├── example
│ │ │ │ │ ├── Consumer.java
│ │ │ │ │ ├── DelayQueueTest.java
│ │ │ │ │ └── Message.java
│ │ │ │ └── orderexample
│ │ │ │ │ ├── DelayOrderQueueManager.java
│ │ │ │ │ ├── DelayOrderTask.java
│ │ │ │ │ ├── DelayOrderWorker.java
│ │ │ │ │ └── Test.java
│ │ │ └── loop
│ │ │ │ ├── LoopQueue.java
│ │ │ │ └── LoopQueueTest.java
│ │ │ ├── set
│ │ │ ├── BinarySearchTreeSet.java
│ │ │ ├── FileOperation.java
│ │ │ ├── LinkedListSet.java
│ │ │ ├── Set.java
│ │ │ └── SetTest.java
│ │ │ ├── stack
│ │ │ ├── ArrayStack.java
│ │ │ ├── LinkedListStack.java
│ │ │ ├── Stack.java
│ │ │ └── StackTest.java
│ │ │ ├── tree
│ │ │ ├── TreeTest.java
│ │ │ ├── balancebinarytree
│ │ │ │ ├── BalanceBinaryTree.java
│ │ │ │ └── BalanceBinaryTreeTest.java
│ │ │ ├── binarysearchtree
│ │ │ │ └── BinarySearchTree.java
│ │ │ ├── redblacktree
│ │ │ │ └── RedBlackTree.java
│ │ │ └── segmenttree
│ │ │ │ ├── Merger.java
│ │ │ │ ├── NumArrayTest.java
│ │ │ │ ├── SegmentTree.java
│ │ │ │ └── SegmentTreeTest.java
│ │ │ ├── trie
│ │ │ ├── RecursiveTrie.java
│ │ │ └── Trie.java
│ │ │ └── unionfind
│ │ │ ├── UnionFind.java
│ │ │ └── UnionFindImpl.java
│ │ └── resources
│ │ ├── a-tale-of-two-cities.txt
│ │ └── pride-and-prejudice.txt
├── deep-in-java
│ ├── doc
│ │ └── java语言基础.md
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── zj
│ │ └── dreamly
│ │ └── relearning
│ │ └── java
│ │ ├── languagefoundation
│ │ ├── FunctionMain.java
│ │ ├── GenericTypeDemo.java
│ │ ├── InnerClassDemo.java
│ │ └── LambdaDemo.java
│ │ └── oop
│ │ ├── ClassName.java
│ │ ├── CloneableDemo.java
│ │ ├── EnumClassDemo.java
│ │ ├── FunctionMain.java
│ │ ├── InnerClassDemo.java
│ │ ├── IntegerDemo.java
│ │ ├── InterfaceDemo.java
│ │ ├── SnapshotDemo.java
│ │ ├── StringDemo.java
│ │ ├── UnmodifiableInterfaceDemo.java
│ │ ├── functional
│ │ ├── ActionDemo.java
│ │ ├── ConsumerDemo.java
│ │ ├── DemoAnnotation.java
│ │ ├── DemoAnnotationDemo.java
│ │ ├── FunctionDemo.java
│ │ ├── FunctionDesignDemo.java
│ │ ├── FunctionalInterfaceDemo.java
│ │ ├── PredicateDemo.java
│ │ ├── PredicateDesignDemo.java
│ │ ├── SupplierDemo.java
│ │ ├── SupplierDesignDemo.java
│ │ └── stream
│ │ │ ├── StreamCollectDemo.java
│ │ │ └── StreamDemo.java
│ │ ├── generic
│ │ ├── ClassCastDemo.java
│ │ ├── GenericParameterTypeDemo.java
│ │ ├── GenericTypeErasureDemo.java
│ │ ├── GenericWildcardsTypeDemo.java
│ │ └── QuestionAndAnswer.java
│ │ └── method
│ │ ├── MethodArgumentsDemo.java
│ │ ├── MethodNameDemo.java
│ │ └── MethodReturnTypeDemo.java
├── design-pattern
│ ├── doc
│ │ ├── Spring实现责任链模式.md
│ │ ├── UML入门.md
│ │ ├── 文档-总-持续更新.md
│ │ ├── 设计原则.md
│ │ ├── 设计模式之创建型.md
│ │ ├── 设计模式之结构型.md
│ │ └── 设计模式之行为型.md
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── zj
│ │ └── dreamly
│ │ └── design
│ │ └── pattern
│ │ ├── pattern
│ │ ├── behavioral
│ │ │ ├── chainofresponsibility
│ │ │ │ ├── Approver.java
│ │ │ │ ├── ArticleApprover.java
│ │ │ │ ├── Course.java
│ │ │ │ ├── Test.java
│ │ │ │ ├── VideoApprover.java
│ │ │ │ ├── orderchain
│ │ │ │ │ ├── InitPrintChainPattern.java
│ │ │ │ │ ├── OnePrintChainPattern.java
│ │ │ │ │ ├── OrderChainController.java
│ │ │ │ │ ├── PrintChainPattern.java
│ │ │ │ │ ├── ThreePrintChainPattern.java
│ │ │ │ │ └── TwoPrintChainPattern.java
│ │ │ │ └── spring
│ │ │ │ │ ├── ChainController.java
│ │ │ │ │ ├── DefaultPipeline.java
│ │ │ │ │ ├── Handler.java
│ │ │ │ │ ├── HandlerBeanProcessor.java
│ │ │ │ │ ├── HandlerContext.java
│ │ │ │ │ ├── OneHandler.java
│ │ │ │ │ ├── Pipeline.java
│ │ │ │ │ ├── Request.java
│ │ │ │ │ ├── Task.java
│ │ │ │ │ ├── ThreeHandler.java
│ │ │ │ │ └── TwoHandler.java
│ │ │ ├── command
│ │ │ │ ├── CloseCourseVideoCommand.java
│ │ │ │ ├── Command.java
│ │ │ │ ├── CourseVideo.java
│ │ │ │ ├── OpenCourseVideoCommand.java
│ │ │ │ ├── Staff.java
│ │ │ │ └── Test.java
│ │ │ ├── interpreter
│ │ │ │ ├── AddInterpreter.java
│ │ │ │ ├── GeelyExpressionParser.java
│ │ │ │ ├── Interpreter.java
│ │ │ │ ├── MultiInterpreter.java
│ │ │ │ ├── NumberInterpreter.java
│ │ │ │ ├── OperatorUtil.java
│ │ │ │ ├── SpringTest.java
│ │ │ │ └── Test.java
│ │ │ ├── iterator
│ │ │ │ ├── Course.java
│ │ │ │ ├── CourseAggregate.java
│ │ │ │ ├── CourseAggregateImpl.java
│ │ │ │ ├── CourseIterator.java
│ │ │ │ ├── CourseIteratorImpl.java
│ │ │ │ └── Test.java
│ │ │ ├── mediator
│ │ │ │ ├── StudyGroup.java
│ │ │ │ ├── Test.java
│ │ │ │ └── User.java
│ │ │ ├── memento
│ │ │ │ ├── Article.java
│ │ │ │ ├── ArticleMemento.java
│ │ │ │ ├── ArticleMementoManager.java
│ │ │ │ └── Test.java
│ │ │ ├── observer
│ │ │ │ ├── Course.java
│ │ │ │ ├── Question.java
│ │ │ │ ├── Teacher.java
│ │ │ │ ├── Test.java
│ │ │ │ └── guavatest
│ │ │ │ │ ├── GuavaEvent.java
│ │ │ │ │ └── GuavaEventTest.java
│ │ │ ├── state
│ │ │ │ ├── CourseVideoContext.java
│ │ │ │ ├── CourseVideoState.java
│ │ │ │ ├── PauseState.java
│ │ │ │ ├── PlayState.java
│ │ │ │ ├── SpeedState.java
│ │ │ │ ├── StopState.java
│ │ │ │ └── Test.java
│ │ │ ├── strategy
│ │ │ │ ├── EmptyPromotionStrategy.java
│ │ │ │ ├── FanXianPromotionStrategy.java
│ │ │ │ ├── LiJianPromotionStrategy.java
│ │ │ │ ├── ManJianPromotionStrategy.java
│ │ │ │ ├── PromotionActivity.java
│ │ │ │ ├── PromotionStrategy.java
│ │ │ │ ├── PromotionStrategyFactory.java
│ │ │ │ ├── Test.java
│ │ │ │ └── spring
│ │ │ │ │ ├── FactoryForStrategy.java
│ │ │ │ │ ├── Strategy.java
│ │ │ │ │ ├── StrategyController.java
│ │ │ │ │ └── StrategyOne.java
│ │ │ ├── templatemethod
│ │ │ │ ├── ACourse.java
│ │ │ │ ├── DesignPatternCourse.java
│ │ │ │ ├── FECourse.java
│ │ │ │ └── Test.java
│ │ │ └── visitor
│ │ │ │ ├── CodingCourse.java
│ │ │ │ ├── Course.java
│ │ │ │ ├── FreeCourse.java
│ │ │ │ ├── IVisitor.java
│ │ │ │ ├── Test.java
│ │ │ │ └── Visitor.java
│ │ ├── creational
│ │ │ ├── abstractfactory
│ │ │ │ ├── Article.java
│ │ │ │ ├── CourseFactory.java
│ │ │ │ ├── JavaArticle.java
│ │ │ │ ├── JavaCourseFactory.java
│ │ │ │ ├── JavaVideo.java
│ │ │ │ ├── PythonArticle.java
│ │ │ │ ├── PythonCourseFactory.java
│ │ │ │ ├── PythonVideo.java
│ │ │ │ ├── Test.java
│ │ │ │ └── Video.java
│ │ │ ├── builder
│ │ │ │ ├── Coach.java
│ │ │ │ ├── Course.java
│ │ │ │ ├── CourseActualBuilder.java
│ │ │ │ ├── CourseBuilder.java
│ │ │ │ ├── Test.java
│ │ │ │ └── v2
│ │ │ │ │ ├── Course.java
│ │ │ │ │ └── Test.java
│ │ │ ├── factorymethod
│ │ │ │ ├── FEVideo.java
│ │ │ │ ├── FEVideoFactory.java
│ │ │ │ ├── JavaVideo.java
│ │ │ │ ├── JavaVideoFactory.java
│ │ │ │ ├── PythonVideo.java
│ │ │ │ ├── PythonVideoFactory.java
│ │ │ │ ├── Test.java
│ │ │ │ ├── Video.java
│ │ │ │ └── VideoFactory.java
│ │ │ ├── prototype
│ │ │ │ ├── Mail.java
│ │ │ │ ├── MailUtil.java
│ │ │ │ ├── Test.java
│ │ │ │ ├── abstractprototype
│ │ │ │ │ ├── A.java
│ │ │ │ │ └── B.java
│ │ │ │ └── clone
│ │ │ │ │ ├── Pig.java
│ │ │ │ │ └── Test.java
│ │ │ ├── simplefactory
│ │ │ │ ├── JavaVideo.java
│ │ │ │ ├── PythonVideo.java
│ │ │ │ ├── Test.java
│ │ │ │ ├── Video.java
│ │ │ │ └── VideoFactory.java
│ │ │ └── singleton
│ │ │ │ ├── ContainerSingleton.java
│ │ │ │ ├── EnumInstance.java
│ │ │ │ ├── HungrySingleton.java
│ │ │ │ ├── LazyDoubleCheckSingleton.java
│ │ │ │ ├── LazySingleton.java
│ │ │ │ ├── StaticInnerClassSingleton.java
│ │ │ │ ├── T.java
│ │ │ │ ├── Test.java
│ │ │ │ └── ThreadLocalInstance.java
│ │ └── structural
│ │ │ ├── adapter
│ │ │ ├── AC220.java
│ │ │ ├── DC5.java
│ │ │ ├── PowerAdapter.java
│ │ │ ├── Test.java
│ │ │ ├── classadapter
│ │ │ │ ├── Adaptee.java
│ │ │ │ ├── Adapter.java
│ │ │ │ ├── ConcreteTarget.java
│ │ │ │ ├── Target.java
│ │ │ │ └── Test.java
│ │ │ └── objectadapter
│ │ │ │ ├── Adaptee.java
│ │ │ │ ├── Adapter.java
│ │ │ │ ├── ConcreteTarget.java
│ │ │ │ ├── Target.java
│ │ │ │ └── Test.java
│ │ │ ├── bridge
│ │ │ ├── ABCBank.java
│ │ │ ├── Account.java
│ │ │ ├── Bank.java
│ │ │ ├── DepositAccount.java
│ │ │ ├── ICBCBank.java
│ │ │ ├── SavingAccount.java
│ │ │ └── Test.java
│ │ │ ├── composite
│ │ │ ├── CatalogComponent.java
│ │ │ ├── Course.java
│ │ │ ├── CourseCatalog.java
│ │ │ └── Test.java
│ │ │ ├── decorator
│ │ │ ├── v1
│ │ │ │ ├── Battercake.java
│ │ │ │ ├── BattercakeWithEgg.java
│ │ │ │ ├── BattercakeWithEggSausage.java
│ │ │ │ └── Test.java
│ │ │ └── v2
│ │ │ │ ├── ABattercake.java
│ │ │ │ ├── AbstractDecorator.java
│ │ │ │ ├── Battercake.java
│ │ │ │ ├── EggDecorator.java
│ │ │ │ ├── SausageDecorator.java
│ │ │ │ └── Test.java
│ │ │ ├── facade
│ │ │ ├── GiftExchangeService.java
│ │ │ ├── PointsGift.java
│ │ │ ├── PointsPaymentService.java
│ │ │ ├── QualifyService.java
│ │ │ ├── ShippingService.java
│ │ │ └── Test.java
│ │ │ ├── flyweight
│ │ │ ├── Employee.java
│ │ │ ├── EmployeeFactory.java
│ │ │ ├── Manager.java
│ │ │ └── Test.java
│ │ │ └── proxy
│ │ │ ├── IOrderDao.java
│ │ │ ├── IOrderService.java
│ │ │ ├── Order.java
│ │ │ ├── OrderDaoImpl.java
│ │ │ ├── OrderServiceImpl.java
│ │ │ ├── db
│ │ │ ├── DataSourceContextHolder.java
│ │ │ └── DynamicDataSource.java
│ │ │ ├── dynamicproxy
│ │ │ ├── OrderServiceDynamicProxy.java
│ │ │ └── Test.java
│ │ │ └── staticproxy
│ │ │ ├── OrderServiceStaticProxy.java
│ │ │ └── Test.java
│ │ └── principle
│ │ ├── compositionaggregation
│ │ ├── DBConnection.java
│ │ ├── MySQLConnection.java
│ │ ├── PostgreSQLConnection.java
│ │ ├── ProductDao.java
│ │ └── Test.java
│ │ ├── demeter
│ │ ├── Boss.java
│ │ ├── Course.java
│ │ ├── TeamLeader.java
│ │ └── Test.java
│ │ ├── dependenceinversion
│ │ ├── FECourse.java
│ │ ├── Geely.java
│ │ ├── ICourse.java
│ │ ├── JavaCourse.java
│ │ ├── PythonCourse.java
│ │ └── Test.java
│ │ ├── interfacesegregation
│ │ ├── Bird.java
│ │ ├── Dog.java
│ │ ├── IAnimalAction.java
│ │ ├── IEatAnimalAction.java
│ │ ├── IFlyAnimalAction.java
│ │ └── ISwimAnimalAction.java
│ │ ├── liskovsubstitution
│ │ ├── Quadrangle.java
│ │ ├── Rectangle.java
│ │ ├── Square.java
│ │ ├── Test.java
│ │ ├── methodinput
│ │ │ ├── Base.java
│ │ │ ├── Child.java
│ │ │ └── Test.java
│ │ └── methodoutput
│ │ │ ├── Base.java
│ │ │ ├── Child.java
│ │ │ └── Test.java
│ │ ├── openclose
│ │ ├── ICourse.java
│ │ ├── JavaCourse.java
│ │ ├── JavaDiscountCourse.java
│ │ └── Test.java
│ │ └── singleresponsibility
│ │ ├── Bird.java
│ │ ├── CourseImpl.java
│ │ ├── FlyBird.java
│ │ ├── ICourse.java
│ │ ├── ICourseContent.java
│ │ ├── ICourseManager.java
│ │ ├── Method.java
│ │ ├── Test.java
│ │ └── WalkBird.java
├── guava
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── github
│ │ │ └── zj
│ │ │ └── dreamly
│ │ │ └── guava
│ │ │ ├── cache
│ │ │ ├── CacheLoaderTest.java
│ │ │ ├── CacheLoaderTest2.java
│ │ │ ├── CacheLoaderTest3.java
│ │ │ ├── CacheLoaderTest4.java
│ │ │ ├── Employee.java
│ │ │ ├── ReferenceExample.java
│ │ │ └── lru
│ │ │ │ ├── LRUCache.java
│ │ │ │ ├── LinkedHashLRUCache.java
│ │ │ │ ├── LinkedListLRUCache.java
│ │ │ │ ├── SoftLRUCache.java
│ │ │ │ └── test
│ │ │ │ ├── LRUCacheExample.java
│ │ │ │ ├── LinkedHashLRUCacheExample.java
│ │ │ │ └── LinkedListLRUCacheExample.java
│ │ │ ├── collections
│ │ │ ├── BiMapExampleTest.java
│ │ │ ├── FluentIterableExampleTest.java
│ │ │ ├── ImmutableCollectionsTest.java
│ │ │ ├── ListsExampleTest.java
│ │ │ ├── MapsExampleTest.java
│ │ │ ├── MultiMapsExampleTest.java
│ │ │ ├── OrderingExampleTest.java
│ │ │ ├── RangeExampleTest.java
│ │ │ ├── SetsExampleTest.java
│ │ │ └── TableExampleTest.java
│ │ │ ├── concurrent
│ │ │ ├── Bucket.java
│ │ │ ├── ListenableFutureExample.java
│ │ │ ├── MonitorExample.java
│ │ │ ├── RateLimiterExample.java
│ │ │ ├── TokenBucket.java
│ │ │ └── test
│ │ │ │ ├── BucketExample.java
│ │ │ │ └── TokenBucketExample.java
│ │ │ ├── eventbus
│ │ │ ├── AsyncEventBusExample.java
│ │ │ ├── ComEachOtherEventBusExample.java
│ │ │ ├── DeadEventBusExample.java
│ │ │ ├── ExceptionEventBusExample.java
│ │ │ ├── InheritEventsEventBusExample.java
│ │ │ ├── InheritListenersEventBusExample.java
│ │ │ ├── MultipleEventBusExample.java
│ │ │ ├── SimpleEventBusExample.java
│ │ │ ├── events
│ │ │ │ ├── Apple.java
│ │ │ │ ├── Fruit.java
│ │ │ │ ├── Request.java
│ │ │ │ └── Response.java
│ │ │ ├── internal
│ │ │ │ ├── Bus.java
│ │ │ │ ├── MyAsyncEventBus.java
│ │ │ │ ├── MyDispatcher.java
│ │ │ │ ├── MyEventBus.java
│ │ │ │ ├── MyEventContext.java
│ │ │ │ ├── MyEventExceptionHandler.java
│ │ │ │ ├── MyRegistry.java
│ │ │ │ ├── MySubscribe.java
│ │ │ │ ├── MySubscriber.java
│ │ │ │ └── test
│ │ │ │ │ ├── MyAsyncBusExample.java
│ │ │ │ │ ├── MyEventBusExample.java
│ │ │ │ │ ├── MySimpleListener.java
│ │ │ │ │ └── MySimpleListener2.java
│ │ │ ├── listeners
│ │ │ │ ├── AbstractListener.java
│ │ │ │ ├── BaseListener.java
│ │ │ │ ├── ConcreteListener.java
│ │ │ │ ├── DeadEventListener.java
│ │ │ │ ├── ExceptionListener.java
│ │ │ │ ├── FruitEaterListener.java
│ │ │ │ ├── MultipleEventListeners.java
│ │ │ │ └── SimpleListener.java
│ │ │ ├── monitor
│ │ │ │ ├── DirectoryTargetMonitor.java
│ │ │ │ ├── FileChangeEvent.java
│ │ │ │ ├── FileChangeListener.java
│ │ │ │ ├── MonitorClient.java
│ │ │ │ └── TargetMonitor.java
│ │ │ └── service
│ │ │ │ ├── QueryService.java
│ │ │ │ └── RequestQueryHandler.java
│ │ │ ├── functional
│ │ │ └── FunctionExample.java
│ │ │ ├── io
│ │ │ ├── Base64.java
│ │ │ ├── BaseEncodingTest.java
│ │ │ ├── ByteSinkTest.java
│ │ │ ├── ByteSourceTest.java
│ │ │ ├── CharSinkTest.java
│ │ │ ├── CharSourceTest.java
│ │ │ ├── CharStreamsTest.java
│ │ │ ├── CloserTest.java
│ │ │ └── FilesTest.java
│ │ │ └── utils
│ │ │ ├── JoinerTest.java
│ │ │ ├── PreconditionsTest.java
│ │ │ ├── SplitterTest.java
│ │ │ └── StringTest.java
│ │ └── resources
│ │ └── io
│ │ ├── files.PNG
│ │ └── source.txt
├── imooc-architect
│ ├── README.md
│ └── pom.xml
├── interview
│ ├── doc
│ │ ├── 2021-3
│ │ │ └── 面试笔记.md
│ │ ├── 2121-12
│ │ │ └── README.md
│ │ ├── java-basic
│ │ │ ├── 01.float f=3.4 是否正确.md
│ │ │ ├── 02.访问修饰符 public, private, protected区别.md
│ │ │ ├── 03.final finally finalize有什么区别.md
│ │ │ ├── 04.this与super的区别.md
│ │ │ ├── 05.说一下static关键字.md
│ │ │ ├── 06.说一说封装,继承与多态.md
│ │ │ ├── 07.面向对象五大基本原则是什么.md
│ │ │ ├── 08.说一说抽象类与接口.md
│ │ │ ├── 09.Java的变量与方法的用法.md
│ │ │ ├── 10.说一说Java的内部类.md
│ │ │ ├── 11.谈一谈重载与重写的区别吧.md
│ │ │ ├── 12.Java是怎么判断两个对象相等的.md
│ │ │ ├── 13.说一说Java的值传递.md
│ │ │ ├── 14.Java的IO流.md
│ │ │ ├── 15.Java反射.md
│ │ │ └── 16.Java常用的集合类.md
│ │ ├── juc
│ │ │ ├── 1.JUC之基础入门.md
│ │ │ ├── 10.JUC之Java对象内存布局和对象头.md
│ │ │ ├── 11.JUC之Synchronized与锁升级.md
│ │ │ ├── 12.JUC之AQS.md
│ │ │ ├── 13.JUC之ReentrantReadWriteLock、StampedLock.md
│ │ │ ├── 2.JUC之CompletableFuture.md
│ │ │ ├── 3.JUC之说一说Java锁事.md
│ │ │ ├── 4.JUC之LockSupport与线程中断.md
│ │ │ ├── 5.JUC之Java内存模型JMM.md
│ │ │ ├── 6.JUC之volatile.md
│ │ │ ├── 7.JUC之CAS.md
│ │ │ ├── 8.JUC之原子操作类.md
│ │ │ └── 9.JUC之ThreadLocal.md
│ │ ├── jvm
│ │ │ ├── 1.字节码篇.md
│ │ │ ├── 2.类的加载篇.md
│ │ │ ├── 3.运行时内存篇.md
│ │ │ ├── 4.对象内存布局篇.md
│ │ │ ├── 5.执行引擎篇.md
│ │ │ ├── 6.垃圾回收篇.md
│ │ │ ├── 7.JVM性能监控篇.md
│ │ │ ├── 8.JVM性能调优案例篇.md
│ │ │ └── 题目
│ │ │ │ ├── 01.JVM的生命周期.md
│ │ │ │ ├── 02Java虚拟机中,数据类型可以分为哪几类.md
│ │ │ │ ├── 03.为什么不把基本类型放在堆中.md
│ │ │ │ ├── 04.Class 的 forName(Java.lang.String) 和 Class 的 getClassLoader() 的 loadClass(Java. lang. string”) 有什么区别?.md
│ │ │ │ ├── 05.tomcat类加载机制.md
│ │ │ │ ├── 06.既然tomcat不遵守双亲委派机制,那么自己定义了一个恶意hashmap会有风险吗.md
│ │ │ │ ├── 07.Tomcat是个web容器,那么它要解决什么问题.md
│ │ │ │ ├── 08.Tomcat 如果使用默认的类加载机制行不行.md
│ │ │ │ ├── 09.如果tomcat 的 Common ClassLoader 想加载 WebApp ClassLoader 中的类,该怎么办.md
│ │ │ │ ├── 10.为什么java文件放在EclipseIDEA中的src文件夹会优先jar包中的class.md
│ │ │ │ ├── 11.栈和堆的区别.md
│ │ │ │ ├── 12.说一说栈溢出的情况.md
│ │ │ │ ├── 13.调整栈大小,就能保证不出现溢出吗.md
│ │ │ │ ├── 14.分配的栈内存越大越好吗.md
│ │ │ │ ├── 15.垃圾回收是否会涉及到虚拟机栈.md
│ │ │ │ └── 16.方法中定义的局部变量是否线程安全.md
│ │ ├── mysql
│ │ │ └── README.md
│ │ ├── 第3季
│ │ │ ├── 00.面试大纲.md
│ │ │ ├── 01.你知道HashMap的底层数据吗.md
│ │ │ ├── 02.JDK1.8中对hash算法和寻址算法是如何优化的.md
│ │ │ ├── 03.你知道HashMap是如何解决hash碰撞问题的吗.md
│ │ │ ├── 04.说说HashMap是如何进行扩容的可以吗.md
│ │ │ ├── 05.说说synchronized关键字的底层原理是什么.md
│ │ │ ├── 06.能聊聊你对CAS的理解以及其底层实现原理可以吗.md
│ │ │ ├── 07.ConcurrentHashMap实现线程安全的底层原理到底是什么.md
│ │ │ ├── 08.如何实现一个公平锁.md
│ │ │ ├── 09.你对JDK中的AQS理解吗?AQS的实现原理是什么.md
│ │ │ ├── 10.说说线程池的底层工作原理可以吗.md
│ │ │ ├── 11.线程池的核心配置参数都是干什么的?平时我们应该怎么用 - 副本.md
│ │ │ ├── 12.如果在线程中使用无界阻塞队列会发生什么问题 - 副本.md
│ │ │ ├── 13.你知道如果线程池的队列满了之后,会发生什么事情吗.md
│ │ │ └── 14.如果线上机器突然宕机,线程池的阻塞队列中的请求怎么办.md
│ │ └── 高频汇总
│ │ │ ├── 1.Spring高频面试题.md
│ │ │ ├── 2.Redis高频面试题.md
│ │ │ └── 大厂.md
│ └── pom.xml
├── io
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── zj
│ │ └── dreamly
│ │ └── socket
│ │ ├── chatroom
│ │ ├── client
│ │ │ ├── Client.java
│ │ │ ├── ClientTest.java
│ │ │ ├── TCPClient.java
│ │ │ ├── UDPSearcher.java
│ │ │ └── bean
│ │ │ │ └── ServerInfo.java
│ │ ├── foo
│ │ │ ├── Foo.java
│ │ │ └── constants
│ │ │ │ ├── TCPConstants.java
│ │ │ │ └── UDPConstants.java
│ │ ├── library
│ │ │ ├── box
│ │ │ │ ├── AbsByteArrayReceivePacket.java
│ │ │ │ ├── BytesReceivePacket.java
│ │ │ │ ├── BytesSendPacket.java
│ │ │ │ ├── FileReceivePacket.java
│ │ │ │ ├── FileSendPacket.java
│ │ │ │ ├── StringReceivePacket.java
│ │ │ │ └── StringSendPacket.java
│ │ │ ├── core
│ │ │ │ ├── Connector.java
│ │ │ │ ├── Frame.java
│ │ │ │ ├── IoArgs.java
│ │ │ │ ├── IoContext.java
│ │ │ │ ├── IoProvider.java
│ │ │ │ ├── Packet.java
│ │ │ │ ├── ReceiveDispatcher.java
│ │ │ │ ├── ReceivePacket.java
│ │ │ │ ├── Receiver.java
│ │ │ │ ├── SendDispatcher.java
│ │ │ │ ├── SendPacket.java
│ │ │ │ ├── Sender.java
│ │ │ │ └── ds
│ │ │ │ │ └── BytePriorityNode.java
│ │ │ ├── frames
│ │ │ │ ├── AbsReceiveFrame.java
│ │ │ │ ├── AbsSendFrame.java
│ │ │ │ ├── AbsSendPacketFrame.java
│ │ │ │ ├── CancelReceiveFrame.java
│ │ │ │ ├── CancelSendFrame.java
│ │ │ │ ├── ReceiveEntityFrame.java
│ │ │ │ ├── ReceiveFrameFactory.java
│ │ │ │ ├── ReceiveHeaderFrame.java
│ │ │ │ ├── SendEntityFrame.java
│ │ │ │ └── SendHeaderFrame.java
│ │ │ ├── impl
│ │ │ │ ├── IoSelectorProvider.java
│ │ │ │ ├── SocketChannelAdapter.java
│ │ │ │ └── async
│ │ │ │ │ ├── AsyncPacketReader.java
│ │ │ │ │ ├── AsyncPacketWriter.java
│ │ │ │ │ ├── AsyncReceiveDispatcher.java
│ │ │ │ │ └── AsyncSendDispatcher.java
│ │ │ └── utils
│ │ │ │ ├── ByteUtils.java
│ │ │ │ └── CloseUtils.java
│ │ └── server
│ │ │ ├── Server.java
│ │ │ ├── TCPServer.java
│ │ │ ├── UDPProvider.java
│ │ │ └── handle
│ │ │ └── ClientHandler.java
│ │ └── demo
│ │ ├── Client.java
│ │ └── Server.java
├── jdk8
│ ├── pom.xml
│ ├── res
│ │ ├── nashorn1.js
│ │ ├── nashorn10.js
│ │ ├── nashorn2.js
│ │ ├── nashorn3.js
│ │ ├── nashorn4.js
│ │ ├── nashorn5.js
│ │ ├── nashorn6.js
│ │ ├── nashorn7.js
│ │ ├── nashorn8.js
│ │ └── nashorn9.js
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── zj
│ │ └── dreamly
│ │ └── java8
│ │ ├── concurrent
│ │ ├── Atomic1.java
│ │ ├── CompletableFuture1.java
│ │ ├── ConcurrentHashMap1.java
│ │ ├── ConcurrentUtils.java
│ │ ├── Executors1.java
│ │ ├── Executors2.java
│ │ ├── Executors3.java
│ │ ├── Lock1.java
│ │ ├── Lock2.java
│ │ ├── Lock3.java
│ │ ├── Lock4.java
│ │ ├── Lock5.java
│ │ ├── Lock6.java
│ │ ├── LongAccumulator1.java
│ │ ├── LongAdder1.java
│ │ ├── Semaphore1.java
│ │ ├── Semaphore2.java
│ │ ├── Synchronized1.java
│ │ ├── Synchronized2.java
│ │ └── Threads1.java
│ │ ├── lambda
│ │ ├── Interface1.java
│ │ ├── Lambda1.java
│ │ ├── Lambda2.java
│ │ ├── Lambda3.java
│ │ ├── Lambda4.java
│ │ ├── Lambda5.java
│ │ └── Person.java
│ │ ├── misc
│ │ ├── Annotations1.java
│ │ ├── CheckedFunctions.java
│ │ ├── Concurrency1.java
│ │ ├── Files1.java
│ │ ├── Maps1.java
│ │ ├── Math1.java
│ │ └── String1.java
│ │ ├── nashorn
│ │ ├── Nashorn1.java
│ │ ├── Nashorn10.java
│ │ ├── Nashorn11.java
│ │ ├── Nashorn2.java
│ │ ├── Nashorn3.java
│ │ ├── Nashorn4.java
│ │ ├── Nashorn5.java
│ │ ├── Nashorn6.java
│ │ ├── Nashorn7.java
│ │ ├── Nashorn8.java
│ │ ├── Nashorn9.java
│ │ ├── Product.java
│ │ └── SuperRunner.java
│ │ ├── snippets
│ │ ├── Snippets.java
│ │ └── SnippetsTests.java
│ │ ├── stream
│ │ ├── Optional1.java
│ │ ├── Optional2.java
│ │ ├── Reduce.java
│ │ ├── Streams1.java
│ │ ├── Streams10.java
│ │ ├── Streams11.java
│ │ ├── Streams12.java
│ │ ├── Streams13.java
│ │ ├── Streams2.java
│ │ ├── Streams3.java
│ │ ├── Streams4.java
│ │ ├── Streams5.java
│ │ ├── Streams6.java
│ │ ├── Streams7.java
│ │ ├── Streams8.java
│ │ └── Streams9.java
│ │ └── time
│ │ ├── LocalDate1.java
│ │ ├── LocalDateTime1.java
│ │ └── LocalTime1.java
├── juc
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── atguigu
│ │ └── juc
│ │ ├── Juc2021Application.java
│ │ ├── aqs
│ │ └── AQSDemo.java
│ │ ├── atomics
│ │ ├── AtomicIntegerArrayDemo.java
│ │ ├── AtomicIntegerDemo.java
│ │ ├── AtomicIntegerFieldUpdaterDemo.java
│ │ ├── AtomicMarkableReferenceDemo.java
│ │ ├── AtomicReferenceDemo.java
│ │ ├── AtomicReferenceFieldUpdaterDemo.java
│ │ ├── LongAdderAPIDemo.java
│ │ └── LongAdderCalcDemo.java
│ │ ├── bashthread
│ │ └── DaemonDemo.java
│ │ ├── cas
│ │ ├── ABADemo.java
│ │ ├── AtomicReferenceDemo.java
│ │ ├── CASDemo.java
│ │ └── SpinLockDemo.java
│ │ ├── cf
│ │ ├── CompletableFutureAPIDemo.java
│ │ ├── CompletableFutureDemo.java
│ │ ├── CompletableFutureNetMallDemo.java
│ │ └── FutureTaskDemo.java
│ │ ├── interrupt
│ │ ├── InterruptDemo.java
│ │ ├── LockSupportDemo.java
│ │ └── T1.java
│ │ ├── jmm
│ │ ├── SafeDoubleCheckSingleton.java
│ │ ├── SingletonDemo.java
│ │ ├── VolatileNoAtomicDemo.java
│ │ └── VolatileSeeDemo.java
│ │ ├── locks
│ │ ├── DeadLockDemo.java
│ │ ├── Lock8Demo.java
│ │ ├── LockByteCodeDemo.java
│ │ ├── ReEntryLockDemo.java
│ │ └── SaleTicketDemo.java
│ │ ├── lockupgrade
│ │ ├── LockBigDemo.java
│ │ ├── LockClearUPDemo.java
│ │ ├── LockUpgradeDemo.java
│ │ ├── MyObject.java
│ │ └── SaleTicketDemo.java
│ │ ├── objecthead
│ │ └── ObjectHeadDemo.java
│ │ ├── rwlock
│ │ ├── LockDownGradingDemo.java
│ │ ├── ReentrantReadWriteLockDemo.java
│ │ └── StampedLockDemo.java
│ │ ├── test
│ │ ├── Book.java
│ │ └── T1.java
│ │ └── tl
│ │ ├── ReferenceDemo.java
│ │ ├── ThreadLocalDateUtils.java
│ │ └── ThreadLocalDemo.java
├── jvm
│ ├── chapter008_tuning
│ │ ├── HELP.md
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── atguigu
│ │ │ │ │ └── demo
│ │ │ │ │ ├── DemoApplication.java
│ │ │ │ │ ├── bean
│ │ │ │ │ └── People.java
│ │ │ │ │ ├── controller
│ │ │ │ │ └── MemoryTestController.java
│ │ │ │ │ ├── mapper
│ │ │ │ │ └── PeopleMapper.java
│ │ │ │ │ └── service
│ │ │ │ │ └── PeopleSevice.java
│ │ │ └── resources
│ │ │ │ ├── application-dev.yml
│ │ │ │ ├── application.yml
│ │ │ │ └── mapping
│ │ │ │ └── PeopleMapper.xml
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── atguigu
│ │ │ └── demo
│ │ │ └── DemoApplicationTests.java
│ ├── chapter01_bytecode
│ │ └── src
│ │ │ └── com
│ │ │ └── atguigu
│ │ │ ├── java
│ │ │ ├── ByteCodeInterview.java
│ │ │ ├── ByteCodeInterview1.java
│ │ │ ├── ClassInstanceTest.java
│ │ │ └── ValueTransfer1.java
│ │ │ ├── java1
│ │ │ ├── ArrayTest.java
│ │ │ ├── Demo.java
│ │ │ └── MethodInvokeTest.java
│ │ │ ├── java2
│ │ │ ├── ArithmeticTest.java
│ │ │ ├── ClassCastTest.java
│ │ │ ├── ExceptionTest.java
│ │ │ ├── IfSwitchGotoTest.java
│ │ │ ├── InterfaceMethodTest.java
│ │ │ ├── LoadAndStoreTest.java
│ │ │ ├── MethodInvokeReturnTest.java
│ │ │ ├── NewTest.java
│ │ │ ├── StackOperateTest.java
│ │ │ └── SynchronizedTest.java
│ │ │ └── java3
│ │ │ └── InterviewTest.java
│ ├── chapter02_classload
│ │ ├── order.dat
│ │ └── src
│ │ │ ├── com
│ │ │ └── atguigu
│ │ │ │ ├── java
│ │ │ │ ├── InitializationTest.java
│ │ │ │ ├── InitializationTest1.java
│ │ │ │ ├── InitializationTest2.java
│ │ │ │ ├── StaticDeadLockMain.java
│ │ │ │ └── SubInitialization.java
│ │ │ │ ├── java1
│ │ │ │ ├── ActiveUse1.java
│ │ │ │ ├── ActiveUse2.java
│ │ │ │ ├── ActiveUse3.java
│ │ │ │ ├── PassiveUse1.java
│ │ │ │ └── PassiveUse2.java
│ │ │ │ ├── java2
│ │ │ │ ├── LeafTest.java
│ │ │ │ ├── T.java
│ │ │ │ ├── Test.java
│ │ │ │ └── Test03.java
│ │ │ │ └── java3
│ │ │ │ ├── ClassLoaderTest.java
│ │ │ │ ├── User.java
│ │ │ │ ├── UserClassLoader.java
│ │ │ │ └── UserDefineClassLoader.java
│ │ │ └── java
│ │ │ └── lang
│ │ │ ├── String.java
│ │ │ └── StringTest.java
│ ├── chapter03_runtimearea
│ │ └── src
│ │ │ └── com
│ │ │ └── atguigu
│ │ │ ├── heap
│ │ │ ├── HeapInstanceTest.java
│ │ │ ├── HeapSpaceInitial.java
│ │ │ ├── OOMTest.java
│ │ │ └── YoungOldAreaTest.java
│ │ │ ├── heap1
│ │ │ ├── GCTest.java
│ │ │ └── TLABArgsTest.java
│ │ │ ├── methodarea
│ │ │ ├── MethodAreaDemo.java
│ │ │ ├── OOMTest.java
│ │ │ ├── StaticFieldTest.java
│ │ │ └── StringLocationTest.java
│ │ │ └── stack
│ │ │ ├── LocalVariableThreadSafe.java
│ │ │ ├── LocalVariablesTest.java
│ │ │ ├── OperandStackTest.java
│ │ │ ├── ReturnAddressTest.java
│ │ │ └── StackErrorTest.java
│ ├── chapter04_object
│ │ └── src
│ │ │ └── com
│ │ │ └── atguigu
│ │ │ └── java
│ │ │ ├── Customer.java
│ │ │ ├── CustomerTest.java
│ │ │ └── ObjectTest.java
│ ├── chapter05_executionengine
│ │ └── src
│ │ │ └── com
│ │ │ └── atguigu
│ │ │ └── java
│ │ │ └── IntCompTest.java
│ ├── chapter06_gc
│ │ └── src
│ │ │ └── com
│ │ │ └── atguigu
│ │ │ ├── ari
│ │ │ └── RefCountGC.java
│ │ │ ├── gclog
│ │ │ ├── GCLogTest.java
│ │ │ ├── GCLogTest1.java
│ │ │ └── GCUseTest.java
│ │ │ ├── other
│ │ │ ├── FinalizeObj.java
│ │ │ ├── MemoryLeak.java
│ │ │ ├── MemoryLeak1.java
│ │ │ ├── MemoryLeak2.java
│ │ │ └── SystemGCTest.java
│ │ │ └── other1
│ │ │ ├── PhantomReferenceTest.java
│ │ │ ├── SoftReferenceTest.java
│ │ │ ├── StrongReferenceTest.java
│ │ │ └── WeakReferenceTest.java
│ ├── chapter07_monitoring
│ │ └── src
│ │ │ └── com
│ │ │ └── atguigu
│ │ │ ├── arthas
│ │ │ ├── ArthasTest.java
│ │ │ ├── OOMTest.java
│ │ │ └── ThreadDeadLock.java
│ │ │ ├── jmap
│ │ │ └── GCTest.java
│ │ │ ├── jprofiler
│ │ │ ├── JProfilerTest.java
│ │ │ ├── OOMTest.java
│ │ │ └── ThreadDeadLock.java
│ │ │ ├── jps
│ │ │ └── JPSTest.java
│ │ │ ├── jstack
│ │ │ ├── AllStackTrace.java
│ │ │ ├── ThreadDeadLock.java
│ │ │ ├── ThreadSyncTest.java
│ │ │ └── TreadSleepTest.java
│ │ │ └── jstat
│ │ │ ├── GCTest.java
│ │ │ └── ScannerTest.java
│ ├── chatper08_tuning
│ │ └── src
│ │ │ └── com
│ │ │ └── atguigu
│ │ │ ├── adaptive
│ │ │ └── AdaptiveSizePolicyTest.java
│ │ │ ├── cpu
│ │ │ └── JstackDeadLockDemo.java
│ │ │ ├── escape
│ │ │ ├── EscapeAnalysis.java
│ │ │ ├── ScalarReplace.java
│ │ │ ├── StackAllocation.java
│ │ │ └── SynchronizedTest.java
│ │ │ └── oom
│ │ │ ├── OOMTest.java
│ │ │ └── TestNativeOutOfMemoryError.java
│ └── pom.xml
├── kafka
│ ├── doc
│ │ └── README.md
│ └── pom.xml
├── netty
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── github
│ │ │ └── zj
│ │ │ └── dreamly
│ │ │ └── netty
│ │ │ ├── bio
│ │ │ └── BIOServer.java
│ │ │ ├── netty
│ │ │ ├── client
│ │ │ │ ├── ClientV0.java
│ │ │ │ ├── ClientV1.java
│ │ │ │ ├── ClientV2.java
│ │ │ │ ├── codec
│ │ │ │ │ ├── OperationToRequestMessageEncoder.java
│ │ │ │ │ ├── OrderFrameDecoder.java
│ │ │ │ │ ├── OrderFrameEncoder.java
│ │ │ │ │ ├── OrderProtocolDecoder.java
│ │ │ │ │ └── OrderProtocolEncoder.java
│ │ │ │ └── handler
│ │ │ │ │ ├── ClientIdleCheckHandler.java
│ │ │ │ │ ├── KeepaliveHandler.java
│ │ │ │ │ └── dispatcher
│ │ │ │ │ ├── OperationResultFuture.java
│ │ │ │ │ ├── RequestPendingCenter.java
│ │ │ │ │ └── ResponseDispatcherHandler.java
│ │ │ ├── common
│ │ │ │ ├── Message.java
│ │ │ │ ├── MessageBody.java
│ │ │ │ ├── MessageHeader.java
│ │ │ │ ├── Operation.java
│ │ │ │ ├── OperationResult.java
│ │ │ │ ├── OperationType.java
│ │ │ │ ├── RequestMessage.java
│ │ │ │ ├── ResponseMessage.java
│ │ │ │ ├── auth
│ │ │ │ │ ├── AuthOperation.java
│ │ │ │ │ └── AuthOperationResult.java
│ │ │ │ ├── keepalive
│ │ │ │ │ ├── KeepaliveOperation.java
│ │ │ │ │ └── KeepaliveOperationResult.java
│ │ │ │ └── order
│ │ │ │ │ ├── OrderOperation.java
│ │ │ │ │ └── OrderOperationResult.java
│ │ │ ├── server
│ │ │ │ ├── Server.java
│ │ │ │ ├── codec
│ │ │ │ │ ├── OrderFrameDecoder.java
│ │ │ │ │ ├── OrderFrameEncoder.java
│ │ │ │ │ ├── OrderProtocolDecoder.java
│ │ │ │ │ └── OrderProtocolEncoder.java
│ │ │ │ └── handler
│ │ │ │ │ ├── AuthHandler.java
│ │ │ │ │ ├── MetricsHandler.java
│ │ │ │ │ ├── OrderServerProcessHandler.java
│ │ │ │ │ └── ServerIdleCheckHandler.java
│ │ │ └── util
│ │ │ │ ├── IdUtil.java
│ │ │ │ └── JsonUtil.java
│ │ │ └── nio
│ │ │ ├── BasicBuffer.java
│ │ │ ├── MappedByteBufferTest.java
│ │ │ ├── NIOByteBufferPutGet.java
│ │ │ ├── NIOClient.java
│ │ │ ├── NIOFileChannel01.java
│ │ │ ├── NIOFileChannel02.java
│ │ │ ├── NIOFileChannel03.java
│ │ │ ├── NIOFileChannel04.java
│ │ │ ├── NIOServer.java
│ │ │ ├── ReadOnlyBuffer.java
│ │ │ ├── ScatteringAndGatheringTest.java
│ │ │ ├── groupchat
│ │ │ ├── GroupChatClient.java
│ │ │ └── GroupChatServer.java
│ │ │ └── zerocopy
│ │ │ ├── NewIOClient.java
│ │ │ ├── NewIOServer.java
│ │ │ ├── OldIOClient.java
│ │ │ └── OldIOServer.java
│ │ └── resources
│ │ ├── leakDetect.txt
│ │ ├── log4j.properties
│ │ └── ssl.txt
├── pom.xml
├── redis
│ ├── doc
│ │ └── Redis入门.md
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── atguigu
│ │ └── redis
│ │ ├── Redis20210511Application.java
│ │ ├── config
│ │ ├── RedisConfig.java
│ │ └── SwaggerConfig.java
│ │ ├── controller
│ │ ├── ArticleController.java
│ │ ├── GeoController.java
│ │ ├── HyperLogLogController.java
│ │ └── UserController.java
│ │ ├── entities
│ │ ├── Order.java
│ │ ├── Product.java
│ │ ├── User.java
│ │ └── UserDTO.java
│ │ ├── mapper
│ │ └── UserMapper.java
│ │ ├── service
│ │ ├── ArticleService.java
│ │ ├── HyperLogLogService.java
│ │ └── UserService.java
│ │ └── util
│ │ └── Constants.java
├── rocketmq
│ ├── doc
│ │ ├── RocketMQ.md
│ │ └── RocketMQ用户指南v3.2.4.pdf
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── imooc
│ │ └── jiangzh
│ │ └── kafka
│ │ ├── KafkaStudyApplication.java
│ │ ├── admin
│ │ └── AdminSample.java
│ │ ├── consumer
│ │ ├── ConsumerRecordThreadSample.java
│ │ ├── ConsumerSample.java
│ │ └── ConsumerThreadSample.java
│ │ ├── producer
│ │ ├── ProducerSample.java
│ │ └── SamplePartition.java
│ │ ├── stream
│ │ └── StreamSample.java
│ │ └── wechat
│ │ ├── common
│ │ ├── BaseResponseVO.java
│ │ └── CorsFilter.java
│ │ ├── conf
│ │ ├── KafkaConf.java
│ │ ├── KafkaProperties.java
│ │ └── WechatTemplateProperties.java
│ │ ├── controller
│ │ └── WechatTemplateController.java
│ │ ├── service
│ │ ├── WechatTemplateService.java
│ │ └── WechatTemplateServiceImpl.java
│ │ └── utils
│ │ └── FileUtils.java
├── skill
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── zj
│ │ └── dreamly
│ │ └── skill
│ │ └── AllLearningApplication.java
├── spring-annotation
│ ├── doc
│ │ ├── Spring注解总结.md
│ │ └── springIOC初始化之refresh方法分析.md
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── github
│ │ │ │ └── zj
│ │ │ │ └── dreamly
│ │ │ │ └── spring
│ │ │ │ └── annotation
│ │ │ │ ├── aop
│ │ │ │ ├── LogAspect.java
│ │ │ │ └── MathCalculator.java
│ │ │ │ ├── bean
│ │ │ │ ├── Blue.java
│ │ │ │ ├── Boss.java
│ │ │ │ ├── Car.java
│ │ │ │ ├── Cat.java
│ │ │ │ ├── Color.java
│ │ │ │ ├── ColorFactoryBean.java
│ │ │ │ ├── Dog.java
│ │ │ │ ├── MyBeanPostProcessor.java
│ │ │ │ ├── Person.java
│ │ │ │ ├── RainBow.java
│ │ │ │ ├── Red.java
│ │ │ │ └── Yellow.java
│ │ │ │ ├── condition
│ │ │ │ ├── LinuxCondition.java
│ │ │ │ ├── MyImportBeanDefinitionRegistrar.java
│ │ │ │ ├── MyImportSelector.java
│ │ │ │ └── WindowsCondition.java
│ │ │ │ ├── config
│ │ │ │ ├── TestConfig1.java
│ │ │ │ ├── TestConfig2.java
│ │ │ │ ├── TestConfigOfAop.java
│ │ │ │ ├── TestConfigOfAutowired.java
│ │ │ │ ├── TestConfigOfLifeCycle.java
│ │ │ │ └── TestConfigOfPropertyValue.java
│ │ │ │ ├── controller
│ │ │ │ └── BookController.java
│ │ │ │ ├── dao
│ │ │ │ └── BookDao.java
│ │ │ │ ├── ext
│ │ │ │ ├── ExtConfig.java
│ │ │ │ ├── MyApplicationListener.java
│ │ │ │ ├── MyBeanDefinitionRegistryPostProcessor.java
│ │ │ │ ├── MyBeanFactoryPostProcessor.java
│ │ │ │ └── UserService.java
│ │ │ │ ├── filter
│ │ │ │ └── MyTypeFilter.java
│ │ │ │ ├── service
│ │ │ │ └── BookService.java
│ │ │ │ └── tx
│ │ │ │ ├── TxConfig.java
│ │ │ │ ├── UserDao.java
│ │ │ │ └── UserService.java
│ │ └── resources
│ │ │ └── person.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── zj
│ │ └── dreamly
│ │ └── spring
│ │ └── annotation
│ │ ├── BaseTest.java
│ │ ├── aop
│ │ └── TestAop.java
│ │ ├── ext
│ │ └── ExtTest.java
│ │ ├── ioc
│ │ ├── IocTest1.java
│ │ ├── IocTest2.java
│ │ ├── IocTestAutowired.java
│ │ ├── IocTestLifeCycle.java
│ │ └── IocTestPropertyValue.java
│ │ └── tx
│ │ └── TxTest.java
├── spring-thinking
│ ├── doc
│ │ └── README.md
│ └── pom.xml
├── util
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ ├── KmpDomain.java
│ │ └── KmpUtil.java
└── zookeeper
│ ├── doc
│ └── doc.md
│ ├── pom.xml
│ └── src
│ └── main
│ └── java
│ └── com
│ └── github
│ └── zj
│ └── dreamly
│ └── zookeeper
│ ├── countdown
│ ├── CheckStartUp.java
│ ├── DangerCenter.java
│ ├── StationBeijingIMooc.java
│ ├── StationJiangsuSanling.java
│ └── StationShandongChangchuan.java
│ ├── curator
│ ├── CuratorAcl.java
│ ├── CuratorOperator.java
│ ├── MyCuratorWatcher.java
│ ├── MyWatcher.java
│ ├── checkConfig
│ │ ├── Client1.java
│ │ ├── Client2.java
│ │ └── Client3.java
│ └── utils
│ │ ├── AclUtils.java
│ │ ├── JsonUtils.java
│ │ ├── RedisConfig.java
│ │ └── RedisConfig.json
│ ├── utils
│ └── AclUtils.java
│ └── zk
│ └── demo
│ ├── Children2CallBack.java
│ ├── ChildrenCallBack.java
│ ├── CreateCallBack.java
│ ├── DeleteCallBack.java
│ ├── ZKConnect.java
│ ├── ZKConnectSessionWatcher.java
│ ├── ZKGetChildrenList.java
│ ├── ZKGetNodeData.java
│ ├── ZKNodeAcl.java
│ ├── ZKNodeExist.java
│ └── ZKNodeOperator.java
├── mini-program
├── README.md
└── pom.xml
├── my-work-doc
├── README.md
├── android
│ └── Android项目导入报错解决.md
├── blog
│ └── 发布Jar包到中央仓库.md
├── bt
│ ├── 宝塔常用指令.md
│ ├── 宝塔配置反向代理.jpg
│ ├── 宝塔默认账户密码.png
│ ├── 脚本.md
│ └── 配置反向代理.png
├── docker
│ ├── SpringBoot项目使用docker快速部署.md
│ ├── docker常用指令.md
│ ├── docker服务器、以及容器设置自动启动.md
│ ├── docker部署前后端分离项目.md
│ ├── 笔记总结.md
│ └── 自己整理的命令.md
├── dubbo
│ └── temp
├── git
│ ├── Git commit comment 汇总标准.md
│ ├── Github搜索技巧.md
│ ├── git clone 时显示Filename too long的解决办法.md
│ ├── git 回滚.md
│ ├── git撤销add操作.md
│ └── 一个项目push到多个远程Git仓库.md
├── idea
│ ├── properties文件Unicode编码怎么办.md
│ └── 常用插件.md
├── image
│ ├── Lusifer_201904010001.png
│ ├── Lusifer_201904010002.png
│ ├── Lusifer_201904010003.png
│ ├── Lusifer_2019040104250001.png
│ └── Lusifer_2019040104270001.png
├── linux
│ ├── Linux常用指令.md
│ └── Llinux安装jdk.md
├── mq
│ └── rabbitmq学习.md
├── mysql
│ ├── MySQL的四种事务隔离级别.md
│ ├── MySql指令总结.md
│ ├── MySql数据库设计.md
│ ├── MySql进阶.md
│ ├── mysql大文件导入失败问题.md
│ ├── mysql集群方案.md
│ └── 自己平时做项目写的一些sql语句.md
├── netty
│ └── netty.md
├── nginx
│ ├── nginx做转发时,带'_'的header内容丢失.md
│ └── nginx安装.md
├── other
│ ├── 乐观锁和悲观锁.md
│ └── 技术名词.md
├── personal
│ └── 2022年6月17日.md
├── pit
│ └── 踩过的坑坑.md
├── pom.xml
├── redis
│ └── redis安装.md
├── springboot
│ ├── SpringBoot-Security和restfulAPI.md
│ ├── pom配置阿里私服及打包.md
│ ├── springboot启动读取外部配置文件.md
│ ├── 启动示例.md
│ └── 跨域配置.md
├── springcloud
│ └── SpringCloud学习笔记.md
├── springsecurity
│ ├── spring-security-oAuth2.md
│ └── spring-security.md
├── swagger
│ └── swagger2 注解整体说明.md
├── vue
│ ├── Vue生命周期函数.md
│ ├── npm切换registry.md
│ ├── vscode格式化代码.md
│ ├── vue关闭严格检查模式.md
│ ├── 安装CNPM.md
│ └── 安装vue-cli时报错解决方法.md
└── 随笔流水.md
├── nginx
├── README.md
└── pom.xml
├── pom.xml
└── python
└── 01.入门
├── 01.基本概念.py
├── 02.基本语法.py
├── 03.变量和标识符.py
├── 04.数值.py
├── 05.字符串.py
├── 06.格式化字符串.py
├── 07.复制字符串.py
├── 08.布尔值和空值.py
├── 09.类型检查.py
├── 10.类型转换.py
├── 11.算术运算符.py
├── 12.赋值运算符.py
├── 13.关系运算符.py
├── 14.逻辑运算符.py
├── 15.条件运算符.py
└── 16.运算符的优先级.py
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | # 空格替代Tab缩进在各种编辑工具下效果一致
5 | [*]
6 | indent_style = space
7 | indent_size = 4
8 | charset = utf-8
9 | end_of_line = lf
10 | trim_trailing_whitespace = true
11 | insert_final_newline = true
12 |
13 | [*.java]
14 | indent_style = tab
15 |
16 | [*.{json,yml}]
17 | indent_size = 2
18 |
19 | [*.md]
20 | insert_final_newline = false
21 | trim_trailing_whitespace = false
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # maven #
2 | target
3 |
4 | logs
5 |
6 | # windows #
7 | Thumbs.db
8 |
9 | # Mac #
10 | .DS_Store
11 |
12 | # eclipse #
13 | .settings
14 | .project
15 | .classpath
16 | .log
17 | *.class
18 |
19 | # idea #
20 | .idea
21 | *.iml
22 |
23 | # Package Files #
24 | *.jar
25 | *.war
26 | *.ear
27 | /target
28 |
--------------------------------------------------------------------------------
/basic/PrinciplesofComputerOrganization/README.md:
--------------------------------------------------------------------------------
1 | - 奇校验码:整个校验码(有效信息位和校验位)中”1“的个数为奇数
2 | - 偶校验码:整个校验码(有效信息位和校验位)中”1“的个数为偶数
--------------------------------------------------------------------------------
/database/mongodb/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | database
7 | com.github.zj.dreamly
8 | 1.2.1
9 |
10 | 4.0.0
11 |
12 | mongodb
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/database/mysql/使用/9.联合查询.md:
--------------------------------------------------------------------------------
1 | # 联合查询
2 |
3 | ## 语法
4 |
5 | ```mysql
6 | 查询语句1
7 | union
8 | 查询语句2
9 | union
10 | ...
11 | ```
12 |
13 | ## 应用场景
14 |
15 | - 要查询的结果来自于多个表,且多个表没有直接的连接关系,但查询的信息一致时
16 |
17 | ## 特点
18 |
19 | - 要求多条查询语句的查询列数是一致的!
20 | - 要求多条查询语句的查询的每一列的类型和顺序最好一致
21 | - union 关键字默认去重,如果使用 union all 可以包含重复项
22 |
23 | ## 案例
24 |
25 | ### 查询部门编号>90或邮箱包含a的员工信息
26 |
27 | ```mysql
28 | SELECT * FROM employees WHERE email LIKE '%a%'
29 | UNION
30 | SELECT * FROM employees WHERE department_id>90;
31 | ```
32 |
33 | ### 查询中国用户中男性的信息以及外国用户中年男性的用户信息
34 |
35 | ```mysql
36 | SELECT id,cname FROM t_ca WHERE csex='男'
37 | UNION ALL
38 | SELECT t_id,tname FROM t_ua WHERE tGender='male';
39 | ```
40 |
41 |
--------------------------------------------------------------------------------
/java/algorithm/src/main/java/com/github/zj/dreamly/algorithm/doc/2.动态数组.md:
--------------------------------------------------------------------------------
1 | # 动态数组
--------------------------------------------------------------------------------
/java/concurrent/doc/Executor框架详细介绍.md:
--------------------------------------------------------------------------------
1 | - Executor
2 | - ThreadPoolExecutor
3 | - Future&Callable
4 | - CompletionService
5 | - ScheduledExecutorService
6 | - ExecutorService
7 | - ThreadFactory
8 | - CompletableFuture
9 |
--------------------------------------------------------------------------------
/java/concurrent/doc/并发之原子类型.md:
--------------------------------------------------------------------------------
1 | - AtomicInteger
2 | - AtomicBoolean
3 | - AtomicLong
4 | - AtomicReference
5 | - AtomicStampedReference
6 | - AtomicIntegerArray
7 | - AtomicLongArray
8 | - AtomicReferenceArray
9 | - Unsafe
10 |
--------------------------------------------------------------------------------
/java/concurrent/doc/并发之工具包.md:
--------------------------------------------------------------------------------
1 | - CountDownLatch
2 | - CyclicBarrier
3 | - Exchanger
4 | - Semaphore
5 | - Lock
6 | - ReadWriteLock
7 | - ForkJoin
8 | - Phaser
9 |
--------------------------------------------------------------------------------
/java/concurrent/image/11.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/11.jpg
--------------------------------------------------------------------------------
/java/concurrent/image/1537329735402.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/1537329735402.png
--------------------------------------------------------------------------------
/java/concurrent/image/19.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/19.jpg
--------------------------------------------------------------------------------
/java/concurrent/image/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/2.jpg
--------------------------------------------------------------------------------
/java/concurrent/image/20180502173012969.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/20180502173012969.png
--------------------------------------------------------------------------------
/java/concurrent/image/201805051421294.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/201805051421294.png
--------------------------------------------------------------------------------
/java/concurrent/image/24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/24.png
--------------------------------------------------------------------------------
/java/concurrent/image/25.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/25.png
--------------------------------------------------------------------------------
/java/concurrent/image/26.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/26.png
--------------------------------------------------------------------------------
/java/concurrent/image/27.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/27.png
--------------------------------------------------------------------------------
/java/concurrent/image/325120-810222c987209828.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/325120-810222c987209828.jpg
--------------------------------------------------------------------------------
/java/concurrent/image/325120-82daf8a71caae552.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/325120-82daf8a71caae552.jpg
--------------------------------------------------------------------------------
/java/concurrent/image/325120-bc5c8371e69048d4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/325120-bc5c8371e69048d4.jpg
--------------------------------------------------------------------------------
/java/concurrent/image/325120-eec3a6a29903a918.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/concurrent/image/325120-eec3a6a29903a918.jpg
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/active/ActiveObject.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.active;
2 |
3 | /**
4 | * 接受异步消息的主动对象
5 | *
6 | * @author 苍海之南
7 | */
8 | public interface ActiveObject {
9 |
10 | Result makeString(int count, char fillChar);
11 |
12 | void displayString(String text);
13 | }
14 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/active/ActiveObjectFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.active;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public final class ActiveObjectFactory {
7 |
8 | private ActiveObjectFactory() {
9 | }
10 |
11 | public static ActiveObject createActiveObject() {
12 | Servant servant = new Servant();
13 | ActivationQueue queue = new ActivationQueue();
14 | SchedulerThread schedulerThread = new SchedulerThread(queue);
15 | ActiveObjectProxy proxy = new ActiveObjectProxy(schedulerThread, servant);
16 | schedulerThread.start();
17 | return proxy;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/active/DisplayStringRequest.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.active;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class DisplayStringRequest extends MethodRequest {
7 |
8 | private final String text;
9 |
10 | public DisplayStringRequest(Servant servant, final String text) {
11 | super(servant, null);
12 | this.text = text;
13 | }
14 |
15 | @Override
16 | public void execute() {
17 | this.servant.displayString(text);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/active/MethodRequest.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.active;
2 |
3 | /**
4 | * 对应ActiveObject的每一个方法
5 | *
6 | * @author 苍海之南
7 | */
8 | public abstract class MethodRequest {
9 |
10 | protected final Servant servant;
11 |
12 | protected final FutureResult futureResult;
13 |
14 | public MethodRequest(Servant servant, FutureResult futureResult) {
15 | this.servant = servant;
16 | this.futureResult = futureResult;
17 | }
18 |
19 | public abstract void execute();
20 | }
21 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/active/RealResult.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.active;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class RealResult implements Result {
7 |
8 | private final Object resultValue;
9 |
10 | public RealResult(Object resultValue) {
11 | this.resultValue = resultValue;
12 | }
13 |
14 | @Override
15 | public Object getResultValue() {
16 | return this.resultValue;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/active/Result.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.active;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface Result {
7 |
8 | Object getResultValue();
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/active/SchedulerThread.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.active;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class SchedulerThread extends Thread {
7 |
8 | private final ActivationQueue activationQueue;
9 |
10 | public SchedulerThread(ActivationQueue activationQueue) {
11 | this.activationQueue = activationQueue;
12 | }
13 |
14 | public void invoke(MethodRequest request) {
15 | this.activationQueue.put(request);
16 | }
17 |
18 | @Override
19 | public void run() {
20 | while (true) {
21 | activationQueue.take().execute();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/active/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.active;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 |
8 | /**
9 | * A a-> B b
10 | *
11 | * main
12 | */
13 | public static void main(String[] args) {
14 | ActiveObject activeObject = ActiveObjectFactory.createActiveObject();
15 | new MakerClientThread(activeObject, "Alice").start();
16 | new MakerClientThread(activeObject, "Bobby").start();
17 |
18 | new DisplayClientThread("Chris", activeObject).start();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/atomic/GetLockException.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.atomic;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class GetLockException extends Exception {
7 |
8 | public GetLockException() {
9 | super();
10 | }
11 |
12 | public GetLockException(String message) {
13 | super(message);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/atomic/TestMe.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.atomic;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class TestMe {
7 | volatile int i;
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/collections/MyQueueTest.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.collections;
2 |
3 | /**
4 | *
MyQueueTest
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-11-26 10:29
8 | **/
9 | public class MyQueueTest {
10 | /**
11 | * FIFO
12 | */
13 | public static void main(String[] args) {
14 | MyQueue queue = new MyQueue<>();
15 | queue.addLast("Hello");
16 | queue.addLast("World");
17 | queue.addLast("Java");
18 |
19 | System.out.println(queue.removeFirst());
20 | System.out.println(queue.removeFirst());
21 | System.out.println(queue.removeFirst());
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/future/AsyncFuture.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.future;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class AsyncFuture implements Future {
7 |
8 | private volatile boolean done = false;
9 |
10 | private T result;
11 |
12 | public void done(T result) {
13 | synchronized (this) {
14 | this.result = result;
15 | this.done = true;
16 | this.notifyAll();
17 | }
18 | }
19 |
20 | @Override
21 | public T get() throws InterruptedException {
22 | synchronized (this) {
23 | while (!done) {
24 | this.wait();
25 | }
26 | }
27 | return result;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/future/Future.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.future;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface Future {
7 |
8 | /**
9 | * get a result ,this method will blocked
10 | * @return result
11 | * @throws InterruptedException InterruptedException
12 | */
13 | T get() throws InterruptedException;
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/future/FutureTask.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.future;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface FutureTask {
7 |
8 | /**
9 | * task method
10 | * @return the result
11 | */
12 | T call();
13 | }
14 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/observer/LifeCycleListener.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.observer;
2 |
3 | /**
4 | * LifeCycleListener
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-11-05 11:12
8 | **/
9 | public interface LifeCycleListener {
10 | void onEvent(ObservableRunnable.RunnableEvent event);
11 | }
12 |
--------------------------------------------------------------------------------
/java/concurrent/src/main/java/com/github/zj/dreamly/concurrent/observer/ThreadLifeCycleObserverTest.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.observer;
2 |
3 | import java.util.Arrays;
4 |
5 | /**
6 | * ThreadLifeCycleObserverTest
7 | *
8 | * @author: 苍海之南
9 | * @since: 2019-11-05 11:16
10 | **/
11 | public class ThreadLifeCycleObserverTest {
12 | public static void main(String[] args) {
13 | new ThreadLifeCycleObserver()
14 | .concurrentQuery(Arrays.asList("1", "2"));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/concurrent/src/test/java/com/github/zj/dreamly/concurrent/collections/blocking/ArrayBlockingQueueExampleTest.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.concurrent.collections.blocking;
2 |
3 | import static org.junit.Assert.*;
4 |
5 | public class ArrayBlockingQueueExampleTest {
6 |
7 |
8 |
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/java/data-structure/src/main/java/com/github/zj/dreamly/datastructure/hash/HashTableTest.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.datastructure.hash;
2 |
3 | /**
4 | * HashTableTest
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-10-10 16:11
8 | **/
9 | public class HashTableTest {
10 | public static void main(String[] args) {
11 | HashTable hashTable = new HashTable<>();
12 |
13 | hashTable.add(1, 1);
14 |
15 | final Integer integer = hashTable.get(1);
16 | System.out.println(integer);
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/java/data-structure/src/main/java/com/github/zj/dreamly/datastructure/queue/array/ArrayQueueTest.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.datastructure.queue.array;
2 |
3 | /**
4 | * ArrayQueueTest
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-08-28 14:52
8 | **/
9 | public class ArrayQueueTest {
10 | public static void main(String[] args) {
11 |
12 | ArrayQueue queue = new ArrayQueue<>();
13 | for (int i = 0; i < 10; i++) {
14 | queue.enqueue(i);
15 | System.out.println(queue);
16 | if (i % 3 == 2) {
17 | queue.dequeue();
18 | System.out.println(queue);
19 | }
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/java/data-structure/src/main/java/com/github/zj/dreamly/datastructure/queue/delay/orderexample/DelayOrderWorker.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.datastructure.queue.delay.orderexample;
2 |
3 | /**
4 | * 具体执行相关业务的业务类
5 | *
6 | * @author 苍海之南
7 | */
8 | public class DelayOrderWorker implements Runnable {
9 |
10 | @Override
11 | public void run() {
12 | //相关业务逻辑处理
13 | System.out.println(Thread.currentThread().getName() + " do something ……");
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/java/data-structure/src/main/java/com/github/zj/dreamly/datastructure/queue/loop/LoopQueueTest.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.datastructure.queue.loop;
2 |
3 | /**
4 | * LoopQueueTest
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-08-30 09:25
8 | **/
9 | public class LoopQueueTest {
10 | public static void main(String[] args){
11 |
12 | LoopQueue queue = new LoopQueue<>(5);
13 | for(int i = 0 ; i < 10 ; i ++){
14 | queue.enqueue(i);
15 | System.out.println(queue);
16 |
17 | if(i % 3 == 2){
18 | queue.dequeue();
19 | System.out.println(queue);
20 | }
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/java/data-structure/src/main/java/com/github/zj/dreamly/datastructure/tree/segmenttree/Merger.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.datastructure.tree.segmenttree;
2 |
3 | /**
4 | * Merger
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-09-29 08:52
8 | **/
9 | public interface Merger {
10 | /**
11 | * 合并操作
12 | * @param a 左节点
13 | * @param b 右节点
14 | * @return E
15 | */
16 | E merge(E a, E b);
17 | }
18 |
--------------------------------------------------------------------------------
/java/data-structure/src/main/java/com/github/zj/dreamly/datastructure/unionfind/UnionFind.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.datastructure.unionfind;
2 |
3 | /**
4 | * 并查集
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-10-04 09:17
8 | **/
9 | public interface UnionFind {
10 | /**
11 | * 大小
12 | * @return 返回并查集大小
13 | */
14 | int getSize();
15 | /**
16 | * 是否有关系
17 | * @param p p
18 | * @param q q
19 | * @return 是否有关系
20 | */
21 | boolean isConnected(int p, int q);
22 |
23 | /**
24 | * 合并
25 | * @param p p
26 | * @param q q
27 | */
28 | void unionElements(int p, int q);
29 | }
30 |
--------------------------------------------------------------------------------
/java/deep-in-java/src/main/java/com/github/zj/dreamly/relearning/java/oop/ClassName.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.relearning.java.oop;
2 |
3 | class ClassName {
4 |
5 | public static void main(String[] args) {
6 |
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/java/deep-in-java/src/main/java/com/github/zj/dreamly/relearning/java/oop/InnerClassDemo.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.relearning.java.oop;
2 |
3 | public class InnerClassDemo {
4 |
5 | private int data;
6 |
7 | private C c;
8 |
9 | public class C {
10 |
11 | private int data;
12 |
13 | }
14 |
15 | public void setData() {
16 | c.data = data;
17 | }
18 |
19 | public static class A {
20 |
21 | }
22 |
23 | public /*static*/ interface B {
24 |
25 | }
26 |
27 | public static void main(String[] args) {
28 | A a = null;
29 | B b = null;
30 | C c = null;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/java/deep-in-java/src/main/java/com/github/zj/dreamly/relearning/java/oop/functional/ActionDemo.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.relearning.java.oop.functional;
2 |
3 | public class ActionDemo {
4 |
5 | public static void main(String[] args) {
6 |
7 | // 匿名内置类
8 | Runnable runnable = new Runnable() {
9 | @Override
10 | public void run() {
11 | System.out.println("小马哥");
12 | }
13 | };
14 |
15 | // invokedynamic 指令 @since JDK 1.7
16 | // 请记住 java.lang.invoke.MethodHandle
17 | // java.lang.invoke.InvokeDynamic
18 | Runnable runnable2 = () -> {
19 |
20 | };
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/java/deep-in-java/src/main/java/com/github/zj/dreamly/relearning/java/oop/functional/DemoAnnotation.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.relearning.java.oop.functional;
2 |
3 | import java.lang.annotation.*;
4 |
5 | @Documented
6 | @Retention(RetentionPolicy.RUNTIME)
7 | @Target(ElementType.TYPE)
8 | public @interface DemoAnnotation {
9 |
10 | String value();
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/java/deep-in-java/src/main/java/com/github/zj/dreamly/relearning/java/oop/functional/DemoAnnotationDemo.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.relearning.java.oop.functional;
2 |
3 | @DemoAnnotation(value = "hello")
4 | public class DemoAnnotationDemo {
5 |
6 | public static void main(String[] args) {
7 | DemoAnnotation demoAnnotation = DemoAnnotationDemo.class.getAnnotation(DemoAnnotation.class);
8 | System.out.println(demoAnnotation.value());
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/java/deep-in-java/src/main/java/com/github/zj/dreamly/relearning/java/oop/functional/FunctionDesignDemo.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.relearning.java.oop.functional;
2 |
3 | import java.util.function.Function;
4 |
5 | public class FunctionDesignDemo {
6 |
7 | public static void main(String[] args) {
8 |
9 | Function function = a -> a;
10 |
11 | // Function 可以用于同类转换
12 | Function divide2 = a -> a / 2;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/java/deep-in-java/src/main/java/com/github/zj/dreamly/relearning/java/oop/functional/PredicateDemo.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.relearning.java.oop.functional;
2 |
3 | import java.io.File;
4 | import java.io.FileFilter;
5 | import java.util.function.Predicate;
6 |
7 | public class PredicateDemo {
8 |
9 | public static void main(String[] args) {
10 |
11 | Predicate predicate = file -> true;
12 |
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/chainofresponsibility/Approver.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.chainofresponsibility;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public abstract class Approver {
7 | protected Approver approver;
8 |
9 | public void setNextApprover(Approver approver) {
10 | this.approver = approver;
11 | }
12 |
13 | public abstract void deploy(Course course);
14 | }
15 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/chainofresponsibility/VideoApprover.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.chainofresponsibility;
2 |
3 | import org.apache.commons.lang3.StringUtils;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class VideoApprover extends Approver {
9 | @Override
10 | public void deploy(Course course) {
11 | if (StringUtils.isNotEmpty(course.getVideo())) {
12 | System.out.println(course.getName() + "含有视频,批准");
13 | if (approver != null) {
14 | approver.deploy(course);
15 | }
16 | } else {
17 | System.out.println(course.getName() + "不含有视频,不批准,流程结束");
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/chainofresponsibility/orderchain/OnePrintChainPattern.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.chainofresponsibility.orderchain;
2 |
3 | import org.springframework.core.annotation.Order;
4 | import org.springframework.stereotype.Component;
5 |
6 | @Order(1)
7 | @Component
8 | public class OnePrintChainPattern extends PrintChainPattern {
9 |
10 | private final int order = 1;
11 |
12 | @Override
13 | public String getMessage() {
14 | return "one";
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/chainofresponsibility/orderchain/ThreePrintChainPattern.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.chainofresponsibility.orderchain;
2 |
3 | import org.springframework.core.annotation.Order;
4 | import org.springframework.stereotype.Component;
5 |
6 | @Order(3)
7 | @Component
8 | public class ThreePrintChainPattern extends PrintChainPattern {
9 |
10 | private final int order = 3;
11 |
12 | @Override
13 | public String getMessage() {
14 | return "three";
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/chainofresponsibility/orderchain/TwoPrintChainPattern.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.chainofresponsibility.orderchain;
2 |
3 | import org.springframework.core.annotation.Order;
4 | import org.springframework.stereotype.Component;
5 |
6 | @Order(2)
7 | @Component
8 | public class TwoPrintChainPattern extends PrintChainPattern {
9 |
10 | private final int order = 2;
11 |
12 | @Override
13 | public String getMessage() {
14 | return "two";
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/chainofresponsibility/spring/OneHandler.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.chainofresponsibility.spring;
2 |
3 | import org.springframework.core.annotation.Order;
4 | import org.springframework.stereotype.Component;
5 |
6 | @Order(1)
7 | @Component
8 | public class OneHandler implements Handler {
9 |
10 | private static final int ORDER = 1;
11 |
12 | @Override
13 | public void filterTask(HandlerContext ctx, Task task) {
14 | System.out.println("apply 1 filter");
15 | ctx.fireTaskFiltered(task);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/chainofresponsibility/spring/Pipeline.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.chainofresponsibility.spring;
2 |
3 | public interface Pipeline {
4 |
5 | Pipeline fireTaskReceived();
6 |
7 | Pipeline fireTaskFiltered();
8 |
9 | Pipeline fireTaskExecuted();
10 |
11 | Pipeline fireAfterCompletion();
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/chainofresponsibility/spring/Request.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.chainofresponsibility.spring;
2 |
3 | /**
4 | * @author: 苍海之南
5 | * @since: 2021-04-15 13:05
6 | **/
7 | public class Request {
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/chainofresponsibility/spring/Task.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.chainofresponsibility.spring;
2 |
3 | /**
4 | * @author: 苍海之南
5 | * @since: 2021-04-15 13:02
6 | **/
7 | public class Task {
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/chainofresponsibility/spring/ThreeHandler.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.chainofresponsibility.spring;
2 |
3 | import org.springframework.core.annotation.Order;
4 | import org.springframework.stereotype.Component;
5 |
6 | @Order(3)
7 | @Component
8 | public class ThreeHandler implements Handler {
9 |
10 | private static final int ORDER = 3;
11 |
12 | @Override
13 | public void filterTask(HandlerContext ctx, Task task) {
14 | System.out.println("apply 3 filter");
15 | ctx.fireTaskFiltered(task);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/chainofresponsibility/spring/TwoHandler.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.chainofresponsibility.spring;
2 |
3 | import org.springframework.core.annotation.Order;
4 | import org.springframework.stereotype.Component;
5 |
6 | @Order(2)
7 | @Component
8 | public class TwoHandler implements Handler {
9 |
10 | private static final int ORDER = 2;
11 |
12 | @Override
13 | public void filterTask(HandlerContext ctx, Task task) {
14 | System.out.println("apply 2 filter");
15 | ctx.fireTaskFiltered(task);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/command/CloseCourseVideoCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.command;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class CloseCourseVideoCommand implements Command {
7 | private CourseVideo courseVideo;
8 |
9 | public CloseCourseVideoCommand(CourseVideo courseVideo) {
10 | this.courseVideo = courseVideo;
11 | }
12 |
13 | @Override
14 | public void execute() {
15 | courseVideo.close();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/command/Command.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.command;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface Command {
7 | void execute();
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/command/CourseVideo.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.command;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class CourseVideo {
7 | private String name;
8 |
9 | public CourseVideo(String name) {
10 | this.name = name;
11 | }
12 |
13 | public void open() {
14 | System.out.println(this.name + "课程视频开放");
15 | }
16 |
17 | public void close() {
18 | System.out.println(this.name + "课程视频关闭");
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/command/OpenCourseVideoCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.command;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class OpenCourseVideoCommand implements Command {
7 | private CourseVideo courseVideo;
8 |
9 | public OpenCourseVideoCommand(CourseVideo courseVideo) {
10 | this.courseVideo = courseVideo;
11 | }
12 |
13 | @Override
14 | public void execute() {
15 | courseVideo.open();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/command/Staff.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.command;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | /**
7 | * @author 苍海之南
8 | */
9 | public class Staff {
10 | private List commandList = new ArrayList();
11 |
12 | public void addCommand(Command command) {
13 | commandList.add(command);
14 | }
15 |
16 | public void executeCommands() {
17 | for (Command command : commandList) {
18 | command.execute();
19 | }
20 | commandList.clear();
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/interpreter/Interpreter.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.interpreter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface Interpreter {
7 | int interpret();
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/interpreter/NumberInterpreter.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.interpreter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class NumberInterpreter implements Interpreter {
7 | private int number;
8 |
9 | public NumberInterpreter(int number) {
10 | this.number = number;
11 | }
12 |
13 | public NumberInterpreter(String number) {
14 | this.number = Integer.parseInt(number);
15 | }
16 |
17 | @Override
18 | public int interpret() {
19 | return this.number;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/interpreter/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.interpreter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | String geelyInputStr = "6 100 11 + *";
9 | GeelyExpressionParser expressionParser = new GeelyExpressionParser();
10 | int result = expressionParser.parse(geelyInputStr);
11 | System.out.println("解释器计算结果: " + result);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/iterator/Course.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.iterator;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Course {
7 | private String name;
8 |
9 | public Course(String name) {
10 | this.name = name;
11 | }
12 |
13 | public String getName() {
14 | return name;
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/iterator/CourseAggregate.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.iterator;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface CourseAggregate {
7 |
8 | void addCourse(Course course);
9 |
10 | void removeCourse(Course course);
11 |
12 | CourseIterator getCourseIterator();
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/iterator/CourseIterator.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.iterator;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface CourseIterator {
7 | Course nextCourse();
8 |
9 | boolean isLastCourse();
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/mediator/StudyGroup.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.mediator;
2 |
3 | import java.util.Date;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class StudyGroup {
9 |
10 | public static void showMessage(User user, String message) {
11 | System.out.println(new Date().toString() + " [" + user.getName() + "] : " + message);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/mediator/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.mediator;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | User geely = new User("Geely");
9 | User tom= new User("Tom");
10 |
11 | geely.sendMessage(" Hey! Tom! Let's learn Design Pattern");
12 | tom.sendMessage("OK! Geely");
13 | }
14 |
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/mediator/User.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.mediator;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class User {
7 | private String name;
8 |
9 | public String getName() {
10 | return name;
11 | }
12 |
13 | public void setName(String name) {
14 | this.name = name;
15 | }
16 |
17 | public User(String name) {
18 | this.name = name;
19 | }
20 |
21 | public void sendMessage(String message) {
22 | StudyGroup.showMessage(this, message);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/memento/ArticleMementoManager.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.memento;
2 |
3 | import java.util.Stack;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class ArticleMementoManager {
9 |
10 | private final Stack ARTICLE_MEMENTO_STACK = new Stack();
11 |
12 | public ArticleMemento getMemento() {
13 | ArticleMemento articleMemento = ARTICLE_MEMENTO_STACK.pop();
14 | return articleMemento;
15 | }
16 |
17 | public void addMemento(ArticleMemento articleMemento) {
18 | ARTICLE_MEMENTO_STACK.push(articleMemento);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/observer/Question.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.observer;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Question {
7 | private String userName;
8 | private String questionContent;
9 |
10 | public String getUserName() {
11 | return userName;
12 | }
13 |
14 | public void setUserName(String userName) {
15 | this.userName = userName;
16 | }
17 |
18 | public String getQuestionContent() {
19 | return questionContent;
20 | }
21 |
22 | public void setQuestionContent(String questionContent) {
23 | this.questionContent = questionContent;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/observer/guavatest/GuavaEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.observer.guavatest;
2 |
3 | import com.google.common.eventbus.Subscribe;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class GuavaEvent {
9 | @Subscribe
10 | public void subscribe(String str) {
11 | //业务逻辑
12 | System.out.println("执行subscribe方法,传入的参数是:" + str);
13 | }
14 |
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/observer/guavatest/GuavaEventTest.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.observer.guavatest;
2 |
3 | import com.google.common.eventbus.EventBus;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class GuavaEventTest {
9 | public static void main(String[] args) {
10 | EventBus eventbus = new EventBus();
11 | GuavaEvent guavaEvent = new GuavaEvent();
12 | eventbus.register(guavaEvent);
13 | eventbus.post("post的内容");
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/state/CourseVideoState.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.state;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public abstract class CourseVideoState {
7 | protected CourseVideoContext courseVideoContext;
8 |
9 | public void setCourseVideoContext(CourseVideoContext courseVideoContext) {
10 | this.courseVideoContext = courseVideoContext;
11 | }
12 |
13 | public abstract void play();
14 |
15 | public abstract void speed();
16 |
17 | public abstract void pause();
18 |
19 | public abstract void stop();
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/strategy/EmptyPromotionStrategy.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.strategy;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class EmptyPromotionStrategy implements PromotionStrategy {
7 | @Override
8 | public void doPromotion() {
9 | System.out.println("无促销活动");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/strategy/FanXianPromotionStrategy.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.strategy;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class FanXianPromotionStrategy implements PromotionStrategy {
7 | @Override
8 | public void doPromotion() {
9 | System.out.println("返现促销,返回的金额存放到慕课网用户的余额中");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/strategy/LiJianPromotionStrategy.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.strategy;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class LiJianPromotionStrategy implements PromotionStrategy {
7 | @Override
8 | public void doPromotion() {
9 | System.out.println("立减促销,课程的价格直接减去配置的价格");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/strategy/ManJianPromotionStrategy.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.strategy;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class ManJianPromotionStrategy implements PromotionStrategy {
7 | @Override
8 | public void doPromotion() {
9 | System.out.println("满减促销,满200-20元");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/strategy/PromotionActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.strategy;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class PromotionActivity {
7 | private PromotionStrategy promotionStrategy;
8 |
9 | public PromotionActivity(PromotionStrategy promotionStrategy) {
10 | this.promotionStrategy = promotionStrategy;
11 | }
12 |
13 | public void executePromotionStrategy() {
14 | promotionStrategy.doPromotion();
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/strategy/PromotionStrategy.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.strategy;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface PromotionStrategy {
7 | void doPromotion();
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/strategy/spring/Strategy.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.strategy.spring;
2 |
3 | public interface Strategy {
4 |
5 | String doOperation();
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/strategy/spring/StrategyOne.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.strategy.spring;
2 |
3 | import org.springframework.stereotype.Component;
4 |
5 | @Component("one")
6 | public class StrategyOne implements Strategy {
7 | @Override
8 | public String doOperation() {
9 | return "one";
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/templatemethod/DesignPatternCourse.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.templatemethod;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class DesignPatternCourse extends ACourse {
7 | @Override
8 | void packageCourse() {
9 | System.out.println("提供课程Java源代码");
10 | }
11 |
12 | @Override
13 | protected boolean needWriteArticle() {
14 | return true;
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/visitor/CodingCourse.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.visitor;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class CodingCourse extends Course {
7 | private int price;
8 |
9 | public int getPrice() {
10 | return price;
11 | }
12 |
13 | public void setPrice(int price) {
14 | this.price = price;
15 | }
16 |
17 | @Override
18 | public void accept(IVisitor visitor) {
19 | visitor.visit(this);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/visitor/Course.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.visitor;
2 |
3 | /**
4 | * @author 苍海之南1
5 | */
6 | public abstract class Course {
7 | private String name;
8 |
9 | public String getName() {
10 | return name;
11 | }
12 |
13 | public void setName(String name) {
14 | this.name = name;
15 | }
16 |
17 | public abstract void accept(IVisitor visitor);
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/visitor/FreeCourse.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.visitor;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class FreeCourse extends Course {
7 |
8 | @Override
9 | public void accept(IVisitor visitor) {
10 | visitor.visit(this);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/visitor/IVisitor.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.visitor;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface IVisitor {
7 |
8 | void visit(FreeCourse freeCourse);
9 |
10 | void visit(CodingCourse codingCourse);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/behavioral/visitor/Visitor.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.behavioral.visitor;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Visitor implements IVisitor {
7 |
8 | //访问免费课程,打印所有免费课程名称
9 | @Override
10 | public void visit(FreeCourse freeCourse) {
11 | System.out.println("免费课程:"+freeCourse.getName());
12 | }
13 |
14 | //访问实战课程,打印所有实战课程名称及价格
15 | @Override
16 | public void visit(CodingCourse codingCourse) {
17 | System.out.println("实战课程:"+codingCourse.getName()+" 价格:"+codingCourse.getPrice()+"元");
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/abstractfactory/Article.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.abstractfactory;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public abstract class Article {
7 | public abstract void produce();
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/abstractfactory/CourseFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.abstractfactory;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface CourseFactory {
7 | Video getVideo();
8 |
9 | Article getArticle();
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/abstractfactory/JavaArticle.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.abstractfactory;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class JavaArticle extends Article {
7 | @Override
8 | public void produce() {
9 | System.out.println("编写Java课程手记");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/abstractfactory/JavaCourseFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.abstractfactory;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class JavaCourseFactory implements CourseFactory {
7 | @Override
8 | public Video getVideo() {
9 | return new JavaVideo();
10 | }
11 |
12 | @Override
13 | public Article getArticle() {
14 | return new JavaArticle();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/abstractfactory/JavaVideo.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.abstractfactory;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class JavaVideo extends Video {
7 | @Override
8 | public void produce() {
9 | System.out.println("录制Java课程视频");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/abstractfactory/PythonArticle.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.abstractfactory;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class PythonArticle extends Article {
7 | @Override
8 | public void produce() {
9 | System.out.println("编写Python课程手记");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/abstractfactory/PythonCourseFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.abstractfactory;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class PythonCourseFactory implements CourseFactory {
7 | @Override
8 | public Video getVideo() {
9 | return new PythonVideo();
10 | }
11 |
12 | @Override
13 | public Article getArticle() {
14 | return new PythonArticle();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/abstractfactory/PythonVideo.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.abstractfactory;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class PythonVideo extends Video {
7 | @Override
8 | public void produce() {
9 | System.out.println("录制Python课程视频");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/abstractfactory/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.abstractfactory;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | CourseFactory courseFactory = new JavaCourseFactory();
9 | Video video = courseFactory.getVideo();
10 | Article article = courseFactory.getArticle();
11 | video.produce();
12 | article.produce();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/abstractfactory/Video.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.abstractfactory;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public abstract class Video {
7 | public abstract void produce();
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/builder/CourseBuilder.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.builder;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public abstract class CourseBuilder {
7 |
8 | public abstract void buildCourseName(String courseName);
9 |
10 | public abstract void buildCoursePPT(String coursePPT);
11 |
12 | public abstract void buildCourseVideo(String courseVideo);
13 |
14 | public abstract void buildCourseArticle(String courseArticle);
15 |
16 | public abstract void buildCourseQA(String courseQA);
17 |
18 | public abstract Course makeCourse();
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/builder/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.builder;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | CourseBuilder courseBuilder = new CourseActualBuilder();
9 | Coach coach = new Coach();
10 | coach.setCourseBuilder(courseBuilder);
11 |
12 | Course course = coach.makeCourse("Java设计模式精讲",
13 | "Java设计模式精讲PPT",
14 | "Java设计模式精讲视频",
15 | "Java设计模式精讲手记",
16 | "Java设计模式精讲问答");
17 | System.out.println(course);
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/factorymethod/FEVideo.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.factorymethod;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class FEVideo extends Video{
7 | @Override
8 | public void produce() {
9 | System.out.println("录制FE课程视频");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/factorymethod/FEVideoFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.factorymethod;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class FEVideoFactory extends VideoFactory {
7 | @Override
8 | public Video getVideo() {
9 | return new FEVideo();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/factorymethod/JavaVideo.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.factorymethod;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class JavaVideo extends Video {
7 | @Override
8 | public void produce() {
9 | System.out.println("录制Java课程视频");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/factorymethod/JavaVideoFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.factorymethod;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class JavaVideoFactory extends VideoFactory {
7 | @Override
8 | public Video getVideo() {
9 | return new JavaVideo();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/factorymethod/PythonVideo.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.factorymethod;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class PythonVideo extends Video {
7 | @Override
8 | public void produce() {
9 | System.out.println("录制Python课程视频");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/factorymethod/PythonVideoFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.factorymethod;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class PythonVideoFactory extends VideoFactory {
7 | @Override
8 | public Video getVideo() {
9 | return new PythonVideo();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/factorymethod/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.factorymethod;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | VideoFactory videoFactory = new PythonVideoFactory();
9 | VideoFactory videoFactory2 = new JavaVideoFactory();
10 | VideoFactory videoFactory3 = new FEVideoFactory();
11 | Video video = videoFactory.getVideo();
12 | video.produce();
13 |
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/factorymethod/Video.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.factorymethod;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public abstract class Video {
7 | public abstract void produce();
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/prototype/MailUtil.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.prototype;
2 |
3 | import java.text.MessageFormat;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class MailUtil {
9 | public static void sendMail(Mail mail) {
10 | String outputContent = "向{0}同学,邮件地址:{1},邮件内容:{2}发送邮件成功";
11 | System.out.println(MessageFormat.format(outputContent, mail.getName(), mail.getEmailAddress(), mail.getContent()));
12 | }
13 |
14 | public static void saveOriginMailRecord(Mail mail) {
15 | System.out.println("存储originMail记录,originMail:" + mail.getContent());
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/prototype/abstractprototype/A.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.prototype.abstractprototype;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public abstract class A implements Cloneable{
7 | @Override
8 | protected Object clone() throws CloneNotSupportedException {
9 | return super.clone();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/prototype/abstractprototype/B.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.prototype.abstractprototype;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class B extends A {
7 | public static void main(String[] args) throws CloneNotSupportedException {
8 | B b = new B();
9 | b.clone();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/simplefactory/JavaVideo.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.simplefactory;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class JavaVideo extends Video {
7 | @Override
8 | public void produce() {
9 | System.out.println("录制Java课程视频");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/simplefactory/PythonVideo.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.simplefactory;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class PythonVideo extends Video {
7 | @Override
8 | public void produce() {
9 | System.out.println("录制Python课程视频");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/creational/simplefactory/Video.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.creational.simplefactory;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public abstract class Video {
7 | public abstract void produce();
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/AC220.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class AC220 {
7 | public int outputAC220V() {
8 | int output = 220;
9 | System.out.println("输出交流电" + output + "V");
10 | return output;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/DC5.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface DC5 {
7 | int outputDC5V();
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/PowerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class PowerAdapter implements DC5 {
7 | private AC220 ac220 = new AC220();
8 |
9 | @Override
10 | public int outputDC5V() {
11 | int adapterInput = ac220.outputAC220V();
12 | //变压器...
13 | int adapterOutput = adapterInput / 44;
14 |
15 | System.out.println("使用PowerAdapter输入AC:" + adapterInput + "V" + "输出DC:" + adapterOutput + "V");
16 | return adapterOutput;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | DC5 dc5 = new PowerAdapter();
9 | dc5.outputDC5V();
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/classadapter/Adaptee.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter.classadapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Adaptee {
7 | public void adapteeRequest() {
8 | System.out.println("被适配者的方法");
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/classadapter/Adapter.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter.classadapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Adapter extends Adaptee implements Target {
7 | @Override
8 | public void request() {
9 | //...
10 | super.adapteeRequest();
11 | //...
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/classadapter/ConcreteTarget.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter.classadapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class ConcreteTarget implements Target {
7 | @Override
8 | public void request() {
9 | System.out.println("concreteTarget目标方法");
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/classadapter/Target.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter.classadapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface Target {
7 | void request();
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/classadapter/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter.classadapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | Target target = new ConcreteTarget();
9 | target.request();
10 |
11 | Target adapterTarget = new Adapter();
12 | adapterTarget.request();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/objectadapter/Adaptee.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter.objectadapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Adaptee {
7 | public void adapteeRequest() {
8 | System.out.println("被适配者的方法");
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/objectadapter/Adapter.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter.objectadapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Adapter implements Target {
7 | private Adaptee adaptee = new Adaptee();
8 |
9 | @Override
10 | public void request() {
11 | //...
12 | adaptee.adapteeRequest();
13 | //...
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/objectadapter/ConcreteTarget.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter.objectadapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class ConcreteTarget implements Target {
7 | @Override
8 | public void request() {
9 | System.out.println("concreteTarget目标方法");
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/objectadapter/Target.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter.objectadapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface Target {
7 | void request();
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/adapter/objectadapter/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.adapter.objectadapter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | Target target = new ConcreteTarget();
9 | target.request();
10 |
11 | Target adapterTarget = new Adapter();
12 | adapterTarget.request();
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/bridge/ABCBank.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.bridge;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class ABCBank extends Bank {
7 | public ABCBank(Account account) {
8 | super(account);
9 | }
10 |
11 | @Override
12 | Account openAccount() {
13 | System.out.println("打开中国农业银行账号");
14 | account.openAccount();
15 | return account;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/bridge/Account.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.bridge;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface Account {
7 | Account openAccount();
8 |
9 | void showAccountType();
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/bridge/Bank.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.bridge;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public abstract class Bank {
7 | protected Account account;
8 |
9 | public Bank(Account account) {
10 | this.account = account;
11 | }
12 |
13 | abstract Account openAccount();
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/bridge/DepositAccount.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.bridge;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class DepositAccount implements Account {
7 | @Override
8 | public Account openAccount() {
9 | System.out.println("打开定期账号");
10 | return new DepositAccount();
11 | }
12 |
13 | @Override
14 | public void showAccountType() {
15 | System.out.println("这是一个定期账号");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/bridge/ICBCBank.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.bridge;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class ICBCBank extends Bank {
7 | public ICBCBank(Account account) {
8 | super(account);
9 | }
10 |
11 | @Override
12 | Account openAccount() {
13 | System.out.println("打开中国工商银行账号");
14 | account.openAccount();
15 | return account;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/bridge/SavingAccount.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.bridge;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class SavingAccount implements Account {
7 | @Override
8 | public Account openAccount() {
9 | System.out.println("打开活期账号");
10 | //...
11 | return new SavingAccount();
12 | }
13 |
14 | @Override
15 | public void showAccountType() {
16 | System.out.println("这是一个活期账号");
17 | }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/decorator/v1/Battercake.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.decorator.v1;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Battercake {
7 | protected String getDesc() {
8 | return "煎饼";
9 | }
10 |
11 | protected int cost() {
12 | return 8;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/decorator/v1/BattercakeWithEgg.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.decorator.v1;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class BattercakeWithEgg extends Battercake {
7 | @Override
8 | public String getDesc() {
9 | return super.getDesc() + " 加一个鸡蛋";
10 | }
11 |
12 | @Override
13 | public int cost() {
14 | return super.cost() + 1;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/decorator/v1/BattercakeWithEggSausage.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.decorator.v1;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class BattercakeWithEggSausage extends BattercakeWithEgg {
7 | @Override
8 | public String getDesc() {
9 | return super.getDesc() + " 加一根香肠";
10 | }
11 |
12 | @Override
13 | public int cost() {
14 | return super.cost() + 2;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/decorator/v2/ABattercake.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.decorator.v2;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public abstract class ABattercake {
7 | protected abstract String getDesc();
8 |
9 | protected abstract int cost();
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/decorator/v2/Battercake.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.decorator.v2;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Battercake extends ABattercake {
7 | @Override
8 | protected String getDesc() {
9 | return "煎饼";
10 | }
11 |
12 | @Override
13 | protected int cost() {
14 | return 8;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/decorator/v2/EggDecorator.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.decorator.v2;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class EggDecorator extends AbstractDecorator {
7 | public EggDecorator(ABattercake aBattercake) {
8 | super(aBattercake);
9 | }
10 |
11 | @Override
12 | protected void doSomething() {
13 |
14 | }
15 |
16 | @Override
17 | protected String getDesc() {
18 | return super.getDesc() + " 加一个鸡蛋";
19 | }
20 |
21 | @Override
22 | protected int cost() {
23 | return super.cost() + 1;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/decorator/v2/SausageDecorator.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.decorator.v2;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class SausageDecorator extends AbstractDecorator {
7 | public SausageDecorator(ABattercake aBattercake) {
8 | super(aBattercake);
9 | }
10 |
11 | @Override
12 | protected void doSomething() {
13 |
14 | }
15 |
16 | @Override
17 | protected String getDesc() {
18 | return super.getDesc() + " 加一根香肠";
19 | }
20 |
21 | @Override
22 | protected int cost() {
23 | return super.cost() + 2;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/decorator/v2/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.decorator.v2;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | ABattercake aBattercake;
9 | aBattercake = new Battercake();
10 | aBattercake = new EggDecorator(aBattercake);
11 | aBattercake = new EggDecorator(aBattercake);
12 | aBattercake = new SausageDecorator(aBattercake);
13 |
14 | System.out.println(aBattercake.getDesc() + " 销售价格:" + aBattercake.cost());
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/facade/PointsGift.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.facade;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class PointsGift {
7 | private String name;
8 |
9 | public PointsGift(String name) {
10 | this.name = name;
11 | }
12 |
13 | public String getName() {
14 | return name;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/facade/PointsPaymentService.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.facade;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class PointsPaymentService {
7 | public boolean pay(PointsGift pointsGift) {
8 | //扣减积分
9 | System.out.println("支付" + pointsGift.getName() + " 积分成功");
10 | return true;
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/facade/QualifyService.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.facade;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class QualifyService {
7 | public boolean isAvailable(PointsGift pointsGift) {
8 | System.out.println("校验" + pointsGift.getName() + " 积分资格通过,库存通过");
9 | return true;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/facade/ShippingService.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.facade;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class ShippingService {
7 | public String shipGift(PointsGift pointsGift) {
8 | //物流系统的对接逻辑
9 | System.out.println(pointsGift.getName() + "进入物流系统");
10 | return "666";
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/facade/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.facade;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | PointsGift pointsGift = new PointsGift("T恤");
9 | GiftExchangeService giftExchangeService = new GiftExchangeService();
10 | giftExchangeService.giftExchange(pointsGift);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/flyweight/Employee.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.flyweight;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface Employee {
7 | void report();
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/flyweight/Manager.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.flyweight;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Manager implements Employee {
7 | @Override
8 | public void report() {
9 | System.out.println(reportContent);
10 | }
11 |
12 | private String title = "部门经理";
13 | private String department;
14 | private String reportContent;
15 |
16 | public void setReportContent(String reportContent) {
17 | this.reportContent = reportContent;
18 | }
19 |
20 | public Manager(String department) {
21 | this.department = department;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/proxy/IOrderDao.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.proxy;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface IOrderDao {
7 | int insert(Order order);
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/proxy/IOrderService.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.proxy;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface IOrderService {
7 | int saveOrder(Order order);
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/proxy/Order.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.proxy;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Order {
7 | private Object orderInfo;
8 | private Integer userId;
9 |
10 | public Object getOrderInfo() {
11 | return orderInfo;
12 | }
13 |
14 | public void setOrderInfo(Object orderInfo) {
15 | this.orderInfo = orderInfo;
16 | }
17 |
18 | public Integer getUserId() {
19 | return userId;
20 | }
21 |
22 | public void setUserId(Integer userId) {
23 | this.userId = userId;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/proxy/OrderDaoImpl.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.proxy;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class OrderDaoImpl implements IOrderDao {
7 | @Override
8 | public int insert(Order order) {
9 | System.out.println("Dao层添加Order成功");
10 | return 1;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/proxy/OrderServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.proxy;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class OrderServiceImpl implements IOrderService {
7 | private IOrderDao iOrderDao;
8 |
9 | @Override
10 | public int saveOrder(Order order) {
11 | //Spring会自己注入,我们课程中就直接new了
12 | iOrderDao = new OrderDaoImpl();
13 | System.out.println("Service层调用Dao层添加Order");
14 | return iOrderDao.insert(order);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/proxy/db/DataSourceContextHolder.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.proxy.db;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class DataSourceContextHolder {
7 | private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal();
8 |
9 | public static void setDBType(String dbType) {
10 | CONTEXT_HOLDER.set(dbType);
11 | }
12 |
13 | public static String getDBType() {
14 | return (String) CONTEXT_HOLDER.get();
15 | }
16 |
17 | public static void clearDBType() {
18 | CONTEXT_HOLDER.remove();
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/pattern/structural/proxy/staticproxy/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.pattern.structural.proxy.staticproxy;
2 |
3 | import com.github.zj.dreamly.design.pattern.pattern.structural.proxy.Order;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class Test {
9 | public static void main(String[] args) {
10 | Order order = new Order();
11 | order.setUserId(2);
12 |
13 | OrderServiceStaticProxy orderServiceStaticProxy = new OrderServiceStaticProxy();
14 | orderServiceStaticProxy.saveOrder(order);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/compositionaggregation/DBConnection.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.compositionaggregation;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public abstract class DBConnection {
7 | // public String getConnection(){
8 | // return "MySQL数据库连接";
9 | // }
10 | public abstract String getConnection();
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/compositionaggregation/MySQLConnection.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.compositionaggregation;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class MySQLConnection extends DBConnection {
7 | @Override
8 | public String getConnection() {
9 | return "MySQL数据库连接";
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/compositionaggregation/PostgreSQLConnection.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.compositionaggregation;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class PostgreSQLConnection extends DBConnection {
7 | @Override
8 | public String getConnection() {
9 | return "PostgreSQL数据库连接";
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/compositionaggregation/ProductDao.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.compositionaggregation;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class ProductDao {
7 | private DBConnection dbConnection;
8 |
9 | public void setDbConnection(DBConnection dbConnection) {
10 | this.dbConnection = dbConnection;
11 | }
12 |
13 | public void addProduct() {
14 | String conn = dbConnection.getConnection();
15 | System.out.println("使用" + conn + "增加产品");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/compositionaggregation/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.compositionaggregation;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | ProductDao productDao = new ProductDao();
9 | productDao.setDbConnection(new PostgreSQLConnection());
10 | productDao.addProduct();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/demeter/Boss.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.demeter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Boss {
7 |
8 | public void commandCheckNumber(TeamLeader teamLeader) {
9 | teamLeader.checkNumberOfCourses();
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/demeter/Course.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.demeter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Course {
7 | }
8 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/demeter/TeamLeader.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.demeter;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | /**
7 | * @author 苍海之南
8 | */
9 | public class TeamLeader {
10 | public void checkNumberOfCourses() {
11 | List courseList = new ArrayList();
12 | for (int i = 0; i < 20; i++) {
13 | courseList.add(new Course());
14 | }
15 | System.out.println("在线课程的数量是:" + courseList.size());
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/demeter/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.demeter;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | Boss boss = new Boss();
9 | TeamLeader teamLeader = new TeamLeader();
10 | boss.commandCheckNumber(teamLeader);
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/dependenceinversion/FECourse.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.dependenceinversion;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class FECourse implements ICourse {
7 | @Override
8 | public void studyCourse() {
9 | System.out.println("Geely在学习FE课程");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/dependenceinversion/Geely.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.dependenceinversion;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Geely {
7 |
8 | public void setiCourse(ICourse iCourse) {
9 | this.iCourse = iCourse;
10 | }
11 |
12 | private ICourse iCourse;
13 |
14 | public void studyImoocCourse() {
15 | iCourse.studyCourse();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/dependenceinversion/ICourse.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.dependenceinversion;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface ICourse {
7 | void studyCourse();
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/dependenceinversion/JavaCourse.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.dependenceinversion;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class JavaCourse implements ICourse {
7 |
8 | @Override
9 | public void studyCourse() {
10 | System.out.println("Geely在学习Java课程");
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/dependenceinversion/PythonCourse.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.dependenceinversion;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class PythonCourse implements ICourse {
7 | @Override
8 | public void studyCourse() {
9 | System.out.println("Geely在学习Python课程");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/interfacesegregation/Bird.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.interfacesegregation;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Bird implements IAnimalAction {
7 | @Override
8 | public void eat() {
9 |
10 | }
11 |
12 | @Override
13 | public void fly() {
14 |
15 | }
16 |
17 | @Override
18 | public void swim() {
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/interfacesegregation/Dog.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.interfacesegregation;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Dog implements ISwimAnimalAction, IEatAnimalAction {
7 |
8 | @Override
9 | public void eat() {
10 |
11 | }
12 |
13 | @Override
14 | public void swim() {
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/interfacesegregation/IAnimalAction.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.interfacesegregation;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface IAnimalAction {
7 | void eat();
8 |
9 | void fly();
10 |
11 | void swim();
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/interfacesegregation/IEatAnimalAction.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.interfacesegregation;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface IEatAnimalAction {
7 | void eat();
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/interfacesegregation/IFlyAnimalAction.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.interfacesegregation;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface IFlyAnimalAction {
7 | void fly();
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/interfacesegregation/ISwimAnimalAction.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.interfacesegregation;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface ISwimAnimalAction {
7 | void swim();
8 | }
9 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/liskovsubstitution/Quadrangle.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.liskovsubstitution;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface Quadrangle {
7 | long getWidth();
8 |
9 | long getLength();
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/liskovsubstitution/Rectangle.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.liskovsubstitution;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Rectangle implements Quadrangle {
7 | private long length;
8 | private long width;
9 |
10 | @Override
11 | public long getWidth() {
12 | return width;
13 | }
14 |
15 | @Override
16 | public long getLength() {
17 | return length;
18 | }
19 |
20 | public void setLength(long length) {
21 | this.length = length;
22 | }
23 |
24 | public void setWidth(long width) {
25 | this.width = width;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/liskovsubstitution/Square.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.liskovsubstitution;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Square implements Quadrangle {
7 | private long sideLength;
8 |
9 | public long getSideLength() {
10 | return sideLength;
11 | }
12 |
13 | public void setSideLength(long sideLength) {
14 | this.sideLength = sideLength;
15 | }
16 |
17 | @Override
18 | public long getWidth() {
19 | return sideLength;
20 | }
21 |
22 | @Override
23 | public long getLength() {
24 | return sideLength;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/liskovsubstitution/methodinput/Base.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.liskovsubstitution.methodinput;
2 |
3 | import java.util.HashMap;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class Base {
9 | public void method(HashMap map) {
10 | System.out.println("父类被执行");
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/liskovsubstitution/methodinput/Child.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.liskovsubstitution.methodinput;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class Child extends Base {
9 | // @Override
10 | // public void method(HashMap map) {
11 | // System.out.println("子类HashMap入参方法被执行");
12 | // }
13 |
14 | public void method(Map map) {
15 | System.out.println("子类HashMap入参方法被执行");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/liskovsubstitution/methodinput/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.liskovsubstitution.methodinput;
2 |
3 | import java.util.HashMap;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class Test {
9 | public static void main(String[] args) {
10 | Base child = new Child();
11 | HashMap hashMap = new HashMap();
12 | child.method(hashMap);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/liskovsubstitution/methodoutput/Base.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.liskovsubstitution.methodoutput;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public abstract class Base {
9 | public abstract Map method();
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/liskovsubstitution/methodoutput/Child.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.liskovsubstitution.methodoutput;
2 |
3 | import java.util.HashMap;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class Child extends Base {
9 | @Override
10 | public HashMap method() {
11 | HashMap hashMap = new HashMap();
12 | System.out.println("子类method被执行");
13 | hashMap.put("message", "子类method被执行");
14 | return hashMap;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/liskovsubstitution/methodoutput/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.liskovsubstitution.methodoutput;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | Child child = new Child();
9 | System.out.println(child.method());
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/openclose/ICourse.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.openclose;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface ICourse {
7 | Integer getId();
8 |
9 | String getName();
10 |
11 | Double getPrice();
12 | }
13 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/openclose/JavaCourse.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.openclose;
2 |
3 | import lombok.Data;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | @Data
9 | public class JavaCourse implements ICourse {
10 | private Integer id;
11 | private String name;
12 | private Double price;
13 |
14 | public JavaCourse(Integer id, String name, Double price) {
15 | this.id = id;
16 | this.name = name;
17 | this.price = price;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/openclose/JavaDiscountCourse.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.openclose;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class JavaDiscountCourse extends JavaCourse {
7 |
8 | public JavaDiscountCourse(Integer id, String name, Double price) {
9 | super(id, name, price);
10 | }
11 |
12 | public Double getDiscountPrice() {
13 | return super.getPrice() * 0.8;
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/openclose/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.openclose;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | ICourse iCourse = new JavaDiscountCourse(96, "Java从零到企业级电商开发", 348d);
9 | JavaDiscountCourse javaCourse = (JavaDiscountCourse) iCourse;
10 | System.out.println("课程ID:" + javaCourse.getId() + " 课程名称:" + javaCourse.getName() + " 课程原价:" + javaCourse.getPrice() + " 课程折后价格:" + javaCourse.getDiscountPrice() + "元");
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/singleresponsibility/Bird.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.singleresponsibility;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Bird {
7 | public void mainMoveMode(String birdName) {
8 | if ("鸵鸟".equals(birdName)) {
9 | System.out.println(birdName + "用脚走");
10 | } else {
11 | System.out.println(birdName + "用翅膀飞");
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/singleresponsibility/CourseImpl.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.singleresponsibility;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class CourseImpl implements ICourseManager, ICourseContent {
7 | @Override
8 | public void studyCourse() {
9 |
10 | }
11 |
12 | @Override
13 | public void refundCourse() {
14 |
15 | }
16 |
17 | @Override
18 | public String getCourseName() {
19 | return null;
20 | }
21 |
22 | @Override
23 | public byte[] getCourseVideo() {
24 | return new byte[0];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/singleresponsibility/FlyBird.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.singleresponsibility;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class FlyBird {
7 | public void mainMoveMode(String birdName) {
8 | System.out.println(birdName + "用翅膀飞");
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/singleresponsibility/ICourse.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.singleresponsibility;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface ICourse {
7 | String getCourseName();
8 |
9 | byte[] getCourseVideo();
10 |
11 | void studyCourse();
12 |
13 | void refundCourse();
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/singleresponsibility/ICourseContent.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.singleresponsibility;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface ICourseContent {
7 | String getCourseName();
8 |
9 | byte[] getCourseVideo();
10 | }
11 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/singleresponsibility/ICourseManager.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.singleresponsibility;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface ICourseManager {
7 | void studyCourse();
8 |
9 | void refundCourse();
10 | }
11 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/singleresponsibility/Test.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.singleresponsibility;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Test {
7 | public static void main(String[] args) {
8 | // Bird bird = new Bird();
9 | // bird.mainMoveMode("大雁");
10 | // bird.mainMoveMode("鸵鸟");
11 |
12 | FlyBird flyBird = new FlyBird();
13 | flyBird.mainMoveMode("大雁");
14 |
15 | WalkBird walkBird = new WalkBird();
16 | walkBird.mainMoveMode("鸵鸟");
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/java/design-pattern/src/main/java/com/github/zj/dreamly/design/pattern/principle/singleresponsibility/WalkBird.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.design.pattern.principle.singleresponsibility;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class WalkBird {
7 | public void mainMoveMode(String birdName){
8 | System.out.println(birdName+"用脚走");
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/cache/lru/LRUCache.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.cache.lru;
2 |
3 | /**
4 | * LRUCache
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-10-29 14:59
8 | **/
9 | public interface LRUCache {
10 | void put(K key, V value);
11 |
12 | V get(K key);
13 |
14 | void remove(K key);
15 |
16 | int size();
17 |
18 | void clear();
19 |
20 | int limit();
21 | }
22 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/concurrent/test/TokenBucketExample.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.concurrent.test;
2 |
3 | import com.github.zj.dreamly.guava.concurrent.TokenBucket;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class TokenBucketExample
9 | {
10 |
11 | public static void main(String[] args)
12 | {
13 | final TokenBucket tokenBucket = new TokenBucket();
14 | for (int i = 0; i < 200; i++)
15 | {
16 | new Thread(tokenBucket::buy).start();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/ComEachOtherEventBusExample.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus;
2 |
3 | import com.github.zj.dreamly.guava.eventbus.service.QueryService;
4 | import com.github.zj.dreamly.guava.eventbus.service.RequestQueryHandler;
5 | import com.google.common.eventbus.EventBus;
6 |
7 | /**
8 | * @author 苍海之南
9 | */
10 | public class ComEachOtherEventBusExample {
11 |
12 | public static void main(String[] args) {
13 | final EventBus eventBus = new EventBus();
14 | QueryService queryService = new QueryService(eventBus);
15 | eventBus.register(new RequestQueryHandler(eventBus));
16 | queryService.query("werwersdf");
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/InheritListenersEventBusExample.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus;
2 |
3 | import com.github.zj.dreamly.guava.eventbus.listeners.ConcreteListener;
4 | import com.google.common.eventbus.EventBus;
5 |
6 | /**
7 | * @author 苍海之南
8 | */
9 | public class InheritListenersEventBusExample {
10 | public static void main(String[] args) {
11 | final EventBus eventBus = new EventBus();
12 | eventBus.register(new ConcreteListener());
13 | System.out.println("post the string event");
14 | eventBus.post("I am string event");
15 | System.out.println("post the int event");
16 | eventBus.post(1000);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/MultipleEventBusExample.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus;
2 |
3 | import com.github.zj.dreamly.guava.eventbus.listeners.MultipleEventListeners;
4 | import com.google.common.eventbus.EventBus;
5 |
6 | /**
7 | * @author 苍海之南
8 | */
9 | public class MultipleEventBusExample {
10 | public static void main(String[] args) {
11 | final EventBus eventBus = new EventBus();
12 | eventBus.register(new MultipleEventListeners());
13 | System.out.println("post the string event");
14 | eventBus.post("I am string event");
15 | System.out.println("post the int event");
16 | eventBus.post(1000);
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/SimpleEventBusExample.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus;
2 |
3 | import com.github.zj.dreamly.guava.eventbus.listeners.SimpleListener;
4 | import com.google.common.eventbus.EventBus;
5 |
6 | /**
7 | * @author 苍海之南
8 | */
9 | public class SimpleEventBusExample {
10 | public static void main(String[] args) {
11 | final EventBus eventBus = new EventBus();
12 | eventBus.register(new SimpleListener());
13 | System.out.println("post the simple event.");
14 | eventBus.post("Simple Event");
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/events/Apple.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.events;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Apple extends Fruit {
7 | public Apple(String name) {
8 | super(name);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/events/Fruit.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.events;
2 |
3 | import com.google.common.base.MoreObjects;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class Fruit {
9 |
10 | private final String name;
11 |
12 | public Fruit(String name) {
13 | this.name = name;
14 | }
15 |
16 | public String getName() {
17 | return name;
18 | }
19 |
20 | @Override
21 | public String toString() {
22 | return MoreObjects.toStringHelper(this).add("Name", name).toString();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/events/Request.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.events;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class Request
7 | {
8 |
9 | private final String orderNo;
10 |
11 | public Request(String orderNo)
12 | {
13 | this.orderNo = orderNo;
14 | }
15 |
16 | @Override
17 | public String toString()
18 | {
19 | return "Request{" +
20 | "orderNo='" + orderNo + '\'' +
21 | '}';
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/events/Response.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.events;
2 |
3 | public class Response
4 | {
5 | }
6 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/internal/Bus.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.internal;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface Bus {
7 |
8 | void register(Object subscriber);
9 |
10 | void unregister(Object subscriber);
11 |
12 | void post(Object event);
13 |
14 | void post(Object Event, String topic);
15 |
16 | void close();
17 |
18 | String getBusName();
19 | }
20 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/internal/MyEventContext.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.internal;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public interface MyEventContext {
9 |
10 | String getSource();
11 |
12 | Object getSubscriber();
13 |
14 | Method getSubscribe();
15 |
16 | Object getEvent();
17 | }
18 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/internal/MyEventExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.internal;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface MyEventExceptionHandler {
7 | void handle(Throwable cause, MyEventContext context);
8 | }
9 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/internal/MySubscribe.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.internal;
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 | * @author 苍海之南
10 | */
11 | @Retention(RetentionPolicy.RUNTIME)
12 | @Target(ElementType.METHOD)
13 | public @interface MySubscribe {
14 | String topic() default "default-topic";
15 | }
16 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/internal/test/MySimpleListener.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.internal.test;
2 |
3 | import com.github.zj.dreamly.guava.eventbus.internal.MySubscribe;
4 |
5 | /**
6 | * @author 苍海之南
7 | */
8 | public class MySimpleListener {
9 |
10 | @MySubscribe
11 | public void test1(String x) {
12 | System.out.println("MySimpleListener===test1==" + x);
13 | }
14 |
15 | @MySubscribe(topic = "alex-topic")
16 | public void test2(Integer x) {
17 | System.out.println("MySimpleListener===test2==" + x);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/listeners/AbstractListener.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.listeners;
2 |
3 | import com.google.common.eventbus.Subscribe;
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 |
7 | /**
8 | * @author 苍海之南
9 | */
10 | public abstract class AbstractListener {
11 |
12 | private final static Logger LOGGER = LoggerFactory.getLogger(AbstractListener.class);
13 |
14 | @Subscribe
15 | public void commonTask(String event) {
16 | if (LOGGER.isInfoEnabled()) {
17 | LOGGER.info("The event [{}] will be handle by {}.{}", event, this.getClass().getSimpleName(), "commonTask");
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/listeners/BaseListener.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.listeners;
2 |
3 | import com.google.common.eventbus.Subscribe;
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 |
7 | /**
8 | * @author 苍海之南
9 | */
10 | public class BaseListener extends AbstractListener {
11 | private final static Logger LOGGER = LoggerFactory.getLogger(BaseListener.class);
12 |
13 | @Subscribe
14 | public void baseTask(String event) {
15 | if (LOGGER.isInfoEnabled()) {
16 | LOGGER.info("The event [{}] will be handle by {}.{}", event, this.getClass().getSimpleName(), "baseTask");
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/listeners/ConcreteListener.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.listeners;
2 |
3 | import com.google.common.eventbus.Subscribe;
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 |
7 | /**
8 | * @author 苍海之南
9 | */
10 | public class ConcreteListener extends BaseListener {
11 | private final static Logger LOGGER = LoggerFactory.getLogger(ConcreteListener.class);
12 |
13 | @Subscribe
14 | public void conTask(String event) {
15 | if (LOGGER.isInfoEnabled()) {
16 | LOGGER.info("The event [{}] will be handle by {}.{}", event, this.getClass().getSimpleName(), "conTask");
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/listeners/DeadEventListener.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.listeners;
2 |
3 | import com.google.common.eventbus.DeadEvent;
4 | import com.google.common.eventbus.Subscribe;
5 |
6 | /**
7 | * @author 苍海之南
8 | */
9 | public class DeadEventListener {
10 | @Subscribe
11 | public void handle(DeadEvent event) {
12 | System.out.println(event.getSource());
13 | System.out.println(event.getEvent());
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/monitor/FileChangeEvent.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.monitor;
2 |
3 | import java.nio.file.Path;
4 | import java.nio.file.WatchEvent;
5 |
6 | /**
7 | * @author 苍海之南
8 | */
9 | public class FileChangeEvent {
10 |
11 | private final Path path;
12 |
13 | private final WatchEvent.Kind> kind;
14 |
15 | public FileChangeEvent(Path path, WatchEvent.Kind> kind) {
16 | this.path = path;
17 | this.kind = kind;
18 | }
19 |
20 | public Path getPath() {
21 | return path;
22 | }
23 |
24 | public WatchEvent.Kind> getKind() {
25 | return kind;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/monitor/FileChangeListener.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.monitor;
2 |
3 | import com.google.common.eventbus.Subscribe;
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 |
7 | /**
8 | * @author 苍海之南
9 | */
10 | public class FileChangeListener {
11 |
12 | private final static Logger LOGGER = LoggerFactory.getLogger(FileChangeListener.class);
13 |
14 | @Subscribe
15 | public void onChange(FileChangeEvent event) {
16 | LOGGER.info("{}-{}", event.getPath(), event.getKind());
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/eventbus/monitor/TargetMonitor.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.eventbus.monitor;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public interface TargetMonitor {
7 |
8 | void startMonitor() throws Exception;
9 |
10 | void stopMonitor() throws Exception;
11 | }
12 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/io/CharSinkTest.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.io;
2 |
3 | import org.junit.Test;
4 |
5 | /**
6 | * CharSinkTest
7 | *
8 | * @author: 苍海之南
9 | * @since: 2019-10-29 11:30
10 | **/
11 | public class CharSinkTest {
12 | /**
13 | * CharSource---->Reader
14 | *
15 | * CharSink------>Writer
16 | */
17 | @Test
18 | public void testCharSink() {
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/java/guava/src/main/java/com/github/zj/dreamly/guava/io/CharStreamsTest.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.guava.io;
2 |
3 | /**
4 | *
CharStreamsTest
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-10-29 11:31
8 | **/
9 | public class CharStreamsTest {
10 | }
11 |
--------------------------------------------------------------------------------
/java/guava/src/main/resources/io/files.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/guava/src/main/resources/io/files.PNG
--------------------------------------------------------------------------------
/java/guava/src/main/resources/io/source.txt:
--------------------------------------------------------------------------------
1 | today we will share the guava io knowledge.
2 | but only for the basic usage. if you wanted to get the more details information
3 | please read the guava document or source code.
4 |
5 | The guava source code is very cleanly and nice.
--------------------------------------------------------------------------------
/java/interview/doc/java-basic/01.float f=3.4 是否正确.md:
--------------------------------------------------------------------------------
1 | # float f=3.4 是否正确
2 |
3 | - 答案:不正确
4 | - 解析
5 | - 3.4 是双精度数,将双精度型(double)赋值给浮点型(float)属于下转型(down-casting,也称为窄化)会造成精度损失,因此需要强制类型转换float f =(float)3.4 或者写成 float f =3.4F
6 | - 在 Java 里面,没小数点的默认是 int ,有小数点的默认是 double
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/java/interview/doc/java-basic/03.final finally finalize有什么区别.md:
--------------------------------------------------------------------------------
1 | # final finally finalize 有什么区别
2 |
3 | - final 可以修饰类、变量、方法,修饰类表示该类不能被继承、修饰方法表示该方法不能被重写、被 final 修饰的变量不可以被改变,被 final 修饰不可变的是变量的引用,而不是引用指向的内容,引用指向的内容是可以改变的
4 | - finally 一般作用在 try-catch 代码块中,在处理异常的时候,通常我们将一定要执行的代码方法 finally 代码块中,表示不管是否出现异常,该代码块都会执行,一般用来存放一些关闭资源的代码。
5 | - finalize 是一个方法,属于 Object 类的一个方法,而 Object 类是所有类的父类,该方法一般由垃圾回收器来调用,当我们调用 System.gc() 方法的时候,由垃圾回收器调用 finalize() ,回收垃圾,一个对象是否可回收的最后判断
--------------------------------------------------------------------------------
/java/interview/doc/java-basic/07.面向对象五大基本原则是什么.md:
--------------------------------------------------------------------------------
1 | # 面向对象五大基本原则
2 |
3 | ## 单一职责原则 SRP (Single Responsibility Principle)
4 |
5 | 类的功能要单一,不能包罗万象,跟杂货铺似的
6 |
7 | ## 开放封闭原则 OCP (Open-Close Principle)
8 |
9 | 一个模块对于拓展是开放的,对于修改是封闭的,想要增加功能热烈欢迎,想要修改,哼,一万个不乐意
10 |
11 | ## 里式替换原则 LSP (the Liskov Substitution Principle LSP)
12 |
13 | 子类可以替换父类出现在父类能够出现的任何地方。比如你能代表你爸去你姥姥家干活
14 |
15 | ## 依赖倒置原则DIP (the Dependency Inversion Principle DIP)
16 |
17 | 高层次的模块不应该依赖于低层次的模块,他们都应该依赖于抽象,抽象不应该依赖于具体实现,具体实现应该依赖于抽象
18 |
19 | ## 接口分离原则ISP (the Interface Segregation Principle ISP)
20 |
21 | 设计时采用多个与特定客户类有关的接口比采用一个通用的接口要好。就比如一个手机拥有打电话,看视频,玩游戏等功能,把这几个功能拆分成不同的接口,比在一个接口里要好的多
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/java/interview/doc/java-basic/11.谈一谈重载与重写的区别吧.md:
--------------------------------------------------------------------------------
1 | # 重写与重载
2 |
3 | ## 构造器(constructor)是否可被重写(override)
4 |
5 | 构造器不能被继承,因此不能被重写,但可以被重载
6 |
7 | ## 重载(Overload)和重写(Override)的区别
8 |
9 | 方法的重载和重写都是实现多态的方式,区别在于前者实现的是编译时的多态性,而后者实现的是运行时的多态性
10 |
11 | 重载:发生在同一个类中,方法名相同参数列表不同(参数类型不同、个数不同、顺序不同),与方法返回值和访问修饰符无关,即重载的方法不能根据返回 类型进行区分
12 |
13 | 重写:发生在父子类中,方法名、参数列表必须相同,返回值小于等于父类,抛出的异常小于等于父类,访问修饰符大于等于父类(里氏代换原则),如果父类 方法访问修饰符为 private 则子类中就不是重写
--------------------------------------------------------------------------------
/java/interview/doc/java-basic/13.说一说Java的值传递.md:
--------------------------------------------------------------------------------
1 | # 为什么 Java 中只有值传递
2 |
3 | - 按值调用 (call by value) 表示方法接收的是调用者提供的值
4 | - 按引用调用 (call by reference) 表示方法接收的是调用者提供的变量地址,一个方法可以修改传递引用所对应的变量值,而不能修改传递值调用所对应的变量值
5 | - Java程序设计语言总是采用按值调用,也就是说,方法得到的是所有参数值的 一个拷贝,也就是说,方法不能修改传递给它的任何参数变量的内容
6 | - 一个方法不能修改一个基本数据类型的参数,即数值型或布尔型
7 | - 一个方法可以改变一个对象参数的状态
8 | - 一个方法不能让对象参数引用一个新的对象
9 |
10 | # 值传递和引用传递有什么区别
11 |
12 | 值传递指的是在方法调用时,传递的参数是按值的拷贝传递,传递的是值的拷贝,也就是说传递后就互不相关了
13 |
14 | 引用传递:指的是在方法调用时,传递的参数是按引用进行传递,其实传递的引用的地址,也就是变量所对应的内存空间的地址,传递的是值的引用,也就是说传递前和传递后都指向同一个引用,也就是同一个内存空间
--------------------------------------------------------------------------------
/java/interview/doc/java-basic/14.Java的IO流.md:
--------------------------------------------------------------------------------
1 | # Java 的 IO流
2 |
3 | 按照流的流向分,可以分为输入流和输出流,按照操作单元划分,可以划分为字节流和字符流,按照流的角色划分为节点流和处理流,Java IO 流共涉及40多个类,这些类看上去很杂乱,但实际上很有规则,而且彼此之间存在非常紧密的联系, Java IO 流的40多个类都是从如下4个抽象类基类 中派生出来的
4 |
5 | - InputStream / Reader:所有的输入流的基类,前者是字节输入流,后者是字符输入流
6 | - OutputStream / Writer:所有输出流的基类,前者是字节输出流,后者是字符输出流
--------------------------------------------------------------------------------
/java/interview/doc/java-basic/15.Java反射.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/interview/doc/java-basic/15.Java反射.md
--------------------------------------------------------------------------------
/java/interview/doc/java-basic/16.Java常用的集合类.md:
--------------------------------------------------------------------------------
1 | # Java 常用的集合类
2 |
3 | - Map
4 | - HashMap
5 | - TreeMap
6 | - Hashtable
7 | - ConcurrentHashMap
8 | - Properties
9 | - Collection
10 | - Set
11 | - HashSet
12 | - LinkedHashSet
13 | - TreeSet
14 | - List
15 | - ArrayList
16 | - LinkedList
17 | - Stack
18 | - Vector
19 |
20 | # List,Set,Map 三者的区别
21 |
22 |
--------------------------------------------------------------------------------
/java/interview/doc/juc/12.JUC之AQS.md:
--------------------------------------------------------------------------------
1 | # JUC 之 AQS
2 |
3 | - AQS是用来构建锁或者其它同步器组件的重量级基础框架及整个JUC体系的基石
4 | - 通过内置的FIFO队列来完成资源获取线程的排队工作,并通过一个int类变量表示持有锁的状态
5 |
6 | [点击查看AQS详细](https://gitee.com/zj-dreamly/lemon-guide/blob/main/JAVA.md)
7 |
8 |
--------------------------------------------------------------------------------
/java/interview/doc/juc/7.JUC之CAS.md:
--------------------------------------------------------------------------------
1 | # JUC之CAS
2 |
3 | CAS是 compare and swap的缩写,中文翻译成比较并交换,实现并发算法时常用到的一种技术
4 |
5 | 它包含三个操作数——内存位置、预期原值及更新值,执行CAS操作的时候,将内存位置的值与预期原值比较,如果相匹配,那么处理器会自动将该位置值更新为新值,如果不匹配,处理器不做任何操作,多个线程同时执行CAS操作只有一个会成功
6 |
7 | ## UnSafe
8 |
9 | Unsafe 是CAS的核心类,由于Java方法无法直接访问底层系统,需要通过本地(native)方法来访问,Unsafe相当于一个后门,基于该类可以直接操作特定内存的数据
10 |
11 | Unsafe 类存在于 sun.misc 包中,其内部方法操作可以像C的指针一样直接操作内存,因为 Java 中 CAS 操作的执行依赖于 Unsafe 类的方法
12 |
13 | 注意 Unsafe 类中的所有方法都是 native 修饰的,也就是说 Unsafe 类中的方法都直接调用操作系统底层资源执行相应任务
14 |
15 | 变量 valueOffset,表示该变量值在内存中的偏移地址,因为 Unsafe 就是根据内存偏移地址获取数据的
16 |
17 | 变量 value 用 volatile 修饰,保证了多线程之间的内存可见性
18 |
19 | ## CAS 缺点
20 |
21 | 循环时间长开销很大
22 |
23 | ABA问题
--------------------------------------------------------------------------------
/java/interview/doc/jvm/7.JVM性能监控篇.md:
--------------------------------------------------------------------------------
1 | # JVM 性能监控篇
2 |
3 | ## 命令行
4 |
5 | - 概述
6 | - jps:查看正在运行的 Java 进程
7 | - jstat:查看 JVM 统计信息
8 | - 查看GC信息:jstat -gc 进程号 采集时间间隔 输出次数
9 | - jinfo:实时查看和修改JVM配置参数
10 | - jmap:导出内存映像文件&内存使用情況
11 | - jhat:Jok自带堆分析工具
12 | - jstack:打印JVM中线程快照
13 | - jcmd:多功能命令行
14 | - jstatd:远程主机信息收集
15 |
16 | ## GUI
17 |
18 | - 工具概述
19 | - jConsole
20 | - Visual VM
21 | - Eclipse MAT
22 | - Jprofiler
23 | - Arthas
24 | - Java Mission Contral
25 |
26 | ## 运行时参数
27 |
28 | ### JVM 参数选项类型
29 |
30 | ### 添加 JVM 参数选项
31 |
32 | ### 常用 JVM 参数选项
33 |
34 | ### 按功能区分 JVM 参数选项
35 |
36 | ### 通过 Java 代码获取 JVM 参数
--------------------------------------------------------------------------------
/java/interview/doc/jvm/题目/01.JVM的生命周期.md:
--------------------------------------------------------------------------------
1 | # JVM生命周期
2 |
3 | ## 虚拟机的启动
4 |
5 | Java虚拟机的启动是通过司导类加载器(bootstrap class 1oader)创建一个初始类(initialclass)来完成的,这个类是由虚拟机的具体实现指定的
6 |
7 | ## 虛拟机的退出
8 |
9 | - 某线程调用 Runtime 类或 System 类的 exit 方法,或 Runtime 类的 halt 方法,并且 Java 安全管理器也允许这次 exit 或 halt 操作程序正常执行结束
10 | - 程序在执行过程中遇到了异常或错误而异常终止
11 | - 由于操作系统出现错误而导致Java虛拟机进程终止
--------------------------------------------------------------------------------
/java/interview/doc/jvm/题目/03.为什么不把基本类型放在堆中.md:
--------------------------------------------------------------------------------
1 | # 为什么不把基本类型放在堆中
2 |
3 | 首先是栈、堆的特点不同。(堆比栈要大,但是栈比堆的运算速度要快)
4 |
5 | 将复杂数据类型放在堆中的目的是为了 不影响栈的效率,而是通过引用的方式去堆中查找(八大基本类型的大小创建时候已经确立,三大引用类型创建时候无法确定大小)
6 |
7 | 简单数据类型比较稳定,并且它只占据很小的内存,将它放在空间小、运算速度快的栈中,能够提高效率
--------------------------------------------------------------------------------
/java/interview/doc/jvm/题目/04.Class 的 forName(Java.lang.String) 和 Class 的 getClassLoader() 的 loadClass(Java. lang. string”) 有什么区别?.md:
--------------------------------------------------------------------------------
1 | # Class.forName 和 class.getClassLoader(). loadClass 有什么区别?
2 |
3 |
4 |
5 | **Class.forName("java.lang.String")**
6 |
7 | 会执行装载,链接,初始化操作
8 |
9 | **loadClass("java.lang.String")**
10 |
11 | 只会执行装载
--------------------------------------------------------------------------------
/java/interview/doc/jvm/题目/06.既然tomcat不遵守双亲委派机制,那么自己定义了一个恶意hashmap会有风险吗.md:
--------------------------------------------------------------------------------
1 | Tomcat不遵循双亲委派机制,只是自定义的classLoader顺序不同,但顶层还是相同的,还是要去顶层请求classloader
--------------------------------------------------------------------------------
/java/interview/doc/jvm/题目/07.Tomcat是个web容器,那么它要解决什么问题.md:
--------------------------------------------------------------------------------
1 | - 一个web容器可能需要部署两个应用程序,不同的应用程序可能会依赖同一个第三方类库的不同版本,不能要求同一个类库在同一个服务器只有一份,因此要保证每个应用程序的类库都是独立的,保证相互隔离
2 | - 部署在同一个web容器中相同的类库相同的版本可以共享。否则,如果服务器有10个应用程序,那么要有10份相同的类库加载进虚拟机,这是扯淡的
3 | - web容器也有自己依赖的类库,不能于应用程序的类库混淆。基于安全考虑,应该让容器的类库和程序的类库隔离开来
4 | - web容器要支持jsp的修改,我们知道,jsp文件最终也是要编译成class文件才能在虚拟机中运行,但程序运行后修改jsp己经是司空见惯的事情,否则要你何用?所以,web容器需要支持 jsp 修改后不用重启
--------------------------------------------------------------------------------
/java/interview/doc/jvm/题目/09.如果tomcat 的 Common ClassLoader 想加载 WebApp ClassLoader 中的类,该怎么办.md:
--------------------------------------------------------------------------------
1 | 我们可以使用线程上下文类加载器实现,使用线程上下文加载器,可以让父类加载器请求子类加载器去完成类加载的动作
--------------------------------------------------------------------------------
/java/interview/doc/jvm/题目/10.为什么java文件放在EclipseIDEA中的src文件夹会优先jar包中的class.md:
--------------------------------------------------------------------------------
1 | 了解tomcat类加载机制的理解,就不难明白,Eclipse/IDEA中的src文件夹中的文件java以及webContent中的JSP都会在tomcat启动时,被编译成class文件放在 WEB-INF/class 中
2 |
3 | 而Eclipse/IDEA外部引用的jar包,则相当于放在 WEB-INF/lib中
--------------------------------------------------------------------------------
/java/interview/doc/jvm/题目/11.栈和堆的区别.md:
--------------------------------------------------------------------------------
1 | # 栈和堆的区别
2 |
3 | ## GC,OOM
4 |
5 | ## 栈和堆的执行效率
6 |
7 | ## 内存大小,数据结构
8 |
9 | ## 栈管运行,堆管存储
--------------------------------------------------------------------------------
/java/interview/doc/jvm/题目/12.说一说栈溢出的情况.md:
--------------------------------------------------------------------------------
1 | 栈滥出:StackoverflowError
2 |
3 | - 一个简单的例子:在main方法中调用main方法,就会不断压栈执行,直到栈滥出
4 | - 栈的大小可以是固定大小的,也可以是动态变化(动态扩展)的
5 | - 如果是固定的,可以通过`-Xss`设置栈的大小
6 | - 如果是动态变化的,当栈大小到达了整个内存空间不足了,就是抛出OutOfMemory异常(java.lang.OutOfMemoryError)
--------------------------------------------------------------------------------
/java/interview/doc/jvm/题目/13.调整栈大小,就能保证不出现溢出吗.md:
--------------------------------------------------------------------------------
1 | 不能,因为调整栈大小,只会减少出现溢出的可能,栈大小不是可以无限扩大的,所以不能保证不出现滥出
--------------------------------------------------------------------------------
/java/interview/doc/jvm/题目/14.分配的栈内存越大越好吗.md:
--------------------------------------------------------------------------------
1 | 不是,因为增加栈大小,会造成每个线程的栈都变的很大,使得一定的栈空间下,能创建的线程数量会变小
--------------------------------------------------------------------------------
/java/interview/doc/jvm/题目/15.垃圾回收是否会涉及到虚拟机栈.md:
--------------------------------------------------------------------------------
1 | 不会,垃圾回收只会涉及到方法区和堆中,方法区和堆也会存在溢出的可能
2 |
3 | 程序计数器,只记录运行下一行的地址,不存在溢出和垃圾回收
4 |
5 | 虚拟机栈和本地方法栈,都是只涉及压栈和出栈,可能存在栈溢出,不存在垃圾回收
6 |
7 |
--------------------------------------------------------------------------------
/java/interview/doc/jvm/题目/16.方法中定义的局部变量是否线程安全.md:
--------------------------------------------------------------------------------
1 | 如果方法内部局部变量没有逃离方法的作用范围它就是安全的,是线程私有的 ,不会产生在多个线程下产生线程干扰
2 |
3 | 如果局部变量引用了对象,并逃离方法的作用范围,它就不是线程安全的(例如:参数变量不是线程安全,会被返回得局部变量不是线程安全的,他们都逃离了方法的作用范围)
--------------------------------------------------------------------------------
/java/interview/doc/mysql/README.md:
--------------------------------------------------------------------------------
1 | # 数据库事务隔离级别
2 |
3 |
4 |
5 | # MVCC 实现原理
6 |
7 | # MySQL 幻读如何解决
8 |
9 | # SQL JOIN 原理
10 |
11 | # MySQL 数据库索引原理,底层索引数据结构,叶子节点存储的是什么,索引失效的情况
12 |
13 | # MySQL 如何做分库分表
14 |
15 | # MySQL 数据存储引擎有哪些
16 |
17 | # InnoDB 与 MyISAM 区别
18 |
19 | # MySQL 聚簇索引与非聚簇索引的区别
20 |
21 | # MySQL 事务有哪些隔离级别,解决了什么问题
22 |
23 | # MySQL 主从复制原理
24 |
25 | # 优化 SQL
26 |
27 | # MySQL 为什么选 B+ 树作为存储结构
28 |
29 | # 描述一下乐观锁与悲观锁,MySQL 锁的种类
30 |
31 | # MySQL 原子性和持久性是怎么保证的
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/java/interview/doc/第3季/01.你知道HashMap的底层数据吗.md:
--------------------------------------------------------------------------------
1 | - JDK1.7及之前:数组 + 链表
2 | - JDK1.8:数组 + 链表 + 红黑树
--------------------------------------------------------------------------------
/java/interview/doc/第3季/03.你知道HashMap是如何解决hash碰撞问题的吗.md:
--------------------------------------------------------------------------------
1 | # Hash Map如何解决 hash 碰撞问题
2 |
3 | ## Hash 运算之后还是有可能得到数组的同一个位置
4 |
5 | - 数组位置存放了链表,不过链表长度过长会导致查询性能很差,极端情况:O(n)
6 | - `TREEIFY_THRESHOLD` 默认为 8,超过之后链表会变为红黑树,时间复杂度:O(logn)
7 |
8 |
--------------------------------------------------------------------------------
/java/interview/doc/第3季/04.说说HashMap是如何进行扩容的可以吗.md:
--------------------------------------------------------------------------------
1 | #### HashMap 如何进行扩容
2 |
3 | - 2倍扩容
4 | - rehash
--------------------------------------------------------------------------------
/java/interview/doc/第3季/05.说说synchronized关键字的底层原理是什么.md:
--------------------------------------------------------------------------------
1 | - **monitorenter**
2 | - **monitorexit**
3 |
4 |
--------------------------------------------------------------------------------
/java/interview/doc/第3季/06.能聊聊你对CAS的理解以及其底层实现原理可以吗.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/interview/doc/第3季/06.能聊聊你对CAS的理解以及其底层实现原理可以吗.md
--------------------------------------------------------------------------------
/java/interview/doc/第3季/07.ConcurrentHashMap实现线程安全的底层原理到底是什么.md:
--------------------------------------------------------------------------------
1 | JDK1.7
2 |
3 | JDK1.8
--------------------------------------------------------------------------------
/java/interview/doc/第3季/08.如何实现一个公平锁.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/interview/doc/第3季/08.如何实现一个公平锁.md
--------------------------------------------------------------------------------
/java/interview/doc/第3季/09.你对JDK中的AQS理解吗?AQS的实现原理是什么.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/interview/doc/第3季/09.你对JDK中的AQS理解吗?AQS的实现原理是什么.md
--------------------------------------------------------------------------------
/java/interview/doc/第3季/10.说说线程池的底层工作原理可以吗.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/interview/doc/第3季/10.说说线程池的底层工作原理可以吗.md
--------------------------------------------------------------------------------
/java/interview/doc/第3季/11.线程池的核心配置参数都是干什么的?平时我们应该怎么用 - 副本.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/interview/doc/第3季/11.线程池的核心配置参数都是干什么的?平时我们应该怎么用 - 副本.md
--------------------------------------------------------------------------------
/java/interview/doc/第3季/12.如果在线程中使用无界阻塞队列会发生什么问题 - 副本.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/interview/doc/第3季/12.如果在线程中使用无界阻塞队列会发生什么问题 - 副本.md
--------------------------------------------------------------------------------
/java/interview/doc/第3季/13.你知道如果线程池的队列满了之后,会发生什么事情吗.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/interview/doc/第3季/13.你知道如果线程池的队列满了之后,会发生什么事情吗.md
--------------------------------------------------------------------------------
/java/interview/doc/第3季/14.如果线上机器突然宕机,线程池的阻塞队列中的请求怎么办.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/interview/doc/第3季/14.如果线上机器突然宕机,线程池的阻塞队列中的请求怎么办.md
--------------------------------------------------------------------------------
/java/interview/doc/高频汇总/2.Redis高频面试题.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/interview/doc/高频汇总/2.Redis高频面试题.md
--------------------------------------------------------------------------------
/java/io/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java
7 | com.github.zj.dreamly
8 | 1.2.1
9 |
10 | 4.0.0
11 |
12 | socket
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/java/io/src/main/java/com/github/zj/dreamly/socket/chatroom/foo/constants/TCPConstants.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.socket.chatroom.foo.constants;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class TCPConstants {
7 | /**
8 | * 服务器固化UDP接收端口
9 | */
10 | public static int PORT_SERVER = 30401;
11 | }
12 |
--------------------------------------------------------------------------------
/java/io/src/main/java/com/github/zj/dreamly/socket/chatroom/foo/constants/UDPConstants.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.socket.chatroom.foo.constants;
2 |
3 | /**
4 | * @author 苍海之南
5 | */
6 | public class UDPConstants {
7 | /**
8 | * 公用头部
9 | */
10 | public static byte[] HEADER = new byte[]{7, 7, 7, 7, 7, 7, 7, 7};
11 | /**
12 | * 服务器固化UDP接收端口
13 | */
14 | public static int PORT_SERVER = 30201;
15 | /**
16 | * 客户端回送端口
17 | */
18 | public static int PORT_CLIENT_RESPONSE = 30202;
19 | }
20 |
--------------------------------------------------------------------------------
/java/io/src/main/java/com/github/zj/dreamly/socket/chatroom/library/box/BytesReceivePacket.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.socket.chatroom.library.box;
2 |
3 | import java.io.ByteArrayOutputStream;
4 |
5 | /**
6 | * 纯Byte数组接收包
7 | *
8 | * @author 苍海之南
9 | */
10 | public class BytesReceivePacket extends AbsByteArrayReceivePacket {
11 |
12 | public BytesReceivePacket(long len) {
13 | super(len);
14 | }
15 |
16 | @Override
17 | public byte type() {
18 | return TYPE_MEMORY_BYTES;
19 | }
20 |
21 | @Override
22 | protected byte[] buildEntity(ByteArrayOutputStream stream) {
23 | return stream.toByteArray();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/io/src/main/java/com/github/zj/dreamly/socket/chatroom/library/box/StringReceivePacket.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.socket.chatroom.library.box;
2 |
3 | import java.io.ByteArrayOutputStream;
4 |
5 | /**
6 | * 字符串接收包
7 | * @author 苍海之南
8 | */
9 | public class StringReceivePacket extends AbsByteArrayReceivePacket {
10 |
11 | public StringReceivePacket(long len) {
12 | super(len);
13 | }
14 |
15 | @Override
16 | protected String buildEntity(ByteArrayOutputStream stream) {
17 | return new String(stream.toByteArray());
18 | }
19 |
20 | @Override
21 | public byte type() {
22 | return TYPE_MEMORY_STRING;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/java/io/src/main/java/com/github/zj/dreamly/socket/chatroom/library/box/StringSendPacket.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.socket.chatroom.library.box;
2 |
3 | /**
4 | * 字符串发送包
5 | *
6 | * @author 苍海之南
7 | */
8 | public class StringSendPacket extends BytesSendPacket {
9 |
10 | /**
11 | * 字符串发送时就是Byte数组,所以直接得到Byte数组,并按照Byte的发送方式发送即可
12 | *
13 | * @param msg 字符串
14 | */
15 | public StringSendPacket(String msg) {
16 | super(msg.getBytes());
17 | }
18 |
19 | @Override
20 | public byte type() {
21 | return TYPE_MEMORY_STRING;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/java/io/src/main/java/com/github/zj/dreamly/socket/chatroom/library/core/ReceiveDispatcher.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.socket.chatroom.library.core;
2 |
3 | import java.io.Closeable;
4 |
5 | /**
6 | * 接收的数据调度封装
7 | * 把一份或者多分IoArgs组合成一份Packet
8 | * @author 苍海之南
9 | */
10 | public interface ReceiveDispatcher extends Closeable {
11 | void start();
12 |
13 | void stop();
14 |
15 | interface ReceivePacketCallback {
16 | ReceivePacket, ?> onArrivedNewPacket(byte type, long length);
17 |
18 | void onReceivePacketCompleted(ReceivePacket packet);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/java/io/src/main/java/com/github/zj/dreamly/socket/chatroom/library/core/Receiver.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.socket.chatroom.library.core;
2 |
3 | import java.io.Closeable;
4 | import java.io.IOException;
5 |
6 | public interface Receiver extends Closeable {
7 | void setReceiveListener(IoArgs.IoArgsEventProcessor processor);
8 |
9 | boolean postReceiveAsync() throws IOException;
10 | }
11 |
--------------------------------------------------------------------------------
/java/io/src/main/java/com/github/zj/dreamly/socket/chatroom/library/core/SendDispatcher.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.socket.chatroom.library.core;
2 |
3 | import java.io.Closeable;
4 |
5 | /**
6 | * 发送数据的调度者
7 | * 缓存所有需要发送的数据,通过队列对数据进行发送
8 | * 并且在发送数据时,实现对数据的基本包装
9 | */
10 | public interface SendDispatcher extends Closeable {
11 | /**
12 | * 发送一份数据
13 | *
14 | * @param packet 数据
15 | */
16 | void send(SendPacket packet);
17 |
18 | /**
19 | * 取消发送数据
20 | *
21 | * @param packet 数据
22 | */
23 | void cancel(SendPacket packet);
24 | }
25 |
--------------------------------------------------------------------------------
/java/io/src/main/java/com/github/zj/dreamly/socket/chatroom/library/core/SendPacket.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.socket.chatroom.library.core;
2 |
3 | import java.io.InputStream;
4 |
5 | /**
6 | * 发送的包定义
7 | */
8 | public abstract class SendPacket extends Packet {
9 | private boolean isCanceled;
10 |
11 | public boolean isCanceled() {
12 | return isCanceled;
13 | }
14 |
15 | /**
16 | * 设置取消发送标记
17 | */
18 | public void cancel() {
19 | isCanceled = true;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/java/io/src/main/java/com/github/zj/dreamly/socket/chatroom/library/core/Sender.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.socket.chatroom.library.core;
2 |
3 | import java.io.Closeable;
4 | import java.io.IOException;
5 |
6 | public interface Sender extends Closeable {
7 | void setSendListener(IoArgs.IoArgsEventProcessor processor);
8 |
9 | boolean postSendAsync() throws IOException;
10 | }
11 |
--------------------------------------------------------------------------------
/java/io/src/main/java/com/github/zj/dreamly/socket/chatroom/library/frames/CancelReceiveFrame.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.socket.chatroom.library.frames;
2 |
3 | import com.github.zj.dreamly.socket.chatroom.library.core.IoArgs;
4 |
5 | import java.io.IOException;
6 |
7 | /**
8 | * 取消传输帧,接收实现
9 | * @author 苍海之南
10 | */
11 | public class CancelReceiveFrame extends AbsReceiveFrame {
12 |
13 | CancelReceiveFrame(byte[] header) {
14 | super(header);
15 | }
16 |
17 | @Override
18 | protected int consumeBody(IoArgs args) throws IOException {
19 | return 0;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/java/io/src/main/java/com/github/zj/dreamly/socket/chatroom/library/utils/CloseUtils.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.socket.chatroom.library.utils;
2 |
3 | import java.io.Closeable;
4 | import java.io.IOException;
5 |
6 | /**
7 | * @author 苍海之南
8 | */
9 | public class CloseUtils {
10 | public static void close(Closeable... closeables) {
11 | if (closeables == null) {
12 | return;
13 | }
14 | for (Closeable closeable : closeables) {
15 | if (closeable == null) {
16 | continue;
17 | }
18 | try {
19 | closeable.close();
20 | } catch (IOException e) {
21 | e.printStackTrace();
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/jdk8/res/nashorn1.js:
--------------------------------------------------------------------------------
1 | var fun1 = function(name) {
2 | print('Hi there from Javascript, ' + name);
3 | return "greetings from javascript";
4 | };
5 |
6 | var fun2 = function (object) {
7 | print("JS Class Definition: " + Object.prototype.toString.call(object));
8 | };
--------------------------------------------------------------------------------
/java/jdk8/res/nashorn10.js:
--------------------------------------------------------------------------------
1 | var results = [];
2 |
3 | var Context = function () {
4 | this.foo = 'bar';
5 | };
6 |
7 | Context.prototype.testArgs = function () {
8 | if (arguments[0]) {
9 | results.push(true);
10 | }
11 | if (arguments[1]) {
12 | results.push(true);
13 | }
14 | if (arguments[2]) {
15 | results.push(true);
16 | }
17 | if (arguments[3]) {
18 | results.push(true);
19 | }
20 | };
21 |
22 | var testPerf = function () {
23 | var context = new Context();
24 | context.testArgs();
25 | context.testArgs(1);
26 | context.testArgs(1, 2);
27 | context.testArgs(1, 2, 3);
28 | context.testArgs(1, 2, 3, 4);
29 | };
--------------------------------------------------------------------------------
/java/jdk8/res/nashorn5.js:
--------------------------------------------------------------------------------
1 | function Product(name) {
2 | this.name = name;
3 | }
4 |
5 | Product.prototype.stock = 0;
6 | Product.prototype.price = 0;
7 | Product.prototype.getValueOfGoods = function() {
8 | return this.stock * this.price;
9 | };
10 |
11 | var product = new Product('Pencil');
12 | product.price = 4.99;
13 | product.stock = 78;
14 |
15 | print('Value of Goods: ' + product.getValueOfGoods());
16 |
17 |
18 | var getValueOfGoods = function(javaProduct) {
19 | var jsProduct = new Product();
20 | Object.bindProperties(jsProduct, javaProduct);
21 | return jsProduct.getValueOfGoods();
22 | };
--------------------------------------------------------------------------------
/java/jdk8/res/nashorn7.js:
--------------------------------------------------------------------------------
1 | function sqrt(x) x * x
2 | print(sqrt(3));
3 |
4 | var array = [1, 2, 3, 4];
5 | for each (var num in array) print(num);
6 |
7 | var runnable = new java.lang.Runnable() {
8 | run: function () {
9 | print('on the run');
10 | }
11 | };
12 |
13 | runnable.run();
14 |
15 | var System = Java.type('java.lang.System');
16 | System.out["println(double)"](12);
17 |
18 | var Arrays = Java.type("java.util.Arrays");
19 | var javaArray = Java.to([2, 3, 7, 11, 14], "int[]");
20 |
21 | Arrays.stream(javaArray)
22 | .filter(function (num) {
23 | return num % 2 === 1;
24 | })
25 | .forEach(function (num) {
26 | print(num);
27 | });
--------------------------------------------------------------------------------
/java/jdk8/res/nashorn8.js:
--------------------------------------------------------------------------------
1 | var evaluate1 = function () {
2 | (function () {
3 | print(eval("this"));
4 | }).call(this);
5 | };
6 |
7 | var evaluate2 = function () {
8 | var context = {};
9 | (function () {
10 | print(eval("this"));
11 | }).call(context);
12 | };
13 |
14 | var evaluate3 = function (context) {
15 | (function () {
16 | print(eval("this"));
17 | }).call(context);
18 | };
--------------------------------------------------------------------------------
/java/jdk8/res/nashorn9.js:
--------------------------------------------------------------------------------
1 | var size = 100000;
2 |
3 | var testPerf = function () {
4 | var result = Math.floor(Math.random() * size) + 1;
5 | for (var i = 0; i < size; i++) {
6 | result += i;
7 | }
8 | return result;
9 | };
--------------------------------------------------------------------------------
/java/jdk8/src/main/java/com/github/zj/dreamly/java8/concurrent/CompletableFuture1.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.java8.concurrent;
2 |
3 | import java.util.concurrent.CompletableFuture;
4 | import java.util.concurrent.ExecutionException;
5 |
6 | /**
7 | * @author Benjamin Winterberg
8 | */
9 | public class CompletableFuture1 {
10 |
11 | public static void main(String[] args) throws ExecutionException, InterruptedException {
12 | CompletableFuture future = new CompletableFuture<>();
13 |
14 | future.complete("42");
15 |
16 | future
17 | .thenAccept(System.out::println)
18 | .thenAccept(v -> System.out.println("done"));
19 |
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/java/jdk8/src/main/java/com/github/zj/dreamly/java8/lambda/Person.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.java8.lambda;
2 |
3 | /**
4 | * @author Benjamin Winterberg
5 | */
6 | public class Person {
7 | public String firstName;
8 | public String lastName;
9 |
10 | public Person() {
11 | }
12 |
13 | public Person(String firstName, String lastName) {
14 | this.firstName = firstName;
15 | this.lastName = lastName;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/jdk8/src/main/java/com/github/zj/dreamly/java8/nashorn/Nashorn3.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.java8.nashorn;
2 |
3 | import javax.script.ScriptEngine;
4 | import javax.script.ScriptEngineManager;
5 |
6 | /**
7 | * Working with java types from javascript.
8 | *
9 | * @author Benjamin Winterberg
10 | */
11 | public class Nashorn3 {
12 |
13 | public static void main(String[] args) throws Exception {
14 | ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
15 | engine.eval("load('res/nashorn3.js')");
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/java/jdk8/src/main/java/com/github/zj/dreamly/java8/nashorn/Nashorn4.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.java8.nashorn;
2 |
3 | import javax.script.ScriptEngine;
4 | import javax.script.ScriptEngineManager;
5 |
6 | /**
7 | * Working with java types from javascript.
8 | *
9 | * @author Benjamin Winterberg
10 | */
11 | public class Nashorn4 {
12 |
13 | public static void main(String[] args) throws Exception {
14 | ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
15 | engine.eval("loadWithNewGlobal('res/nashorn4.js')");
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/java/jdk8/src/main/java/com/github/zj/dreamly/java8/nashorn/SuperRunner.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.java8.nashorn;
2 |
3 | /**
4 | * @author Benjamin Winterberg
5 | */
6 | public class SuperRunner implements Runnable {
7 |
8 | @Override
9 | public void run() {
10 | System.out.println("super run");
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/java/jdk8/src/main/java/com/github/zj/dreamly/java8/stream/Optional1.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.java8.stream;
2 |
3 | import java.util.Optional;
4 |
5 | /**
6 | * @author Benjamin Winterberg
7 | */
8 | public class Optional1 {
9 |
10 | public static void main(String[] args) {
11 | Optional optional = Optional.of("bam");
12 |
13 | optional.isPresent(); // true
14 | optional.get(); // "bam"
15 | optional.orElse("fallback"); // "bam"
16 |
17 | optional.ifPresent((s) -> System.out.println(s.charAt(0))); // "b"
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/java/jdk8/src/main/java/com/github/zj/dreamly/java8/stream/Streams9.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.java8.stream;
2 |
3 | import java.util.Arrays;
4 |
5 | /**
6 | * @author Benjamin Winterberg
7 | */
8 | public class Streams9 {
9 |
10 | public static void main(String[] args) {
11 | Arrays.asList("a1", "a2", "b1", "c2", "c1")
12 | .stream()
13 | .filter(s -> s.startsWith("c"))
14 | .map(String::toUpperCase)
15 | .sorted()
16 | .forEach(System.out::println);
17 |
18 | // C1
19 | // C2
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/java/juc/src/main/java/com/atguigu/juc/Juc2021Application.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.juc;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Juc2021Application
8 | {
9 |
10 | public static void main(String[] args)
11 | {
12 | SpringApplication.run(Juc2021Application.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/java/juc/src/main/java/com/atguigu/juc/cas/CASDemo.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.juc.cas;
2 |
3 | import java.util.concurrent.atomic.AtomicInteger;
4 |
5 | /**
6 | * @auther zzyy
7 | * @create 2021-03-17 15:13
8 | */
9 | public class CASDemo
10 | {
11 | public static void main(String[] args)
12 | {
13 | AtomicInteger atomicInteger = new AtomicInteger(5);
14 | System.out.println(atomicInteger.get());
15 |
16 |
17 | System.out.println(atomicInteger.compareAndSet(5, 308)+"\t"+atomicInteger.get());
18 |
19 | System.out.println(atomicInteger.compareAndSet(5, 3333)+"\t"+atomicInteger.get());
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/java/juc/src/main/java/com/atguigu/juc/cf/CompletableFutureDemo.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.juc.cf;
2 |
3 |
4 | import java.util.concurrent.*;
5 |
6 | /**
7 | * @auther zzyy
8 | * @create 2021-03-02 11:56
9 | */
10 | public class CompletableFutureDemo
11 | {
12 | public static void main(String[] args)throws Exception
13 | {
14 | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 20, 1L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(50), Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
15 |
16 |
17 |
18 | threadPoolExecutor.shutdown();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/java/juc/src/main/java/com/atguigu/juc/jmm/SingletonDemo.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.juc.jmm;
2 |
3 | /**
4 | * @auther zzyy
5 | * @create 2021-03-19 19:21
6 | */
7 | public class SingletonDemo
8 | {
9 | private SingletonDemo() { }
10 |
11 | private static class SingletonDemoHandler
12 | {
13 | private static SingletonDemo instance = new SingletonDemo();
14 | }
15 |
16 | public static SingletonDemo getInstance()
17 | {
18 | return SingletonDemoHandler.instance;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/java/juc/src/main/java/com/atguigu/juc/locks/LockByteCodeDemo.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.juc.locks;
2 |
3 | /**
4 | * @auther zzyy
5 | * @create 2021-03-03 15:21
6 | * 从字节码角度分析synchronized实现
7 | */
8 | public class LockByteCodeDemo
9 | {
10 | final Object object = new Object();
11 |
12 |
13 |
14 | public void m1()
15 | {
16 | synchronized (object){
17 | System.out.println("----------hello sync");
18 | throw new RuntimeException("----ex");
19 | }
20 | }
21 |
22 | /*public synchronized void m2()
23 | {
24 |
25 | }*/
26 |
27 | public static synchronized void m2()
28 | {
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/java/juc/src/main/java/com/atguigu/juc/test/Book.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.juc.test;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | /**
8 | * @auther zzyy
9 | * @create 2021-03-10 10:13
10 | */
11 | @Data
12 | @AllArgsConstructor
13 | @NoArgsConstructor
14 | //@Accessors(chain = true)
15 | public class Book
16 | {
17 | private Integer id;
18 | private String bookName;
19 | private double price;
20 | private String author;
21 | }
22 |
--------------------------------------------------------------------------------
/java/jvm/chapter008_tuning/src/main/java/com/atguigu/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.demo;
2 |
3 | import org.mybatis.spring.annotation.MapperScan;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 |
7 | @SpringBootApplication
8 | @MapperScan("com.atguigu.demo.mapper")
9 | public class DemoApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DemoApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/java/jvm/chapter008_tuning/src/main/java/com/atguigu/demo/mapper/PeopleMapper.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.demo.mapper;
2 |
3 | import com.atguigu.demo.bean.People;
4 | import org.springframework.stereotype.Repository;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | *
10 | * @author : shkstart
11 | * email : shkstart@126.com
12 | * time : 15:21
13 | * version : v1.0
14 | *
15 | */
16 | @Repository
17 | public interface PeopleMapper {
18 | List getPeopleList();
19 | }
20 |
--------------------------------------------------------------------------------
/java/jvm/chapter008_tuning/src/main/resources/application-dev.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8080
3 |
4 | spring:
5 | datasource:
6 | username: root
7 | password: abc123
8 | url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
9 | driver-class-name: com.mysql.cj.jdbc.Driver
10 |
11 | mybatis:
12 | mapper-locations: classpath:mapping/*Mapper.xml
13 | type-aliases-package: com.atguigu.demo.bean
14 |
15 | #showSql
16 | logging:
17 | level:
18 | com:
19 | example:
20 | mapper : debug
--------------------------------------------------------------------------------
/java/jvm/chapter008_tuning/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | profiles:
3 | active: dev
--------------------------------------------------------------------------------
/java/jvm/chapter008_tuning/src/test/java/com/atguigu/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class DemoApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/java/jvm/chapter01_bytecode/src/com/atguigu/java/ValueTransfer1.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java;
2 |
3 | import java.util.Date;
4 |
5 | /**
6 | * @author shkstart
7 | * @create 0:34
8 | */
9 | public class ValueTransfer1 {
10 | public static void main(String[] args) {
11 | int m = 10;
12 | int n = m;
13 |
14 | long l1 = 10L;
15 | long l2 = 10L;
16 |
17 | Date date1 = new Date();
18 | Date date2 = date1;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/java/jvm/chapter01_bytecode/src/com/atguigu/java1/ArrayTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java1;
2 |
3 | /**
4 | * @author shkstart
5 | * @create 2020-09-04 19:03
6 | */
7 | public class ArrayTest {
8 | public static void main(String[] args) {
9 | Object[] arr = new Object[10];
10 | System.out.println(arr);//[Ljava.lang.Object;@1540e19d
11 |
12 | String[] arr1 = new String[10];
13 | System.out.println(arr1);//[Ljava.lang.String;@677327b6
14 |
15 | long[][] arr2 = new long[10][];
16 | System.out.println(arr2);//[[J@14ae5a5
17 |
18 | boolean[] arr3 = new boolean[10];
19 | System.out.println(arr3);//[Z@330bedb4
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/java/jvm/chapter01_bytecode/src/com/atguigu/java1/Demo.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java1;
2 |
3 | /**
4 | * @author shkstart
5 | * @create 2020-08-31 8:52
6 | * 全类名:com.atguigu.java1.Demo
7 | * 全限定名:com/atguigu/java1/Demo
8 | */
9 | public class Demo {
10 | private int num = 1;
11 |
12 | public int add(){
13 | num = num + 2;
14 | return num;
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/jvm/chapter01_bytecode/src/com/atguigu/java2/InterfaceMethodTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java2;
2 |
3 | /**
4 | * @author shkstart
5 | * @create 2020-09-10 17:26
6 | * 补充:方法调用指令的补充说明
7 | */
8 | public class InterfaceMethodTest {
9 | public static void main(String[] args) {
10 | AA aa = new BB();
11 |
12 | aa.method2();
13 |
14 | AA.method1();
15 | }
16 | }
17 |
18 |
19 | interface AA{
20 | public static void method1(){
21 |
22 | }
23 |
24 | public default void method2(){
25 |
26 | }
27 | }
28 |
29 | class BB implements AA{
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/java/jvm/chapter01_bytecode/src/com/atguigu/java2/StackOperateTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java2;
2 |
3 | /**
4 | * @author shkstart
5 | * @create 2020-09-08 10:13
6 | *
7 | * 指令6:操作数栈管理指令
8 | */
9 | public class StackOperateTest {
10 |
11 | public void print(){
12 | Object obj = new Object();
13 | // String info = obj.toString();
14 | obj.toString();
15 | }
16 | //类似的
17 | public void foo(){
18 | bar();
19 | }
20 | public long bar(){
21 | return 0;
22 | }
23 |
24 | public long nextIndex() {
25 | return index++;
26 | }
27 |
28 | private long index = 0;
29 | }
30 |
--------------------------------------------------------------------------------
/java/jvm/chapter01_bytecode/src/com/atguigu/java2/SynchronizedTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java2;
2 |
3 | /**
4 | * @author shkstart
5 | * @create 2020-09-08 13:54
6 | *
7 | * 指令9:同步控制指令
8 | */
9 | public class SynchronizedTest {
10 |
11 | private int i = 0;
12 | public void add(){
13 | i++;
14 | }
15 |
16 |
17 | private Object obj = new Object();
18 | public void subtract(){
19 |
20 | synchronized (obj){
21 | i--;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/java/jvm/chapter01_bytecode/src/com/atguigu/java3/InterviewTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java3;
2 |
3 | import org.junit.Test;
4 |
5 | /**
6 | * @author shkstart
7 | * @create 14:52
8 | */
9 | public class InterviewTest {
10 | @Test
11 | public void test1(){
12 | Integer x = 128;
13 | int y = 128;
14 | System.out.println(x == y);//true
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/jvm/chapter02_classload/order.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/jvm/chapter02_classload/order.dat
--------------------------------------------------------------------------------
/java/jvm/chapter02_classload/src/com/atguigu/java/InitializationTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java;
2 |
3 | /**
4 | * @author shkstart
5 | * @create 2020-09-13 11:55
6 | *
7 | * 过程三:初始化阶段
8 | */
9 | public class InitializationTest {
10 | public static int id = 1;
11 | public static int number;
12 |
13 | static {
14 | number = 2;
15 | System.out.println("father static{}");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/jvm/chapter02_classload/src/com/atguigu/java/InitializationTest1.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java;
2 |
3 | /**
4 | * @author shkstart
5 | * @create 18:49
6 | * 哪些场景下,java编译器就不会生成()方法
7 | */
8 | public class InitializationTest1 {
9 | //场景1:对于非静态的字段,不管是否进行了显式赋值,都不会生成()方法
10 | public int num = 1;
11 | //场景2:静态的字段,没有显式的赋值,不会生成()方法
12 | public static int num1;
13 | //场景3:比如对于声明为static final的基本数据类型的字段,不管是否进行了显式赋值,都不会生成()方法
14 | public static final int num2 = 1;
15 | }
16 |
--------------------------------------------------------------------------------
/java/jvm/chapter02_classload/src/com/atguigu/java/SubInitialization.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java;
2 |
3 | /**
4 | * @author shkstart
5 | * @create 2020-09-13 11:59
6 | */
7 | public class SubInitialization extends InitializationTest {
8 | static{
9 | number = 4;//number属性必须提前已经加载:一定会先加载父类。
10 | System.out.println("son static{}");
11 | }
12 |
13 | public static void main(String[] args) {
14 | System.out.println(number);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/jvm/chapter02_classload/src/com/atguigu/java2/Test.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java2;
2 |
3 | /**
4 | * @author shkstart
5 | * @create 15:43
6 | */
7 | public class Test {
8 | static int x, y, z;
9 |
10 | static {
11 | int x = 5;
12 | x--;
13 | }
14 |
15 | static {
16 | x--;
17 | }
18 |
19 | public static void main(String[] args) {
20 | System.out.println("x=" + x);
21 | z--;
22 | method();
23 | System.out.println("result:" + (z + y + ++z));
24 | }
25 |
26 | public static void method() {
27 | y = z++ + ++z;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/java/jvm/chapter02_classload/src/com/atguigu/java3/User.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java3;
2 |
3 | /**
4 | * @author shkstart
5 | * @create 0:23
6 | */
7 | public class User {
8 | private int id;
9 |
10 | @Override
11 | public String toString() {
12 | return "User{" +
13 | "id=" + id +
14 | '}';
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/jvm/chapter02_classload/src/java/lang/String.java:
--------------------------------------------------------------------------------
1 | package java.lang;
2 |
3 | /**
4 | * @author shkstart
5 | * @create 9:41
6 | */
7 | //public class String {
8 | // byte[] value;
9 | //}
10 |
--------------------------------------------------------------------------------
/java/jvm/chapter02_classload/src/java/lang/StringTest.java:
--------------------------------------------------------------------------------
1 | package java.lang;
2 |
3 | /**
4 | * @author shkstart
5 | * @create 9:41
6 | */
7 | public class StringTest {
8 | public static void main(String[] args) {
9 | String str = new String();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/jvm/chapter03_runtimearea/src/com/atguigu/heap/YoungOldAreaTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.heap;
2 |
3 | /** 测试:大对象直接进入老年代
4 | * -Xms60m -Xmx60m -XX:NewRatio=2 -XX:SurvivorRatio=8 -XX:+PrintGCDetails
5 | * @author shkstart shkstart@126.com
6 | * @create 2021 21:48
7 | */
8 | public class YoungOldAreaTest {
9 | public static void main(String[] args) {
10 | byte[] buffer = new byte[1024 * 1024 * 20];//20m
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/java/jvm/chapter03_runtimearea/src/com/atguigu/heap1/TLABArgsTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.heap1;
2 |
3 | /**
4 | * 测试-XX:+/-UseTLAB参数是否开启的情况:默认情况是开启的
5 | *
6 | * @author shkstart shkstart@126.com
7 | * @create 2020 16:16
8 | */
9 | public class TLABArgsTest {
10 | public static void main(String[] args) {
11 | System.out.println("我只是来打个酱油~");
12 | try {
13 | Thread.sleep(1000000);
14 | } catch (InterruptedException e) {
15 | e.printStackTrace();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/java/jvm/chapter04_object/src/com/atguigu/java/CustomerTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java;
2 |
3 | /**
4 | * @author shkstart shkstart@126.com
5 | * @create 2020 18:42
6 | */
7 | public class CustomerTest {
8 | public static void main(String[] args) {
9 | // Customer cust1 = new Customer();
10 |
11 | Customer cust2 = new Customer("Tom");
12 | System.out.println(cust2.name);
13 |
14 | System.out.println(cust2.getClass());
15 |
16 | System.out.println(cust2);
17 |
18 | Customer cust3 = cust2;
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/java/jvm/chapter04_object/src/com/atguigu/java/ObjectTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.java;
2 |
3 | /**
4 | * @author shkstart shkstart@126.com
5 | * @create 2020 17:16
6 | */
7 | public class ObjectTest {
8 | public static void main(String[] args) {
9 | Object obj = new Object();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/jvm/chapter06_gc/src/com/atguigu/other1/StrongReferenceTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.other1;
2 |
3 | /**
4 | * 强引用的测试
5 | *
6 | * @author shkstart shkstart@126.com
7 | * @create 2020 16:05
8 | */
9 | public class StrongReferenceTest {
10 | public static void main(String[] args) {
11 | StringBuffer str = new StringBuffer ("Hello,尚硅谷");
12 | StringBuffer str1 = str;
13 |
14 | str = null;
15 | System.gc();
16 |
17 | try {
18 | Thread.sleep(3000);
19 | } catch (InterruptedException e) {
20 | e.printStackTrace();
21 | }
22 |
23 | System.out.println(str1);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/jvm/chapter07_monitoring/src/com/atguigu/jps/JPSTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.jps;
2 |
3 | import java.util.Scanner;
4 |
5 | /**
6 | * @author shkstart
7 | * @create 14:57
8 | *
9 | */
10 | public class JPSTest {
11 | public static void main(String[] args) {
12 | try {
13 | Thread.sleep(100000);
14 | } catch (InterruptedException e) {
15 | e.printStackTrace();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/java/jvm/chapter07_monitoring/src/com/atguigu/jstack/TreadSleepTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.jstack;
2 |
3 | /**
4 | * 演示线程:TIMED_WAITING
5 | *
6 | * @author shkstart
7 | * @create 15:28
8 | */
9 | public class TreadSleepTest {
10 | public static void main(String[] args) {
11 | System.out.println("hello - 1");
12 | try {
13 | Thread.sleep(1000 * 60 * 10);
14 | } catch (InterruptedException e) {
15 | e.printStackTrace();
16 | }
17 |
18 | System.out.println("hello - 2");
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/java/jvm/chapter07_monitoring/src/com/atguigu/jstat/ScannerTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.jstat;
2 |
3 | import java.util.Scanner;
4 |
5 | /**
6 | * @author shkstart
7 | * @create 14:57
8 | *
9 | */
10 | public class ScannerTest {
11 | public static void main(String[] args) {
12 | Scanner scanner = new Scanner(System.in);
13 | String info = scanner.next();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/java/jvm/chatper08_tuning/src/com/atguigu/adaptive/AdaptiveSizePolicyTest.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.adaptive;
2 |
3 | /**
4 | * 使用ParallelGC的情况下,不管是否开启了UseAdaptiveSizePolicy参数,默认Eden与Survivor的比例都为:6:1:1
5 | *
6 | *
7 | *
8 | * @author shkstart
9 | * @create 12:53
10 | */
11 | public class AdaptiveSizePolicyTest {
12 | public static void main(String[] args) {
13 | try {
14 | Thread.sleep(1000000);
15 | } catch (InterruptedException e) {
16 | e.printStackTrace();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/client/codec/OrderFrameDecoder.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.client.codec;
2 |
3 |
4 | import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
5 |
6 | public class OrderFrameDecoder extends LengthFieldBasedFrameDecoder {
7 | public OrderFrameDecoder() {
8 | super(Integer.MAX_VALUE, 0, 2, 0, 2);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/client/codec/OrderFrameEncoder.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.client.codec;
2 |
3 |
4 | import io.netty.handler.codec.LengthFieldPrepender;
5 |
6 | public class OrderFrameEncoder extends LengthFieldPrepender {
7 | public OrderFrameEncoder() {
8 | super(2);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/client/handler/ClientIdleCheckHandler.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.client.handler;
2 |
3 | import io.netty.handler.timeout.IdleStateHandler;
4 |
5 | public class ClientIdleCheckHandler extends IdleStateHandler {
6 |
7 | public ClientIdleCheckHandler() {
8 | super(0, 5, 0);
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/client/handler/dispatcher/OperationResultFuture.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.client.handler.dispatcher;
2 |
3 | import com.github.zj.dreamly.netty.netty.common.OperationResult;
4 | import io.netty.util.concurrent.DefaultPromise;
5 |
6 | public class OperationResultFuture extends DefaultPromise {
7 | }
8 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/common/MessageBody.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.common;
2 |
3 | public abstract class MessageBody {
4 | }
5 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/common/MessageHeader.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.common;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public class MessageHeader {
7 |
8 | private int version = 1;
9 | private int opCode;
10 | private long streamId;
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/common/Operation.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.common;
2 |
3 | public abstract class Operation extends MessageBody {
4 |
5 | public abstract OperationResult execute();
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/common/OperationResult.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.common;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public abstract class OperationResult extends MessageBody {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/common/ResponseMessage.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.common;
2 |
3 | public class ResponseMessage extends Message {
4 | @Override
5 | public Class getMessageBodyDecodeClass(int opcode) {
6 | return OperationType.fromOpCode(opcode).getOperationResultClazz();
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/common/auth/AuthOperationResult.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.common.auth;
2 |
3 | import com.github.zj.dreamly.netty.netty.common.OperationResult;
4 | import lombok.Data;
5 |
6 | @Data
7 | public class AuthOperationResult extends OperationResult {
8 |
9 | private final boolean passAuth;
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/common/keepalive/KeepaliveOperationResult.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.common.keepalive;
2 |
3 | import com.github.zj.dreamly.netty.netty.common.OperationResult;
4 | import lombok.Data;
5 |
6 | @Data
7 | public class KeepaliveOperationResult extends OperationResult {
8 |
9 | private final long time;
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/common/order/OrderOperationResult.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.common.order;
2 |
3 | import com.github.zj.dreamly.netty.netty.common.OperationResult;
4 | import lombok.Data;
5 |
6 | @Data
7 | public class OrderOperationResult extends OperationResult {
8 |
9 | private final int tableId;
10 | private final String dish;
11 | private final boolean complete;
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/server/codec/OrderFrameDecoder.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.server.codec;
2 |
3 |
4 | import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
5 |
6 | public class OrderFrameDecoder extends LengthFieldBasedFrameDecoder {
7 | public OrderFrameDecoder() {
8 | super(10240, 0, 2, 0, 2);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/server/codec/OrderFrameEncoder.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.server.codec;
2 |
3 |
4 | import io.netty.handler.codec.LengthFieldPrepender;
5 |
6 | public class OrderFrameEncoder extends LengthFieldPrepender {
7 | public OrderFrameEncoder() {
8 | super(2);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/util/IdUtil.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.util;
2 |
3 | import java.util.concurrent.atomic.AtomicLong;
4 |
5 | public final class IdUtil {
6 |
7 | private static final AtomicLong IDX = new AtomicLong();
8 |
9 | private IdUtil() {
10 | //no instance
11 | }
12 |
13 | public static long nextId() {
14 | return IDX.incrementAndGet();
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/java/netty/src/main/java/com/github/zj/dreamly/netty/netty/util/JsonUtil.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.netty.netty.util;
2 |
3 | import com.google.gson.Gson;
4 |
5 | public final class JsonUtil {
6 |
7 | private static final Gson GSON = new Gson();
8 |
9 | private JsonUtil() {
10 | //no instance
11 | }
12 |
13 | public static T fromJson(String jsonStr, Class clazz) {
14 | return GSON.fromJson(jsonStr, clazz);
15 | }
16 |
17 | public static String toJson(Object object) {
18 | return GSON.toJson(object);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/java/netty/src/main/resources/leakDetect.txt:
--------------------------------------------------------------------------------
1 | -Dio.netty.leakDetection.level=PARANOID
--------------------------------------------------------------------------------
/java/netty/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootLogger=debug,console
2 | log4j.appender.console=org.apache.log4j.ConsoleAppender
3 | log4j.appender.console.layout=org.apache.log4j.PatternLayout
4 | log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss} [%t] %C{1}: %m%n
5 |
6 |
--------------------------------------------------------------------------------
/java/redis/src/main/java/com/atguigu/redis/Redis20210511Application.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.redis;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import tk.mybatis.spring.annotation.MapperScan;
6 |
7 | @SpringBootApplication
8 | @MapperScan("com.atguigu.redis.mapper") //import tk.mybatis.spring.annotation.MapperScan;
9 | public class Redis20210511Application
10 | {
11 |
12 | public static void main(String[] args)
13 | {
14 | SpringApplication.run(Redis20210511Application.class, args);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/java/redis/src/main/java/com/atguigu/redis/mapper/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.redis.mapper;
2 |
3 | import com.atguigu.redis.entities.User;
4 | import tk.mybatis.mapper.common.Mapper;
5 |
6 | public interface UserMapper extends Mapper {
7 | }
8 |
--------------------------------------------------------------------------------
/java/redis/src/main/java/com/atguigu/redis/util/Constants.java:
--------------------------------------------------------------------------------
1 | package com.atguigu.redis.util;
2 |
3 | /**
4 | * @auther zzyy
5 | * @create 2021-05-09 14:48
6 | */
7 | public class Constants {
8 |
9 | public static final String JHS_KEY="jhs";
10 |
11 | public static final String JHS_KEY_A="jhs:a";
12 |
13 | public static final String JHS_KEY_B="jhs:b";
14 |
15 | public static final String REBLOOM="rebloom:uid:";
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/java/rocketmq/doc/RocketMQ用户指南v3.2.4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/java/rocketmq/doc/RocketMQ用户指南v3.2.4.pdf
--------------------------------------------------------------------------------
/java/rocketmq/src/main/java/com/imooc/jiangzh/kafka/KafkaStudyApplication.java:
--------------------------------------------------------------------------------
1 | package com.imooc.jiangzh.kafka;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class KafkaStudyApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(KafkaStudyApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/java/rocketmq/src/main/java/com/imooc/jiangzh/kafka/wechat/conf/KafkaProperties.java:
--------------------------------------------------------------------------------
1 | package com.imooc.jiangzh.kafka.wechat.conf;
2 |
3 | import lombok.Data;
4 | import org.springframework.boot.context.properties.ConfigurationProperties;
5 | import org.springframework.context.annotation.Configuration;
6 |
7 | @Data
8 | @Configuration
9 | @ConfigurationProperties(prefix = "wechat.kafka")
10 | public class KafkaProperties {
11 |
12 | private String bootstrapServers;
13 | private String acksConfig;
14 | private String partitionerClass;
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/java/rocketmq/src/main/java/com/imooc/jiangzh/kafka/wechat/service/WechatTemplateService.java:
--------------------------------------------------------------------------------
1 | package com.imooc.jiangzh.kafka.wechat.service;
2 |
3 |
4 | import com.alibaba.fastjson.JSONObject;
5 | import com.imooc.jiangzh.kafka.wechat.conf.WechatTemplateProperties;
6 |
7 | public interface WechatTemplateService {
8 |
9 | // 获取微信调查问卷模板 - 获取目前active为true的模板就可以了
10 | WechatTemplateProperties.WechatTemplate getWechatTemplate();
11 |
12 | // 上报调查问卷填写结果
13 | void templateReported(JSONObject reportInfo);
14 |
15 | // 获取调查问卷的统计结果
16 | JSONObject templateStatistics(String templateId);
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/java/skill/src/main/java/com/github/zj/dreamly/skill/AllLearningApplication.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.skill;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.web.servlet.ServletComponentScan;
6 |
7 | @SpringBootApplication
8 | @ServletComponentScan
9 | public class AllLearningApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(AllLearningApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/java/spring-annotation/src/main/java/com/github/zj/dreamly/spring/annotation/aop/MathCalculator.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.spring.annotation.aop;
2 |
3 | /**
4 | * MathCalculator
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-06-30 09:52
8 | **/
9 | public class MathCalculator {
10 | public int div(int i, int j) {
11 | System.out.println("MathCalculator...div...");
12 | return i / j;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/java/spring-annotation/src/main/java/com/github/zj/dreamly/spring/annotation/bean/Blue.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.spring.annotation.bean;
2 |
3 | /**
4 | * Blue
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-06-28 08:44
8 | **/
9 | public class Blue {
10 | }
11 |
--------------------------------------------------------------------------------
/java/spring-annotation/src/main/java/com/github/zj/dreamly/spring/annotation/bean/Car.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.spring.annotation.bean;
2 |
3 | import org.springframework.stereotype.Component;
4 |
5 | /**
6 | * Car
7 | *
8 | * @author: 苍海之南
9 | * @since: 2019-06-28 10:33
10 | **/
11 | @Component
12 | public class Car {
13 |
14 | public Car() {
15 | System.out.println("car constructor...");
16 | }
17 |
18 | public void init() {
19 | System.out.println("car init...");
20 | }
21 |
22 | public void detroy() {
23 | System.out.println("car detroy...");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/spring-annotation/src/main/java/com/github/zj/dreamly/spring/annotation/bean/Color.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.spring.annotation.bean;
2 |
3 | /**
4 | * Color
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-06-28 08:59
8 | **/
9 | public class Color {
10 |
11 | private Car car;
12 |
13 | public Car getCar() {
14 | return car;
15 | }
16 |
17 | public void setCar(Car car) {
18 | this.car = car;
19 | }
20 |
21 | @Override
22 | public String toString() {
23 | return "Color [car=" + car + "]";
24 | }
25 |
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/java/spring-annotation/src/main/java/com/github/zj/dreamly/spring/annotation/bean/RainBow.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.spring.annotation.bean;
2 |
3 | /**
4 | * RainBow
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-06-28 09:43
8 | **/
9 | public class RainBow {
10 | }
11 |
--------------------------------------------------------------------------------
/java/spring-annotation/src/main/java/com/github/zj/dreamly/spring/annotation/bean/Yellow.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.spring.annotation.bean;
2 |
3 | /**
4 | * Yellow
5 | *
6 | * @author: 苍海之南
7 | * @since: 2019-06-28 08:59
8 | **/
9 | public class Yellow {
10 | }
11 |
--------------------------------------------------------------------------------
/java/spring-annotation/src/main/java/com/github/zj/dreamly/spring/annotation/controller/BookController.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.spring.annotation.controller;
2 |
3 | import org.springframework.stereotype.Controller;
4 |
5 | /**
6 | * BookController
7 | *
8 | * @author: 苍海之南
9 | * @since: 2019-06-27 17:32
10 | **/
11 | @Controller
12 | public class BookController {
13 | }
14 |
--------------------------------------------------------------------------------
/java/spring-annotation/src/main/java/com/github/zj/dreamly/spring/annotation/dao/BookDao.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.spring.annotation.dao;
2 |
3 | import org.springframework.stereotype.Repository;
4 |
5 | /**
6 | * book dao
7 | *
8 | * @author: 苍海之南
9 | * @since: 2019-06-27 17:30
10 | **/
11 | @Repository
12 | public class BookDao {
13 |
14 | private String lable = "1";
15 |
16 | public String getLable() {
17 | return lable;
18 | }
19 |
20 | public void setLable(String lable) {
21 | this.lable = lable;
22 | }
23 |
24 | @Override
25 | public String toString() {
26 | return "BookDao [lable=" + lable + "]";
27 | }
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/java/spring-annotation/src/main/java/com/github/zj/dreamly/spring/annotation/ext/MyApplicationListener.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.spring.annotation.ext;
2 |
3 | import org.springframework.context.ApplicationEvent;
4 | import org.springframework.context.ApplicationListener;
5 |
6 | /**
7 | * MyApplicationListener
8 | *
9 | * @author: 苍海之南
10 | * @since: 2019-07-02 09:39
11 | **/
12 | public class MyApplicationListener implements ApplicationListener {
13 | @Override
14 | public void onApplicationEvent(ApplicationEvent applicationEvent) {
15 | System.out.println("收到事件:" + applicationEvent);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/spring-annotation/src/main/java/com/github/zj/dreamly/spring/annotation/ext/UserService.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.spring.annotation.ext;
2 |
3 | import org.springframework.context.ApplicationEvent;
4 | import org.springframework.context.event.EventListener;
5 |
6 | /**
7 | * UserService
8 | *
9 | * @author: 苍海之南
10 | * @since: 2019-07-02 09:43
11 | **/
12 | public class UserService {
13 | @EventListener(classes = {ApplicationEvent.class})
14 | public void listen(ApplicationEvent event) {
15 | System.out.println("UserService。。监听到的事件:" + event);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/spring-annotation/src/main/resources/person.properties:
--------------------------------------------------------------------------------
1 | person.nickName=lyy
2 |
--------------------------------------------------------------------------------
/java/spring-annotation/src/test/java/com/github/zj/dreamly/spring/annotation/BaseTest.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.spring.annotation;
2 |
3 | import com.github.zj.dreamly.spring.annotation.bean.Person;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | /**
9 | * base test
10 | *
11 | * @author: 苍海之南
12 | * @since: 2019-06-27 17:15
13 | **/
14 | @RunWith(SpringRunner.class)
15 | @SpringBootTest(classes = Person.class)
16 | public class BaseTest {
17 | }
18 |
--------------------------------------------------------------------------------
/java/util/src/main/java/KmpDomain.java:
--------------------------------------------------------------------------------
1 |
2 | import lombok.Data;
3 |
4 | @Data
5 | public class KmpDomain {
6 |
7 | //起始位置
8 | private Integer start;
9 | //截止位置
10 | private Integer end;
11 | }
12 |
--------------------------------------------------------------------------------
/java/zookeeper/src/main/java/com/github/zj/dreamly/zookeeper/curator/MyCuratorWatcher.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.zookeeper.curator;
2 |
3 | import org.apache.curator.framework.api.CuratorWatcher;
4 | import org.apache.zookeeper.WatchedEvent;
5 |
6 | public class MyCuratorWatcher implements CuratorWatcher {
7 |
8 | @Override
9 | public void process(WatchedEvent event) throws Exception {
10 | System.out.println("触发watcher,节点路径为:" + event.getPath());
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/java/zookeeper/src/main/java/com/github/zj/dreamly/zookeeper/curator/MyWatcher.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.zookeeper.curator;
2 |
3 | import org.apache.zookeeper.WatchedEvent;
4 | import org.apache.zookeeper.Watcher;
5 |
6 | public class MyWatcher implements Watcher {
7 |
8 | @Override
9 | public void process(WatchedEvent event) {
10 | System.out.println("触发watcher,节点路径为:" + event.getPath());
11 | }
12 |
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/java/zookeeper/src/main/java/com/github/zj/dreamly/zookeeper/curator/utils/RedisConfig.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type": "add",
4 | "url": "ftp://192.168.10.123/config/redis.xml",
5 | "remark": "add"
6 | },
7 |
8 | {
9 | "type": "update",
10 | "url": "ftp://192.168.10.123/config/redis.xml",
11 | "remark": "update"
12 | },
13 | {
14 | "type": "delete",
15 | "url": "",
16 | "remark": "delete"
17 | }
18 | ]
19 |
--------------------------------------------------------------------------------
/java/zookeeper/src/main/java/com/github/zj/dreamly/zookeeper/zk/demo/ChildrenCallBack.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.zookeeper.zk.demo;
2 |
3 |
4 | import java.util.List;
5 |
6 | import org.apache.zookeeper.AsyncCallback.ChildrenCallback;
7 |
8 | public class ChildrenCallBack implements ChildrenCallback {
9 |
10 | @Override
11 | public void processResult(int rc, String path, Object ctx, List children) {
12 | for (String s : children) {
13 | System.out.println(s);
14 | }
15 | System.out.println("ChildrenCallback:" + path);
16 | System.out.println((String)ctx);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/java/zookeeper/src/main/java/com/github/zj/dreamly/zookeeper/zk/demo/CreateCallBack.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.zookeeper.zk.demo;
2 |
3 |
4 | import org.apache.zookeeper.AsyncCallback.StringCallback;
5 |
6 | public class CreateCallBack implements StringCallback {
7 |
8 | @Override
9 | public void processResult(int rc, String path, Object ctx, String name) {
10 | System.out.println("创建节点: " + path);
11 | System.out.println((String)ctx);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/java/zookeeper/src/main/java/com/github/zj/dreamly/zookeeper/zk/demo/DeleteCallBack.java:
--------------------------------------------------------------------------------
1 | package com.github.zj.dreamly.zookeeper.zk.demo;
2 |
3 |
4 | import org.apache.zookeeper.AsyncCallback.VoidCallback;
5 |
6 | public class DeleteCallBack implements VoidCallback {
7 | @Override
8 | public void processResult(int rc, String path, Object ctx) {
9 | System.out.println("删除节点" + path);
10 | System.out.println((String)ctx);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/mini-program/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | my-program-learning
7 | com.github.zj.dreamly
8 | 1.2.1
9 |
10 | 4.0.0
11 |
12 | mini-program
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/my-work-doc/README.md:
--------------------------------------------------------------------------------
1 | 这里记录了我工作遇到了问题总结,希望能给看到的人一点帮助。
2 |
3 | ### 通用文件文件集成
4 | ```xml
5 |
6 | com.amazonaws
7 | aws-java-sdk-s3
8 | 1.12.285
9 |
10 | ```
--------------------------------------------------------------------------------
/my-work-doc/android/Android项目导入报错解决.md:
--------------------------------------------------------------------------------
1 | 在build.gradle文件中追加:
2 |
3 | ```xml
4 | buildscript {
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.5.3'
11 | //注意:更换成自己的AS的版本
12 | }
13 | }
14 | ```
15 |
16 |
--------------------------------------------------------------------------------
/my-work-doc/bt/宝塔配置反向代理.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/my-work-doc/bt/宝塔配置反向代理.jpg
--------------------------------------------------------------------------------
/my-work-doc/bt/宝塔默认账户密码.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/my-work-doc/bt/宝塔默认账户密码.png
--------------------------------------------------------------------------------
/my-work-doc/bt/配置反向代理.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/my-work-doc/bt/配置反向代理.png
--------------------------------------------------------------------------------
/my-work-doc/dubbo/temp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/my-work-doc/dubbo/temp
--------------------------------------------------------------------------------
/my-work-doc/git/git clone 时显示Filename too long的解决办法.md:
--------------------------------------------------------------------------------
1 | 在git bash中,运行下列命令:
2 |
3 | ```shell
4 | git config --global core.longpaths true
5 | ```
6 |
7 | 就可以解决该问题。
8 |
9 | --global是该参数的使用范围,如果只想对本版本库设置该参数,只要在上述命令中去掉--global即可。
10 |
11 |
--------------------------------------------------------------------------------
/my-work-doc/git/git 回滚.md:
--------------------------------------------------------------------------------
1 | Git回滚代码到某个commit
2 | 回退命令:
3 |
4 | git reset --hard HEAD^ 回退到上个版本
5 |
6 | git reset --hard HEAD~3 回退到前3次提交之前,以此类推,回退到n次提交之前
7 |
8 | git reset --hard commit_id 退到/进到,指定commit的哈希码(这次提交之前或之后的提交都会回滚)
9 |
10 |
11 |
12 | 回滚后提交可能会失败,必须强制提交
13 |
14 | 强推到远程:(可能需要解决对应分支的保护状态)
15 |
16 | git push origin HEAD --force
--------------------------------------------------------------------------------
/my-work-doc/git/git撤销add操作.md:
--------------------------------------------------------------------------------
1 | git reset HEAD 文件名
--------------------------------------------------------------------------------
/my-work-doc/idea/properties文件Unicode编码怎么办.md:
--------------------------------------------------------------------------------
1 | 设置里搜索`File Encoding`,看到`Transparent native-to-ascii conversion`,打勾,保存。
2 |
3 |
--------------------------------------------------------------------------------
/my-work-doc/idea/常用插件.md:
--------------------------------------------------------------------------------
1 | - Alibaba Cloud Toolkit
2 | - Alibaba Java Coding Guidelines
3 | - FindBugs-IDEA
4 | - GenerateAllSetter
5 | - GsonFormat
6 | - Lombok
7 | - MybatisX
8 | - probie
9 | - RestfulToolkit
10 | - Statistic
11 | - Translation
12 | - VisualVM Launcher
13 | - Maven helper
--------------------------------------------------------------------------------
/my-work-doc/image/Lusifer_201904010001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/my-work-doc/image/Lusifer_201904010001.png
--------------------------------------------------------------------------------
/my-work-doc/image/Lusifer_201904010002.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/my-work-doc/image/Lusifer_201904010002.png
--------------------------------------------------------------------------------
/my-work-doc/image/Lusifer_201904010003.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/my-work-doc/image/Lusifer_201904010003.png
--------------------------------------------------------------------------------
/my-work-doc/image/Lusifer_2019040104250001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/my-work-doc/image/Lusifer_2019040104250001.png
--------------------------------------------------------------------------------
/my-work-doc/image/Lusifer_2019040104270001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj-dreamly/my-program-learning/cadc57095ee57392b207b0693ad1913e34312a8b/my-work-doc/image/Lusifer_2019040104270001.png
--------------------------------------------------------------------------------
/my-work-doc/personal/2022年6月17日.md:
--------------------------------------------------------------------------------
1 | # 2022年6月17日
2 |
3 |
--------------------------------------------------------------------------------
/my-work-doc/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | my-program-learning
7 | com.github.zj.dreamly
8 | 1.2.1
9 |
10 | 4.0.0
11 |
12 | my-work-doc
13 |
14 |
--------------------------------------------------------------------------------
/my-work-doc/springboot/springboot启动读取外部配置文件.md:
--------------------------------------------------------------------------------
1 | ### springboot 有读取外部配置文件的方法,如下优先级
2 |
3 | #### 使用
4 |
5 | - 第一种是在jar包的同一目录下建一个config文件夹,然后把配置文件放到这个文件夹下。
6 | - 第二种是直接把配置文件放到jar包的同级目录。
7 | - 第三种在classpath下建一个config文件夹,然后把配置文件放进去。
8 | - 第四种是在classpath下直接放配置文件。
9 |
10 | #### 总结
11 |
12 | - 内外都有配置文件,配置文件读取是有优先级,外配置文件优于内配置文件读取。
13 | - 如果内配置文件里有外配置文件没有的配置,那两者互补。比如外配置文件没有配置数据库,内配置文件里配置了数据库,那内配置文件的配置会被使用。
14 | - 如果内配置文件里和外配置文件里都有相同的配置,比如两者都配置了数据库,但是两个连接的不同,那外配置文件会覆盖内配置文件里的配置
15 |
16 |
--------------------------------------------------------------------------------
/my-work-doc/vue/npm切换registry.md:
--------------------------------------------------------------------------------
1 | ```javascript
2 | npm install --registry=https://registry.npm.taobao.org
3 | ```
4 |
5 |
--------------------------------------------------------------------------------
/my-work-doc/vue/vue关闭严格检查模式.md:
--------------------------------------------------------------------------------
1 | #### 在.eslintrc.js中添加rule
2 |
3 | ```json
4 | module.exports = {
5 | root: true,
6 | env: {
7 | node: true
8 | },
9 | extends: [
10 | 'plugin:vue/essential',
11 | '@vue/standard'
12 | ],
13 | parserOptions: {
14 | parser: 'babel-eslint'
15 | },
16 | rules: {
17 | // 关闭缩进问题
18 | "indent": ["off", 2],
19 | 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
20 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
21 | }
22 | }
23 |
24 | ```
25 |
26 |
--------------------------------------------------------------------------------
/nginx/README.md:
--------------------------------------------------------------------------------
1 | please go to https://github.com/zj-dreamly/nginx-learning
--------------------------------------------------------------------------------
/nginx/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java
7 | com.github.zj.dreamly
8 | 1.2.1
9 |
10 | 4.0.0
11 |
12 | nginx
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/python/01.入门/01.基本概念.py:
--------------------------------------------------------------------------------
1 | print('hello', '哈哈', 'abc')
2 | print(123)
3 | print('bcd')
4 |
5 | a = 20
6 | print(a)
7 |
--------------------------------------------------------------------------------
/python/01.入门/02.基本语法.py:
--------------------------------------------------------------------------------
1 | print('he\
2 | aaa\
3 | aaa')
4 |
5 | # 这是一个打印语句,请你看见了不要慌张
6 | # 这是一个注释
7 | # 注释会被解释器所忽略
8 | # print(123+456) 这行代码被注释了,将不会执行
9 | print('abc') # 这是一个单行注释
--------------------------------------------------------------------------------
/python/01.入门/04.数值.py:
--------------------------------------------------------------------------------
1 | # 在Python数值分成了三种:整数、浮点数(小数)、复数
2 | # 在Python中所有的整数都是int类型
3 | a = 10
4 | b = 20
5 | # Python中的整数的大小没有限制,可以是一个无限大的整数
6 | # c = 999999999999999999999999999999999999999999999 ** 100
7 |
8 | # 如果数字的长度过大,可以使用下划线作为分隔符
9 | c = 123_456_789
10 |
11 | # d = 0123 10进制的数字不能以0开头
12 | # 其他进制的整数,只要是数字打印时一定是以十进制的形式显示的
13 | # 二进制 0b开头
14 | c = 0b10 # 二进制的10
15 | # 八进制 0o开头
16 | c = 0o10
17 | # 十六进制 0x开头
18 | c = 0x10
19 |
20 | # 也可以通过运算符来对数字进行运算,并且可以保证整数运算的精确
21 | c = -100
22 | c = c + 3
23 |
24 | # 浮点数(小数),在Python中所有的小数都是float类型
25 | c = 1.23
26 | c = 4.56
27 |
28 | # 对浮点数进行运算时,可能会得到一个不精确的结果
29 | c = 0.1 + 0.2 # 0.30000000000000004
30 |
31 | print(c)
--------------------------------------------------------------------------------
/python/01.入门/07.复制字符串.py:
--------------------------------------------------------------------------------
1 | # 创建一个变量来保存你的名字
2 | name = '孙悟空'
3 |
4 | # 使用四种方式来输出,欢迎 xxx 光临
5 | # 拼串
6 | print('欢迎 '+name+' 光临!')
7 | # 多个参数
8 | print('欢迎',name,'光临!')
9 | # 占位符
10 | print('欢迎 %s 光临!'%name)
11 | # 格式化字符串
12 | print(f'欢迎 {name} 光临!')
13 |
14 | # 字符串的复制(将字符串和数字相乘)
15 | a = 'abc'
16 | # * 在语言中表示乘法
17 | # 如果将字符串和数字相乘,则解释器会将字符串重复指定的次数并返回
18 | a = a * 20
19 |
20 | print(a)
--------------------------------------------------------------------------------
/python/01.入门/08.布尔值和空值.py:
--------------------------------------------------------------------------------
1 | # 布尔值(bool)
2 | # 布尔值主要用来做逻辑判断
3 | # 布尔值一共有两个 True 和 False
4 | # True表示真 False表示假
5 | a = True
6 | a = False
7 | # print('a =',a)
8 |
9 | # 布尔值实际上也属于整型,True就相当于1,False就相当于0
10 | # print(1 + False)
11 |
12 | # None(空值)
13 | # None专门用来表示不存在
14 | b = None
15 | print(b)
--------------------------------------------------------------------------------
/python/01.入门/09.类型检查.py:
--------------------------------------------------------------------------------
1 | # 通过类型检查,可以检查只能值(变量)的类型
2 |
3 | a = 123 # 数值
4 | b = '123' # 字符串
5 |
6 | # print('a =',a)
7 | # print('b =',b)、
8 |
9 | # type()用来检查值的类型
10 | # 该函数会将检查的结果作为返回值返回,可以通过变量来接收函数的返回值
11 | c = type('123')
12 | c = type(a)
13 | # print(type(b))
14 | print(type(1)) #
15 | print(type(1.5)) #
16 | print(type(True)) #
17 | print(type('hello')) #
18 | print(type(None)) #
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/python/01.入门/12.赋值运算符.py:
--------------------------------------------------------------------------------
1 | # 赋值运算符
2 | # = 可以将等号右侧的值赋值给等号左侧的变量
3 | # += a += 5 相当于 a = a + 5
4 | # -= a -= 5 相当于 a = a - 5
5 | # *= a *= 5 相当于 a = a * 5
6 | # **= a **= 5 相当于 a = a ** 5
7 | # /= a /= 5 相当于 a = a / 5
8 | # //= a //= 5 相当于 a = a // 5
9 | # %= a %= 5 相当于 a = a % 5
10 | a = 10
11 | # a = a + 5
12 | # a += 5
13 | a -= 5
14 | a *= 5
15 | a **= 2
16 | a /= 25
17 | a = 25.0 # 在对浮点数做算术运算时,结果也会返回一个浮点数
18 | a //= 5
19 | # a = 5
20 | # a %= 4
21 |
22 | print('a =',a)
23 |
--------------------------------------------------------------------------------
/python/01.入门/15.条件运算符.py:
--------------------------------------------------------------------------------
1 | # 条件运算符(三元运算符)
2 | # 语法: 语句1 if 条件表达式 else 语句2
3 | # 执行流程:
4 | # 条件运算符在执行时,会先对条件表达式进行求值判断
5 | # 如果判断结果为True,则执行语句1,并返回执行结果
6 | # 如果判断结果为False,则执行语句2,并返回执行结果
7 | # 练习:
8 | # 现在有a b c三个变量,三个变量中分别保存有三个数值,
9 | # 请通过条件运算符获取三个值中的最大值
10 |
11 | # print('你好') if False else print('Hello')
12 |
13 | a = 30
14 | b = 50
15 |
16 | # print('a的值比较大!') if a > b else print('b的值比较大!')
17 | # 获取a和b之间的较大值
18 | max = a if a > b else b
19 |
20 | print(max)
--------------------------------------------------------------------------------