├── .gitignore ├── LessonsList.txt ├── Student.json ├── StudentStream.json ├── boot ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── max │ │ │ ├── Main.java │ │ │ ├── MainDb.java │ │ │ ├── MainWeb.java │ │ │ ├── controllers │ │ │ └── WebController.java │ │ │ ├── entities │ │ │ └── User.java │ │ │ ├── impl │ │ │ └── MyComponentImpl.java │ │ │ └── interfaces │ │ │ ├── MyComponent.java │ │ │ └── UserRepository.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── BootTest.java ├── ee ├── resources │ ├── META-INF │ │ ├── XmlLesson.xml │ │ ├── beans.xml │ │ └── constraints.xml │ └── ValidationMessages.properties ├── src │ ├── META-INF │ │ └── MANIFEST.MF │ ├── collections │ │ ├── CollectionsLesson.java │ │ ├── ComplexityLesson.java │ │ ├── ConcurentLesson.java │ │ ├── ListsLesson.java │ │ ├── MapsLesson.java │ │ ├── QueuesLesson.java │ │ ├── SetsLesson.java │ │ └── SortArrays.java │ ├── controllers │ │ ├── ELController.java │ │ └── TempController.java │ ├── ee │ │ ├── batch │ │ │ ├── BatchServlet.java │ │ │ ├── MyBatchlet.java │ │ │ ├── MyCheckpoint.java │ │ │ ├── MyProcessor.java │ │ │ ├── MyReader.java │ │ │ └── MyWriter.java │ │ ├── beanvalidation │ │ │ ├── ChronologicalDates.java │ │ │ ├── ClassValidation.java │ │ │ ├── Constraints.java │ │ │ ├── CustomValidator.java │ │ │ ├── CustomValidator2.java │ │ │ ├── DescriptionValidate.java │ │ │ ├── Email.java │ │ │ ├── GroupsValidator.java │ │ │ ├── InheritanceValidation.java │ │ │ ├── MessageValidator.java │ │ │ ├── URL.java │ │ │ └── ValidationExample.java │ │ ├── cdi │ │ │ ├── ChainIntercepttors.java │ │ │ ├── ConcurencyUtilsServletLesson.java │ │ │ ├── ConversationScope.java │ │ │ ├── DIAlternative.java │ │ │ ├── DIProducers.java │ │ │ ├── DIQuantifier.java │ │ │ ├── DecoratorExample.java │ │ │ ├── DependencyInjectionServlet.java │ │ │ ├── Disposers.java │ │ │ ├── ELBeans.java │ │ │ ├── EventExample.java │ │ │ ├── InjectionPointApi.java │ │ │ ├── InterceptorBindingExample.java │ │ │ ├── InterceptorClass.java │ │ │ ├── LiveCycle.java │ │ │ ├── OpenWebBeansExample.java │ │ │ ├── Scope.java │ │ │ └── SpecializationLesson.java │ │ ├── ejb │ │ │ ├── AsyncLesson.java │ │ │ ├── AtuthServletLesson.java │ │ │ ├── ConcurencyLesson.java │ │ │ ├── DataSourceLesson.java │ │ │ ├── DependsOnAndStartupServletLesson.java │ │ │ ├── EjbDifferenceServletLesson.java │ │ │ ├── EjbHelloWorldServletLesson.java │ │ │ ├── ExampleServlet.java │ │ │ ├── JNDINameLesson.java │ │ │ ├── LiveCycleServletLesson.java │ │ │ ├── LocalAndRemoteServletLesson.java │ │ │ ├── MainLesson.java │ │ │ ├── SessionContextDILesson.java │ │ │ ├── TimeServiceServletLesson.java │ │ │ ├── XmlServletLesson.java │ │ │ └── beans │ │ │ │ ├── AsyncBean.java │ │ │ │ ├── AuthBean.java │ │ │ │ ├── ConcurencyBean.java │ │ │ │ ├── DataSourceBean.java │ │ │ │ ├── DependsOnAndStartupBean1.java │ │ │ │ ├── DependsOnAndStartupBean2.java │ │ │ │ ├── EjbDifferenceSessionBean.java │ │ │ │ ├── ExampleBean.java │ │ │ │ ├── HelloWorldEjb.java │ │ │ │ ├── JndiBean.java │ │ │ │ ├── LiveCycleBean.java │ │ │ │ ├── LocalAndRemoteBean.java │ │ │ │ ├── NonJtaDataSourceLesson.java │ │ │ │ ├── SessionContextDIBean.java │ │ │ │ ├── TimeServiceBean.java │ │ │ │ ├── XmlBean.java │ │ │ │ └── interfaces │ │ │ │ ├── LocalBeanInteface.java │ │ │ │ └── RemoteBeanInterface.java │ │ ├── jaxrs │ │ │ ├── ApplicationPathLesson.java │ │ │ ├── CallRestLesson.java │ │ │ ├── ContextInfoLesson.java │ │ │ ├── ExceptionLesson.java │ │ │ ├── ExtractingParamsLesson.java │ │ │ ├── ExtractingServlet.java │ │ │ ├── HelloWorldRest.java │ │ │ ├── ReturnTypesLesson.java │ │ │ ├── Student.java │ │ │ ├── UriBuilderLesson.java │ │ │ └── provider │ │ │ │ ├── CustomStudentReader.java │ │ │ │ ├── CustomStudentWriter.java │ │ │ │ ├── EntityProviderLesson.java │ │ │ │ └── Student.java │ │ ├── jaxws │ │ │ ├── AdjustWsdlLesson.java │ │ │ ├── container │ │ │ │ ├── ContainerService.java │ │ │ │ ├── ContainerServiceImpl.java │ │ │ │ └── WSContainerServlet.java │ │ │ ├── exception │ │ │ │ ├── CallExceptionWebService.java │ │ │ │ ├── ExceptionWebService.java │ │ │ │ ├── ExceptionWebServiceImpl.java │ │ │ │ ├── PublishExceptionWebService.java │ │ │ │ └── ValueIsNullException.java │ │ │ └── main │ │ │ │ ├── CallMainService.java │ │ │ │ ├── Hello.java │ │ │ │ ├── HelloWs.java │ │ │ │ └── Student.java │ │ ├── jms │ │ │ ├── JmsConsumerServletExample.java │ │ │ ├── JmsProducerServletExample.java │ │ │ ├── advanced │ │ │ │ ├── AdvancedJmxServletLesson.java │ │ │ │ ├── ConnectionFactoryDefinitionServletLesson.java │ │ │ │ ├── DefinitionBean.java │ │ │ │ ├── JmsListenerServlet.java │ │ │ │ ├── MdBean.java │ │ │ │ ├── MdbServletLesson.java │ │ │ │ └── jmsSendObjectLesson.java │ │ │ ├── classic │ │ │ │ ├── ConsumerServlet.java │ │ │ │ ├── MainClassicExample.java │ │ │ │ └── ProducerServlet.java │ │ │ └── simplify │ │ │ │ ├── ConsumerServletSimpl.java │ │ │ │ ├── JmsContextServletConsumer.java │ │ │ │ ├── JmxContextServletProducer.java │ │ │ │ ├── MainSimpleExample.java │ │ │ │ └── ProducerServletSimpl.java │ │ ├── jpa │ │ │ ├── JpaBean.java │ │ │ ├── MainExample.java │ │ │ ├── ServletExample.java │ │ │ ├── advanced │ │ │ │ ├── CacheApiLesson.java │ │ │ │ ├── CallbacksLesson.java │ │ │ │ ├── ConcurencyAndLockingLesson.java │ │ │ │ ├── EntityGraphLesson.java │ │ │ │ ├── ListenersLesson.java │ │ │ │ └── VersioningLesson.java │ │ │ ├── em │ │ │ │ ├── CascadeLesson.java │ │ │ │ ├── ContainsClearDetachLesson.java │ │ │ │ ├── FlushLesson.java │ │ │ │ ├── ManipulateEntitiesLesson.java │ │ │ │ ├── MerginLesson.java │ │ │ │ ├── OrphanLesson.java │ │ │ │ ├── PersistenceContextLesson.java │ │ │ │ └── RefreshLesson.java │ │ │ ├── ementity │ │ │ │ ├── Customer.java │ │ │ │ ├── CustomerAddress.java │ │ │ │ ├── ListenerEntity.java │ │ │ │ ├── LiveCycleEntity.java │ │ │ │ └── VersionBook.java │ │ │ ├── entities │ │ │ │ ├── AccessTypeLesson.java │ │ │ │ ├── BasicLesson.java │ │ │ │ ├── Book.java │ │ │ │ ├── Book_.java │ │ │ │ ├── CollectionsLesson.java │ │ │ │ ├── CollumnLesson.java │ │ │ │ ├── EbeddableLesson.java │ │ │ │ ├── EmbeddedIdLesson.java │ │ │ │ ├── EntityGraphBookLesson.java │ │ │ │ ├── EnumeratedLesson.java │ │ │ │ ├── GenValuePerson.java │ │ │ │ ├── IdLesson.java │ │ │ │ ├── InheritanceStrategiesLesson.java │ │ │ │ ├── ManyToManyLesson.java │ │ │ │ ├── NamedBook.java │ │ │ │ ├── OneToManyLesson.java │ │ │ │ ├── OneToOneLesson.java │ │ │ │ ├── OrderLesson.java │ │ │ │ ├── Student.java │ │ │ │ ├── StudentAddress.java │ │ │ │ ├── TableLesson.java │ │ │ │ ├── TemproralLesson.java │ │ │ │ ├── TransientLesson.java │ │ │ │ └── XmlLesson.java │ │ │ ├── jpql │ │ │ │ ├── DeleteUpdateLesson.java │ │ │ │ ├── GroupByHavingLesson.java │ │ │ │ ├── OrderByLesson.java │ │ │ │ ├── ParametersLesson.java │ │ │ │ ├── SelectLesson.java │ │ │ │ └── WhereLesson.java │ │ │ └── queries │ │ │ │ ├── CriteriaApiLesson.java │ │ │ │ ├── DinamicQueriesLesson.java │ │ │ │ ├── NamedQueriesLesson.java │ │ │ │ ├── NativeQueriesLesson.java │ │ │ │ └── StoredProceduresLesson.java │ │ ├── jsf │ │ │ ├── BackingBean.java │ │ │ ├── CommandsController.java │ │ │ ├── Converters.java │ │ │ ├── CustomConverter.java │ │ │ ├── CustomValidator.java │ │ │ ├── InputBean.java │ │ │ ├── MessageController.java │ │ │ ├── Navigate.java │ │ │ ├── PrintHello.java │ │ │ └── Validations.java │ │ ├── json │ │ │ ├── OMJsonLesson.java │ │ │ └── StreamJsonLesson.java │ │ ├── jta │ │ │ ├── BeanManagedServletLesson.java │ │ │ ├── ExampleServlet.java │ │ │ ├── JtaServletLesson.java │ │ │ ├── RolbackExceptionBean.java │ │ │ ├── RolbackExceptionServletLesson.java │ │ │ ├── TransactionalServletLesson.java │ │ │ └── beans │ │ │ │ ├── ExampleJtaBean.java │ │ │ │ ├── JtaBean.java │ │ │ │ ├── ManagedTransactionBean.java │ │ │ │ └── PersistentBean.java │ │ └── websockets │ │ │ ├── AnnotatedEndpoint.java │ │ │ ├── ClientLesson.java │ │ │ ├── CustomServerAppConfigProvider.java │ │ │ ├── MessagesLesson.java │ │ │ ├── ParamsLesson.java │ │ │ ├── ProgrammaticEndpointLesson.java │ │ │ └── decode │ │ │ ├── ClientLesson.java │ │ │ ├── DecodeMessage.java │ │ │ ├── EncodeMessage.java │ │ │ ├── Message.java │ │ │ └── ServerEncodeMessageEndpoint.java │ ├── interview │ │ ├── BooksSellLesson.java │ │ ├── CloneLesson.java │ │ ├── CreateGenericClassLesson.java │ │ ├── DeadLockSearch.java │ │ ├── DoubleCheckLesson.java │ │ ├── ExternalizableLesson.java │ │ ├── HashCodeEqualsFieldsLesson.java │ │ ├── HashCodeImplementationLesson.java │ │ ├── ImmutableCollectionsLesson.java │ │ ├── ImmutableLesson.java │ │ ├── IntegerPoolLesson.java │ │ ├── InternalStringsLesson.java │ │ ├── Main.java │ │ ├── MemoryLeakExample.java │ │ ├── OffHeapLesson.java │ │ ├── ReferencesLesson.java │ │ ├── ThreadLocalLesson.java │ │ └── VolatileHappensBeforeLesson.java │ ├── jmh │ │ ├── MyBenchmark.java │ │ ├── MyOptionBenchmark.java │ │ ├── RunBenchmark.java │ │ └── benchmarks │ │ │ ├── Iteration.java │ │ │ ├── Lists.java │ │ │ ├── ListsIteration.java │ │ │ └── Maps.java │ ├── jsp │ │ ├── ContextListener.java │ │ ├── InnerTag.java │ │ ├── JSPHelper.java │ │ ├── MyFilter.java │ │ ├── MyThread.java │ │ ├── SimpleTag.java │ │ └── Student.java │ ├── lombok │ │ ├── BuilderLesson.java │ │ ├── ClenupLesson.java │ │ ├── ConstructorsLesson.java │ │ ├── DataLesson.java │ │ ├── EqualsAndHashCodeLesson.java │ │ ├── GetSetLesson.java │ │ ├── LoggerLesson.java │ │ ├── NonNullLesson.java │ │ ├── SneakythrowLesson.java │ │ ├── SynchronizedLesson.java │ │ ├── ToStringLesson.java │ │ ├── ValLesson.java │ │ ├── ValueLesson.java │ │ └── WhatIsLombok.java │ ├── mapped │ │ ├── A.java │ │ ├── B.java │ │ └── C.java │ ├── multithreading │ │ └── MultithreadingIsBadLesson.java │ └── servlets │ │ ├── AsyncServlet.java │ │ ├── ContextReadServlet.java │ │ ├── ContextServlet.java │ │ ├── Controller.java │ │ ├── CookiesServlet.java │ │ ├── CrossSiteScriptingServlet.java │ │ ├── DataSourceServletLesson.java │ │ ├── ExceptionServlet.java │ │ ├── FilterServlet.java │ │ ├── GetIp.java │ │ ├── GzipServlet.java │ │ ├── HeaderServlet.java │ │ ├── HelloServlet.java │ │ ├── InitServlet.java │ │ ├── LogOutBasicServlet.java │ │ ├── LogOutServlet.java │ │ ├── Model.java │ │ ├── ParametersServlet.java │ │ ├── SecureServlet.java │ │ ├── ServletLiveCycle.java │ │ ├── SessionServlet.java │ │ ├── SingleThreadServlet.java │ │ └── StatusServlet.java └── web │ ├── WEB-INF │ ├── Inc.jsp │ ├── beans.xml │ ├── classes │ │ └── META-INF │ │ │ └── batch-jobs │ │ │ └── simplejob.xml │ ├── ejb-jar.xml │ ├── persistence.xml │ ├── resources.xml │ ├── tags │ │ └── SimpleJspTag.tag │ ├── text.txt │ ├── validation.xml │ └── web.xml │ ├── html │ ├── default.html │ └── websocket.html │ ├── img │ ├── icon16.gif │ └── icon32.gif │ ├── jsf │ ├── BackingBean.xhtml │ ├── Commands.xhtml │ ├── Converters.xhtml │ ├── CoreTags.xhtml │ ├── Graphics.xhtml │ ├── GridTables.xhtml │ ├── Hello.xhtml │ ├── HelloWorld.xhtml │ ├── Implicit.xhtml │ ├── Inputs.xhtml │ ├── Messages.xhtml │ ├── Navigate.xhtml │ ├── NewPage.xhtml │ ├── Outputs.xhtml │ ├── Selects.xhtml │ ├── Targets.xhtml │ ├── Template.xhtml │ ├── Validations.xhtml │ └── layout.xhtml │ ├── jsp │ ├── BasicTag.jsp │ ├── Bean.jsp │ ├── EL.jsp │ ├── ELBean.jsp │ ├── Error.jsp │ ├── Footer.jsp │ ├── ForwardAction.jsp │ ├── Header.jsp │ ├── IncludeDircetive.jsp │ ├── Included.jsp │ ├── Init.jsp │ ├── Page.jsp │ ├── PageDirective.jsp │ ├── PredefinedVariables.jsp │ ├── Temp.jsp │ ├── View.jsp │ └── hello.jsp │ ├── secure │ ├── Page.jsp │ ├── login-error.jsp │ └── login.jsp │ └── tld │ └── SimpleTagDescriptor.tld ├── hiber ├── resources │ ├── entities │ │ ├── Book.hbm.xml │ │ └── Student.hbm.xml │ ├── hibernate.cfg.xml │ └── hibernate.properties └── src │ ├── ConfigHiberLesson.java │ ├── HelloWorld.java │ ├── Main.java │ ├── entities │ ├── Address.java │ ├── EntityStates.java │ ├── HomeAddress.java │ ├── LockExample.java │ ├── Person.java │ ├── Role.java │ ├── Student.java │ ├── User.java │ └── hierarchies │ │ ├── Car.java │ │ ├── Opel.java │ │ └── Toyota.java │ └── enums │ └── Days.java ├── kotln └── src │ └── com │ └── max │ ├── Annotations.kt │ ├── BasicTypes.kt │ ├── CallFunctions.kt │ ├── Classes.kt │ ├── Collections.kt │ ├── CollectionsArrays.kt │ ├── Constructors.kt │ ├── ControlFlow.kt │ ├── DelegatingProperties.kt │ ├── Enums.kt │ ├── Exceptions.kt │ ├── Functions.kt │ ├── GenericVarience.kt │ ├── Generics.kt │ ├── GenericsInRuntime.kt │ ├── Hierarhies.kt │ ├── HighOrderFunctions.kt │ ├── InlineFunctions.kt │ ├── Lambda.kt │ ├── Loop.kt │ ├── Main.kt │ ├── ObjectKeyword.kt │ ├── OverloadOperations.kt │ ├── Reflection.kt │ ├── TypeSystem.kt │ └── Variables.kt ├── lessons ├── pom.xml └── src │ ├── main │ └── java │ │ ├── Calculator.java │ │ └── badpractice │ │ ├── Service.java │ │ ├── Singleton.java │ │ ├── User.java │ │ └── UserFactory.java │ └── test │ └── java │ ├── CalculatorTest.java │ ├── HamcrestTest.java │ ├── SuitExample.java │ └── badpractice │ └── ServiceTest.java ├── lib ├── activemq-broker-5.14.3.jar ├── activemq-client-5.14.3.jar ├── activemq-jdbc-store-5.14.3.jar ├── activemq-kahadb-store-5.14.3.jar ├── activemq-openwire-legacy-5.14.3.jar ├── activemq-protobuf-1.1.jar ├── activemq-ra-5.14.3.jar ├── commons-math3-3.2.jar ├── eclipselink.jar ├── hibernate-core-5.2.10.Final.jar ├── javaee-api-7.0-1.jar ├── javax.ejb-api.jar ├── javax.faces-2.2.12.jar ├── jmh-core-1.17.3.jar ├── jmh-core-1.19.jar ├── jmh-generator-annprocess-1.17.3.jar ├── jmh-generator-annprocess-1.19.jar ├── jmh-java-benchmark-archetype-1.19.jar ├── jopt-simple-4.6.jar ├── jsp-api.jar ├── junit-4.12.jar ├── lombok.jar ├── mysql-connector-java-5.1.40-bin.jar ├── openwebbeans-impl-1.7.2.jar ├── openwebbeans-spi-1.7.2.jar ├── servlet-api.jar ├── tomcat-api.jar ├── tomcat-juli-7.0.16.jar ├── tomcat-util.jar ├── tomcat-websocket.jar └── websocket-api.jar ├── mongo ├── resources │ └── META-INF │ │ └── persistence.xml └── src │ ├── ArrayInsert.java │ ├── BulkInsert.java │ ├── EmbeddedInsert.java │ ├── HelloMongo.java │ ├── HiberExample.java │ ├── Indexes.java │ ├── Main.java │ ├── MongoAuth.java │ ├── SampleDelete.java │ ├── SampleInsert.java │ ├── SampleQuery.java │ ├── SampleUpdate.java │ └── entity │ └── User.java ├── program.properties ├── prop.xml ├── saved.png ├── smile.jpg ├── spark ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── max │ │ ├── BasicActions.java │ │ ├── BasicTransformations.java │ │ ├── CachLesson.java │ │ ├── FileSystem.java │ │ ├── JdbcLesson.java │ │ ├── Main.java │ │ ├── PairRddLesson.java │ │ ├── Person.java │ │ ├── RddLesson.java │ │ ├── SharedVariables.java │ │ ├── SqlLesson.java │ │ └── StreamingLesson.java │ └── resources │ ├── test.txt │ ├── users.json │ └── users.txt ├── springweb ├── pom.xml └── src │ └── main │ ├── java │ ├── com │ │ └── max │ │ │ └── web │ │ │ ├── MyFlowBean.java │ │ │ ├── WebFlowActions.java │ │ │ ├── config │ │ │ ├── DbConfig.java │ │ │ ├── HiberConfig.java │ │ │ ├── JpaConfig.java │ │ │ ├── MyWebConfig.java │ │ │ ├── RootConfig.java │ │ │ └── WebConfig.java │ │ │ ├── controllers │ │ │ ├── DbController.java │ │ │ ├── ExceptionController.java │ │ │ ├── FileController.java │ │ │ ├── HelloWorldController.java │ │ │ ├── HiberController.java │ │ │ ├── MethodArguments.java │ │ │ ├── ModelViewController.java │ │ │ ├── MyExceptionHandler.java │ │ │ ├── MyLogin.java │ │ │ ├── ParametersController.java │ │ │ ├── RedirectController.java │ │ │ ├── SpringLibController.java │ │ │ ├── TestController.java │ │ │ └── TestController2.java │ │ │ ├── entities │ │ │ └── User.java │ │ │ ├── repo │ │ │ ├── MyRepo.java │ │ │ ├── Repo.java │ │ │ ├── User.java │ │ │ ├── UserAutoRepository.java │ │ │ ├── UserRepo.java │ │ │ ├── UserRepository.java │ │ │ └── UserRepository2.java │ │ │ └── webconfig │ │ │ ├── MySecurityConfig.java │ │ │ ├── MyWebAppInitializer2.java │ │ │ ├── MyWebApplicationInitializer.java │ │ │ ├── SecurityConfig.java │ │ │ ├── SecurityWebInitializer.java │ │ │ ├── WebAppInitializer.java │ │ │ └── WebFlowConfig.java │ └── webapp │ │ └── WEB-INF │ │ ├── applicationContext.xml │ │ ├── flows │ │ ├── first-flow.xml │ │ └── hello-flow.xml │ │ ├── helloSpring-servlet.xml │ │ ├── views │ │ ├── activation.jsp │ │ ├── end.jsp │ │ ├── failure.jsp │ │ ├── file.jsp │ │ ├── first.jsp │ │ ├── home.jsp │ │ ├── modelView.jsp │ │ ├── myForm.jsp │ │ ├── mylogin.jsp │ │ ├── second.jsp │ │ ├── springLib.jsp │ │ ├── start.jsp │ │ ├── success.jsp │ │ ├── test.jsp │ │ └── third.jsp │ │ └── web.xml │ └── resources │ └── jetty.xml ├── springweb2 ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── max │ │ │ ├── Main.java │ │ │ ├── MyHandler.java │ │ │ ├── config │ │ │ ├── AmqpConfig.java │ │ │ ├── JmsConfig.java │ │ │ ├── RestConfig.java │ │ │ ├── WebAppInitializer.java │ │ │ ├── WebConfig.java │ │ │ ├── WebSocketConfig.java │ │ │ ├── security │ │ │ │ ├── MethodSecurityConfig.java │ │ │ │ ├── SecurityConfig.java │ │ │ │ └── SecurityWebInitializer.java │ │ │ └── soap │ │ │ │ ├── SoapClientConfig.java │ │ │ │ └── SoapServlerConfig.java │ │ │ ├── controllers │ │ │ ├── AmqpController.java │ │ │ ├── HomeControllers.java │ │ │ ├── JmsController.java │ │ │ ├── TestController.java │ │ │ └── UserRestController.java │ │ │ ├── entities │ │ │ └── User.java │ │ │ ├── impl │ │ │ ├── JmsServiceImpl.java │ │ │ └── UserRepo.java │ │ │ ├── interfaces │ │ │ ├── JmsService.java │ │ │ └── Repo.java │ │ │ ├── soap │ │ │ ├── SoapService.java │ │ │ ├── SoapServiceEndpoint.java │ │ │ └── SoapServiceImpl.java │ │ │ └── test │ │ │ ├── controllers │ │ │ ├── MyController.java │ │ │ └── TestController.java │ │ │ ├── entities │ │ │ └── User.java │ │ │ ├── impl │ │ │ ├── TestRepoImpl.java │ │ │ └── Toyota.java │ │ │ └── interfaces │ │ │ ├── Car.java │ │ │ └── TestRepo.java │ ├── resources │ │ └── WebSocket.js │ └── webapp │ │ └── WEB-INF │ │ └── views │ │ ├── home.jsp │ │ ├── login.jsp │ │ └── test.jsp │ └── test │ └── java │ ├── DbTest.java │ └── WebTest.java ├── sprng ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── max │ │ │ ├── Main.java │ │ │ ├── Main2.java │ │ │ ├── MyMBean.java │ │ │ ├── aop │ │ │ ├── AopMain.java │ │ │ ├── AspectConf.java │ │ │ ├── DefaultEncoreable.java │ │ │ ├── Encoreable.java │ │ │ ├── Repo.java │ │ │ ├── TransactionAround.java │ │ │ ├── TransactionAspect.java │ │ │ ├── TransactionAspect2.java │ │ │ ├── UserRepoIntroducer.java │ │ │ └── UserRepository.java │ │ │ ├── config │ │ │ ├── AppConfig.java │ │ │ ├── Config.java │ │ │ ├── Config2.java │ │ │ ├── DbConfig.java │ │ │ ├── HiberConfig.java │ │ │ ├── JmxConfig.java │ │ │ ├── JpaConfig.java │ │ │ ├── MongoConfig.java │ │ │ ├── MyRadio.java │ │ │ ├── RmiConfig.java │ │ │ └── RmiConfig2.java │ │ │ ├── entities │ │ │ ├── Book.java │ │ │ └── User.java │ │ │ ├── impl │ │ │ ├── BestFm.java │ │ │ ├── BookRepository.java │ │ │ ├── BookRepositoryImpl.java │ │ │ ├── Ferrary.java │ │ │ ├── RmiServiceImpl.java │ │ │ ├── Toyota.java │ │ │ ├── UserRepoImpl.java │ │ │ ├── UserRepository.java │ │ │ └── WorstFm.java │ │ │ ├── interfaces │ │ │ ├── BookAutoRepository.java │ │ │ ├── BookRepo.java │ │ │ ├── Car.java │ │ │ ├── Radio.java │ │ │ ├── Repo.java │ │ │ ├── RmiService.java │ │ │ ├── UserAutoRepository.java │ │ │ └── UserRepo.java │ │ │ ├── mongo │ │ │ ├── StudentAutoRepository.java │ │ │ ├── StudentRepo.java │ │ │ ├── StudentRepository.java │ │ │ └── entities │ │ │ │ └── Student.java │ │ │ └── test │ │ │ ├── Car.java │ │ │ ├── Main.java │ │ │ ├── MyInitializer.java │ │ │ ├── TestConfig.java │ │ │ └── Toyota.java │ └── resources │ │ ├── META-INF │ │ └── persistence.xml │ │ ├── aspConf.xml │ │ ├── config.xml │ │ ├── config2.xml │ │ ├── my.properties │ │ └── myScript.sql │ └── test │ └── java │ └── FirstTest.java ├── src ├── META-INF │ └── MANIFEST.MF ├── Main.java ├── MyApp.policy ├── advanced │ ├── ArrayListAndLinkedListLesson.java │ ├── AssertionsLesson.java │ ├── AutoClosableReThrowExceptionLesson.java │ ├── BinarySearch.java │ ├── CohesionAndCouplingLesson.java │ ├── EnumLesson.java │ ├── EqualsLesson.java │ ├── FinalLesson.java │ ├── ImutableLesson.java │ ├── InnerClassLesson.java │ ├── InterfacesLesson.java │ ├── IsAHasALesson.java │ ├── LocalInnerClassesLesson.java │ ├── MethodsThrowsExceptionsLesson.java │ ├── MultiCatchLesson.java │ ├── MultipleInheritenceLesson.java │ ├── OverridingAdvancedLesson.java │ ├── StackAndQueueLesson.java │ ├── StaticInnerClass.java │ └── TryWithResourcesLesson.java ├── anotation │ ├── AnnotationExample.java │ ├── AnotationLesson.java │ ├── ComileJavaLesson.java │ ├── ScriptingLesson.java │ └── package-info.java ├── bestpractice │ ├── AvoidExcessiveSync.java │ ├── CheckedVsUncheckedExceptions.java │ ├── CloneableLesson.java │ ├── CompositionOverInheritance.java │ ├── ConcurrencyBestPractice.java │ ├── CopyInImmutableObjects.java │ ├── DesignForInheritance.java │ ├── DesignMethodSignature.java │ ├── DocumentThreadSafety.java │ ├── DontOptimize.java │ ├── DontUseRawTypes.java │ ├── EnumsAgainstConstants.java │ ├── EqualsLesson.java │ ├── ExceptionFailureAtomicity.java │ ├── ExceptionsLesson.java │ ├── FinalizeLesson.java │ ├── FloatAndDouble.java │ ├── HashCodeLesson.java │ ├── ImmutableLesson.java │ ├── InterfaceOverAbstractClass.java │ ├── ListOverArray.java │ ├── MinimizeAccessibility.java │ ├── MinimizeScopeAndLoops.java │ ├── OverloadingUseCarefully.java │ ├── OverrideLesson.java │ ├── PrimitivesOverWrappers.java │ ├── ReferObjectsByInterface.java │ ├── ReturnNullInstedOfCollection.java │ ├── Singleton.java │ ├── StaticFactory.java │ ├── SuppressWarningsLesson.java │ ├── SyncAccessToMutualData.java │ ├── ToStringLesson.java │ ├── UnnecessaryObjects.java │ ├── UseSerializableJudiciously.java │ ├── UseStandardExceptions.java │ ├── UseWildCard.java │ ├── ValidateParams.java │ └── WaitAndNotify.java ├── debugging │ ├── DebugSwing.java │ ├── DebuggingLesson.java │ └── RobotLesson.java ├── fx │ ├── AnimationLesson.java │ ├── BindingLesson.java │ ├── CanvasLesson.java │ ├── ChartLesson.java │ ├── CollectionsLesson.java │ ├── Controller.java │ ├── CssStyleLesson.java │ ├── CustomConstrolLesson.java │ ├── CustomControl.java │ ├── EventLesson.java │ ├── FxmlLesson.java │ ├── HelloWorld.java │ ├── ImageLesson.java │ ├── LayoutLesson.java │ ├── MediaPlayerLesson.java │ ├── NumberTextField.java │ ├── PieChartLesson.java │ ├── Scene3DLesson.java │ ├── ShapesLesson.java │ ├── SwingFxLesson.java │ ├── ThreadsLesson.java │ ├── UIContrlsLesson.java │ ├── WebLesson.java │ ├── custom_control.fxml │ ├── form.fxml │ └── sample.css ├── generics │ ├── BoundGenLesson.java │ ├── GenBeginLesson.java │ ├── GenInheritanceLesson.java │ ├── GenMethodsLesson.java │ ├── GenNonGenCodeLesson.java │ └── WildCardLesson.java ├── internationalization │ ├── BandleLesson.java │ ├── CollatorLesson.java │ ├── LocaleLesson.java │ ├── MessageFormatLesson.java │ └── resources │ │ ├── ClassLogging_de.java │ │ ├── ClassLogging_en.java │ │ └── ClassLogging_ru_ru.java ├── interview │ ├── StaticCallLesson.java │ ├── StaticInitLesson.java │ ├── USA.java │ └── usa.txt ├── io │ ├── FilesPathLesson.java │ ├── IOLesson.java │ └── ScannerPrintWriterLesson.java ├── jaas.config ├── java8 │ ├── CollectorLesson.java │ ├── DefaultMethodsLesson.java │ ├── FunctionalInterfacesLesson.java │ ├── FunctionalProgrammingLesson.java │ ├── LambdasLesson.java │ ├── LocaDateLesson.java │ ├── MethodReferences.java │ ├── OptionalLesson.java │ ├── ParallelismLesson.java │ ├── PeriodLesson.java │ ├── StreamsHowTheyWorksLesson.java │ └── StreamsLesson.java ├── jdbc │ ├── AutogeneratedKeysLesson.java │ ├── BatchLesson.java │ ├── BlobLesson.java │ ├── JDBCConectionLesson.java │ ├── JDBCExecuteQueeryLesson.java │ ├── MetadataLesson.java │ ├── MultipleResultsLesson.java │ ├── PrepareStatemantLesson.java │ ├── RowSetLesson.java │ ├── ScrolableSetLesson.java │ ├── SqlDateAndEscapeLesson.java │ ├── StoredPrcedureLesson.java │ ├── TransactionLesson.java │ ├── UpdatableSetLesson.java │ └── transactionisolationlevel │ │ ├── DirtyReadLesson.java │ │ ├── PhantomReadLesson.java │ │ └── RepeatableReadLesson.java ├── jmx │ ├── Hello.java │ ├── HelloMBean.java │ ├── Main.java │ ├── Person.java │ └── client │ │ ├── ClientListener.java │ │ └── Main.java ├── jmxlesson │ ├── Hello.java │ ├── HelloMBean.java │ ├── Main.java │ ├── Person.java │ └── client │ │ ├── Client.java │ │ └── ClientListener.java ├── keytoolLesson ├── logging │ ├── LogginLesson.java │ └── log.properties ├── logging_de.properties ├── logging_en.properties ├── logging_ru_RU.properties ├── mail.properties ├── multithreading │ ├── a1 │ │ └── CreateThread.java │ ├── a10 │ │ └── WaitNotifyExample.java │ ├── a11 │ │ └── MyReentrantLock.java │ ├── a12 │ │ └── TryLock.java │ ├── a13 │ │ └── Conditions.java │ ├── a14 │ │ └── CallableAndFuture.java │ ├── a15 │ │ ├── MyExecutor.java │ │ └── SheduledExecutionService.java │ ├── a16 │ │ └── Semophore.java │ ├── a17 │ │ └── CountDownLounch.java │ ├── a18 │ │ └── Excenger.java │ ├── a19 │ │ └── CyclicBarier.java │ ├── a2 │ │ ├── Join.java │ │ ├── LiveCycle.java │ │ └── Yield.java │ ├── a20 │ │ └── MyPhaser.java │ ├── a21 │ │ └── MyBlockingQueue.java │ ├── a22 │ │ └── MyThreadFactory.java │ ├── a23 │ │ ├── ForkJoinFramework.java │ │ └── ForkJoinFramework2.java │ ├── a24 │ │ └── RundomAndTimeUnit.java │ ├── a25 │ │ └── DeamonLesson.java │ ├── a26 │ │ └── ReadWriteLockLesson.java │ ├── a3 │ │ └── Synchronize.java │ ├── a4 │ │ └── StaticSync.java │ ├── a5 │ │ └── Volatile.java │ ├── a6 │ │ └── Atomic.java │ ├── a7 │ │ └── SyncColletions.java │ ├── a8 │ │ └── Deadlock.java │ └── a9 │ │ └── WaitNotify.java ├── native │ ├── HelloNative.c │ ├── HelloNative.h │ ├── HelloNative.java │ ├── HelloNativeTest.java │ ├── libHelloNative.so │ └── run.sh ├── network │ ├── EmailLesson.java │ ├── ServerLesson.java │ ├── ServerSocketLesson.java │ ├── SocketLesson.java │ └── WebDataLesson.java ├── patterns │ ├── DemoOfClientState.java │ ├── MediatorDemo.java │ ├── MyApp.java │ ├── behavioral │ │ ├── ChainOfResponsibilityLesson.java │ │ ├── CommandLesson.java │ │ ├── InterpreterLesson.java │ │ ├── IteratorLesson.java │ │ ├── MediatorLesson.java │ │ ├── MomentoLesson.java │ │ ├── NullObjectPatter.java │ │ ├── ObservableExample.java │ │ ├── ObservableLesson.java │ │ ├── StateLesson.java │ │ ├── StrategyLesson.java │ │ ├── TemplateLesson.java │ │ └── VisotorLesson.java │ ├── creational │ │ ├── AbstractFactoryLesson.java │ │ ├── BuilderLesson.java │ │ ├── FactoryLesson.java │ │ ├── FactoryMehodLesson.java │ │ ├── ObjectPoolLesson.java │ │ ├── PrototypeLesson.java │ │ └── SingeltonLesson.java │ ├── structural │ │ ├── AdapterLesson.java │ │ ├── BridgeLesson.java │ │ ├── CompositeLesson.java │ │ ├── DecoratorLesson.java │ │ ├── FacadeLesson.java │ │ ├── FilterLesson.java │ │ ├── FlyWeightLesson.java │ │ └── ProxyLesson.java │ └── web │ │ ├── BusinessDelegatePatternt.java │ │ ├── BusinessObjectLesson.java │ │ ├── CompositeEntityLesson.java │ │ ├── DAOPatternLesson.java │ │ ├── FrontControllerLesson.java │ │ ├── InterceptingFilterLesson.java │ │ ├── MVCLesson.java │ │ └── ServiceLocatorLesson.java ├── properties │ ├── PreferencesLesson.java │ └── PropertiesLesson.java ├── regexp │ ├── AtomicGroupLesson.java │ ├── CharackterClassesLesson.java │ ├── CommentsAndFreeSpacingLesson.java │ ├── ContinueEndOfPreviousMatchLesson.java │ ├── DotLesson.java │ ├── IfThenElseLesson.java │ ├── LiteralCharactersLesson.java │ ├── LookaroundLesson.java │ ├── MatchingModeLesson.java │ ├── NamedCapturingGroup.java │ ├── OptionalItemsLesson.java │ ├── PipeLesson.java │ ├── PosixCharacterClassesLesson.java │ ├── PossessiveQuantifiersLesson.java │ ├── RegExpLesson.java │ ├── RoundBracketsGroupingLesson.java │ ├── StarPlusRepetitioinLesson.java │ ├── StartEndStringAnchorsLesson.java │ ├── TestMultipleRequirementsLesson.java │ ├── UnicodeRegExp.java │ └── WordBoundariesLesson.java ├── resources.properties ├── resources │ ├── resource.java │ ├── resource_de.java │ ├── resource_fr.java │ └── resource_ru.java ├── resources_de.properties ├── resources_fr.properties ├── resources_ru.properties ├── rmi │ ├── JndiLesson.java │ ├── RmiClientLesson.java │ └── RmiServerLesson.java ├── security │ ├── CipherLesson.java │ ├── ClassLoaderLesson.java │ ├── Main.java │ ├── MessageDigestShaLesson.java │ ├── MyPermission.java │ ├── PolicyLesson.java │ ├── RSALesson.java │ ├── UserAuthLesson.java │ └── VerifierTest.java ├── solid │ ├── DependencyInversionPrincipleLesson.java │ ├── InterfaceSegregationPrincipleLesson.java │ ├── LiskovPrincipleLesson.java │ ├── OpenCloseLesson.java │ └── SingleResponsibilityLesson.java ├── swing │ ├── JComponentLesson.java │ ├── TraversalOrder.java │ ├── actions │ │ ├── ActionListernerLesson.java │ │ ├── ActionsLesson.java │ │ ├── KeyStrokeLesson.java │ │ ├── MouseLesson.java │ │ ├── SingleCallLesson.java │ │ └── WindowListenerLesson.java │ ├── adwanced │ │ ├── DesctopPaneLesson.java │ │ ├── DontCustomFormatterLesson.java │ │ ├── InputCustomMaskFormatterLesson.java │ │ ├── InputDocumentFilterLesson.java │ │ ├── InputStandartFormatLesson.java │ │ ├── InputVerifyerLesson.java │ │ ├── JEditorPaneLesson.java │ │ ├── JListLesson.java │ │ ├── JSpinnerLesson.java │ │ ├── ProgressIndicatorLesson.java │ │ ├── ProgressMonitorInputStreamLesson.java │ │ ├── ProgressMonitorLesson.java │ │ ├── SplitPaneLesson.java │ │ ├── TabbedPaneLesson.java │ │ ├── TableLesson.java │ │ └── TreeLesson.java │ ├── awt │ │ ├── AreasLesson.java │ │ ├── ClipLesson.java │ │ ├── ClipboardStringLesson.java │ │ ├── DragAndDropLesson.java │ │ ├── ImageTransferLesson.java │ │ ├── ImgFilterLesson.java │ │ ├── ImgRasterLesson.java │ │ ├── ImgReaderWriterLesson.java │ │ ├── PaintLesson.java │ │ ├── PringLesson.java │ │ ├── PrintPictureService.java │ │ ├── PrintPostScriptLesson.java │ │ ├── RenderingSpeedLesson.java │ │ ├── RunDesctoopAppsLesson.java │ │ ├── ShapesLesson.java │ │ ├── SplashLesson.java │ │ ├── StrokeLesson.java │ │ ├── SystemTrayLesson.java │ │ ├── TransformationLesson.java │ │ └── TransparentLesson.java │ ├── bean │ │ ├── BeanForm.form │ │ ├── BeanForm.java │ │ ├── FaceBean.java │ │ └── Main.java │ ├── components │ │ ├── ChoiceComponentLesson.java │ │ ├── LoockAndFeelLesson.java │ │ └── TextInputLesson.java │ ├── dialog │ │ ├── ColorChooserLesson.java │ │ ├── DialogBoxLesson.java │ │ ├── FileDialogLesson.java │ │ └── JDialogLesson.java │ ├── layout │ │ ├── CustomLayoutManager.java │ │ ├── GridBagLayoutLesson.java │ │ ├── LayoutLesson.java │ │ └── NoLayout.java │ ├── menu │ │ ├── MenuLesson.java │ │ ├── PopupMenu.java │ │ └── ToolBarMenu.java │ └── web │ │ ├── AppletsLesson.java │ │ ├── WebStart.jnlp │ │ ├── WebStartLesson.java │ │ └── index.html └── xml │ ├── DomLesson.java │ ├── GenerateStaxXml.java │ ├── GenerateXml.java │ ├── SaxLesson.java │ ├── XPathLesson.java │ ├── jaxb │ ├── Customer.java │ ├── JAXBExample.java │ └── JAXBExample2.java │ └── jaxbexample │ ├── Customer.java │ ├── JaxbReader.java │ └── JaxbWriter.java ├── temp.txt └── test.png /LessonsList.txt: -------------------------------------------------------------------------------- 1 | java 8 Period lesson 2 | jmh lesson 3 | memory leak lesson 4 | Lombok lessons 5 | memory leak lesson -------------------------------------------------------------------------------- /Student.json: -------------------------------------------------------------------------------- 1 | {"Student":{"name":"Max","age":22,"address":{"street":"Lenina","city":"Moscov"},"exams":["math","english","chemistry"]}} -------------------------------------------------------------------------------- /StudentStream.json: -------------------------------------------------------------------------------- 1 | {"Student":{"name":"Max","age":22,"address":{"city":"New-York","street":"26 st"},"exams":["english","math","chemistry"]}} -------------------------------------------------------------------------------- /boot/src/main/java/com/max/MainWeb.java: -------------------------------------------------------------------------------- 1 | package com.max; 2 | 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | public class MainWeb { 9 | public static void main(String[] args) { 10 | SpringApplication.run(MainWeb.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /boot/src/main/java/com/max/controllers/WebController.java: -------------------------------------------------------------------------------- 1 | package com.max.controllers; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class WebController { 8 | @GetMapping("webBoot") 9 | public String webBoot() { 10 | return "Hello world"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /boot/src/main/java/com/max/impl/MyComponentImpl.java: -------------------------------------------------------------------------------- 1 | package com.max.impl; 2 | 3 | import com.max.interfaces.MyComponent; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class MyComponentImpl implements MyComponent { 8 | @Override 9 | public void print() { 10 | System.out.println("Hello world"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /boot/src/main/java/com/max/interfaces/MyComponent.java: -------------------------------------------------------------------------------- 1 | package com.max.interfaces; 2 | 3 | public interface MyComponent { 4 | void print(); 5 | } 6 | -------------------------------------------------------------------------------- /boot/src/main/java/com/max/interfaces/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.max.interfaces; 2 | 3 | import com.max.entities.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | @Transactional 8 | public interface UserRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /boot/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto=create-drop 2 | spring.datasource.url=jdbc:mysql://localhost:3306/Lessons 3 | spring.datasource.username=root 4 | spring.datasource.password=1 5 | management.security.enabled=false 6 | logging.level.org.hibernate.SQL=DEBUG 7 | spring.jpa.properties.hibernate.show_sql=true -------------------------------------------------------------------------------- /ee/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | ee.cdi.ChildOneA 8 | 9 | 10 | ee.cdi.LoggingInterceptor 11 | ee.cdi.LoggingInterceptor2 12 | 13 | 14 | ee.cdi.MyDecorator 15 | 16 | -------------------------------------------------------------------------------- /ee/resources/ValidationMessages.properties: -------------------------------------------------------------------------------- 1 | javax.validation.constraints.Size.message = size must be between {min} and {max} 2 | javax.validation.constraints.url.port.message = port must be {port} 3 | -------------------------------------------------------------------------------- /ee/src/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: ee.ejb.MainLesson 3 | 4 | -------------------------------------------------------------------------------- /ee/src/collections/ComplexityLesson.java: -------------------------------------------------------------------------------- 1 | package collections; 2 | 3 | import java.util.*; 4 | 5 | public class ComplexityLesson { 6 | public static void main(String[] args) { 7 | //O(1) - constant 8 | String[] strings; 9 | HashMap hashMap; 10 | ArrayList list; 11 | ArrayDeque deque; 12 | HashSet hashSet; 13 | LinkedHashSet linkedHashSet; 14 | LinkedHashMap linkedHashMap; 15 | 16 | //O(lon(n)) - logarithmic 17 | TreeMap treeMap; 18 | TreeSet treeSet; 19 | 20 | //O(n) - linear 21 | LinkedList linkedList; 22 | 23 | //O(n*log(n)) - quasilinear 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ee/src/collections/QueuesLesson.java: -------------------------------------------------------------------------------- 1 | package collections; 2 | 3 | import java.util.*; 4 | 5 | public class QueuesLesson { 6 | public static void main(String[] args) { 7 | Queue queue = new LinkedList<>(); 8 | Deque deque = new LinkedList<>(); 9 | Queue priorityQueue = new PriorityQueue<>(); 10 | Deque arrayDeque = new ArrayDeque<>(); 11 | priorityQueue.add("a"); 12 | priorityQueue.add("c"); 13 | priorityQueue.add("b"); 14 | while (priorityQueue.size() != 0) 15 | { 16 | System.out.println(priorityQueue.remove()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ee/src/controllers/TempController.java: -------------------------------------------------------------------------------- 1 | package controllers; 2 | 3 | import javax.servlet.ServletException; 4 | import javax.servlet.annotation.WebServlet; 5 | import javax.servlet.http.HttpServlet; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | @WebServlet("/tempController") 11 | public class TempController extends HttpServlet { 12 | @Override 13 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ee/src/ee/batch/BatchServlet.java: -------------------------------------------------------------------------------- 1 | package ee.batch; 2 | 3 | import javax.batch.operations.JobOperator; 4 | import javax.batch.runtime.BatchRuntime; 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import java.io.IOException; 11 | 12 | @WebServlet("/batchServlet") 13 | public class BatchServlet extends HttpServlet { 14 | @Override 15 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 16 | JobOperator jo = BatchRuntime.getJobOperator(); 17 | jo.start("simplejob", null); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ee/src/ee/batch/MyCheckpoint.java: -------------------------------------------------------------------------------- 1 | package ee.batch; 2 | 3 | import java.io.Serializable; 4 | 5 | public class MyCheckpoint implements Serializable { 6 | private long lineNum = 0; 7 | public void increase() { lineNum++; } 8 | public long getLineNum() { return lineNum; } 9 | } 10 | -------------------------------------------------------------------------------- /ee/src/ee/batch/MyProcessor.java: -------------------------------------------------------------------------------- 1 | package ee.batch; 2 | 3 | import javax.enterprise.context.Dependent; 4 | import javax.inject.Named; 5 | 6 | @Dependent 7 | @Named("MyProcessor") 8 | public class MyProcessor implements javax.batch.api.chunk.ItemProcessor { 9 | public MyProcessor() {} 10 | @Override 11 | public Object processItem(Object obj) throws Exception { 12 | System.out.println("processor process item"); 13 | String line = (String) obj; 14 | return line.toUpperCase(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ee/src/ee/beanvalidation/ChronologicalDates.java: -------------------------------------------------------------------------------- 1 | package ee.beanvalidation; 2 | 3 | import javax.validation.Constraint; 4 | import javax.validation.Payload; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.Target; 7 | 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | @Constraint(validatedBy = {ChronologicalDatesValidator.class}) 12 | @Target({TYPE}) 13 | @Retention(RUNTIME) 14 | public @interface ChronologicalDates { 15 | String message() default "dates invalid"; 16 | Class[] groups() default {}; 17 | Class[] payload() default {}; 18 | } 19 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/AtuthServletLesson.java: -------------------------------------------------------------------------------- 1 | package ee.ejb; 2 | 3 | import ee.ejb.beans.AuthBean; 4 | 5 | import javax.ejb.EJB; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | @WebServlet("/authLesson") 14 | public class AtuthServletLesson extends HttpServlet { 15 | @EJB 16 | AuthBean authBean; 17 | @Override 18 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 19 | resp.getWriter().write(authBean.sayHello()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/DataSourceLesson.java: -------------------------------------------------------------------------------- 1 | package ee.ejb; 2 | 3 | import ee.ejb.beans.DataSourceBean; 4 | 5 | import javax.ejb.EJB; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | @WebServlet("/dataSourceLesson") 14 | public class DataSourceLesson extends HttpServlet { 15 | @EJB 16 | DataSourceBean bean; 17 | @Override 18 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 19 | bean.saveBook(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/ExampleServlet.java: -------------------------------------------------------------------------------- 1 | package ee.ejb; 2 | 3 | import ee.ejb.beans.ExampleBean; 4 | 5 | import javax.ejb.EJB; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | @WebServlet("/ejbExample") 14 | public class ExampleServlet extends HttpServlet { 15 | @EJB 16 | ExampleBean exampleBean; 17 | @Override 18 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 19 | resp.getWriter().write(exampleBean.getName()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/TimeServiceServletLesson.java: -------------------------------------------------------------------------------- 1 | package ee.ejb; 2 | 3 | import ee.ejb.beans.TimeServiceBean; 4 | 5 | import javax.ejb.EJB; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | @WebServlet("/timeServiceLesson") 14 | public class TimeServiceServletLesson extends HttpServlet { 15 | @EJB 16 | TimeServiceBean timeServiceBean; 17 | @Override 18 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 19 | timeServiceBean.setTimer(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/XmlServletLesson.java: -------------------------------------------------------------------------------- 1 | package ee.ejb; 2 | 3 | import ee.ejb.beans.XmlBean; 4 | 5 | import javax.ejb.EJB; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | @WebServlet("/xmlServlet") 14 | public class XmlServletLesson extends HttpServlet { 15 | @EJB 16 | XmlBean xmlBean; 17 | @Override 18 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 19 | resp.getWriter().write(xmlBean.sayHello()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/beans/AsyncBean.java: -------------------------------------------------------------------------------- 1 | package ee.ejb.beans; 2 | 3 | import javax.ejb.AsyncResult; 4 | import javax.ejb.Asynchronous; 5 | import javax.ejb.Stateless; 6 | import java.util.concurrent.Future; 7 | 8 | @Stateless 9 | @Asynchronous 10 | public class AsyncBean { 11 | @Asynchronous 12 | public void doLongJob() { 13 | try { 14 | Thread.sleep(10_000); 15 | } catch (InterruptedException e) { 16 | e.printStackTrace(); 17 | } 18 | } 19 | public Future getResults() { 20 | try { 21 | Thread.sleep(2_000); 22 | } catch (InterruptedException e) { 23 | e.printStackTrace(); 24 | } 25 | return new AsyncResult<>(1); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/beans/DependsOnAndStartupBean1.java: -------------------------------------------------------------------------------- 1 | package ee.ejb.beans; 2 | 3 | import javax.annotation.PostConstruct; 4 | import javax.ejb.DependsOn; 5 | import javax.ejb.Singleton; 6 | import javax.ejb.Startup; 7 | 8 | @Singleton 9 | @DependsOn("DependsOnAndStartupBean2") 10 | //@DependsOn("myJar.jar#DependsOnAndStartupBean2") 11 | @Startup 12 | public class DependsOnAndStartupBean1 { 13 | public void print() { 14 | System.out.println("hello world"); 15 | } 16 | @PostConstruct 17 | void postConstruct() { 18 | System.out.println("postConctruct bean 2"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/beans/DependsOnAndStartupBean2.java: -------------------------------------------------------------------------------- 1 | package ee.ejb.beans; 2 | 3 | import javax.annotation.PostConstruct; 4 | import javax.ejb.Singleton; 5 | 6 | @Singleton 7 | public class DependsOnAndStartupBean2 { 8 | @PostConstruct 9 | void postConstruct() { 10 | System.out.println("postConctruct bean 1"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/beans/EjbDifferenceSessionBean.java: -------------------------------------------------------------------------------- 1 | package ee.ejb.beans; 2 | 3 | import javax.ejb.Remove; 4 | import javax.ejb.Stateful; 5 | import javax.ejb.StatefulTimeout; 6 | 7 | @Stateful 8 | @StatefulTimeout(20) 9 | //@Startup 10 | public class EjbDifferenceSessionBean { 11 | int i; 12 | 13 | public int getI() { 14 | return i; 15 | } 16 | 17 | public void setI(int i) { 18 | this.i = i; 19 | } 20 | 21 | @Remove 22 | private void remove() { 23 | System.out.println("remove statefull bean"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/beans/ExampleBean.java: -------------------------------------------------------------------------------- 1 | package ee.ejb.beans; 2 | 3 | import javax.ejb.Singleton; 4 | 5 | @Singleton 6 | public class ExampleBean { 7 | public String getName() { 8 | return "Max"; 9 | } 10 | } -------------------------------------------------------------------------------- /ee/src/ee/ejb/beans/HelloWorldEjb.java: -------------------------------------------------------------------------------- 1 | package ee.ejb.beans; 2 | 3 | import javax.ejb.Stateless; 4 | 5 | @Stateless 6 | //@Stateful 7 | //@Singleton 8 | public class HelloWorldEjb { 9 | public String sayHello() { 10 | return "Hello world"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/beans/JndiBean.java: -------------------------------------------------------------------------------- 1 | package ee.ejb.beans; 2 | 3 | import javax.ejb.Stateless; 4 | 5 | @Stateless 6 | public class JndiBean { 7 | public String sayHello() { 8 | return "hello"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/beans/LocalAndRemoteBean.java: -------------------------------------------------------------------------------- 1 | package ee.ejb.beans; 2 | 3 | import ee.ejb.beans.interfaces.LocalBeanInteface; 4 | import ee.ejb.beans.interfaces.RemoteBeanInterface; 5 | 6 | import javax.ejb.LocalBean; 7 | import javax.ejb.Stateless; 8 | 9 | @Stateless 10 | //@Local(LocalBeanInteface.class) 11 | //@Remote(RemoteBeanInterface.class) 12 | @LocalBean 13 | public class LocalAndRemoteBean implements LocalBeanInteface, RemoteBeanInterface { 14 | @Override 15 | public String sayHello() { 16 | return "hello"; 17 | } 18 | 19 | @Override 20 | public String sayRemoteHello() { 21 | return "remote hello"; 22 | } 23 | 24 | public String sayLocalHello() { 25 | return "local hello"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/beans/XmlBean.java: -------------------------------------------------------------------------------- 1 | package ee.ejb.beans; 2 | 3 | import javax.annotation.Resource; 4 | 5 | public class XmlBean { 6 | @Resource(name = "currencyEntry") 7 | String currencyEntry; 8 | @Resource(name = "currencyRate") 9 | double currencyRate; 10 | public String sayHello() { 11 | return "Hello " + currencyEntry + " " + currencyRate; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/beans/interfaces/LocalBeanInteface.java: -------------------------------------------------------------------------------- 1 | package ee.ejb.beans.interfaces; 2 | 3 | public interface LocalBeanInteface { 4 | String sayHello(); 5 | } 6 | -------------------------------------------------------------------------------- /ee/src/ee/ejb/beans/interfaces/RemoteBeanInterface.java: -------------------------------------------------------------------------------- 1 | package ee.ejb.beans.interfaces; 2 | 3 | public interface RemoteBeanInterface { 4 | String sayRemoteHello(); 5 | } 6 | -------------------------------------------------------------------------------- /ee/src/ee/jaxrs/ApplicationPathLesson.java: -------------------------------------------------------------------------------- 1 | package ee.jaxrs; 2 | 3 | import javax.ws.rs.ApplicationPath; 4 | import javax.ws.rs.core.Application; 5 | 6 | @ApplicationPath("/rs") 7 | public class ApplicationPathLesson extends Application { 8 | } 9 | -------------------------------------------------------------------------------- /ee/src/ee/jaxrs/ContextInfoLesson.java: -------------------------------------------------------------------------------- 1 | package ee.jaxrs; 2 | 3 | import javax.ws.rs.GET; 4 | import javax.ws.rs.Path; 5 | import javax.ws.rs.Produces; 6 | import javax.ws.rs.core.*; 7 | import javax.ws.rs.ext.Providers; 8 | 9 | @Path("/contextInfo") 10 | public class ContextInfoLesson { 11 | @Context 12 | UriInfo uriInfo; 13 | @GET 14 | @Produces(MediaType.TEXT_PLAIN) 15 | public String getString(@Context HttpHeaders headers, @Context Request request, @Context SecurityContext securityContext, @Context Providers providers) { 16 | return uriInfo.getAbsolutePath().toString(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ee/src/ee/jaxrs/HelloWorldRest.java: -------------------------------------------------------------------------------- 1 | package ee.jaxrs; 2 | 3 | import javax.ws.rs.*; 4 | 5 | @Path("/rest") 6 | public class HelloWorldRest { 7 | @GET 8 | @Produces("text/plain") 9 | public String sayHello() { 10 | return "Hello"; 11 | } 12 | 13 | @GET 14 | @Path("/get") 15 | public String getGet() { 16 | return "Get"; 17 | } 18 | 19 | @POST 20 | public String getPost() { 21 | return "Post"; 22 | } 23 | 24 | @GET 25 | public String getString() { 26 | return "test"; 27 | } 28 | 29 | @HEAD 30 | // @PUT 31 | // @DELETE 32 | // @OPTIONS 33 | public void getHead() { 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ee/src/ee/jaxrs/Student.java: -------------------------------------------------------------------------------- 1 | package ee.jaxrs; 2 | 3 | import javax.xml.bind.annotation.XmlElement; 4 | import javax.xml.bind.annotation.XmlRootElement; 5 | 6 | @XmlRootElement 7 | public class Student { 8 | String name; 9 | 10 | public Student() { 11 | } 12 | 13 | public Student(String name) { 14 | this.name = name; 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | @XmlElement 22 | public void setName(String name) { 23 | this.name = name; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ee/src/ee/jaxrs/provider/EntityProviderLesson.java: -------------------------------------------------------------------------------- 1 | package ee.jaxrs.provider; 2 | 3 | import javax.ws.rs.*; 4 | import javax.ws.rs.core.MediaType; 5 | 6 | @Path("/entityProvider") 7 | public class EntityProviderLesson { 8 | @GET 9 | @Produces("my/format") 10 | public Student getCustomStudent() { 11 | return new Student("Max", "22"); 12 | } 13 | @POST 14 | @Consumes("my/format") 15 | @Path("/getName/") 16 | @Produces(MediaType.TEXT_PLAIN) 17 | public String getCustomStudent(Student student) { 18 | return student.getName(); 19 | } 20 | } -------------------------------------------------------------------------------- /ee/src/ee/jaxrs/provider/Student.java: -------------------------------------------------------------------------------- 1 | package ee.jaxrs.provider; 2 | 3 | public class Student { 4 | String name; 5 | String age; 6 | 7 | public Student() { 8 | } 9 | 10 | public Student(String name, String age) { 11 | this.name = name; 12 | this.age = age; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public String getAge() { 24 | return age; 25 | } 26 | 27 | public void setAge(String age) { 28 | this.age = age; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ee/src/ee/jaxws/container/ContainerService.java: -------------------------------------------------------------------------------- 1 | package ee.jaxws.container; 2 | 3 | import javax.jws.WebService; 4 | 5 | @WebService 6 | public interface ContainerService { 7 | String sayHello(); 8 | } 9 | -------------------------------------------------------------------------------- /ee/src/ee/jaxws/container/ContainerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ee.jaxws.container; 2 | 3 | import javax.jws.WebService; 4 | 5 | @WebService(endpointInterface = "ee.jaxws.container.ContainerService") 6 | public class ContainerServiceImpl implements ContainerService { 7 | public String sayHello() { 8 | return "hello"; 9 | } 10 | } -------------------------------------------------------------------------------- /ee/src/ee/jaxws/exception/CallExceptionWebService.java: -------------------------------------------------------------------------------- 1 | package ee.jaxws.exception; 2 | 3 | import javax.xml.namespace.QName; 4 | import javax.xml.ws.Service; 5 | import java.net.URL; 6 | 7 | public class CallExceptionWebService { 8 | public static void main(String[] args) throws Exception { 9 | 10 | URL url = new URL("http://localhost:8080/ExceptionWs?wsdl"); 11 | 12 | QName qname = new QName("http://exception.jaxws.ee/", "ExceptionWebServiceImplService"); 13 | 14 | Service service = Service.create(url, qname); 15 | 16 | ExceptionWebService exceptionWebService = service.getPort(ExceptionWebService.class); 17 | System.out.println(exceptionWebService.divide(5, 0)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ee/src/ee/jaxws/exception/ExceptionWebService.java: -------------------------------------------------------------------------------- 1 | package ee.jaxws.exception; 2 | 3 | import javax.jws.WebService; 4 | import javax.xml.soap.SOAPException; 5 | 6 | @WebService 7 | public interface ExceptionWebService { 8 | double divide(double a, double b) throws SOAPException; 9 | } 10 | -------------------------------------------------------------------------------- /ee/src/ee/jaxws/exception/PublishExceptionWebService.java: -------------------------------------------------------------------------------- 1 | package ee.jaxws.exception; 2 | 3 | import javax.xml.ws.Endpoint; 4 | 5 | public class PublishExceptionWebService { 6 | public static void main(String[] args) { 7 | Endpoint.publish("http://localhost:8080/ExceptionWs", new ExceptionWebServiceImpl()); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ee/src/ee/jaxws/exception/ValueIsNullException.java: -------------------------------------------------------------------------------- 1 | package ee.jaxws.exception; 2 | 3 | import javax.xml.soap.SOAPFault; 4 | import javax.xml.ws.WebFault; 5 | import javax.xml.ws.soap.SOAPFaultException; 6 | 7 | @WebFault(name = "ValueIsWrong") 8 | class ValueIsNullException extends SOAPFaultException {// Exception { 9 | // public ValueIsNullException() { 10 | // super(); 11 | // } 12 | // 13 | // public ValueIsNullException(String message) { 14 | // super(message); 15 | // } 16 | 17 | public ValueIsNullException(SOAPFault fault) { 18 | super(fault); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ee/src/ee/jaxws/main/CallMainService.java: -------------------------------------------------------------------------------- 1 | package ee.jaxws.main; 2 | 3 | import javax.xml.namespace.QName; 4 | import javax.xml.ws.Service; 5 | import java.net.URL; 6 | 7 | public class CallMainService { 8 | //wsimport -keep http://localhost:8080/HelloWs?wsdl 9 | public static void main(String[] args) throws Exception { 10 | 11 | URL url = new URL("http://localhost:8080/HelloWs?wsdl"); 12 | 13 | QName qname = new QName("http://main.jaxws.ee/", "HelloWsService"); 14 | 15 | Service service = Service.create(url, qname); 16 | 17 | Hello hello = service.getPort(Hello.class); 18 | System.out.println(hello.print("Max")); 19 | System.out.println(hello.checkStudent(new Student(3))); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ee/src/ee/jaxws/main/Hello.java: -------------------------------------------------------------------------------- 1 | package ee.jaxws.main; 2 | 3 | import javax.jws.WebService; 4 | 5 | @WebService 6 | public interface Hello { 7 | String print(String name); 8 | boolean checkStudent(Student student); 9 | } 10 | -------------------------------------------------------------------------------- /ee/src/ee/jaxws/main/HelloWs.java: -------------------------------------------------------------------------------- 1 | package ee.jaxws.main; 2 | 3 | import javax.jws.WebService; 4 | import javax.xml.ws.Endpoint; 5 | 6 | @WebService(endpointInterface = "ee.jaxws.main.Hello") 7 | public class HelloWs { 8 | public static void main(String[] args) { 9 | Endpoint.publish("http://localhost:8080/HelloWs", new HelloWs()); 10 | } 11 | public String print(String name) { 12 | return "Hello " + name; 13 | } 14 | public boolean checkStudent(Student student) { 15 | return student.avarageMark > 3; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ee/src/ee/jaxws/main/Student.java: -------------------------------------------------------------------------------- 1 | package ee.jaxws.main; 2 | 3 | import javax.xml.bind.annotation.XmlRootElement; 4 | 5 | @XmlRootElement 6 | public class Student { 7 | int avarageMark; 8 | 9 | public Student() { 10 | } 11 | 12 | public Student(int avarageMark) { 13 | this.avarageMark = avarageMark; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ee/src/ee/jms/advanced/DefinitionBean.java: -------------------------------------------------------------------------------- 1 | package ee.jms.advanced; 2 | 3 | import javax.ejb.MessageDriven; 4 | import javax.jms.*; 5 | 6 | @JMSConnectionFactoryDefinition(name = "MyFactory") 7 | @JMSDestinationDefinition(name = "MyQueue", 8 | interfaceName = "javax.jms.Queue") 9 | @MessageDriven(mappedName = "MyQueue") 10 | public class DefinitionBean implements MessageListener { 11 | @Override 12 | public void onMessage(Message message) { 13 | try { 14 | System.out.println("Message received: " + message.getBody(String.class)); 15 | } catch (JMSException e) {} 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ee/src/ee/jpa/JpaBean.java: -------------------------------------------------------------------------------- 1 | package ee.jpa; 2 | 3 | import ee.jpa.entities.Book; 4 | 5 | import javax.ejb.Stateless; 6 | import javax.persistence.EntityManager; 7 | import javax.persistence.PersistenceContext; 8 | 9 | @Stateless 10 | public class JpaBean { 11 | @PersistenceContext 12 | EntityManager entityManager; 13 | 14 | public void saveBook(Book book) { 15 | entityManager.persist(book); 16 | } 17 | } -------------------------------------------------------------------------------- /ee/src/ee/jpa/ServletExample.java: -------------------------------------------------------------------------------- 1 | package ee.jpa; 2 | 3 | import ee.jpa.entities.Book; 4 | 5 | import javax.ejb.EJB; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | @WebServlet("/jpaExample") 14 | public class ServletExample extends HttpServlet { 15 | @EJB 16 | JpaBean jpaBean; 17 | @Override 18 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 19 | jpaBean.saveBook(new Book("main")); 20 | } 21 | } -------------------------------------------------------------------------------- /ee/src/ee/jpa/ementity/Customer.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.ementity; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.GeneratedValue; 5 | import javax.persistence.Id; 6 | import javax.persistence.OneToOne; 7 | 8 | @Entity 9 | public class Customer { 10 | @Id @GeneratedValue 11 | int id; 12 | String name; 13 | @OneToOne(orphanRemoval = true) 14 | CustomerAddress customerAddress; 15 | 16 | public Customer() { 17 | } 18 | 19 | public Customer(String name, CustomerAddress customerAddress) { 20 | this.name = name; 21 | this.customerAddress = customerAddress; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ee/src/ee/jpa/entities/AccessTypeLesson.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.entities; 2 | 3 | import javax.persistence.*; 4 | 5 | @Entity 6 | @Access(AccessType.FIELD) 7 | public class AccessTypeLesson { 8 | @Id @GeneratedValue 9 | int id; 10 | @Transient 11 | String name; 12 | 13 | 14 | public void setId(int id) { 15 | this.id = id; 16 | } 17 | 18 | public int getId() { 19 | return id; 20 | } 21 | 22 | @Access(AccessType.PROPERTY) 23 | public String getName() { 24 | return "Mr. " + name; 25 | } 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ee/src/ee/jpa/entities/BasicLesson.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.entities; 2 | 3 | import javax.persistence.*; 4 | 5 | @Entity 6 | public class BasicLesson { 7 | @Id @GeneratedValue 8 | int id; 9 | @Basic(fetch = FetchType.LAZY, optional = false) 10 | @Lob 11 | byte[] img; 12 | } 13 | -------------------------------------------------------------------------------- /ee/src/ee/jpa/entities/Book.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.entities; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.GeneratedValue; 5 | import javax.persistence.Id; 6 | 7 | @Entity 8 | public class Book { 9 | @Id 10 | @GeneratedValue 11 | private int id; 12 | private String title; 13 | public Book() {} 14 | 15 | public Book(String title) { 16 | this.title = title; 17 | } 18 | 19 | public int getId() { 20 | return id; 21 | } 22 | public String getTitle() { 23 | return title; 24 | } 25 | 26 | public void setTitle(String title) { 27 | this.title = title; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ee/src/ee/jpa/entities/Book_.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.entities; 2 | 3 | import javax.annotation.Generated; 4 | import javax.persistence.metamodel.SingularAttribute; 5 | import javax.persistence.metamodel.StaticMetamodel; 6 | 7 | @Generated("EclipseLink") 8 | @StaticMetamodel(Book.class) 9 | public class Book_ { 10 | public static volatile SingularAttribute id; 11 | public static volatile SingularAttribute title; 12 | } 13 | -------------------------------------------------------------------------------- /ee/src/ee/jpa/entities/CollumnLesson.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.entities; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.Id; 7 | 8 | @Entity 9 | public class CollumnLesson { 10 | @Id @GeneratedValue 11 | int id; 12 | @Column(name = "studentName", length = 50, unique = true, nullable = false, insertable = true, updatable = false) 13 | String name; 14 | @Column(columnDefinition = "varchar(255) null") 15 | String serName; 16 | 17 | public CollumnLesson() { 18 | } 19 | 20 | public CollumnLesson(String name) { 21 | this.name = name; 22 | } 23 | } -------------------------------------------------------------------------------- /ee/src/ee/jpa/entities/EbeddableLesson.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.entities; 2 | 3 | import javax.persistence.*; 4 | 5 | @Entity 6 | public class EbeddableLesson { 7 | @Id @GeneratedValue 8 | int id; 9 | String name; 10 | @Embedded 11 | Address address; 12 | 13 | public EbeddableLesson() { 14 | name = "Max"; 15 | address = new Address(); 16 | address.street = "MyStreet"; 17 | address.city = "MyCity"; 18 | } 19 | } 20 | 21 | @Embeddable 22 | class Address { 23 | String street; 24 | String city; 25 | String zipCode; 26 | } 27 | -------------------------------------------------------------------------------- /ee/src/ee/jpa/entities/EntityGraphBookLesson.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.entities; 2 | 3 | import javax.persistence.*; 4 | 5 | @NamedEntityGraphs({ 6 | @NamedEntityGraph(name = "getOnlyName", attributeNodes = {@NamedAttributeNode("name")}) 7 | }) 8 | //@NamedEntityGraph 9 | @Entity 10 | public class EntityGraphBookLesson { 11 | @Id 12 | @GeneratedValue 13 | int id; 14 | @Basic(fetch = FetchType.EAGER) 15 | String title; 16 | String author; 17 | String name; 18 | String content; 19 | } 20 | -------------------------------------------------------------------------------- /ee/src/ee/jpa/entities/EnumeratedLesson.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.entities; 2 | 3 | import javax.persistence.*; 4 | 5 | @Entity 6 | public class EnumeratedLesson { 7 | @Id @GeneratedValue 8 | int id; 9 | @Enumerated(EnumType.STRING) 10 | Gender gender; 11 | 12 | public EnumeratedLesson() { 13 | gender = Gender.MALE; 14 | } 15 | } 16 | enum Gender {MALE, ALIEN, FIMALE} -------------------------------------------------------------------------------- /ee/src/ee/jpa/entities/IdLesson.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.entities; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | 6 | @Entity 7 | public class IdLesson { 8 | @Id 9 | int id; 10 | String name; 11 | 12 | public IdLesson() { 13 | } 14 | 15 | public IdLesson(String name) { 16 | this.name = name; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ee/src/ee/jpa/entities/Student.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.entities; 2 | 3 | import javax.persistence.*; 4 | 5 | @Entity 6 | public class Student { 7 | @Id @GeneratedValue 8 | int id; 9 | String name; 10 | 11 | public Student() { 12 | } 13 | public Student(String name) { 14 | this.name = name; 15 | } 16 | 17 | public int getId() { 18 | return id; 19 | } 20 | 21 | public void setId(int id) { 22 | this.id = id; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | } -------------------------------------------------------------------------------- /ee/src/ee/jpa/entities/TemproralLesson.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.entities; 2 | 3 | import javax.persistence.*; 4 | import java.util.Calendar; 5 | import java.util.Date; 6 | 7 | @Entity 8 | public class TemproralLesson { 9 | @Id @GeneratedValue 10 | int id; 11 | @Temporal(TemporalType.TIME) 12 | Calendar date; 13 | 14 | public TemproralLesson() { 15 | date = Calendar.getInstance();//new Date(); 16 | date.setTime(new Date()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ee/src/ee/jpa/entities/TransientLesson.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.entities; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.GeneratedValue; 5 | import javax.persistence.Id; 6 | 7 | @Entity 8 | public class TransientLesson { 9 | @Id @GeneratedValue 10 | int id; 11 | String name; 12 | // @Transient 13 | transient 14 | int age; 15 | 16 | public TransientLesson() { 17 | } 18 | 19 | public TransientLesson(String name, int age) { 20 | this.name = name; 21 | this.age = age; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ee/src/ee/jpa/entities/XmlLesson.java: -------------------------------------------------------------------------------- 1 | package ee.jpa.entities; 2 | 3 | public class XmlLesson { 4 | int id; 5 | String name; 6 | } 7 | -------------------------------------------------------------------------------- /ee/src/ee/jsf/BackingBean.java: -------------------------------------------------------------------------------- 1 | package ee.jsf; 2 | 3 | import javax.faces.bean.RequestScoped; 4 | import javax.inject.Named; 5 | 6 | @Named 7 | @RequestScoped 8 | public class BackingBean { 9 | private String someValue = "some value"; 10 | 11 | public String getSomeValue() { 12 | return someValue; 13 | } 14 | 15 | public void setSomeValue(String someValue) { 16 | this.someValue = someValue; 17 | } 18 | 19 | public void doJob() { 20 | System.out.println("do job"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ee/src/ee/jsf/CommandsController.java: -------------------------------------------------------------------------------- 1 | package ee.jsf; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | 5 | @ManagedBean 6 | public class CommandsController { 7 | public void sayHello() { 8 | System.out.println("hello world"); 9 | } 10 | public void printMessage(String myInput) { 11 | System.out.println("you print: " + myInput); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ee/src/ee/jsf/CustomConverter.java: -------------------------------------------------------------------------------- 1 | package ee.jsf; 2 | 3 | import javax.faces.component.UIComponent; 4 | import javax.faces.context.FacesContext; 5 | import javax.faces.convert.Converter; 6 | import javax.faces.convert.FacesConverter; 7 | 8 | @FacesConverter("euroConverter") 9 | public class CustomConverter implements Converter { 10 | @Override 11 | public Object getAsObject(FacesContext context, UIComponent component, String value) { 12 | return value; 13 | } 14 | 15 | @Override 16 | public String getAsString(FacesContext ctx, UIComponent component, Object value) { 17 | return "€" + value; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ee/src/ee/jsf/InputBean.java: -------------------------------------------------------------------------------- 1 | package ee.jsf; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | 5 | @ManagedBean 6 | public class InputBean { 7 | String myTextInput; 8 | 9 | public String getMyTextInput() { 10 | return myTextInput; 11 | } 12 | 13 | public void setMyTextInput(String myTextInput) { 14 | this.myTextInput = myTextInput; 15 | } 16 | 17 | public void printInput() { 18 | System.out.println(myTextInput); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ee/src/ee/jsf/Navigate.java: -------------------------------------------------------------------------------- 1 | package ee.jsf; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | 5 | @ManagedBean 6 | public class Navigate { 7 | public String goToNewPage() { 8 | return "NewPage.xhtml"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ee/src/ee/jsf/PrintHello.java: -------------------------------------------------------------------------------- 1 | package ee.jsf; 2 | 3 | import javax.faces.bean.ManagedBean; 4 | 5 | @ManagedBean 6 | public class PrintHello { 7 | String input; 8 | 9 | public String getInput() { 10 | return input; 11 | } 12 | 13 | public void setInput(String input) { 14 | this.input = input; 15 | } 16 | 17 | public void printHello() { 18 | System.out.println("hello world " + input); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ee/src/ee/jta/ExampleServlet.java: -------------------------------------------------------------------------------- 1 | package ee.jta; 2 | 3 | import ee.jta.beans.ExampleJtaBean; 4 | 5 | import javax.ejb.EJB; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | @WebServlet("/exampleJtaServlet") 14 | public class ExampleServlet extends HttpServlet { 15 | @EJB 16 | ExampleJtaBean exampleJtaBean; 17 | @Override 18 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 19 | exampleJtaBean.saveStudent(); 20 | } 21 | } -------------------------------------------------------------------------------- /ee/src/ee/jta/beans/ExampleJtaBean.java: -------------------------------------------------------------------------------- 1 | package ee.jta.beans; 2 | 3 | import ee.jpa.entities.Student; 4 | 5 | import javax.ejb.Singleton; 6 | import javax.persistence.EntityManager; 7 | import javax.persistence.PersistenceContext; 8 | 9 | @Singleton 10 | public class ExampleJtaBean { 11 | @PersistenceContext 12 | EntityManager entityManager; 13 | public void saveStudent() { 14 | entityManager.persist(new Student("Max")); 15 | } 16 | } -------------------------------------------------------------------------------- /ee/src/ee/jta/beans/JtaBean.java: -------------------------------------------------------------------------------- 1 | package ee.jta.beans; 2 | 3 | import javax.ejb.EJB; 4 | import javax.ejb.Singleton; 5 | 6 | @Singleton 7 | public class JtaBean { 8 | @EJB 9 | PersistentBean persistentBean; 10 | public void saveBook() { 11 | persistentBean.saveBook(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ee/src/ee/jta/beans/PersistentBean.java: -------------------------------------------------------------------------------- 1 | package ee.jta.beans; 2 | 3 | import ee.jpa.entities.Book; 4 | 5 | import javax.ejb.Singleton; 6 | import javax.ejb.TransactionAttribute; 7 | import javax.ejb.TransactionAttributeType; 8 | import javax.persistence.EntityManager; 9 | import javax.persistence.PersistenceContext; 10 | 11 | @Singleton 12 | //@TransactionAttribute(TransactionAttributeType.SUPPORTS) 13 | public class PersistentBean { 14 | @PersistenceContext 15 | EntityManager entityManager; 16 | @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) 17 | public void saveBook() { 18 | entityManager.persist(new Book("jta book")); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ee/src/ee/websockets/AnnotatedEndpoint.java: -------------------------------------------------------------------------------- 1 | package ee.websockets; 2 | 3 | import javax.websocket.OnMessage; 4 | import javax.websocket.Session; 5 | import javax.websocket.server.ServerEndpoint; 6 | import java.io.IOException; 7 | 8 | @ServerEndpoint("/echoEndpoint") 9 | public class AnnotatedEndpoint { 10 | @OnMessage 11 | public void onMessage(Session session, String msg) throws IOException { 12 | session.getBasicRemote().sendText(msg); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ee/src/ee/websockets/ParamsLesson.java: -------------------------------------------------------------------------------- 1 | package ee.websockets; 2 | 3 | import javax.websocket.OnMessage; 4 | import javax.websocket.Session; 5 | import javax.websocket.server.PathParam; 6 | import javax.websocket.server.ServerEndpoint; 7 | import java.io.IOException; 8 | 9 | @ServerEndpoint("/paramsEndpoint/{param}") 10 | public class ParamsLesson { 11 | @OnMessage 12 | public void onMessage(Session session, String msg, @PathParam("param") String param) throws IOException { 13 | System.out.println(param); 14 | System.out.println(msg); 15 | session.getBasicRemote().sendText(param); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ee/src/ee/websockets/decode/DecodeMessage.java: -------------------------------------------------------------------------------- 1 | package ee.websockets.decode; 2 | 3 | import javax.websocket.DecodeException; 4 | import javax.websocket.Decoder; 5 | import javax.websocket.EndpointConfig; 6 | 7 | public class DecodeMessage implements Decoder.Text { 8 | @Override 9 | public Message decode(String s) throws DecodeException { 10 | return new Message(s); 11 | } 12 | 13 | @Override 14 | public boolean willDecode(String s) { 15 | return true; 16 | } 17 | 18 | @Override 19 | public void init(EndpointConfig endpointConfig) {} 20 | 21 | @Override 22 | public void destroy() {} 23 | } 24 | -------------------------------------------------------------------------------- /ee/src/ee/websockets/decode/EncodeMessage.java: -------------------------------------------------------------------------------- 1 | package ee.websockets.decode; 2 | 3 | import javax.websocket.EncodeException; 4 | import javax.websocket.Encoder; 5 | import javax.websocket.EndpointConfig; 6 | 7 | public class EncodeMessage implements Encoder.Text { 8 | @Override 9 | public String encode(Message message) throws EncodeException { 10 | return message.s; 11 | } 12 | 13 | @Override 14 | public void init(EndpointConfig endpointConfig) {} 15 | 16 | @Override 17 | public void destroy() {} 18 | } 19 | -------------------------------------------------------------------------------- /ee/src/ee/websockets/decode/Message.java: -------------------------------------------------------------------------------- 1 | package ee.websockets.decode; 2 | 3 | public class Message { 4 | String s; 5 | 6 | public Message(String s) { 7 | this.s = s; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ee/src/ee/websockets/decode/ServerEncodeMessageEndpoint.java: -------------------------------------------------------------------------------- 1 | package ee.websockets.decode; 2 | 3 | import javax.websocket.EncodeException; 4 | import javax.websocket.OnMessage; 5 | import javax.websocket.Session; 6 | import javax.websocket.server.ServerEndpoint; 7 | import java.io.IOException; 8 | 9 | @ServerEndpoint(value = "/decodeEndpoint", decoders = DecodeMessage.class, encoders = EncodeMessage.class) 10 | public class ServerEncodeMessageEndpoint { 11 | @OnMessage 12 | public void onMessage(Session session, Message message) throws IOException, EncodeException { 13 | System.out.println(message.s); 14 | session.getBasicRemote().sendObject(message); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ee/src/interview/CloneLesson.java: -------------------------------------------------------------------------------- 1 | package interview; 2 | 3 | public class CloneLesson implements Cloneable { 4 | int i; 5 | public static void main(String[] args) throws CloneNotSupportedException { 6 | CloneLesson cloneLesson = new CloneLesson(); 7 | cloneLesson.i = 5; 8 | CloneLesson clone = (CloneLesson) cloneLesson.clone(); 9 | System.out.println(clone.i); 10 | } 11 | 12 | @Override 13 | protected Object clone() throws CloneNotSupportedException { 14 | return super.clone(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ee/src/interview/CreateGenericClassLesson.java: -------------------------------------------------------------------------------- 1 | package interview; 2 | 3 | public class CreateGenericClassLesson { 4 | public static void main(String[] args) throws InstantiationException, IllegalAccessException { 5 | Object object = getT(Object.class); 6 | } 7 | static T getT(Class clazz) throws IllegalAccessException, InstantiationException { 8 | return clazz.newInstance(); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /ee/src/interview/DeadLockSearch.java: -------------------------------------------------------------------------------- 1 | package interview; 2 | 3 | import java.lang.management.ManagementFactory; 4 | import java.lang.management.ThreadInfo; 5 | import java.lang.management.ThreadMXBean; 6 | 7 | public class DeadLockSearch { 8 | public static void main(String[] args) { 9 | ThreadMXBean bean = ManagementFactory.getThreadMXBean(); 10 | long[] threadIds = bean.findDeadlockedThreads(); 11 | if(threadIds != null) { 12 | ThreadInfo[] infos = bean.getThreadInfo(threadIds); 13 | for (ThreadInfo info : infos) { 14 | System.out.println(info); 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ee/src/interview/HashCodeImplementationLesson.java: -------------------------------------------------------------------------------- 1 | package interview; 2 | 3 | public class HashCodeImplementationLesson { 4 | public static void main(String[] args) { 5 | Object o = new Object(); 6 | Object o2 = new Object(); 7 | Object o3 = new Object(); 8 | Object o4 = new Object(); 9 | System.out.println(o.hashCode()); 10 | System.out.println(o2.hashCode()); 11 | System.out.println(o3.hashCode()); 12 | System.out.println(o4.hashCode()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ee/src/interview/ImmutableCollectionsLesson.java: -------------------------------------------------------------------------------- 1 | package interview; 2 | 3 | import java.util.*; 4 | 5 | public class ImmutableCollectionsLesson { 6 | public static void main(String[] args) { 7 | List list = new ArrayList<>(); 8 | list.add("one"); 9 | list.add("two"); 10 | List list2 = Collections.unmodifiableList(list); 11 | list.add("three"); 12 | System.out.println(list.get(0)); 13 | System.out.println(list.get(1)); 14 | System.out.println(list.get(2)); 15 | 16 | Set set = Collections.unmodifiableSet(new HashSet<>()); 17 | Map map = Collections.unmodifiableMap(new HashMap()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ee/src/interview/IntegerPoolLesson.java: -------------------------------------------------------------------------------- 1 | package interview; 2 | 3 | public class IntegerPoolLesson { 4 | public static void main(String[] args) { 5 | Byte by = 127; 6 | Short sh = 127; 7 | Integer a = 128; 8 | Integer b = 128; 9 | // 128 10 | // System.out.println(a == b); 11 | // a++; 12 | // System.out.println(a == b); 13 | // System.out.println(b); 14 | 15 | System.out.println(a == b); 16 | System.out.println(a.equals(b)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ee/src/interview/InternalStringsLesson.java: -------------------------------------------------------------------------------- 1 | package interview; 2 | 3 | public class InternalStringsLesson { 4 | public static void main(String[] args) { 5 | String one = "one"; 6 | String two = new String("one").intern(); 7 | System.out.println(one.equals(two)); 8 | System.out.println(one == two); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ee/src/interview/Main.java: -------------------------------------------------------------------------------- 1 | package interview; 2 | 3 | 4 | public class Main { 5 | public static void main(String[] args) throws InterruptedException { 6 | 7 | } 8 | } -------------------------------------------------------------------------------- /ee/src/interview/VolatileHappensBeforeLesson.java: -------------------------------------------------------------------------------- 1 | package interview; 2 | 3 | public class VolatileHappensBeforeLesson { 4 | static int a = 0; 5 | static int b = 0; 6 | public static void main(String[] args) { 7 | new Thread() { 8 | @Override 9 | public void run() { 10 | int r2 = a; 11 | b = 1; 12 | } 13 | }.start(); 14 | new Thread() { 15 | @Override 16 | public void run() { 17 | int r1 = b; 18 | a = 2; 19 | } 20 | }.start(); 21 | //r2 = 2; r1 = 1 impossible 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ee/src/jmh/MyOptionBenchmark.java: -------------------------------------------------------------------------------- 1 | package jmh; 2 | 3 | import org.openjdk.jmh.runner.Runner; 4 | import org.openjdk.jmh.runner.RunnerException; 5 | import org.openjdk.jmh.runner.options.Options; 6 | import org.openjdk.jmh.runner.options.OptionsBuilder; 7 | 8 | public class MyOptionBenchmark { 9 | public static void main(String[] args) throws RunnerException { 10 | Options options = new OptionsBuilder().include(MyBenchmark.class.getSimpleName()).forks(1).build(); 11 | new Runner(options).run(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ee/src/jsp/JSPHelper.java: -------------------------------------------------------------------------------- 1 | package jsp; 2 | 3 | public class JSPHelper { 4 | public static int minux(int a, int b) { 5 | return a - b; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /ee/src/jsp/MyThread.java: -------------------------------------------------------------------------------- 1 | package jsp; 2 | 3 | public class MyThread implements Runnable { 4 | @Override 5 | public void run() { 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /ee/src/jsp/Student.java: -------------------------------------------------------------------------------- 1 | package jsp; 2 | 3 | public class Student { 4 | public Student(String name, int age) { 5 | this.name = name; 6 | this.age = age; 7 | } 8 | 9 | public Student() { 10 | } 11 | 12 | private String name; 13 | private int age; 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public int getAge() { 24 | return age; 25 | } 26 | 27 | public void setAge(int age) { 28 | this.age = age; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ee/src/lombok/BuilderLesson.java: -------------------------------------------------------------------------------- 1 | package lombok; 2 | 3 | import java.util.List; 4 | 5 | public class BuilderLesson { 6 | public static void main(String[] args) { 7 | LombokStudent lombokStudent = LombokStudent.builder().age(22).name("Max").mark("1").mark("2").build(); 8 | System.out.println(lombokStudent.age); 9 | System.out.println(lombokStudent.name); 10 | for (String mark : lombokStudent.marks) { 11 | System.out.println(mark); 12 | 13 | } 14 | } 15 | @Builder 16 | static class LombokStudent { 17 | int age; 18 | String name; 19 | @Singular 20 | List marks; 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ee/src/lombok/ConstructorsLesson.java: -------------------------------------------------------------------------------- 1 | package lombok; 2 | 3 | public class ConstructorsLesson { 4 | public static void main(String[] args) { 5 | LombokStudent lombokStudent = new LombokStudent(); 6 | LombokStudent lombokStudent3 = new LombokStudent("Max"); 7 | LombokStudent lombokStudent4 = new LombokStudent(22, "Max"); 8 | } 9 | @NoArgsConstructor 10 | @RequiredArgsConstructor 11 | @AllArgsConstructor 12 | static class LombokStudent { 13 | int age; 14 | @NonNull 15 | String name; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ee/src/lombok/EqualsAndHashCodeLesson.java: -------------------------------------------------------------------------------- 1 | package lombok; 2 | 3 | public class EqualsAndHashCodeLesson { 4 | public static void main(String[] args) { 5 | LombokStudent lombokStudent = new LombokStudent(); 6 | lombokStudent.age = 22; 7 | lombokStudent.name = "Max"; 8 | LombokStudent lombokStudent2 = new LombokStudent(); 9 | lombokStudent2.age = 22; 10 | lombokStudent2.name = "Max"; 11 | System.out.println(lombokStudent.equals(lombokStudent2)); 12 | System.out.println(lombokStudent.hashCode()); 13 | } 14 | @EqualsAndHashCode(exclude = "id") 15 | static class LombokStudent { 16 | int id; 17 | int age; 18 | String name; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ee/src/lombok/GetSetLesson.java: -------------------------------------------------------------------------------- 1 | package lombok; 2 | 3 | public class GetSetLesson { 4 | public static void main(String[] args) { 5 | LombokStudent lombokStudent = new LombokStudent(); 6 | lombokStudent.setAge(22); 7 | System.out.println(lombokStudent.getAge()); 8 | } 9 | static class LombokStudent { 10 | @Getter @Setter(AccessLevel.PUBLIC) 11 | int age; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ee/src/lombok/LoggerLesson.java: -------------------------------------------------------------------------------- 1 | package lombok; 2 | 3 | import lombok.extern.java.Log; 4 | 5 | @Log 6 | //@Slf4j 7 | //@CommonsLog(topic="CounterLog") 8 | public class LoggerLesson { 9 | public static void main(String[] args) { 10 | log.warning("test warning"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ee/src/lombok/NonNullLesson.java: -------------------------------------------------------------------------------- 1 | package lombok; 2 | 3 | public class NonNullLesson { 4 | public static void main(String[] args) { 5 | LombokStudent.print(null); 6 | } 7 | static class LombokStudent { 8 | static void print(@NonNull String s) { 9 | System.out.println(s.toUpperCase()); 10 | } 11 | } 12 | static class Student { 13 | static void print(String s) { 14 | if(s == null) 15 | throw new NullPointerException("student"); 16 | System.out.println(s.toUpperCase()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ee/src/lombok/SneakythrowLesson.java: -------------------------------------------------------------------------------- 1 | package lombok; 2 | 3 | import java.io.File; 4 | import java.io.FileReader; 5 | import java.io.IOException; 6 | import java.util.Scanner; 7 | 8 | public class SneakythrowLesson { 9 | public static void main(String[] args) { 10 | LambokStudent.readFile(); 11 | } 12 | static class LambokStudent { 13 | @SneakyThrows(IOException.class) 14 | public static void readFile() { 15 | Scanner scanner = new Scanner(new FileReader(new File("temp.txt"))); 16 | while(scanner.hasNext()) 17 | System.out.println(scanner.next()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ee/src/lombok/SynchronizedLesson.java: -------------------------------------------------------------------------------- 1 | package lombok; 2 | 3 | public class SynchronizedLesson { 4 | public static void main(String[] args) throws InterruptedException { 5 | for (int i = 0; i < 1000; i++) { 6 | new Thread() { 7 | @Override 8 | public void run() { 9 | LombokStudent.increment(); 10 | } 11 | }.start(); 12 | } 13 | Thread.sleep(500); 14 | System.out.println(LombokStudent.i); 15 | } 16 | static class LombokStudent { 17 | static int i; 18 | @Synchronized 19 | static void increment() { 20 | i++; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ee/src/lombok/ToStringLesson.java: -------------------------------------------------------------------------------- 1 | package lombok; 2 | 3 | public class ToStringLesson { 4 | public static void main(String[] args) { 5 | System.out.println(new LombokStudent().toString()); 6 | } 7 | @ToString(exclude = "id") 8 | static class LombokStudent { 9 | int id; 10 | int age; 11 | String name; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ee/src/lombok/ValueLesson.java: -------------------------------------------------------------------------------- 1 | package lombok; 2 | 3 | public class ValueLesson { 4 | public static void main(String[] args) { 5 | LambokStudent lambokStudent = new LambokStudent(22, "Max"); 6 | System.out.println(lambokStudent.getAge()); 7 | System.out.println(lambokStudent.getName()); 8 | // lambokStudent.age = 5; 9 | } 10 | @Value 11 | static class LambokStudent { 12 | int age; 13 | String name; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ee/src/mapped/A.java: -------------------------------------------------------------------------------- 1 | package mapped; 2 | 3 | import servlets.HelloServlet; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | public class A extends HelloServlet { 11 | @Override 12 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 13 | resp.getWriter().write("a"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ee/src/mapped/B.java: -------------------------------------------------------------------------------- 1 | package mapped; 2 | 3 | import javax.servlet.ServletException; 4 | import javax.servlet.http.HttpServlet; 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | import java.io.IOException; 8 | 9 | public class B extends HttpServlet { 10 | @Override 11 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 12 | resp.getWriter().write("b"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ee/src/mapped/C.java: -------------------------------------------------------------------------------- 1 | package mapped; 2 | 3 | import javax.servlet.ServletException; 4 | import javax.servlet.http.HttpServlet; 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | import java.io.IOException; 8 | 9 | public class C extends HttpServlet { 10 | @Override 11 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 12 | resp.getWriter().write("c"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ee/src/multithreading/MultithreadingIsBadLesson.java: -------------------------------------------------------------------------------- 1 | package multithreading; 2 | 3 | public class MultithreadingIsBadLesson { 4 | public static void main(String[] args) { 5 | long start = System.currentTimeMillis(); 6 | Counter counter = new Counter(); 7 | for (int i = 0; i < 1_000_000_000; i++) { 8 | counter.increase(); 9 | } 10 | System.out.println(System.currentTimeMillis() - start); 11 | } 12 | static class Counter { 13 | volatile int i; 14 | synchronized void increase() { 15 | i++; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ee/src/servlets/ExceptionServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import javax.servlet.ServletException; 4 | import javax.servlet.annotation.WebServlet; 5 | import javax.servlet.http.HttpServlet; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | @WebServlet("/exception") 11 | public class ExceptionServlet extends HttpServlet { 12 | @Override 13 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 14 | throw new ServletException("this is servlet excetption"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ee/src/servlets/FilterServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import javax.servlet.ServletException; 4 | import javax.servlet.annotation.WebServlet; 5 | import javax.servlet.http.HttpServlet; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | @WebServlet("/filterServlet") 11 | public class FilterServlet extends HttpServlet { 12 | @Override 13 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 14 | resp.getWriter().write("servlet"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ee/src/servlets/GetIp.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import javax.servlet.ServletException; 4 | import javax.servlet.annotation.WebServlet; 5 | import javax.servlet.http.HttpServlet; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | @WebServlet("/getIp") 11 | public class GetIp extends HttpServlet { 12 | @Override 13 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 14 | resp.getWriter().write(req.getRemoteAddr()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ee/src/servlets/HelloServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import javax.servlet.ServletException; 4 | import javax.servlet.annotation.WebServlet; 5 | import javax.servlet.http.HttpServlet; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | @WebServlet("/hello") 11 | public class HelloServlet extends HttpServlet { 12 | @Override 13 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 14 | resp.getWriter().write("hello word"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ee/src/servlets/LogOutBasicServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import javax.servlet.ServletException; 4 | import javax.servlet.annotation.WebServlet; 5 | import javax.servlet.http.HttpServlet; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | @WebServlet("/logoutBasic") 11 | public class LogOutBasicServlet extends HttpServlet { 12 | @Override 13 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 14 | resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED); 15 | resp.setHeader("WWW-Authenticate","BASIC realm=\"Insider-Trading\""); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ee/src/servlets/LogOutServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import javax.servlet.ServletException; 4 | import javax.servlet.annotation.WebServlet; 5 | import javax.servlet.http.HttpServlet; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | @WebServlet("/logout") 11 | public class LogOutServlet extends HttpServlet { 12 | @Override 13 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 14 | req.getSession().invalidate(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ee/src/servlets/Model.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import jsp.Student; 4 | 5 | public class Model { 6 | public Student getData() { 7 | Student student = new Student(); 8 | student.setName("Max"); 9 | student.setAge(22); 10 | return student; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ee/web/WEB-INF/Inc.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | test 8 | <%! int k = 5;%> 9 | 10 | 11 | -------------------------------------------------------------------------------- /ee/web/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | ee.cdi.ChildOneA 10 | 11 | 12 | ee.cdi.LoggingInterceptor 13 | ee.cdi.LoggingInterceptor2 14 | 15 | 16 | ee.cdi.MyDecorator 17 | 18 | -------------------------------------------------------------------------------- /ee/web/WEB-INF/classes/META-INF/batch-jobs/simplejob.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /ee/web/WEB-INF/resources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | jdbcDriver = com.mysql.jdbc.Driver 10 | jdbcUrl = jdbc:mysql://localhost:3306/Lessons 11 | jtaManaged = true 12 | password = 1 13 | userName = root 14 | 15 | -------------------------------------------------------------------------------- /ee/web/WEB-INF/tags/SimpleJspTag.tag: -------------------------------------------------------------------------------- 1 | <%@ attribute title="title" required="false" %> 2 | hello world
3 | <%=title%>
4 | <% 5 | out.print(""); 6 | getJspBody().invoke(null); 7 | out.print(""); 8 | %> -------------------------------------------------------------------------------- /ee/web/WEB-INF/text.txt: -------------------------------------------------------------------------------- 1 | qwe -------------------------------------------------------------------------------- /ee/web/WEB-INF/validation.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | META-INF/constraints.xml 10 | META-INF/temp.xml 11 | 12 | -------------------------------------------------------------------------------- /ee/web/html/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | this is default html 9 | 10 | -------------------------------------------------------------------------------- /ee/web/img/icon16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/ee/web/img/icon16.gif -------------------------------------------------------------------------------- /ee/web/img/icon32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/ee/web/img/icon32.gif -------------------------------------------------------------------------------- /ee/web/jsf/BackingBean.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | 9 | do job 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /ee/web/jsf/Commands.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | 12 | A hyperlink 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /ee/web/jsf/Graphics.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /ee/web/jsf/HelloWorld.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | hello world 10 | 11 | 12 | Hello World 13 | 14 | 15 | -------------------------------------------------------------------------------- /ee/web/jsf/Implicit.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 |

headerValues

10 | 11 | = 12 | 13 |
14 |
15 |
16 |
17 | 18 | -------------------------------------------------------------------------------- /ee/web/jsf/Navigate.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /ee/web/jsf/NewPage.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ee/web/jsf/Targets.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | commands link 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ee/web/jsp/BasicTag.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | <%@ taglib uri="/tld/SimpleTagDescriptor.tld" prefix="simple"%> 3 | <%@ taglib tagdir="/WEB-INF/tags" prefix="simpleJsp"%> 4 | 5 | 6 | Title 7 | 8 | 9 | 10 | yohoho ${title} 5 - 4 = ${simple:Minus(5, 4)} 11 | 12 | 13 | 14 | 15 | yohoho 16 | 17 | 18 | -------------------------------------------------------------------------------- /ee/web/jsp/ELBean.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | ${elbean.s} 8 | 9 | 10 | -------------------------------------------------------------------------------- /ee/web/jsp/Error.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | This is error page 8 | 9 | 10 | -------------------------------------------------------------------------------- /ee/web/jsp/Footer.jsp: -------------------------------------------------------------------------------- 1 | This is footer 2 | 3 | 4 | -------------------------------------------------------------------------------- /ee/web/jsp/ForwardAction.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ee/web/jsp/Header.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | This is header
8 | -------------------------------------------------------------------------------- /ee/web/jsp/IncludeDircetive.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | <%@ include file="hello.jsp" %> 8 | <%= i %> 9 | 10 | 11 | 12 | 13 | 14 | <%--<%= k %>--%> 15 | 16 | 17 | -------------------------------------------------------------------------------- /ee/web/jsp/Included.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | <%! int i = 5;%> 8 | <%= "yohoho"%> 9 | Hello 10 | 11 | 12 | -------------------------------------------------------------------------------- /ee/web/jsp/Init.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | init jsp 8 | <%! 9 | public void jspInit() 10 | { 11 | System.out.println("initialize jsp"); 12 | }; 13 | public void jspDestroy() { 14 | System.out.println("destroy jsp"); 15 | } 16 | %> 17 | 18 | 19 | -------------------------------------------------------------------------------- /ee/web/jsp/Page.jsp: -------------------------------------------------------------------------------- 1 | this is main page
-------------------------------------------------------------------------------- /ee/web/jsp/PageDirective.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="java.util.Date" %> 2 | <%@ page contentType="text/html;charset=UTF-8" language="java" session="false" %> 3 | <%--<%@ page session="false" %>--%> 4 | <%@ page isELIgnored="true" %> 5 | <%@ page buffer="8kb" %> 6 | <%@ page autoFlush="true" %> 7 | <%@ page info="some message" %> 8 | <%@ page errorPage="hello.jsp" %> 9 | <%@ page isErrorPage="true" %> 10 | <%@ page isThreadSafe="true" %> 11 | <%--<%@ page extends="HttpServlet" %>--%> 12 | 13 | 14 | Title 15 | 16 | 17 | <%= new Date() %> 18 | <%= 1/0 %> 19 | hello 20 | 21 | 22 | -------------------------------------------------------------------------------- /ee/web/jsp/PredefinedVariables.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | <%=request.getMethod()%> 8 | <%=response.setStatus(HttpServletResponse.SC_OK)%> 9 | <%=session.getAttribute("one")%> 10 | <%=application.getAttribute("")%> 11 | <%=application.getServerInfo()%> 12 | <%=application.getServletContextName()%> 13 | <%=config.getServletContext()%> 14 | 15 | 16 | -------------------------------------------------------------------------------- /ee/web/jsp/Temp.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | <%@ page isELIgnored="true" %> 3 | 4 | 5 | Title 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ee/web/jsp/View.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="jsp.Student" %> 2 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 3 | 4 | 5 | Title 6 | 7 | 8 | <%--<%= ((Student)request.getAttribute("student")).getTitle() %>--%> 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /ee/web/secure/Page.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | this is restricted page 8 | 9 | 10 | -------------------------------------------------------------------------------- /ee/web/secure/login-error.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | this is error page 8 | 9 | 10 | -------------------------------------------------------------------------------- /ee/web/secure/login.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | <% 8 | response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); 9 | response.setHeader("Pragma", "no-cache"); 10 | if (request.getRemoteUser() != null) { 11 | response.sendRedirect("/logout"); 12 | } 13 | %> 14 |
15 | User title:
16 | Password:
17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /hiber/resources/entities/Book.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /hiber/resources/entities/Student.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /hiber/resources/hibernate.properties: -------------------------------------------------------------------------------- 1 | #hibernate.connection.url = jdbc:mysql://localhost:3306/Lessons -------------------------------------------------------------------------------- /hiber/src/entities/HomeAddress.java: -------------------------------------------------------------------------------- 1 | package entities; 2 | 3 | import javax.persistence.Embeddable; 4 | import javax.persistence.GeneratedValue; 5 | import javax.persistence.Id; 6 | 7 | //@Entity 8 | @Embeddable 9 | public class HomeAddress { 10 | // @Id 11 | // @GeneratedValue 12 | // int id; 13 | String street; 14 | 15 | public HomeAddress() {} 16 | public HomeAddress(String street) { 17 | this.street = street; 18 | } 19 | 20 | public String getStreet() { 21 | return street; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /hiber/src/entities/Role.java: -------------------------------------------------------------------------------- 1 | package entities; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.GeneratedValue; 5 | import javax.persistence.Id; 6 | 7 | @Entity 8 | public class Role { 9 | @Id 10 | @GeneratedValue 11 | int id; 12 | String name; 13 | 14 | public Role() {} 15 | public Role(String name) { 16 | this.name = name; 17 | } 18 | 19 | public int getId() { 20 | return id; 21 | } 22 | 23 | public void setId(int id) { 24 | this.id = id; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /hiber/src/entities/hierarchies/Opel.java: -------------------------------------------------------------------------------- 1 | package entities.hierarchies; 2 | 3 | import javax.persistence.Entity; 4 | 5 | @Entity 6 | public class Opel extends Car { 7 | private int price; 8 | 9 | public Opel(String number, int price) { 10 | super(number); 11 | this.price = price; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /hiber/src/entities/hierarchies/Toyota.java: -------------------------------------------------------------------------------- 1 | package entities.hierarchies; 2 | 3 | import javax.persistence.Entity; 4 | 5 | @Entity 6 | public class Toyota extends Car { 7 | private String maxSpeed; 8 | 9 | public Toyota(String number, String maxSpeed) { 10 | super(number); 11 | this.maxSpeed = maxSpeed; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /hiber/src/enums/Days.java: -------------------------------------------------------------------------------- 1 | package enums; 2 | 3 | public enum Days { 4 | MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY 5 | } 6 | -------------------------------------------------------------------------------- /kotln/src/com/max/Annotations.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | fun main(args: Array) { 4 | 5 | } 6 | const val message = "" 7 | @Deprecated(message) 8 | @MyAnnotation("") 9 | fun test() {} 10 | 11 | @Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) 12 | annotation class MyAnnotation(val name: String) -------------------------------------------------------------------------------- /kotln/src/com/max/BasicTypes.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | fun main(args: Array) { 4 | val i: Int = 1 5 | val j: Int? = null 6 | val l: Long = i.toLong() 7 | val list: List = listOf(1, 2, 3) 8 | l.toInt() in list 9 | var any: Any = 5 10 | var any2: Any = "Str" 11 | var any3: Any? = null 12 | var unit: Unit 13 | } 14 | fun f(): Unit { } 15 | fun fail(): Nothing { 16 | // return Nothing() 17 | throw IllegalStateException() 18 | } -------------------------------------------------------------------------------- /kotln/src/com/max/Classes.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | fun main(args: Array) { 4 | var user = User("Max", 22) 5 | } 6 | 7 | class User(name:String, age: Int) -------------------------------------------------------------------------------- /kotln/src/com/max/Collections.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | fun main(args: Array) { 3 | val set = setOf(1, 1, 2) 4 | val list = listOf(1, 2, 3) 5 | val map = mapOf(1 to "one", 2 to "two") 6 | print(set.first()) 7 | print(set.last()) 8 | print(set.size) 9 | print(set.max()) 10 | print(set.average()) 11 | print(set) 12 | } 13 | -------------------------------------------------------------------------------- /kotln/src/com/max/CollectionsArrays.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | fun main(args: Array) { 4 | val result = ArrayList() 5 | ///// 6 | val arr1 = arrayOf(1,2,3) 7 | val arr2 = arrayOfNulls(10) 8 | val arr3 = Array(26) { i -> ('a' + i).toString() } 9 | val arr4 = IntArray(5) 10 | val arr5 = intArrayOf(0, 0, 0, 0, 0) 11 | val arr6 = IntArray(5) { i -> (i+1) * (i+1) } 12 | } 13 | fun arrays(numbers: List) {} 14 | fun arrays2(numbers: List?) {} 15 | fun copyElements(source: Collection, target: MutableCollection, list: List, mutableList: MutableList) {} -------------------------------------------------------------------------------- /kotln/src/com/max/ControlFlow.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | fun main(args: Array) { 4 | // lookForAlice(people) 5 | } 6 | 7 | fun lookForAlice(people: List) { 8 | people.forEach label@{ 9 | if (it.name == "Alice") return@label 10 | } 11 | println("Alice might be somewhere") 12 | } 13 | 14 | fun lookForAlice2(people: List) { 15 | people.forEach { 16 | if (it.name == "Alice") { 17 | println("Found!") 18 | return@forEach 19 | } 20 | } 21 | println("Alice is not found") 22 | } -------------------------------------------------------------------------------- /kotln/src/com/max/DelegatingProperties.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | import kotlin.reflect.KProperty 4 | 5 | fun main(args: Array) { 6 | val foo = Foo() 7 | print(foo.p) 8 | foo.p = 6 9 | print(foo.p) 10 | } 11 | class Foo { 12 | var p: Int by Delegate(5) 13 | } 14 | 15 | class Delegate(var value: Int) { 16 | operator fun getValue(foo: Foo, kProperty: KProperty<*>) :Int { return value } 17 | operator fun setValue(foo: Foo, kProperty: KProperty<*>, value: Int) { this.value = value } 18 | } -------------------------------------------------------------------------------- /kotln/src/com/max/Enums.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | fun main(args: Array) { 4 | val color = Color.BLUE 5 | when(color) { 6 | Color.RED,Color.GREEN -> print("red") 7 | Color.BLUE -> print("blue") 8 | } 9 | print(bigger(5, 6)) 10 | } 11 | 12 | fun bigger(a: Int, b: Int) = if(a > b) a else b 13 | 14 | enum class Color { 15 | RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET 16 | } 17 | enum class Color2(val r: Int, val g: Int, val b: Int) { 18 | RED(255, 0, 0), ORANGE(255, 165, 0), 19 | YELLOW(255, 255, 0), GREEN(0, 255, 0), BLUE(0, 0, 255), 20 | INDIGO(75, 0, 130), VIOLET(238, 130, 238); 21 | fun rgb() = (r * 256 + g) * 256 + b 22 | } 23 | -------------------------------------------------------------------------------- /kotln/src/com/max/Exceptions.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | import java.io.IOException 4 | 5 | fun main(args: Array) { 6 | var i = try { 7 | throw IOException("hello") 8 | throw Exception("hello") 9 | 1 10 | } catch (e: Exception) { 11 | print("catch") 12 | 2 13 | } finally { 14 | print("finaly") 15 | 3 16 | } 17 | print(i as Int) 18 | } -------------------------------------------------------------------------------- /kotln/src/com/max/Functions.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | fun main(args: Array) { 3 | 4 | } 5 | fun add(a: Int, b: Int) = a + b; -------------------------------------------------------------------------------- /kotln/src/com/max/GenericVarience.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | fun main(args: Array) { 4 | var list :List = ArrayList() 5 | var producer :Producer = Producer() 6 | var producer2 :Producer2 = Producer2() 7 | var producer3 :Producer<*> = Producer() 8 | var producer4 :Producer2<*> = Producer2() 9 | } 10 | class Producer { 11 | // operator fun invoke():T 12 | } 13 | class Producer2 { 14 | fun produce(t: T) {} 15 | } 16 | class Producer3 { 17 | // operator fun invoke(t: T): R 18 | } 19 | open class Animal {} 20 | class Cat : Animal() {} -------------------------------------------------------------------------------- /kotln/src/com/max/Generics.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | fun main(args: Array) { 4 | val authors = listOf("Dmitry", "Svetlana") 5 | val authors2 = listOf("Dmitry", 2) 6 | val authors3: List = listOf("Dmitry", "Sveta") 7 | // val authors4: List = listOf("Dmitry", "Sveta") 8 | } 9 | 10 | fun gen(t: T, predicate: (T) -> T): T { 11 | return t 12 | } 13 | interface MyList { 14 | operator fun get(t: T): T = t 15 | } 16 | class StringList: MyList { 17 | } 18 | class GenericList: MyList { 19 | } 20 | fun oneHalf(value: T): Double { 21 | return value.toDouble() / 2.0 22 | } -------------------------------------------------------------------------------- /kotln/src/com/max/GenericsInRuntime.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | import java.util.* 4 | import javax.xml.ws.Service 5 | 6 | fun main(args: Array) { 7 | var value: List = ArrayList() 8 | check(value) 9 | 10 | val items = listOf("one", 2, "three") 11 | println(items.filterIsInstance()) 12 | } 13 | fun check(value: Any) { 14 | // value is List 15 | value is List<*> 16 | } 17 | //fun isA(value: Any) = value is T 18 | inline fun isA(value: Any) = value is T -------------------------------------------------------------------------------- /kotln/src/com/max/HighOrderFunctions.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | fun main(args: Array) { 4 | val sum = { x: Int, y: Int -> x + y } 5 | val action = { println(42) } 6 | val sum2: (Int, Int) -> Int = { x, y -> x + y } 7 | val action2: () -> Unit = { println(42) } 8 | 9 | twoAndThree { a, b -> a + b } 10 | twoAndThree { a, b -> a * b } 11 | } 12 | fun twoAndThree(operation: (Int, Int) -> Int) { 13 | val result = operation(2, 3) 14 | println("The result is $result") 15 | } 16 | fun toString(transform: (it: Int) -> String? = { it.toString() }) {} 17 | 18 | fun getShippingCostCalculator(bool: Boolean): (i: Int) -> Double { 19 | if (bool) { 20 | return { i -> i * 1.5 } 21 | } 22 | return { i -> i * 1.3 } 23 | } -------------------------------------------------------------------------------- /kotln/src/com/max/Loop.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | fun main(args: Array) { 3 | var i = 1..10 4 | for(j in i) 5 | print(j) 6 | for(i in 10 downTo 1 step 1) 7 | print(i) 8 | for(i in 1..10) 9 | print(i) 10 | for(i in 1 until 10) 11 | print(i) 12 | for(j in i) 13 | if(j !in 5..10) print(j) 14 | } 15 | -------------------------------------------------------------------------------- /kotln/src/com/max/Main.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | fun main(args: Array) {} -------------------------------------------------------------------------------- /kotln/src/com/max/ObjectKeyword.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | 3 | fun main(args: Array) { 4 | // Bar.i = 6 5 | // Bar.printI() 6 | // Bar2.Foo 7 | // Bar2.getI() 8 | var bar = Bar2.getBar() 9 | var runnable = object : Runnable { 10 | override fun run() { 11 | //new thread 12 | } 13 | } 14 | } 15 | 16 | object Bar { 17 | var i = 5 18 | fun printI() { 19 | print(i) 20 | } 21 | object Foo {} 22 | } 23 | 24 | class Bar2 { 25 | private constructor() 26 | companion object Foo { 27 | fun getBar() { 28 | Bar2() 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /kotln/src/com/max/Variables.kt: -------------------------------------------------------------------------------- 1 | package com.max 2 | fun main(args: Array) { 3 | var a: Int 4 | var b: String 5 | var c = 5 6 | } 7 | -------------------------------------------------------------------------------- /lessons/src/main/java/Calculator.java: -------------------------------------------------------------------------------- 1 | public class Calculator { 2 | public int add(int a, int b) { 3 | return a + b; 4 | } 5 | 6 | public double div(int a, int b) { 7 | return a/b; 8 | } 9 | } -------------------------------------------------------------------------------- /lessons/src/main/java/badpractice/Singleton.java: -------------------------------------------------------------------------------- 1 | package badpractice; 2 | 3 | public class Singleton { 4 | static Singleton get() { 5 | return new Singleton(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lessons/src/main/java/badpractice/User.java: -------------------------------------------------------------------------------- 1 | package badpractice; 2 | 3 | public class User { 4 | void exec() { 5 | } 6 | static String getInfo() { 7 | return "info"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lessons/src/main/java/badpractice/UserFactory.java: -------------------------------------------------------------------------------- 1 | package badpractice; 2 | 3 | public class UserFactory { 4 | User getUser() { 5 | return new User(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lessons/src/test/java/SuitExample.java: -------------------------------------------------------------------------------- 1 | import org.junit.runner.RunWith; 2 | import org.junit.runners.Suite; 3 | 4 | @RunWith(Suite.class) 5 | @Suite.SuiteClasses(value = {CalculatorTest.class, CalculatorTest.class}) 6 | public class SuitExample { 7 | } 8 | -------------------------------------------------------------------------------- /lessons/src/test/java/badpractice/ServiceTest.java: -------------------------------------------------------------------------------- 1 | package badpractice; 2 | 3 | public class ServiceTest { 4 | void testLogIn() { 5 | Service service = new Service(new User(), 5); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lib/activemq-broker-5.14.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/activemq-broker-5.14.3.jar -------------------------------------------------------------------------------- /lib/activemq-client-5.14.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/activemq-client-5.14.3.jar -------------------------------------------------------------------------------- /lib/activemq-jdbc-store-5.14.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/activemq-jdbc-store-5.14.3.jar -------------------------------------------------------------------------------- /lib/activemq-kahadb-store-5.14.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/activemq-kahadb-store-5.14.3.jar -------------------------------------------------------------------------------- /lib/activemq-openwire-legacy-5.14.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/activemq-openwire-legacy-5.14.3.jar -------------------------------------------------------------------------------- /lib/activemq-protobuf-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/activemq-protobuf-1.1.jar -------------------------------------------------------------------------------- /lib/activemq-ra-5.14.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/activemq-ra-5.14.3.jar -------------------------------------------------------------------------------- /lib/commons-math3-3.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/commons-math3-3.2.jar -------------------------------------------------------------------------------- /lib/eclipselink.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/eclipselink.jar -------------------------------------------------------------------------------- /lib/hibernate-core-5.2.10.Final.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/hibernate-core-5.2.10.Final.jar -------------------------------------------------------------------------------- /lib/javaee-api-7.0-1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/javaee-api-7.0-1.jar -------------------------------------------------------------------------------- /lib/javax.ejb-api.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/javax.ejb-api.jar -------------------------------------------------------------------------------- /lib/javax.faces-2.2.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/javax.faces-2.2.12.jar -------------------------------------------------------------------------------- /lib/jmh-core-1.17.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/jmh-core-1.17.3.jar -------------------------------------------------------------------------------- /lib/jmh-core-1.19.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/jmh-core-1.19.jar -------------------------------------------------------------------------------- /lib/jmh-generator-annprocess-1.17.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/jmh-generator-annprocess-1.17.3.jar -------------------------------------------------------------------------------- /lib/jmh-generator-annprocess-1.19.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/jmh-generator-annprocess-1.19.jar -------------------------------------------------------------------------------- /lib/jmh-java-benchmark-archetype-1.19.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/jmh-java-benchmark-archetype-1.19.jar -------------------------------------------------------------------------------- /lib/jopt-simple-4.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/jopt-simple-4.6.jar -------------------------------------------------------------------------------- /lib/jsp-api.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/jsp-api.jar -------------------------------------------------------------------------------- /lib/junit-4.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/junit-4.12.jar -------------------------------------------------------------------------------- /lib/lombok.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/lombok.jar -------------------------------------------------------------------------------- /lib/mysql-connector-java-5.1.40-bin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/mysql-connector-java-5.1.40-bin.jar -------------------------------------------------------------------------------- /lib/openwebbeans-impl-1.7.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/openwebbeans-impl-1.7.2.jar -------------------------------------------------------------------------------- /lib/openwebbeans-spi-1.7.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/openwebbeans-spi-1.7.2.jar -------------------------------------------------------------------------------- /lib/servlet-api.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/servlet-api.jar -------------------------------------------------------------------------------- /lib/tomcat-api.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/tomcat-api.jar -------------------------------------------------------------------------------- /lib/tomcat-juli-7.0.16.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/tomcat-juli-7.0.16.jar -------------------------------------------------------------------------------- /lib/tomcat-util.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/tomcat-util.jar -------------------------------------------------------------------------------- /lib/tomcat-websocket.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/tomcat-websocket.jar -------------------------------------------------------------------------------- /lib/websocket-api.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/lib/websocket-api.jar -------------------------------------------------------------------------------- /mongo/src/HelloMongo.java: -------------------------------------------------------------------------------- 1 | import com.mongodb.MongoClient; 2 | import com.mongodb.client.MongoDatabase; 3 | import com.mongodb.client.MongoIterable; 4 | 5 | public class HelloMongo { 6 | public static void main( String args[] ){ 7 | MongoClient mongoClient = new MongoClient("localhost", 27017); 8 | MongoDatabase db = mongoClient.getDatabase("test"); 9 | db.createCollection("myCollection"); 10 | MongoIterable strings = db.listCollectionNames(); 11 | for (String name : strings) { 12 | System.out.println(name); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /mongo/src/HiberExample.java: -------------------------------------------------------------------------------- 1 | import entity.User; 2 | 3 | import javax.persistence.EntityManager; 4 | import javax.persistence.EntityManagerFactory; 5 | import javax.persistence.Persistence; 6 | 7 | public class HiberExample { 8 | public static void main(String[] args) throws InterruptedException { 9 | EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("mongo-ogm"); 10 | EntityManager entityManager = entityManagerFactory.createEntityManager(); 11 | 12 | entityManager.getTransaction().begin(); 13 | entityManager.persist(new User("Max3", 33)); 14 | entityManager.getTransaction().commit(); 15 | 16 | entityManager.close(); 17 | entityManagerFactory.close(); 18 | } 19 | } -------------------------------------------------------------------------------- /mongo/src/Main.java: -------------------------------------------------------------------------------- 1 | import com.mongodb.MongoClient; 2 | import com.mongodb.client.MongoCollection; 3 | import com.mongodb.client.MongoDatabase; 4 | import org.bson.Document; 5 | 6 | public class Main { 7 | public static void main(String[] args) { 8 | MongoClient mongoClient = new MongoClient("localhost", 27017); 9 | MongoDatabase db = mongoClient.getDatabase("test"); 10 | MongoCollection users = db.getCollection("users"); 11 | } 12 | } -------------------------------------------------------------------------------- /program.properties: -------------------------------------------------------------------------------- 1 | #My commets 2 | #Tue Oct 04 12:16:53 EEST 2016 3 | width=200 4 | height=500 -------------------------------------------------------------------------------- /saved.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/saved.png -------------------------------------------------------------------------------- /smile.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hacker85/JavaLessons/deb6472227b0c27e5945e37c54bcd806d1e56085/smile.jpg -------------------------------------------------------------------------------- /spark/src/main/java/com/max/Person.java: -------------------------------------------------------------------------------- 1 | package com.max; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Person implements Serializable { 6 | String name; 7 | int age; 8 | 9 | public Person() {} 10 | public Person(String name, int age) { 11 | this.name = name; 12 | this.age = age; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public int getAge() { 24 | return age; 25 | } 26 | 27 | public void setAge(int age) { 28 | this.age = age; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spark/src/main/resources/test.txt: -------------------------------------------------------------------------------- 1 | hello 2 | world -------------------------------------------------------------------------------- /spark/src/main/resources/users.json: -------------------------------------------------------------------------------- 1 | {"name": "Max", "age": "22"} 2 | {"name": "Mike", "age": "33"} -------------------------------------------------------------------------------- /spark/src/main/resources/users.txt: -------------------------------------------------------------------------------- 1 | Max,22 2 | Mike,33 -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/MyFlowBean.java: -------------------------------------------------------------------------------- 1 | package com.max.web; 2 | 3 | import com.max.web.repo.User; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class MyFlowBean { 8 | public void printHello() { 9 | System.out.println("hello world"); 10 | } 11 | public boolean trueOrFalse() { 12 | return false; 13 | } 14 | public void printUser(User user) { 15 | System.out.println(user.getName()); 16 | } 17 | public void printI(int i) { 18 | System.out.println(i); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/config/RootConfig.java: -------------------------------------------------------------------------------- 1 | package com.max.web.config; 2 | 3 | //@Configuration 4 | //@ComponentScan(basePackages={"com.max.web"}) 5 | public class RootConfig { 6 | } 7 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/controllers/DbController.java: -------------------------------------------------------------------------------- 1 | package com.max.web.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.ResponseBody; 6 | 7 | @Controller 8 | public class DbController { 9 | // @Autowired 10 | // JdbcOperations jdbcOperations; 11 | 12 | @GetMapping("createTable") 13 | @ResponseBody 14 | public String createTeble() { 15 | // jdbcOperations.execute("CREATE TABLE IF NOT EXISTS Books (id MEDIUMINT NOT NULL AUTO_INCREMENT, name CHAR(30) NOT NULL, PRIMARY KEY (id))"); 16 | return "table was created"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/controllers/ExceptionController.java: -------------------------------------------------------------------------------- 1 | package com.max.web.controllers; 2 | 3 | //@Controller 4 | public class ExceptionController { 5 | // @GetMapping("exception") 6 | // public void getException() { 7 | //// throw new RuntimeException("some error"); 8 | // throw new UserNotFoundException(); 9 | // } 10 | //// @ExceptionHandler(UserNotFoundException.class) 11 | //// @ResponseBody 12 | //// public String handleDuplicateSpittle() { 13 | //// return "some error"; 14 | //// } 15 | // @ResponseStatus(value= HttpStatus.NOT_FOUND, reason="User Not Found") 16 | // public class UserNotFoundException extends RuntimeException {} 17 | } 18 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/controllers/HiberController.java: -------------------------------------------------------------------------------- 1 | package com.max.web.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.ResponseBody; 6 | 7 | @Controller 8 | public class HiberController { 9 | // @Autowired 10 | // UserAutoRepository userAutoRepository; 11 | // MyRepo myRepo; 12 | @GetMapping("hiber") 13 | @ResponseBody 14 | public String saveUser() { 15 | // userAutoRepository.findAll(); 16 | // myRepo.saveUser(new User("Max")); 17 | return "user was saved"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/controllers/ModelViewController.java: -------------------------------------------------------------------------------- 1 | package com.max.web.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | @Controller 8 | public class ModelViewController { 9 | @GetMapping("modelView") 10 | public ModelAndView getMethod() { 11 | ModelAndView modelAndView = new ModelAndView("modelView"); 12 | modelAndView.addObject("userName", "Max"); 13 | return modelAndView; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/controllers/MyExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.max.web.controllers; 2 | 3 | //@ControllerAdvice 4 | public class MyExceptionHandler { 5 | // @ExceptionHandler(ExceptionController.UserNotFoundException.class) 6 | // @ResponseBody 7 | // public String duplicateSpittleHandler() { 8 | // return "some error"; 9 | // } 10 | } 11 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/controllers/MyLogin.java: -------------------------------------------------------------------------------- 1 | package com.max.web.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | 6 | @Controller 7 | public class MyLogin { 8 | @GetMapping("mylogin") 9 | public String MyLogin() { 10 | return "mylogin"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/controllers/SpringLibController.java: -------------------------------------------------------------------------------- 1 | package com.max.web.controllers; 2 | 3 | import com.max.web.repo.User; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.Model; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | 8 | @Controller 9 | public class SpringLibController { 10 | @GetMapping("/springLib") 11 | public String getParams(Model model) { 12 | model.addAttribute("user", new User()); 13 | return "springLib"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/controllers/TestController.java: -------------------------------------------------------------------------------- 1 | package com.max.web.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.ResponseBody; 6 | 7 | @Controller 8 | public class TestController { 9 | @RequestMapping("test") 10 | @ResponseBody 11 | public String test() { 12 | return "test"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/controllers/TestController2.java: -------------------------------------------------------------------------------- 1 | package com.max.web.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.ResponseBody; 6 | 7 | @Controller 8 | public class TestController2 { 9 | @GetMapping("test2") 10 | @ResponseBody 11 | public String test() { 12 | return "test2"; 13 | } 14 | } -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/repo/MyRepo.java: -------------------------------------------------------------------------------- 1 | package com.max.web.repo; 2 | 3 | import com.max.web.entities.User; 4 | 5 | public interface MyRepo { 6 | void saveUser(User user); 7 | } 8 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/repo/Repo.java: -------------------------------------------------------------------------------- 1 | package com.max.web.repo; 2 | 3 | public interface Repo { 4 | User getUser(); 5 | } 6 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/repo/User.java: -------------------------------------------------------------------------------- 1 | package com.max.web.repo; 2 | 3 | import org.springframework.lang.NonNull; 4 | 5 | public class User { 6 | @NonNull 7 | String name; 8 | int age; 9 | 10 | public User() {} 11 | 12 | public User(String name, int age) { 13 | this.name = name; 14 | this.age = age; 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public int getAge() { 26 | return age; 27 | } 28 | 29 | public void setAge(int age) { 30 | this.age = age; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/repo/UserAutoRepository.java: -------------------------------------------------------------------------------- 1 | package com.max.web.repo; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import com.max.web.entities.User; 5 | 6 | public interface UserAutoRepository extends JpaRepository { 7 | User findByName(String name); 8 | } 9 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/repo/UserRepo.java: -------------------------------------------------------------------------------- 1 | package com.max.web.repo; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import java.io.Serializable; 6 | 7 | @Component 8 | public class UserRepo implements Repo, Serializable { 9 | public User getUser() { 10 | return new User("Max", 22); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/repo/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.max.web.repo; 2 | 3 | import com.max.web.entities.User; 4 | import org.hibernate.Session; 5 | import org.hibernate.SessionFactory; 6 | 7 | //@Repository 8 | public class UserRepository implements MyRepo { 9 | // @Autowired 10 | SessionFactory sessionFactory; 11 | // @Transactional 12 | public void saveUser(User user) { 13 | Session currentSession = sessionFactory.getCurrentSession(); 14 | currentSession.save(user); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/repo/UserRepository2.java: -------------------------------------------------------------------------------- 1 | package com.max.web.repo; 2 | 3 | import com.max.web.entities.User; 4 | 5 | //@Repository 6 | //@Transactional 7 | public class UserRepository2 implements MyRepo { 8 | // @PersistenceContext 9 | // EntityManager entityManager; 10 | public void saveUser(User user) { 11 | // entityManager.persist(user); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /springweb/src/main/java/com/max/web/webconfig/SecurityWebInitializer.java: -------------------------------------------------------------------------------- 1 | package com.max.web.webconfig; 2 | 3 | import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; 4 | 5 | public class SecurityWebInitializer extends AbstractSecurityWebApplicationInitializer {} -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/activation.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello World!

4 | 5 |
6 | 7 | 8 |
9 | 10 |
11 | 12 | 13 |
14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/end.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | This is END!!! 8 | 9 | 10 | -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/failure.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Activation Failed

4 | 5 | -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/file.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 |
8 |
9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/first.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 |
8 | 9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Hello text 5 | 6 | 7 | hello world ${user.age} ${test} 8 | 9 | -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/modelView.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | ${userName} 8 | 9 | 10 | -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/myForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Hello text 5 | 6 | 7 |
8 |
9 |
10 |
11 |
12 | 13 | -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/mylogin.jsp: -------------------------------------------------------------------------------- 1 | hello -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/second.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | second 8 | 9 | -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/springLib.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | <%@ taglib uri="http://www.springframework.org/tags/form" prefix="sf" %> 3 | 4 | 5 | Title 6 | 7 | 8 | 9 | Name:
10 | Age:
11 | 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/start.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | This is start! 8 |
9 | 10 | 11 |
12 | 13 | -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/success.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Activation Successful!

4 |
5 | 6 | 7 |
8 | 9 | -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/test.jsp: -------------------------------------------------------------------------------- 1 | test world -------------------------------------------------------------------------------- /springweb/src/main/java/webapp/WEB-INF/views/third.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | Title 5 | 6 | 7 | third 8 | 9 | 10 | -------------------------------------------------------------------------------- /springweb/src/main/resources/jetty.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jdbc/testDB 5 | 6 | 7 | com.mysql.jdbc.Driver 8 | jdbc:mysql://localhost:3306/Lessons 9 | root 10 | 1 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/Main.java: -------------------------------------------------------------------------------- 1 | package com.max; 2 | 3 | import com.max.entities.User; 4 | import org.springframework.web.client.RestTemplate; 5 | 6 | public class Main { 7 | public static void main(String[] args) { 8 | RestTemplate rest = new RestTemplate(); 9 | User user = rest.getForObject("http://localhost:8080/userest", User.class); 10 | System.out.println(user.getName()); 11 | // ApplicationContext context = new AnnotationConfigApplicationContext(SoapClientConfig.class); 12 | // SoapService bean = context.getBean(SoapService.class); 13 | // bean.printMessage("Hello world"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/MyHandler.java: -------------------------------------------------------------------------------- 1 | package com.max; 2 | 3 | import org.springframework.web.socket.TextMessage; 4 | import org.springframework.web.socket.WebSocketSession; 5 | import org.springframework.web.socket.handler.TextWebSocketHandler; 6 | 7 | import java.io.IOException; 8 | 9 | public class MyHandler extends TextWebSocketHandler { 10 | @Override 11 | public void handleTextMessage(WebSocketSession session, TextMessage message) throws IOException { 12 | System.out.println(message.getPayload()); 13 | session.sendMessage(new TextMessage("World")); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/config/AmqpConfig.java: -------------------------------------------------------------------------------- 1 | package com.max.config; 2 | 3 | //@Configuration 4 | public class AmqpConfig { 5 | // @Bean 6 | // public ConnectionFactory connectionFactory() { 7 | // return new CachingConnectionFactory("localhost"); 8 | // } 9 | // @Bean 10 | // public RabbitTemplate rabbitTemplate() { 11 | // RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory()); 12 | // rabbitTemplate.setQueue("myqueue"); 13 | // return rabbitTemplate; 14 | // } 15 | // @Bean 16 | // public Queue myQueue() { 17 | // return new Queue("myqueue"); 18 | // } 19 | } 20 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/config/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package com.max.config; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | protected Class[] getRootConfigClasses() {return null;} 7 | 8 | protected Class[] getServletConfigClasses() { 9 | return new Class[] { WebConfig.class}; 10 | } 11 | 12 | protected String[] getServletMappings() { 13 | return new String[] { "/" }; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package com.max.config; 2 | 3 | import com.max.MyHandler; 4 | import org.springframework.web.socket.config.annotation.WebSocketConfigurer; 5 | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; 6 | 7 | //@Configuration 8 | //@EnableWebSocket 9 | public class WebSocketConfig implements WebSocketConfigurer { 10 | public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { 11 | registry.addHandler(new MyHandler(), "/myHandler"); 12 | } 13 | } -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/config/security/MethodSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.max.config.security; 2 | 3 | //@Configuration 4 | //@EnableGlobalMethodSecurity(securedEnabled=true, jsr250Enabled=true, prePostEnabled = true) 5 | public class MethodSecurityConfig {}// extends GlobalMethodSecurityConfiguration {} 6 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/config/security/SecurityWebInitializer.java: -------------------------------------------------------------------------------- 1 | package com.max.config.security; 2 | 3 | public class SecurityWebInitializer {}// extends AbstractSecurityWebApplicationInitializer {} -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/config/soap/SoapClientConfig.java: -------------------------------------------------------------------------------- 1 | package com.max.config.soap; 2 | 3 | //@Configuration 4 | public class SoapClientConfig { 5 | // @Bean 6 | // JaxWsPortProxyFactoryBean portProxyFactoryBean() throws MalformedURLException { 7 | // JaxWsPortProxyFactoryBean bean = new JaxWsPortProxyFactoryBean(); 8 | // bean.setWsdlDocumentUrl(new URL("http://localhost:8889/SoapService?wsdl")); 9 | // bean.setServiceName("SoapService"); 10 | // bean.setServiceInterface(SoapService.class); 11 | // bean.setPortName("SoapServiceEndpointPort"); 12 | // bean.setNamespaceUri("http://soap.max.com/"); 13 | // return bean; 14 | // } 15 | } 16 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/config/soap/SoapServlerConfig.java: -------------------------------------------------------------------------------- 1 | package com.max.config.soap; 2 | 3 | //@Configuration 4 | public class SoapServlerConfig { 5 | // @Bean 6 | // SoapService soapService() { 7 | // return new SoapServiceImpl(); 8 | // } 9 | // @Bean 10 | // SimpleJaxWsServiceExporter exporter() { 11 | // SimpleJaxWsServiceExporter exporter = new SimpleJaxWsServiceExporter(); 12 | // exporter.setBaseAddress("http://localhost:8889/"); 13 | // return exporter; 14 | // } 15 | } 16 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/controllers/HomeControllers.java: -------------------------------------------------------------------------------- 1 | package com.max.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | 6 | @Controller 7 | public class HomeControllers { 8 | @GetMapping("home") 9 | public String home() { 10 | return "home"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/controllers/TestController.java: -------------------------------------------------------------------------------- 1 | package com.max.controllers; 2 | 3 | import com.max.interfaces.Repo; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | 8 | import java.io.IOException; 9 | 10 | @Controller 11 | public class TestController { 12 | @Autowired 13 | Repo repo; 14 | @GetMapping("test") 15 | public String test() throws IOException { 16 | // repo.createTable(); 17 | return "test"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/entities/User.java: -------------------------------------------------------------------------------- 1 | package com.max.entities; 2 | 3 | import java.io.Serializable; 4 | 5 | public class User implements Serializable { 6 | String name; 7 | 8 | public User() {} 9 | public User(String name) { 10 | this.name = name; 11 | } 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/impl/UserRepo.java: -------------------------------------------------------------------------------- 1 | package com.max.impl; 2 | 3 | import com.max.interfaces.Repo; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public class UserRepo implements Repo { 8 | // @Secured("ROLE_ADMIN") 9 | // @RolesAllowed("ROLE_ADMIN") 10 | // @PreAuthorize("hasRole('ROLE_ADMIN')") 11 | // @PostAuthorize("hasRole('ROLE_ADMIN')") 12 | public void createTable() { 13 | System.out.println("user table was created"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/interfaces/JmsService.java: -------------------------------------------------------------------------------- 1 | package com.max.interfaces; 2 | 3 | import com.max.entities.User; 4 | 5 | public interface JmsService { 6 | void sendMessage(User user); 7 | User receiveMessage(); 8 | void listen(User user); 9 | } 10 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/interfaces/Repo.java: -------------------------------------------------------------------------------- 1 | package com.max.interfaces; 2 | 3 | public interface Repo { 4 | void createTable(); 5 | } 6 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/soap/SoapService.java: -------------------------------------------------------------------------------- 1 | package com.max.soap; 2 | 3 | import javax.jws.WebService; 4 | 5 | @WebService(serviceName = "SoapService") 6 | public interface SoapService { 7 | void printMessage(String s); 8 | } 9 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/soap/SoapServiceEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.max.soap; 2 | 3 | import javax.jws.WebService; 4 | 5 | //@Component 6 | @WebService(serviceName = "SoapService") 7 | public class SoapServiceEndpoint { 8 | // @Autowired 9 | // SoapService soapService; 10 | public void printMessage(String s) { 11 | // soapService.printMessage(s); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/soap/SoapServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.max.soap; 2 | 3 | public class SoapServiceImpl implements SoapService { 4 | public void printMessage(String s) { 5 | System.out.println(s); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/test/controllers/MyController.java: -------------------------------------------------------------------------------- 1 | package com.max.test.controllers; 2 | 3 | import com.max.test.entities.User; 4 | import org.springframework.web.bind.annotation.*; 5 | 6 | @RestController 7 | public class MyController { 8 | @GetMapping("myTest") 9 | public String test() { 10 | return "test!!!"; 11 | } 12 | @PostMapping("testJson") 13 | public User json() { 14 | return new User("Max"); 15 | } 16 | @PutMapping("testParam") 17 | public String testParams(@RequestParam int id) { 18 | // @PutMapping("testParam/{id}") 19 | // public String testParams(@PathVariable int id) { 20 | return "" + id; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/test/controllers/TestController.java: -------------------------------------------------------------------------------- 1 | package com.max.test.controllers; 2 | 3 | import com.max.test.entities.User; 4 | import org.springframework.web.bind.annotation.*; 5 | 6 | @RestController 7 | public class TestController { 8 | @GetMapping("test") 9 | public String test() { 10 | return "test!!!"; 11 | } 12 | @PostMapping(value = "testPost") 13 | public User testPost() { 14 | return new User("Max"); 15 | } 16 | // @GetMapping("testParams/{id}") 17 | // public String testParams(@PathVariable int id) { 18 | @GetMapping("testParams") 19 | public String testParams(@RequestParam int id) { 20 | return "" + id; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/test/impl/Toyota.java: -------------------------------------------------------------------------------- 1 | package com.max.test.impl; 2 | 3 | import com.max.test.interfaces.Car; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class Toyota implements Car { 8 | @Override 9 | public void drive() { 10 | System.out.println("drive"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/test/interfaces/Car.java: -------------------------------------------------------------------------------- 1 | package com.max.test.interfaces; 2 | 3 | public interface Car { 4 | void drive(); 5 | } 6 | -------------------------------------------------------------------------------- /springweb2/src/main/java/com/max/test/interfaces/TestRepo.java: -------------------------------------------------------------------------------- 1 | package com.max.test.interfaces; 2 | 3 | import com.max.test.entities.User; 4 | 5 | public interface TestRepo { 6 | void saveUser(User student); 7 | User findUser(); 8 | } 9 | -------------------------------------------------------------------------------- /springweb2/src/main/resources/WebSocket.js: -------------------------------------------------------------------------------- 1 | var sock = new WebSocket('ws://' + window.location.host + '/mySocketHandler'); 2 | sock.onmessage = function(e) { 3 | console.log('Received message: ', e.data); 4 | }; 5 | sock.send("Hello "); -------------------------------------------------------------------------------- /springweb2/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | hello world -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/Main2.java: -------------------------------------------------------------------------------- 1 | package com.max; 2 | 3 | import com.max.config.RmiConfig2; 4 | import com.max.interfaces.RmiService; 5 | import org.springframework.context.ApplicationContext; 6 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 7 | 8 | public class Main2 { 9 | public static void main(String[] args) { 10 | ApplicationContext context = new AnnotationConfigApplicationContext(RmiConfig2.class); 11 | RmiService bean = context.getBean(RmiService.class); 12 | bean.printMessage("hello world"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/MyMBean.java: -------------------------------------------------------------------------------- 1 | package com.max; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class MyMBean { 7 | 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 void printName() throws InterruptedException { 18 | System.out.println(name); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/aop/AspectConf.java: -------------------------------------------------------------------------------- 1 | package com.max.aop; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | 5 | //@Configuration 6 | //@EnableAspectJAutoProxy(exposeProxy = true) 7 | //@ComponentScan 8 | public class AspectConf { 9 | @Bean 10 | TransactionAspect getTransaction() { 11 | return new TransactionAspect(); 12 | } 13 | // @Bean 14 | // TransactionAspect2 getTransaction2() { 15 | // return new TransactionAspect2(); 16 | // } 17 | // @Bean 18 | // TransactionAround getTransactionAround() { 19 | // return new TransactionAround(); 20 | // } 21 | // @Bean 22 | // UserRepoIntroducer getIntroducer() { 23 | // return new UserRepoIntroducer(); 24 | // } 25 | } -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/aop/DefaultEncoreable.java: -------------------------------------------------------------------------------- 1 | package com.max.aop; 2 | 3 | public class DefaultEncoreable implements Encoreable { 4 | public void performEncore() { 5 | System.out.println("encore"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/aop/Encoreable.java: -------------------------------------------------------------------------------- 1 | package com.max.aop; 2 | 3 | public interface Encoreable { 4 | void performEncore(); 5 | } 6 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/aop/Repo.java: -------------------------------------------------------------------------------- 1 | package com.max.aop; 2 | 3 | public interface Repo { 4 | void getInfo(); 5 | void printName(String name); 6 | } 7 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/aop/TransactionAround.java: -------------------------------------------------------------------------------- 1 | package com.max.aop; 2 | 3 | import org.aspectj.lang.ProceedingJoinPoint; 4 | 5 | //@Aspect 6 | public class TransactionAround { 7 | // @Around("execution(* com.max.aop.Repo.getInfo())") 8 | public void watchPerformance(ProceedingJoinPoint jp) { 9 | try { 10 | System.out.println("transaction begin"); 11 | jp.proceed(); 12 | System.out.println("transaction end"); 13 | } catch (Throwable e) { 14 | System.out.println("transaction rollback"); 15 | } finally { 16 | System.out.println("transaction commit"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/aop/TransactionAspect2.java: -------------------------------------------------------------------------------- 1 | package com.max.aop; 2 | 3 | 4 | import org.aspectj.lang.annotation.Aspect; 5 | import org.aspectj.lang.annotation.Before; 6 | import org.springframework.core.annotation.Order; 7 | 8 | @Aspect 9 | @Order(value = 0) 10 | public class TransactionAspect2 { //implements Ordered { 11 | @Before("execution(* com.max.aop.Repo.getInfo())") 12 | private void before() { 13 | System.out.println("transaction begin2"); 14 | } 15 | 16 | // public int getOrder() { 17 | // return 1; 18 | // } 19 | } 20 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/aop/UserRepoIntroducer.java: -------------------------------------------------------------------------------- 1 | package com.max.aop; 2 | 3 | import org.aspectj.lang.annotation.Aspect; 4 | import org.aspectj.lang.annotation.DeclareParents; 5 | 6 | @Aspect 7 | public class UserRepoIntroducer { 8 | @DeclareParents(value = "com.max.aop.Repo+", defaultImpl = DefaultEncoreable.class) 9 | public static Encoreable encoreable; 10 | } 11 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/aop/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.max.aop; 2 | 3 | import org.springframework.aop.framework.AopContext; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component("userRepo") 7 | public class UserRepository implements Repo { 8 | // @Primary 9 | public void getInfo() { 10 | System.out.println("User max, age 22"); 11 | } 12 | 13 | public void printName(String name) { 14 | ((Repo) AopContext.currentProxy()).getInfo(); 15 | System.out.println(name); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.max.config; 2 | 3 | //@Configuration 4 | public class AppConfig { 5 | // @Bean 6 | // public Car getCar1() { 7 | // Toyota car = new Toyota(); 8 | // car.setRadio(bestFm()); 9 | // return car; 10 | // } 11 | // 12 | // @Bean 13 | // public Car getCar2() { 14 | // Ferrary car = new Ferrary(); 15 | // car.setRadio(bestFm()); 16 | // return car; 17 | // } 18 | 19 | // @Bean 20 | // public Radio bestFm() { 21 | // return new BestFm(); 22 | // } 23 | } 24 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/config/Config.java: -------------------------------------------------------------------------------- 1 | package com.max.config; 2 | 3 | //@Configuration 4 | //@ComponentScan 5 | //@Import(Config2.class) 6 | //@ImportResource("classpath:config2.xml") 7 | //@PropertySource("classpath:my.properties") 8 | public class Config { 9 | // @Autowired 10 | // Environment env; 11 | // @Bean 12 | // public Car getToyota(@MyRadio Radio radio) { 13 | // return new Toyota(radio, env.getProperty("name")); 14 | // } 15 | } 16 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/config/Config2.java: -------------------------------------------------------------------------------- 1 | package com.max.config; 2 | 3 | //@Configuration 4 | public class Config2 { 5 | // @Bean 6 | //// @Profile("default") 7 | // @Primary 8 | // @MyRadio 9 | // public Radio getRadio() { 10 | // return new BestFm(); 11 | // } 12 | // @Bean 13 | // @Profile("dev") 14 | // @Conditional(MyCondition.class) 15 | // @Primary 16 | // public Radio getWorstFm() { 17 | // return new WorstFm(); 18 | // } 19 | } 20 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/config/JmxConfig.java: -------------------------------------------------------------------------------- 1 | package com.max.config; 2 | 3 | import com.max.MyMBean; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.jmx.export.MBeanExporter; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | //@Configuration 11 | //@ComponentScan("com.max") 12 | public class JmxConfig { 13 | @Bean 14 | public MBeanExporter mbeanExporter(MyMBean myMBean) { 15 | MBeanExporter exporter = new MBeanExporter(); 16 | Map beans = new HashMap<>(); 17 | beans.put("myBean:name=MyMBean", myMBean); 18 | exporter.setBeans(beans); 19 | return exporter; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/config/MyRadio.java: -------------------------------------------------------------------------------- 1 | package com.max.config; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Qualifier 10 | public @interface MyRadio {} -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/config/RmiConfig2.java: -------------------------------------------------------------------------------- 1 | package com.max.config; 2 | 3 | import com.max.interfaces.RmiService; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.remoting.rmi.RmiProxyFactoryBean; 6 | 7 | //@Configuration 8 | public class RmiConfig2 { 9 | @Bean 10 | public RmiProxyFactoryBean proxyFactoryBean() { 11 | RmiProxyFactoryBean bean = new RmiProxyFactoryBean(); 12 | bean.setServiceUrl("rmi://localhost/rmiServiceName"); 13 | bean.setServiceInterface(RmiService.class); 14 | return bean; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/impl/BestFm.java: -------------------------------------------------------------------------------- 1 | package com.max.impl; 2 | 3 | import com.max.interfaces.Radio; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component//("radio") 8 | //@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) 9 | public class BestFm implements Radio { 10 | @Value("best") 11 | String name; 12 | public void listenMusic() { 13 | System.out.println("cool music"); 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/impl/BookRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package com.max.impl; 2 | 3 | import com.max.entities.Book; 4 | import com.max.interfaces.BookRepo; 5 | 6 | import javax.persistence.EntityManager; 7 | import javax.persistence.PersistenceContext; 8 | import javax.persistence.TypedQuery; 9 | 10 | public class BookRepositoryImpl implements BookRepo { 11 | @PersistenceContext 12 | private EntityManager em; 13 | @Override 14 | public Book getById(int id) { 15 | TypedQuery query = em.createQuery("select b from Book b where b.id = " + id, Book.class); 16 | return query.getSingleResult(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/impl/Ferrary.java: -------------------------------------------------------------------------------- 1 | package com.max.impl; 2 | 3 | import com.max.interfaces.Car; 4 | 5 | //@Component 6 | public class Ferrary implements Car { 7 | 8 | // @Autowired 9 | // Radio radio; 10 | // 11 | // public void setRadio(Radio radio) { 12 | // this.radio = radio; 13 | // } 14 | // 15 | public void drive() { 16 | System.out.println("ferrary"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/impl/RmiServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.max.impl; 2 | 3 | import com.max.interfaces.RmiService; 4 | 5 | public class RmiServiceImpl implements RmiService { 6 | @Override 7 | public void printMessage(String s) { 8 | System.out.println(s); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/impl/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.max.impl; 2 | 3 | import com.max.entities.User; 4 | import com.max.interfaces.UserRepo; 5 | import org.hibernate.SessionFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | 9 | //@Repository 10 | public class UserRepository implements UserRepo { 11 | @Autowired 12 | SessionFactory sessionFactory; 13 | 14 | @Override 15 | public User getById(int id) { 16 | return null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/impl/WorstFm.java: -------------------------------------------------------------------------------- 1 | package com.max.impl; 2 | 3 | import com.max.interfaces.Radio; 4 | 5 | public class WorstFm implements Radio { 6 | public void listenMusic() { 7 | System.out.println("worst music"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/interfaces/BookRepo.java: -------------------------------------------------------------------------------- 1 | package com.max.interfaces; 2 | 3 | import com.max.entities.Book; 4 | 5 | public interface BookRepo { 6 | Book getById(int id); 7 | } 8 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/interfaces/Car.java: -------------------------------------------------------------------------------- 1 | package com.max.interfaces; 2 | 3 | public interface Car { 4 | void drive(); 5 | } 6 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/interfaces/Radio.java: -------------------------------------------------------------------------------- 1 | package com.max.interfaces; 2 | 3 | public interface Radio { 4 | void listenMusic(); 5 | } 6 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/interfaces/Repo.java: -------------------------------------------------------------------------------- 1 | package com.max.interfaces; 2 | 3 | public interface Repo { 4 | void createTable(); 5 | } 6 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/interfaces/RmiService.java: -------------------------------------------------------------------------------- 1 | package com.max.interfaces; 2 | 3 | public interface RmiService { 4 | void printMessage(String s); 5 | } 6 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/interfaces/UserRepo.java: -------------------------------------------------------------------------------- 1 | package com.max.interfaces; 2 | 3 | import com.max.entities.User; 4 | 5 | public interface UserRepo { 6 | User getById(int id); 7 | } -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/mongo/StudentAutoRepository.java: -------------------------------------------------------------------------------- 1 | package com.max.mongo; 2 | 3 | import com.max.mongo.entities.Student; 4 | import org.springframework.data.mongodb.repository.MongoRepository; 5 | import org.springframework.data.mongodb.repository.Query; 6 | 7 | public interface StudentAutoRepository extends MongoRepository { 8 | @Query("{'name': ?0}") 9 | Student getStudentByName(String name); 10 | } 11 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/mongo/StudentRepo.java: -------------------------------------------------------------------------------- 1 | package com.max.mongo; 2 | 3 | public interface StudentRepo { 4 | void saveStudent(); 5 | } 6 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/mongo/StudentRepository.java: -------------------------------------------------------------------------------- 1 | package com.max.mongo; 2 | 3 | import com.max.mongo.entities.Student; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.data.mongodb.core.MongoOperations; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | public class StudentRepository implements StudentRepo { 10 | @Autowired 11 | MongoOperations mongoOperations; 12 | @Override 13 | public void saveStudent() { 14 | mongoOperations.save(new Student("Mike"), "students"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/mongo/entities/Student.java: -------------------------------------------------------------------------------- 1 | package com.max.mongo.entities; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.mongodb.core.mapping.Document; 5 | 6 | @Document 7 | public class Student { 8 | @Id 9 | String id; 10 | String name; 11 | 12 | public Student() {} 13 | public Student(String name) { 14 | this.name = name; 15 | } 16 | 17 | public String getId() { 18 | return id; 19 | } 20 | 21 | public void setId(String id) { 22 | this.id = id; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/test/Car.java: -------------------------------------------------------------------------------- 1 | package com.max.test; 2 | 3 | public interface Car { 4 | void drive(); 5 | } 6 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/test/Main.java: -------------------------------------------------------------------------------- 1 | package com.max.test; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | 6 | public class Main { 7 | public static void main(String[] args) { 8 | ApplicationContext context = new AnnotationConfigApplicationContext(com.max.test.TestConfig.class); 9 | Car bean = context.getBean(Toyota.class); 10 | bean.drive(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/test/MyInitializer.java: -------------------------------------------------------------------------------- 1 | package com.max.test; 2 | 3 | import org.springframework.context.ApplicationContextInitializer; 4 | import org.springframework.context.ConfigurableApplicationContext; 5 | 6 | public class MyInitializer implements ApplicationContextInitializer { 7 | @Override 8 | public void initialize(ConfigurableApplicationContext applicationContext) { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/test/TestConfig.java: -------------------------------------------------------------------------------- 1 | package com.max.test; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | @ComponentScan(value = "com.max.test") 8 | public class TestConfig { 9 | } 10 | -------------------------------------------------------------------------------- /sprng/src/main/java/com/max/test/Toyota.java: -------------------------------------------------------------------------------- 1 | package com.max.test; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class Toyota implements Car { 7 | public void drive() { 8 | System.out.println("drive"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /sprng/src/main/resources/my.properties: -------------------------------------------------------------------------------- 1 | name=Max -------------------------------------------------------------------------------- /sprng/src/main/resources/myScript.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS Books (id MEDIUMINT NOT NULL AUTO_INCREMENT, name CHAR(30) NOT NULL, img BLOB, PRIMARY KEY (id)) -------------------------------------------------------------------------------- /src/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: Main 3 | 4 | -------------------------------------------------------------------------------- /src/Main.java: -------------------------------------------------------------------------------- 1 | import java.text.ParseException; 2 | 3 | public class Main { 4 | public static void main(String[] args) throws ParseException { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /src/MyApp.policy: -------------------------------------------------------------------------------- 1 | grant { 2 | permission java.io.FilePermission "/tmp/*", "read,write"; 3 | permission java.net.SocketPermission "*.horstmann.com:8000-8999", "connect"; 4 | //permission java.util.PropertyPermission "os.title", "read"; 5 | permission security.MyPermission "use"; 6 | }; 7 | 8 | grant{ 9 | permission javax.security.auth.AuthPermission "createLoginContext.Login1"; 10 | permission javax.security.auth.AuthPermission "doAsPrivileged"; 11 | }; 12 | grant principal com.sun.security.auth.UnixPrincipal "max" { 13 | permission java.util.PropertyPermission "user.*", "read"; 14 | permission java.util.PropertyPermission "os.title", "read"; 15 | }; -------------------------------------------------------------------------------- /src/advanced/AssertionsLesson.java: -------------------------------------------------------------------------------- 1 | package advanced; 2 | 3 | import java.io.IOException; 4 | 5 | public class AssertionsLesson { 6 | static int number = 10; 7 | public static void main(String[] args) throws IOException { 8 | assert false : getI(); 9 | assert false : new IOException(); 10 | assert false : number = 11; 11 | assert (++number > 5); 12 | } 13 | static int getI() { 14 | return 1; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/advanced/BinarySearch.java: -------------------------------------------------------------------------------- 1 | package advanced; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | public class BinarySearch { 8 | public static void main(String[] args) { 9 | List list = new ArrayList<>(); 10 | list.add(5); 11 | list.add(1); 12 | list.add(2); 13 | list.add(3); 14 | list.add(4); 15 | list.add(6); 16 | 17 | Collections.sort(list); 18 | int index = Collections.binarySearch(list, 5); 19 | System.out.println(index); 20 | System.out.println(list.get(index)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/advanced/CohesionAndCouplingLesson.java: -------------------------------------------------------------------------------- 1 | package advanced; 2 | 3 | public class CohesionAndCouplingLesson { 4 | public static void main(String[] args) { 5 | 6 | } 7 | } 8 | 9 | class A { 10 | private int i; 11 | public int getI() { 12 | return i; 13 | } 14 | } 15 | 16 | class B { 17 | void printI() { 18 | System.out.println(new A().getI()); 19 | } 20 | } 21 | 22 | class Zakkusachnaya { 23 | Cook cook; 24 | Weiter weiter; 25 | Janitor janitor; 26 | } 27 | 28 | class Cook { 29 | void cook() { 30 | 31 | } 32 | } 33 | class Weiter { 34 | void deliverFood() { 35 | 36 | } 37 | } 38 | class Janitor { 39 | void cleanFloor() { 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/advanced/FinalLesson.java: -------------------------------------------------------------------------------- 1 | package advanced; 2 | 3 | public class FinalLesson { 4 | public static void main(String[] args) { 5 | One one = new Two(); 6 | one.executeMathod(); 7 | } 8 | } 9 | 10 | class One { 11 | private final void method() { 12 | System.out.println("one"); 13 | } 14 | void executeMathod() { 15 | One one = new Two(); 16 | one.method(); 17 | } 18 | } 19 | class Two extends One { 20 | void method() { 21 | System.out.println("two"); 22 | } 23 | } -------------------------------------------------------------------------------- /src/advanced/InnerClassLesson.java: -------------------------------------------------------------------------------- 1 | package advanced; 2 | 3 | public class InnerClassLesson { 4 | 5 | private static int j = 6; 6 | private int i = 5; 7 | 8 | Inner inner = new Inner(); 9 | 10 | void method() { 11 | Inner inner = new Inner(); 12 | } 13 | 14 | class Inner { 15 | int q = j; 16 | int w = i; 17 | void method() { 18 | q = j + i; 19 | } 20 | 21 | final static int e = 4; 22 | } 23 | 24 | public static void main(String[] args) { 25 | Inner inner = new InnerClassLesson().new Inner(); 26 | } 27 | } 28 | class OtherClass2 { 29 | InnerClassLesson.Inner inner = new InnerClassLesson().new Inner(); 30 | } 31 | -------------------------------------------------------------------------------- /src/advanced/InterfacesLesson.java: -------------------------------------------------------------------------------- 1 | package advanced; 2 | 3 | public class InterfacesLesson { 4 | public static void main(String[] args) { 5 | 6 | } 7 | } 8 | 9 | interface Animal { 10 | 11 | public static enum E { 12 | 13 | } 14 | 15 | public static interface MyInnerInterface { 16 | int i = 5; 17 | void eat(); 18 | } 19 | 20 | public static class MyInnerClass { 21 | 22 | } 23 | 24 | int i = 5; 25 | void eat(); 26 | } 27 | 28 | interface Cat extends Animal { 29 | void move(); 30 | } 31 | 32 | class Tiger implements Animal, Cat { 33 | @Override 34 | public void eat() { 35 | 36 | } 37 | 38 | @Override 39 | public void move() { 40 | 41 | } 42 | } -------------------------------------------------------------------------------- /src/advanced/IsAHasALesson.java: -------------------------------------------------------------------------------- 1 | package advanced; 2 | 3 | public class IsAHasALesson { 4 | public static void main(String[] args) { 5 | MyCar myCar = new MyCar(); 6 | myCar.listen(); 7 | 8 | } 9 | } 10 | 11 | class Telega { 12 | int weels = 4; 13 | } 14 | class MyCar { 15 | Radio radio = new Radio(); 16 | void listen() { 17 | radio.listen(); 18 | } 19 | void drive() { 20 | 21 | } 22 | } 23 | class Radio { 24 | void listen() { 25 | System.out.println("listen radio"); 26 | } 27 | } -------------------------------------------------------------------------------- /src/advanced/LocalInnerClassesLesson.java: -------------------------------------------------------------------------------- 1 | package advanced; 2 | 3 | public class LocalInnerClassesLesson { 4 | 5 | static int i = 5; 6 | int j = 6; 7 | 8 | void does(int e) { 9 | int r = 5; 10 | class Local { 11 | private final static int q = 4; 12 | public int w = j; 13 | int t = e; 14 | int y = r; 15 | void method() { 16 | 17 | } 18 | } 19 | Local local = new Local(); 20 | } 21 | void does2() { 22 | class Local { 23 | 24 | } 25 | } 26 | 27 | public static void main(String[] args) { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/advanced/OverridingAdvancedLesson.java: -------------------------------------------------------------------------------- 1 | package advanced; 2 | 3 | public class OverridingAdvancedLesson { 4 | void method(Parent p) { 5 | System.out.println("parent"); 6 | } 7 | void method(Child c) { 8 | System.out.println("child"); 9 | } 10 | public static void main(String[] args) { 11 | OverridingAdvancedLesson overridingAdvancedLesson = new OverridingAdvancedLesson(); 12 | overridingAdvancedLesson.method(null); 13 | 14 | overridingAdvancedLesson.equals(null); 15 | } 16 | } 17 | class Parent { 18 | 19 | } 20 | class Child extends Parent { 21 | 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/anotation/ComileJavaLesson.java: -------------------------------------------------------------------------------- 1 | package anotation; 2 | 3 | import javax.tools.JavaCompiler; 4 | import javax.tools.ToolProvider; 5 | import java.io.FileNotFoundException; 6 | 7 | /** 8 | * Created by max on 2/19/17. 9 | */ 10 | public class ComileJavaLesson { 11 | public static void main(String[] args) throws FileNotFoundException { 12 | JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 13 | int result = compiler.run(null, null, null, "/home/max/Test.java"); 14 | System.out.println(result); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/anotation/package-info.java: -------------------------------------------------------------------------------- 1 | @Test("test") 2 | package anotation; -------------------------------------------------------------------------------- /src/bestpractice/ConcurrencyBestPractice.java: -------------------------------------------------------------------------------- 1 | package bestpractice; 2 | 3 | //don't use lazy initialization 4 | //Don’t depend on the thread scheduler //don't use Thread.yield - better Thread.sleep(1) //no testable //same about thread priorities 5 | //Avoid thread groups 6 | public class ConcurrencyBestPractice { 7 | public static void main(String[] args) {} 8 | } 9 | -------------------------------------------------------------------------------- /src/bestpractice/DesignMethodSignature.java: -------------------------------------------------------------------------------- 1 | package bestpractice; 2 | 3 | //Choose method names carefully 4 | //Too many methods make a class difficult to learn, use, document, test, and maintain 5 | //Avoid long parameter lists //Long sequences of identically typed parameters are especially harmful 6 | //1. break the method up into multiple methods 7 | //2. create helper classes to hold groups of parameters 8 | //3. Builder pattern 9 | //For parameter types, favor interfaces over classes 10 | //Prefer two-element enum types to boolean parameters 11 | public class DesignMethodSignature { 12 | public static void main(String[] args) {} 13 | } -------------------------------------------------------------------------------- /src/bestpractice/DontUseRawTypes.java: -------------------------------------------------------------------------------- 1 | package bestpractice; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Set; 6 | 7 | //dont use raw types 8 | //two exceptions: 1) List.class 2) instanceof 9 | public class DontUseRawTypes { 10 | public static void main(String[] args) { 11 | List x = new ArrayList<>(); 12 | if(x instanceof List) { 13 | List y = x; 14 | } 15 | } 16 | static int numElementsInCommon(Set s1, Set s2) { 17 | int result = 0; 18 | for (Object o1 : s1) 19 | if (s2.contains(o1)) 20 | result++; 21 | return result; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/bestpractice/ExceptionFailureAtomicity.java: -------------------------------------------------------------------------------- 1 | package bestpractice; 2 | 3 | import java.util.EmptyStackException; 4 | 5 | //failed method invocation should leave the object in the state that it was in prior to the invocation 6 | //1. immutable objects 7 | //2. check params before use 8 | //3. recovery code 9 | //4. temporary copy 10 | public class ExceptionFailureAtomicity { 11 | Object[] elements; 12 | public Object pop(int size) { 13 | if (size == 0) 14 | throw new EmptyStackException(); 15 | return elements[--size]; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/bestpractice/ExceptionsLesson.java: -------------------------------------------------------------------------------- 1 | package bestpractice; 2 | 3 | //don't ignore exceptions 4 | //capture all information 5 | public class ExceptionsLesson { 6 | public static void main(String[] args) { 7 | // try { 8 | // System.out.println("hello"); 9 | // } catch (Exception e) { 10 | // } 11 | try { 12 | System.out.println("hello"); 13 | } catch (Exception e) { 14 | System.out.println("args: " + args + " letngh: " + args.length); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/bestpractice/ReferObjectsByInterface.java: -------------------------------------------------------------------------------- 1 | package bestpractice; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Vector; 6 | 7 | //next release can improve performance 8 | //but if it sync it should be sync 9 | //if no interface it's ok 10 | public class ReferObjectsByInterface { 11 | List list = new ArrayList<>();//good 12 | static Vector vector = new Vector<>();//bad 13 | public static void main(String[] args) { 14 | ThreadLocal threadLocal; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/bestpractice/SuppressWarningsLesson.java: -------------------------------------------------------------------------------- 1 | package bestpractice; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | //eliminate warnings 7 | //use smallest scope possible 8 | //always comment 9 | public class SuppressWarningsLesson { 10 | public static void main(String[] args) { 11 | run(); 12 | }public static Set run() { 13 | //some code 14 | @SuppressWarnings("unchecked") //value return from old method 15 | Set exaltation = new HashSet(); 16 | return exaltation; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/bestpractice/SyncAccessToMutualData.java: -------------------------------------------------------------------------------- 1 | package bestpractice; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | public class SyncAccessToMutualData { 6 | private volatile static boolean stopRequested; 7 | public static void main(String[] args) throws InterruptedException { 8 | new Thread(new Runnable() { 9 | public void run() { 10 | while (!stopRequested) {} 11 | } 12 | }).start(); 13 | TimeUnit.SECONDS.sleep(1); 14 | stopRequested = true; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/bestpractice/ToStringLesson.java: -------------------------------------------------------------------------------- 1 | package bestpractice; 2 | //value classes 3 | //all fields 4 | //format 5 | //documented 6 | //programmatic access 7 | public class ToStringLesson { 8 | int i; 9 | public static void main(String[] args) { 10 | ToStringLesson stringLesson = new ToStringLesson(); 11 | stringLesson.i = 5; 12 | try { 13 | throw new RuntimeException(); 14 | } catch (RuntimeException e) { 15 | System.out.println(stringLesson); 16 | } 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "ToStringLesson{i=" + i + '}'; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/bestpractice/UseSerializableJudiciously.java: -------------------------------------------------------------------------------- 1 | package bestpractice; 2 | 3 | //use serialization carefully 4 | //it's difficult to change after release 5 | //serialization don't run constructor 6 | //if class design for inheritance it should't implement serializable 7 | //don't use it on inner classes, anonymous, local, but static is ok 8 | //use UID 9 | //don't use Serialization on singletons 10 | public class UseSerializableJudiciously { 11 | private static final long serialVersionUID = 1; 12 | UseSerializableJudiciously INSTANCE; 13 | private Object readResolve() { 14 | return INSTANCE; 15 | } 16 | } -------------------------------------------------------------------------------- /src/bestpractice/UseStandardExceptions.java: -------------------------------------------------------------------------------- 1 | package bestpractice; 2 | 3 | //code reuse 4 | //make api familiar 5 | //your API easier to learn 6 | //easier to read 7 | //smaller memory amount 8 | //java api covers almost all 9 | //IllegalArgumentException //IllegalStateException //NullPointerException//IndexOutOfBoundsException //ConcurrentModificationException 10 | //UnsupportedOperationException 11 | public class UseStandardExceptions { 12 | public static void main(String[] args) { 13 | exceptionMethod(5); 14 | } 15 | public static void exceptionMethod(int i) { 16 | if(i < 0) 17 | throw new IllegalArgumentException("i < 0"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/fx/Controller.java: -------------------------------------------------------------------------------- 1 | package fx; 2 | 3 | import javafx.event.ActionEvent; 4 | import javafx.fxml.FXML; 5 | import javafx.fxml.Initializable; 6 | 7 | import java.net.URL; 8 | import java.util.ResourceBundle; 9 | 10 | public class Controller implements Initializable { 11 | @Override 12 | public void initialize(URL url, ResourceBundle resourceBundle) 13 | { 14 | } 15 | @FXML 16 | private void test(ActionEvent event) 17 | { 18 | System.out.println("lollolol"); 19 | } 20 | } -------------------------------------------------------------------------------- /src/fx/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package fx; 2 | 3 | import javafx.application.Application; 4 | import javafx.scene.Group; 5 | import javafx.scene.Scene; 6 | import javafx.stage.Stage; 7 | 8 | public class HelloWorld extends Application { 9 | 10 | public static void main(String[] args) { 11 | Application.launch(args); 12 | } 13 | 14 | @Override 15 | public void start(Stage primaryStage) throws Exception { 16 | Group group = new Group(); 17 | Scene scene = new Scene(group, 400, 300); 18 | 19 | primaryStage.setTitle("Hello world!"); 20 | primaryStage.setScene(scene); 21 | primaryStage.show(); 22 | } 23 | } -------------------------------------------------------------------------------- /src/fx/NumberTextField.java: -------------------------------------------------------------------------------- 1 | package fx; 2 | 3 | import javafx.scene.control.TextField; 4 | 5 | public class NumberTextField extends TextField { 6 | String numberRegEx = "[0-9]*"; 7 | 8 | @Override 9 | public void replaceText(int start, int end, String text) { 10 | String oldValue = getText(); 11 | if ((validate(text))) { 12 | super.replaceText(start, end, text); 13 | String newText = super.getText(); 14 | if (!validate(newText)) { 15 | super.setText(oldValue); 16 | } 17 | } 18 | } 19 | 20 | private boolean validate(String text) { 21 | return ("".equals(text) || text.matches(numberRegEx)); 22 | } 23 | } -------------------------------------------------------------------------------- /src/fx/custom_control.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |