Struts Features : ✔️ Configurable MVC components ✔️ POJO based actions ✔️ AJAX support ✔️ Integration support ✔️ Various Result Types ✔️ Various Tag support ✔️ Theme and Template support
Intro to Struts Framework ✔️ Apache Struts is a free, open-source, MVC framework for creating elegant, modern Java web applications. ✔️ It favors convention over configuration, is extensible using a plugin architecture, and ships with plugins to support REST, AJAX and JSON. The framework provides three key components: ✔️ A “request” handler provided by the application developer that is mapped to a standard URI. ✔️ A “response” handler that transfers control to another resource which completes the response. ✔️ A tag library that helps developers create interactive form-based applications with server pages.
Aspect Oriented Programming (AOP) ✔️ AOP complements OOP by providing another way of thinking about program structure. ✔️ The key unit of modularity in OOP is the class. ✔️ In AOP the unit of modularity is the aspect (piece/portion/module) ✔️ Aspects enable the modularization of concerns such as transaction management that cut across multiple types and objects, such concerns are often termed crosscutting concerns in AOP ✔️ Breaking down program logic into distinct parts called so-called concerns in AOP. ✔️ The functions that span multiple points of an app are called cross-cutting concerns. ✔️ These cross-cutting concerns are conceptually separate from the application’s business logic. ✔️ There are various common good examples of aspects like logging, auditing, declarative transactions, security, and caching etc.
Dependency Injection (IoC) ✔️ Objects can be added and tested independently of other objects. ✔️ Because they don’t depend on anything other than what you pass them. ✔️ To test an object you have to create an environment where all of its dependencies exist and are reachable before you can test it. ✔️ With DI, it’s possible to test the object in isolation passing it mock objects for the ones you don’t want or need to create. ✔️ Likewise, adding a class to a project is facilitated because the class is self-contained. ✔️ DI frameworks are often driven by XML files that help specify what to pass to whom and when. ✔️ IoC describes that a dependency injection needs to be done by an external entity instead of creating the dependencies by component itself. ✔️ Dependency injection is a process of injecting (pushing) the dependencies into an object
Tight coupling: ✔️ In general, Tight coupling means the two classes often change together. ✔️ In other words, if A knows more than it should about the way in which B was implemented, then A and B are tightly coupled.
Loose coupling: ✔️ In simple words, loose coupling means they are mostly independent. If the only knowledge that class A has about class B, is what class B has exposed through its interface, then class A and class B are said to be loosely coupled. ✔️ In order to over come from the problems of tight coupling between objects, spring framework uses dependency injection mechanism with the help of POJO/POJI model and through dependency injection its possible to achieve loose coupling.
Advantages ✔️ Predefined Templates ✔️ Loose Coupling ✔️ Easy to test ✔️ Lightweight ✔️ Fast Development ✔️ Powerful abstraction
Architecture of Spring Framework and Spring modules group ✔️ Test ✔️ Core Container ✔️ AOP, Aspects, Instrumentation ✔️ Data Access / Integration ✔️ Web (MVC / Remote)
✔️ First version of Spring was written by Rod Johnson, released on February 2003. ✔️ It has become popular in the Java community as an addition to, or even ✔️ replacement for the Enterprise JavaBeans (EJB) model. ✔️ Spring is a lightweight framework. ✔️ It can be thought of as a framework of frameworks because it provides support to various frameworks such as Struts, Hibernate, Tapestry, EJB, JSF etc. ✔️ In broader sense, it can be defined as a structure where we find solution of the various technical problems.
We can map the inheritance hierarchy classes with the table of the database. There are three inheritance mapping strategies defined in the hibernate:
✔️ Table Per Class Hierarchy ➖ Single table is required to map the whole hierarchy, an extra column (discriminator column) is added to identify the class ➖ But, nullable values are stored in the table ✔️ Table Per Subclass Hierarchy ➖ Tables are created as per class but related by foreign key. ➖ So there are no duplicate columns. ✔️ Table Per Concrete class Hierarchy ➖ Tables are created as per class. ➖ But duplicate column is added in subclass tables.
Hibernate Inheritance with Annotation ✔️ Inheritance annotation ✔️ Defines the inheritance strategy to be used for an entity class hierarchy. It is specified on the entity class that is the root of the entity class hierarchy.
Hibernate Sessions Factory ✔️ SessionFactory is an interface. ✔️ SessionFactory can be created by providing Configuration object, which will contain all DB related property details pulled from either hibernate.cfg.xml file or hibernate.properties file. ✔️ SessionFactory is a factory for Session objects.
Hibernate Sessions ✔️ Unlike SessionFactory, the Session object will be created on demand. ✔️ Session provides a physical connectivity between application and DB. ✔️ It will be established each time an application wants do something with DB. ✔️ All the persistent objects will be saved and retrieved through Session object. ✔️ The session object must be destroyed after using it. ✔️ Session object will be provided by SessionFactory object.
Hibernate Sessions states (life cycle states of an object) ✔️ Transient : A new instance of a persistent class which is not associated with a Session and has no representation in the database and no identifier value is considered transient by Hibernate. ✔️ Persistent : A transient instance is made persistent by associating it with a Session. | A persistent instance has a representation in the database, an identifier value and is associated with a Session. ✔️ Detached : When the Hibernate Session is closed, the persistent instance will become a detached instance.
Hibernate Configuration file: ✔️ Hibernate requires some the mapping information that defines the Java classes that relates to the database tables. ✔️ A set of configuration settings related to database and other related parameters are required and stored in a standard Java properties file called hibernate.properties, or as an XML file named hibernate.cfg.xml.
Hibernate Mapping file: ✔️ Mapping and Configuration always co-exist in hibernate as every hibernate program need these two xml files. ✔️ It is the core part of hibernate. ✔️ ORM tool requires mapping which puts an object’s properties into the columns of a table. ✔️ Though, Mapping can be done in the form of an XML or in the form of the annotations
Annotation: ✔️ The hibernate application can be created with annotation. ✔️ There are many annotations that can be used to create hibernate application such as @Entity, @Id, @Table etc. The core advantage of using hibernate annotation is that you don’t need to create mapping (hbm) file. ✔️ Mapping file instructs Hibernate how to map the defined class or classes to the database tables.
Hibernate framework Architecture: It includes many objects such as ✔️ persistent object ✔️ session factory, ✔️ transaction factory, ✔️ connection factory, ✔️ session, ✔️ transaction etc.
The Hibernate architecture is categorized in four layers ✔️Java application layer ✔️Hibernate framework layer ✔️Backend API layer ✔️Database layer