Stuff

Day 1 of class history of Java and introduction to Spring

  • Open source

  • Lightweigh

  • DI container

  • Framework

  • DI container

infrastructural support Dev focus on the requirements not the plubing / testing / manage transactions / threads / mem /etc

Dry dont repeat yourself

Separation of concerns

Convention over configuration - save time take defaults can change things if you are special

Testability - automation of testing

Programatic interfaces

Spring solution for J2EE EJB complexity No backend server

Type Datasource / Type ID

SPA Dspring.profiles.active=embedded,jpa — Spring profiles active … Actgivate the profile on the command line

SpEL - docs.spring.io/spring/current/spring-frameworks-reference/html/expressions.html

@Component
@Configuration
@Componentscan 
SpringApplication.run()
JSR-330

BeanFactoryPostProcessor (Used for reading properties/Registering a custome scope)

Stuff

mindmap
  root((Spring))
    Dependency Injection
      Magic
      Decouple implementation/lifecycle
      reduce overhead duplicate/objects 
    Beans
      lifecycle
      initializers
        only on called bean
      before/after
        on all
  

Day 2

Bean post processing What you see on a bean is not the end of it look for BPP and BFPP

BPP impacts all loaded beans this seems like a good place to plce bad logic -fun thing might be to make what looks like a small simple app and have the BPP do stuff for fun

Java Config(@Bean) VS Annotation(@Compenent) Stuff

Bean Proxy wrapper from spring Created by BeanPostProcessor

Proxy pattern Can be JDK Proxy or CGLib Proxy

  • JDK _ Dynamic built into JDK no other libs needed based on Java interface All interfaces proxied
  • CGLib proxy not in JDK fallback included in spring jars used when interface not availalbe cannot be applied to final classes or methods

https://docs.spring.io/spring-framework/reference

Write to interfaces return interfaces all the things = interfaces

AOP

  • Problem that its solving

    • enables modularization of cross-cutting concerns
      • Functionality that is needed in a lot of places
        • Logging tracing
        • transaction management
        • security
        • Caching
        • errors
        • perf
        • business rules
  • Exmaple req that is cross cutting

    • Perform a role-based security check before every application method
    • Write aspects
    • Weave them into the app code
  • Terms

    • join point
      • spot to insert new logic
    • pointcut
      • expression that selects join point
      • AspectJ pointcut expression language was good not easy but still seems to be the best
    • advice
      • code to be executed at each selected join point
    • Aspect
      • Module that encapsulates pointcuts and advice
    • Weaving
      • technique to compbine aspects with main code
  • AOP options

    • AspectJ
      • original 1995 bytecode modifictaion
    • Spring AOP
      • uses dynamic proxies for weaving
      • trying to solve enterprise problems

Pointcut

AspectJ did it right.

  • quickstart
  • pointcuts
  • Advice label

Checked Exceptions vs Unchecked

SQLExceptions are checked Compiler checks this — before runtime Null pointer exception is a runtime exception cant detect this on compile Java strong want tog et as many as possible on Compile time – this is why checked exceptions are around get ahead of that stuff

Row mappers ?

  • JDBCTemplate review this stuff

TRansactions

JDBC Template

Day3

Spring Boot !!

An opinionated runtime for Pring Projects

google how thats getting someones opinion on how you do it Spring was like we can give good defaults and keep things the same for predictable items is not a code generator
not an IDE plug-in

Fat jar or shaded jar bundles up all the jars plus dependencies now u have a single artifact to deploy done with spring-boot-maven-package

spring.sql.init.schema-locations= spring.sql.init.data-locations=

or just put them in resources and call schema.sql data.sql

FUN

https://patorjk.com/software/taag/#p=display&f=Graffiti&t=Tj

Docker

paquito? paquito build pack buildpacks.io