We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 8
Freshers: corejava tadvjova + ora +CRT+ spring
se it Fresher ops -CRT «hibernate wih PA
2+ + Fresher toper CRT +hibernat with PA + webservices
211 Fresher opie CRT + biberete with PA webservice ping microverices
34 5:95 full ttck developer
SMtopics + U Technologies Angular IS/Resct
For experience people the common topics re 3) Desing patterns
2 Reatime Toots (12)
20040 120sessone
soring?am + ‘etarazjavaarenatigmailcom
‘baroup nataracavaarena
Spring Spm parcel —> SOsessons
et
jini, mock tp unit
Debursine
Senne
Docker
AoE lout sta)
and et.
‘ering ial sbout 3 hinge
{a} Java language (Cre Java course)
(0) Java Technologies (J08G serve, jp JMS, EIB and etc)
{c) Frameworks (Spring Hibernate, Webservices}
‘nd: ava Naming And Directory interface
108¢: ova D8 Connectity
Jp Java server Pages
IMs: ava MEssaging SErvice
18: Enterprise va Beans
‘on vesplain what are Progamming language, Technology and Framework?
‘Risa raw materia and installable s/w providing base
feature of pplication development
Ie defines syntaes and semantics of programming by
upping compilers andinterpetes.
‘These ore hee to crest technologies, frameworks,
‘Operatingsystems, DBs/w ,Tools and etn.
eg Ge foe, and etn
Sofware Tein) sattarsgeteation that proieetfaesane gietnes
{or vendor comparies to develop implementation softwares by
‘sling support one or nother progranimingangusge
“Technologies ae notinstallabe Bu tchnologes based
Implementation sw ar installable or arangable.» Working tise
Implementation s/w: nothing but working with Technologies.
‘=>1D8C is tehcology ing rules and guidelines to
evelope JO8C Drive s/w » Working with JO8C driver
fis nothing but working with DBC Technology.
5 JDBC Serlt jsp 8 nd and et.
upto ave
Technology rules are the technology apinterfaces
Technology ulines ae the technology ap classes (oncrete class)
note: The technology ap abstract clases reprsent oth rules and gullies
from ava
“Technoolgyapintfaces abstract classes represent both
ules and guidlines
Technoology api concrente asses represent only sidines.
Java javesal and ete. called je api packages
‘these packages interfaces abstract elses both represent rules and gudelines
‘tehee paces ealsiesrepresnet ony guidelines.
‘Tworypes of sw Technologies
to
Here the technology rules and guns are open
twallthesjw vendodors to create implementations)
‘9g: Alliava Technologies are open technologies
Tike BC Servet, 8, IMS ae ten
6
‘> Here the technology ules and guldelions are specific
te-one vendor and only tha vendor allowed to develope the
Implementation ss
eg? AllMicrosat technologies ike aspinet.
TOBC Technology
‘ives 108C AI aval ovens and ei BHGS)~———
having rlas and eldalins to develope JDBC driver
shane
Vendor’ (Oracle corp)” Wenctor2 (eva) Enterprise 08 (Vendor3) \ Natraj Soft (vendora)_
oe ives je diver s/w ‘ies abe driver s/w for (Ges fe driver for mys
pane mts (ae =Different types java frameworks based on the kind of apps they devleope
{a} web application frameworks
{b) ORM frameworks
{€) application Frameworks
(4) Bigdata Frameworks
{e} Distributed App developement Frameworks
and ete.
‘wm. youtube con/nareshit
web apy
= These frameworks provide abstraction on servlet,jp technologies and simplifies
MVC architecture based web application development...
cg: struts ——-> from apache
Spring mve (part of spring) ———> from interface2. (1)
1S > from sun Ms race corp. (2)
ADF ———> from oracle corp
4 approaches developing spring Apps
(a) using xm driven configurations
(b) using annotation driven configurations
Se maaan (€) 100% java code /jave Config driven
aie ‘configurations.
RERULARTamRaR Tem MAR {4) Spring Boot driven configurations.
ASF #: Java Server Faces
jenniidinenai {Object Relational Mapping)
‘Provides abstraction on plain JDBC/java DBC Technology and simplifes to devieope
objects based DB s/w independent Persistence logic.
hiberante ~
Toplink
-> from softtree/redhat (1)
-> from oracle corp All these ORM frameworks
-> from eclipse (3) are given based on the
> from apache (4) rules and guidelines of
from apache JPA Specification.
-> from sunMs/Oracle corp (2)
(018 —>object java beans
JPA —>Java Persistence API
Application frameworks
‘=> It isall rounder frameworks that provides abstraction on multiple jse jee
‘tehnologies and even on some frameworks to develop all kinds of logics and diff types
app:
‘eg: Spring framework {from interface21 (pivotal)
Using springwe can devieop presentation logics, business logics, peristnece logics
and ete.
Using spring we can deviope stanalone Apps, web applications Distributed Apps,
enterprise Apps and etc.
The enterprise cn be a standalone spp oF
Spring provides abstraction on multiple JSE,JEE Technologies ike JDBC,Jndi, web application or distributed App or
Servet, JSp,JMSandet...and also provides abstraction on frameworks other combination of mivip., Get Chas to deat
fremewort lc Mbematopink bets onde a
‘>The App /comp (class with reusable logics) that allows other remote Apps accessing _narshit.con ---> web applicaiton
its logics is called Distributed App /Remoting Applicaiton.. ‘lpr i tao,
Paypall ----> otstrosuted Sopp
Paypal for E-commerce Apps Centerpetse Ap)
GPay /Phone for E-Commerce Apps
BSE /NSE Comps for Stock Trading Apps like ShareKhan ,BigAdda.com andetc.. __FRKArE with paypal/Gpay/Phone
(Enterprisentyp)
=>Springis not good developing distributed Apps... So prefer using WebServices..
Distributed App devieopment Frameworks
> Simplifies the process of developing Distributed Apps /Remoting Apps.
SOAP Based WebService Developemt :: Javicrpe (ol), jax-ws axis and ete.
outdated)
Rest Based WebServiec /Restfull webSerices:: Jersy RestEasy and et
(latest)
fipkarticom
(websites)
i —T Paypal/Gpay
(épri ) 7
(Distributed App)
: Ke ‘Webservice)
srikath 991 6902 968 665
(spring ve)
IMI, £18 Corba and etc. Distributed Technologies to develop disrbuted Apps and they are
outdated...
Big Data frameworks
‘Bigdata —>The data that is beyond processing capacity is called BigData...
like PB, 78, XB, YB amounts data
youtube facebook and generates bigamounts data... and this data
‘an not be stored in requlat Db s/w. So Big data frameworks are given
To store and process such data by using stack of ordinary computers...
Based on mode of app development we do , there are two frameworks
(a) Invasive Frameworks
(6) Non-Invasive Frameworks
Invasive Frameworks
Here the programmer developed classes of Framework based app development
are tightly coupled with Frameworks APls .e theze classes must be developed
t’lther implementing framework apis interfaces or extending framework api classes.
Due this we can not out App/project classes to other frameworks for execution.
‘=SThese frameworks says to programmers —> come tome , use me and stay with
me forever,
eg: struts Lx (outdated)
note: our serviet comp class also invasive becozit has to implement
javoxervlet.Serviet() directly or indirectly.
Non-lnvasive frameworks
‘=> Here the programmer developed classes of framework based App /project are
loose copupled with frameworks api. these calsses need not to implement or
‘extend from framework api interfaces and classes...So we can move these
classes to another frameworks .. becoze these classes ordinary classes interfaces.
‘= These frameworks say to programers —-> come to me juse me and go to another
framework by taking u r code when ever u want.
28: Spring hibernate, eclipse link, toplink and ete.
important Terminelogies
(2) Middleware services /Aspects_(b) JavaBean (c} Local Client Vs Remote Client
‘Middleware services /Aspects/Cross cutting concerns
‘These are addtional ,optional and secondary that can enabled or disabled on primary logics
‘of the App /project to make app /project more perfect and accurate.
=>These are not mandatory logics /minumum logics of App/project development..
these are addtional and configurable (enabling/disabling) logics.
‘The minimum and mandatory logics of App development are called primary logics
(eg: wrt banking project
withdraw, deposit transfermoney checking balance ,opening account and etc. logics
=> The optional and configurable logics ofthe app development are called secondary logics.
checking checking the access permission of
theidentity the user.
of user
Loan Mk
—_Mutul
Generally in Project development Primary logies
secondary logics are veritcal.Java Bean
java bean is a java class that is developed by following some standards...
=>Java bean does not contain any logics.. It acts as helper class to carry data from one class
to another class with in the project.. or acorss the multiple projects..
=> In order to pass more than 3 values from 1 one class to anothother class or
from one project to another project take the support of java bean...
The standards are
{a) class must be taken public class
(b) Recomanded to implement java.io.Serializable (I)
{c) All member variables (bean properites) should be private and non-static
(d) Every Bean property should one setter method and one getter method
(Accessor methods) —_pote:: Setter method is useful to set data /to modify of
data of bean property
note: getter method is useful to read data from bean property
{e) There should be one zero param consturctor directly (created by the programmer)
or indirectly (given by the java compiler as default constructor)
Example
public class StudentBean implements java.io.Serializable{
//bean properties
private int sno;
private String sname;
private String sadd;
public void setSno(int sno){
this.sno=sno;
}
public int getSno(){
return sno;
}
public void setSname(String sname){
this.sname=sname;
}
public String getSname(){
return sname;
Designing java method having more than 3 params in bad pratice..
//Main class
public class StudentRegistration{
pubic String register(int sno,String sname, String sadd int m1 ,int m2, int m3){
.. [[logic to insert them DB table as record.
StudentRegistration registration=new StudentRegistration();
String result=registration.register(101,"raja","hyd",55,66,88);
tations of designing java method having more than 3 params
while calling method
(a) _u should know the count of arguments
{b)_u should know the index of arguments
(c) we can not ignore to pass one or another agument value which we
do know.. we should still pass dummy values as arg value...
Solution:
Use javabean to carry Data...
public class StudentBean implements Serializable{
private int sno;
private String sname,sadd;
private int m1,m2,m3;
//setters && getters
}
/1Main class
public class StudentRegistration {
public String register(StudentBean bean){
//use getter methods to read dat from
//bean object and use them b.logics..
Client App
/[create Java Bean class obj having data
StudentBean bean=new StudentBean();
bean.setSno(110); bean.setM1(23);
bean.setM2(56); bean.setSname("raja");
[create Main class object
StudentRegistration registration =new StudentRegistration();
String result=registration.register(bean);
S.o.plresult);
Advantages of taking java bean as method param
with respect to method call
{a) we need not worry about count of values to set to Bean class object,
{b) we need not worray aobut order /index of values to set bean class object
(c) we can ignore to set values the we dé how... becoz bean object itself takes
default viaues...
Remote Client Vs Local Client
if The App /Comp and its
Local client to App/comp.
if The App /Comp and its client are staying on two diff jvms of same or different
computers then that client is called Remote client to App/comp...
nt are staying on the same jvm then that client is called
Normal Apps can have only local client... where as Distributed Apps like
EJB/RMI/Webservice Apps can have both local and remote clients..
Machine1.
=>In One computer we can start one or more jvms ... simultaenously...
To run each java App one JVM is required.. So to run multiple java Apps simultaenously we
need the support multiple jvms..How Spring is evolved?
Applet -
Java bean
(started developing by using java classes + java beans)
pros
(Good for Gaming)
->Light weight
~-easy to learn and to use
cons
-> does not allow remote clients i.e allows only local clients
-> Not suitable for large scale apps
-->No built-in middiware servies i.e middleware services must
be developed the programmers manually along with main or
primary logics .. This improves burden on the programmer
->EJB (Enterprise Java Beans) as Distributed Technology
|-->runs on the top RMI
EJB is no way related java bean... better not to compare...
->EJB is useful to develiped Distributed App/comps
pros
lows both Remote clients and Local clients
->Gives built-in middleware services ..
-->Suitable for medium scale and large scale Apps development
cons
~-> Heavy weight...
-> Very Complex to learn and use
Transaction Mgmt (Middleware service)
The process of combining related operations into single unit
and executing them by applying do everything or nothing priciple is called
Transaction Management...
~-->TransferMoney operation Is commbination of
money withdraw, deposite operations. and these operations must
be executed by applying do everything or nothing principle.
note:: 1998 to 2005 the Companies have used EJB ..even in non-distrubuted Apps
only to take the advantage of TransactionMgmt... which was bad practice...
2002/3
> Spring framework ~ > by Rod Jhonson
|-->Providing absraction on multiple Techologies /frameworks
pros
> All kinds of development is possible.
--> All kinds of logics is development is possible
-> App development using by using ordiary java classes giving
non-invasive programming
-> Built-in Middlware services support... on kinds apps we can add
built-in middleware service
-->Light weight App devleopment
-> easy to learn and easy to use.
and etc...
Is Spring alternate to EJB?
Ans) No,
=> EJBis Distributed Techonology to develop distributed Apps.. where as spring is
framework to develope all kinds of Apps like standalone Apps,web applicaitons,
Distributed Apps.. Spring Frameworks provides abstraction on multiple technologies
including RMI,EJB ... But spring based distributed Apps are not good...
=> Webservices is real alternate for EJB.
\s Spring alternate for Struts?
Ans) No
Struts is useful only to develop web applications .. where as spring is
given to develope all kinds of Apps including web applications. A module
of spring called spring MVC is alternate to Struts to developme the
web applications...
Is Spring alternate for JEE Technologies?
‘Ans)No Spring Compliments JEE Technoloigies like JDBc,Jndi, Serviet,isp and etc.
i.e spring internally uses these technolguies to generate common logics dynamically
and makes the programmer to just develop app specific logics... This nothing but
spring providing abstraction on technologies...
Is Spring Alternate for Hibernate?
Ans) No
Spring is not having its own orm frameworks... Spring ORM module is providing
abstraction on multiple ORM frameworks including hibernate. to simplify Object based
o-r mapping peristence logic... ( persistence logic using objects. and no SQL queries)
note : spring ORM module is complimenting ORM frameworks including hibernate.Spring Latest version 5.x (current 5.2.7)
spring overview diagrams
3.x/4.x /5.x-----> 20+ modules.
spring 1.x overview diagram
Spring Framework I.x«
spring 2.x overview diagram
DAO ORM Web
= = EE
AOP =.
Ee
Core
Spring 2.x web module = spring 1.x web module +spring 1.x web mvc + misc...
spring JEE module = spring 1.x context module + misc ...
spring Core
=> It is base module for other modules.
=> This module is given to supply Spring Containers and to peform Dependency Management
Container
Container is a s/w program that manages the whole life cycle of given comp(class) from
birth to death (Object creation to object destruction)
->Servletcontainer manages the life cycle of servlet comps
->Jsp container manages the life cycle of jsp comps
-> Spring Containers manages the life cycle of spring beans.
note: any java class (pre-defined or user-defined or third party class) whose obj
is created and managed spring container is called spring bean.
note: even java bean also can be taken as spring bean.. but object should be
created and managed by spring containers...
->Spring frameworks gives two built-in spring containers
a)BeanFactory (Basic) These are no way related to
b) application context (Advanced) | or no way alternate to
servlet jsp containers.
‘ApplicationContext
Container (Aquirium)
Dependency Management
It is the process of assignig Dependent class object to target class object by loading
both classes and by creating both objects...
=>The class that uses other classes services is called target / main class...
‘The class that acts as helper class to main/target class Is called Dependent class...
Target class Dependent class
eg: Flipkart proc
Vehicle Engine
Student Course Material
Department Employee
Mobile device Simcard
and etc.
if we given Target class name, dependent class name to spring container
either through xml file or through annotations or through properties file.. Then
Spring Container performs
(a) Loading of both classes
(b) creating both classes ojbects
(c) assinging/injecting Dependent class object to tArget class object.
=>ServletContainer,JspContainer can be used only in web env.... to manage the life cycle
of only web comps (servlet, jsp comps) where as spring containers can be used in all kinds of
apps to manage life cycle and dependency management for all kinds of classes/comps...
note:: if i use spring core module alone to develop the Apps ... at max we can develop
only standalone Apps... Generally we use other modules spring for spring Apps
development which internally uses spring core module...
Spring DAO (DAO —>Data Access Object)
==>Provides abstraction on plain jdbc /java jdbc technology and simplifies jdbc style
SQL Queries based Persistnece logic devleopment
=> Gives Details Exception classes hierarchy to display diff error messages for different
DB related problems.
note: Spring DAO also called as spring JDBC is given to develop jdbc style DB s/w
dependent persistence logic using SQL queries...
Spring ORM {ORM ---->Object relational mapping)
I
>HEre the objects of java classes represent
DB table records ..So we can manipulate records
through objects
provides abstraction on multiple ORM frameworks like hibernate, iBatis, Toplink,
JDO and etc...and simplifies object based DB s/w independent Persistnece logic with out
SQL Queries...
Spring DAO Persistnece logic Is jdbc style Db s/w dependent PErsistnecen logic usisng
SQL geries where Spring ORM persistnece logic is DB s/w indepedennt objectb based
PErsistnece logic with out using SQL queries ...
note: JDBC is not outdated becoz Hibernate, Spring JDBC and other orm f/w
still internally used JDBC... Developer
Spring 108
"A and etc.
Spring Web
=> This module provides plugins to make our spring Apps interactable or communicatable
from web framework Apps like Struts Apps, JSF Apps, Webwork Apps and etc....
=> Plugin is a small /patch s/w or code that provides addtional functionalities to existing s/w or
code.
Sturts App/JSF App/
WebWork App
(itis outdated ~~ becoz Struts,J5F are outdated to develop
web applications. more ever developer are using spring web MVC module
inthat place)
‘Spring MVC /Spring Web MVC
Itis spring's direct framework to develop MVC architecture based web applications as alternate
to JSF,Struts and webwork frameworks...
=>Spring MVC provides better and more features in web application development compare to
Struts , JSF..
Spring JEE/SpringContext
=>This provides abstraction on multiple modules to simplifiy different types application
developent..
plain jndi and Spring Jndi
indi —> java naming and directory interface...
=> To provide global visibility to java objects they need to be placed in Indi registry... To interact
with Jndi registry from our Java Apps .. we take suport of Jndi api
Indi registry
(‘coay | googiePayonje}}ret We can keep any object in jn registry.
but we generally keep Distributed App
[om | cot taps bec
they need to have visbitity in order get
[eevee | Paypal Comp re accessed by remote clients.
key
(indiname/ {object/objectref)
nickname)
—->Db s/w (oracle,mysql and etc...)
> Indi registry (rmi registry, cos registry, tomcat registry)
I latest servers like web logic ,glassfish ,wildifly are having their own
registries)
provides abstraction on plain jndi technology and simplifies
indi code development.
{indi or spring jndi we perform following operations on jndi registry
bind operation :: keeping object/object ref in jndi registry having nick name/jndi name
rebind operation:: replacing existing object/object ref with new object /object ref
unbind operation :: removing object/object ref from jndl registry
lookup operation :: searching and getting object/object ref from jndl registry based
on the given nickname/jndi name...
plain RMIEJB and Spring RMI, EJB
RMI £8 are distributed Technlogies to develop Apps/Objects/comps Distributed Apps/
Objetets/Comps ..
‘The Objects/Comps/Apps whose services/methods can be invoked from remote clients are
caled Distributed Objects/comps/apps
eg:: PhonePe , PayPall , BSE stock comp and etc..
note:: after developing Distributed App /comp/object it will be placed in jndi registry
for global visvibility for remote clients... Machine10
Remote client!
(Like (flipkart.com)
network
dopa ones
000);
paypalcompref.
®
(MachineI00y—~ jookup
aypal_| PaypalComp fef|
|
=>we can not call methods of ordinary/normal class obj (RMI ,EJB not envolved) from
remote clients.. though its obj ref is kept in jndi registry
-we can call methods of Distributed Comp/class obj (RMI,EJB) from remote clients.
keeping its obj ref in jndi registry...
=>Spring RMI Provides abstraction on plain RMI Technology and simplifies Distributed App devieopment
=>spring EJB providestr abstraction on plain EJB technology and simplifies EJB App development ...
note: RMI,£JB both are outdated. to develop Distriobuted Apps ,, So spring rmi,EJB are aslo outdate
note: WebServices is best option to develope distributed Apps...
Java Mail and Spring Mail
Email accoutns and email messages will not mainted in DB s/w .. They will be managed
in sperated mail servers..
eg:: James Mail server , MS exchange server , Smtp One Server .. and etc.
Java App
“ ‘App
forms mail operations like
sending mail with /with out attachment,Spring AOP
AOP —> Aspect Oriented Programming
AOP is not replacement for OOP .. infact it compliments OOP ...1.e itis built on the top of OOP.
=> The logics that are minimum and mandatory to complete the tasks in Application are called
primary logics
wart Banking Apps
withdraw money ,deposite money, transfer money , opening account and etc... primary logics
=> The logics that are addtional ,optional in Application devieopment , but useful to make apps more
Perfect and accurate are called secondary logics.. ie our Apps can be executed with out secondary logics...
but primary logics are must...
eg: Logging (keeps track App's flow) ~
‘Auditing (keeps track User's flow)
Security ( Authentication +Authorization)
Transaction Management ( Executes logics by applying do everything or nothing pr
and etc...
itis noway related to logi
Problem with OOP style programming
> here in the methods of classes we mix up both primary and secondary logi
public class BankService{
public String withdraw(long acno ,float amount){
security logic
= secondary logics
// Logging logic .
H1duditing logic
balance=balance-amount; | Primary logics
,
public String deposite (long acno float amount){
Hsecurity logics
Heats secodary logics
Hassiting logics
balance=balancetamount; | Primary logic
Limitations of oop style progamming
{a) Primary and secodnary logics are mixedup i.e there is no clean st
(b) Secondary are not reusable across the multiple methods of multiple classes.
{€) To siabié or Hteab la. Secondary togscs on primary loglés. aba need to ftserut thi
source code... if Client Org is not access to source code after release of project..
then would be big problem..
(A) overall looks very clumzy .... JSE ~>jar 2 exe Tool can be used
to encrypt .class files...
Solution using AOP
AOP is a methodoly of programming , that say seperate secondary logic primary logics... and give
them AP enabled S/w like spring AOP/AspectjAOP/JbossAop and etc... to generate Dynamic class
at rutime having both primary logics and secondary mixedup.
public class Logging( ecurity{
Main Class
public class BankService{
public String withdraw(long acno , float amount){
balance=balance-amount; //primary logic
return...
}
Public String deposite(Te
balance=balance+amo
1cno , float amount){
: [Iprimary logic
return
Xml file_or annoations
{Spring AoP/AspeclaoP/
JbossAOP)
GEnerates Intemory Proxy
class (in the JM memory of RAM) having both primary and
secondary log|cs
public class BankServiceSProxy extends BankService {
public String withdraw(long acno, float amount}{
logging logics
logics
security logics
t
public String deposite,(tong acno, float amount){
logging logics
auditing logics,
security logics
Hprimary logics
balance=balancetamount;
,
Advantages of AOP style programming
{a) Code is not clumzy becoz primary and secondary logics are seperated
{b) Secondary logics are reusable across the multiple primary logics of multiple methods in multiple classes
(c) We can enable or disable Secondary logics on primary logics with out distrubing source code .. only by
giving instructions to AP enabled S/w through xm! file or Annotations
{d) We can add new Secondary logics on primary logics dyamically...Explain POJI,POJO class, Java Bean class , Bean class/component class and Spring Bean class?
POJO class (Plain Old Java Object class)
> Normal /simple /ordinary java classes with out any specilaties is called POJO class
=> The java class that is not extending or implementing technology /framework specific/api
classes or interfaces is called POJO clas:
=> POJO class is not against of inheritering from class and also not agaist implementing
interfaces .. It is against of extending technology /framework api classes and it is also
against of implementing technology/framework api interfaces..
=> Generally we can compile POJO classes by using the support of jdk libraries
no need of any technology /framwork api libraries (jar files) in the classpath.
class Test {
+
"Test" is POJO class
class Test implements Serializable{
|+{part of jdk apis)
"Test" is POJO class
class Test implements java.sql.Connection{
(itis part of jdbc technology api)
fest" is not a POJO class
class Test implements java.rmi.Remote{_
: (part of RMI Technology api)
}
"Test" is not a POJO class
class Test extends javax.servlet.GenericServiet{
(part of servibechnology)
"Testis not a POJO class"
class Test extends Thread{
(part of jdk/java lang api)
‘ops, exeception handling,
networking api, 10 streams , utility api, collections,
a POO class” awt swings, applets, reflection api ,multil threading
and etc.. concepts /apis are part of java language or
jdk libraries...
class Test extends Demo{ class Demo{
} }
“Test","Demo" classes are POJO classes
Anse Teeitentenits Dowel class Demo implements javax.serviet.Serviet{
sst","Demo" classes are not POJO classes...
class Test{
public void mi(}{
jdbc cod
Mi ee le
} hibernate code
“Test is POJO class , But class can not be compiled by using jdk libraries...
‘@Remote ~>given by EJB api
class Test
}
“Test is POJO class , But we can not compile this only using jdk libraries in classpat!
POI (Plain Old Java interface)
Itis an ordinary /simple /normal java interface with out any specialitie:
Itis an interface that does not extend from Technology/framework api interfaces.
eno need adding
=> generally this interface can be compiled by using jdk libraries.
third party libraries to classpath...
interface Demo{
"Demo" is POJ!
interface Demo extends java.
. part of java lang api /jdk libraries
}
"Demo" is POI!
interface Demo extends java.rmi.Remote{
part of RMI Technology
interface Demo extends Demol{
}
Demo,Demol are POJIs
interface Demo extends Demol{
‘Demo1" are not POIIs..
@local —> part of EJB api
interface Demo{
}
"Demo" is POJI... but "Demo" can not be compiled using only having jdk libraries in
classpath..
Spring is Light weight ... becoz_ spring support POJO-POII model programming...
note: The target and Dependent classes we take as spring Beans to perform Dependency
Management .. can be taken POJO classes...
Java Bean class
==> Refere previous classes...
note:: every Java bean class is POJO class... but every POJO class is not a java bean.
Bean class /Component class
=>The perfectly designed java class that is having both state (member variables)
and reusable behaviour (methods ) and state is also used in behaviour (methods) is called
Bean class or Component class..
public class Bankserivee {
private String brachName;
private String ifscCode;
private String location;
state
public String withdraw(long acno, float amount){
(b.logicy //state will be used here
p77 return.
public String deposite(long acno,float amount}{
‘J /state will be used here
return
public String transferMoney(long srcAcno, long destAcno, float amount}{
/{state will be used hre..
return.
}
}
note:: Bean class /component class can be developed as POJO class or
non -pojo class... based on the requirement..
Spring Bean
=>The java class whose object is created and managed by spring container... ie whose life
cycle is managed by spring container is called Spring bean.
=>Spring bean can be a pre-defined class ,uuser-defined class or third party supplied class...
=>we can take POJO class, java bean class component classes also as spring beans....
=> To make java class as spring bean class it must be configured (details must be
specified! ‘bean configuration file.. or configure using
annotations.
Spring Apps can be developed in 4 approaches
=>Any .xml of any location can be specified as (4) (a) using xml driven configurations
springbean cig file while cresting springcontainer..in (2) (6) Using Annotation driven configurations
cur spring Applcitn..butitisrecomended te take (3). Using lava code driven Configurations
applica ntext.xm! as spring bean cfg file » (1) (d) spring Boot driven configurations
note:: opplicationContextaml ais mo way elated oul cee aide oo
to ApplicationContext spring container... vl ec em ine far epg a
to underlying server or container or framework
note:; While working with both BeanFactory and or JVM is called configuration
ApplicationContext containers, it is recomanded
to applicationContext.xml as the spring bean
cfg file..
applicationContext.xml (Spring bean file)
I" wg" class=""com.nt.beans.WishMessageGenerator"/>
fully qualifies class name:
can we develope Spring bean as POJO class? yes
Every POJO class is spring bean? no (we should cfgin xml file)
every Java Bean is POJO class ? yes
comp class can be taken spring bean ? yes
Every Spring bean must be a compoment class ? no
We can java class as spring bean with out using xml, annotations ? no
Spring youtube.com/nareshit
= natarazjavaarena
[email protected]
type i: Java based Application framework
version :: 5.2.7 (compitable with jdk1.8+ ——> javal4.x)
vendor :: Interface21 (pivotal team)
creator :: Mr. Rod Jhonson
Open soruce framework
To download s/w :: download from repo.spring.io as zip fil
(dist)
To install spring :: extract zip file..
\docs folder gives api docs , ref docs
g_home>\libs folder gives spring libraries of diff modules (jar files)
\schema folder gives. xsd files (xml schema definitations) as rules
to develop spring bean files for diff spring modules
Whats Spring? Define Spring?
spring is an opensource , light weight ,loosely coupled, Aspect oriented, non-invasive ,
Dependecy Management based Java Application framework given by pivotal team of,
interface21 company to develope various Java JE Apps in simplified manner by providing
abstraction on various java, jee Technolgies and java frameworks .What is Spring? Define Spring?
spring is an opensource , light weight ,loosely coupled, Aspect oriented, non-invasive,
Dependecy Management based Java Application framework given by pivotal team of
interface21 company to develope various Java ,JEE Apps in simplified manner by providing
abstraction on various java, jee Technolgies and java frameworks .
opensource
‘Spring framework is not only free and we will get its source code along with installation...(extracting zp file)
This spring as an open source framework.
‘= «Spring_home>\libs folder contains jars
representing bycodes of spring modules (-.release.
docs of spring modules (cname>-cver>.telease-javadocs jar)
source code of spring modules (-cver>.release-sources jar)
lightweight
"= spring framework Is released as zip file having less size
‘= Spring framework supplied containers are lightweight containers
->By just creating object for predefined that implements BeanFactory(!),we can create
BeanFactory container
€€: _//Hold the name and location of spring bean cfg file
Resource ressnew FileSystemResource("/applicationContext.xm");
FllesystemRe¥ource Is the Impl of
Resouree(I) that interally uses to java.io.File
class to hold the name and location of,
J {create BeanFactory container strensprins beeniris Be
BeanFactory factory=new XmiBeanFactory(res);
note:: Servit container, jsp containers are heavy weight... Becoz we can not crerate/start
programatically... we need start the web server Application server in order to Arraylist aenew ArrayList); (bed)
star ServietContalaner/jsp container. but Webserver /Applcation serveris heavy weight Ustalenew ArrayList! (ggg)
alznew Vector}
to Install and to start.
Loosely coupled
if the degree of dependency is less between comps then they are called lightly coupled..
if the degree of dependency is more between comps then they are called tightly coupled...
‘pring framework is loosely coupled the reasons are
=> Spring framework is given in the form of modules having less dependency with each other
=> We can develop spring Apps by using our choice no.of modules .. by adding libraries
of required modules
= Spring App development supports lots of interface model programming..
=> Spring comps can be developed as POJO classes and POUIS with out having any
Dependency with spring apis.
and ete.
‘Aspect oriented
‘==> AOP style programming is all about seperating secondary logics from primary logics during the developing
but mixing them dynamically at runtime...
= Spring frameworks gives support for spring AOP, Aspect] AOP_ approaches to develop Aop style Applications...
‘The classes of Spring App development can be developed with out having any tight coupling with Spring API
that means we can develope them ordinary classes /intrfaces .. (POJOS and POlIS) ,So we can move
to another frameworks or technologies of java... where ever we want.. This make spring framework
8 non-invasive.
Dependency Mananagement
‘= Itall about arranging and giving Dependent class object to Target class object. so target class
‘can use dependent class services.
Two ways of Dependency Management
(2) Dependency Lookup (b) Dependency Injection.
(2) Dependency Lookup
Here TArget class writes some logics and spends some time to search and get the
required Dependent class object.
‘egli: Student (target) asking for course material (Dependent) and getting from Wareshit Employee
‘96213 Our app getting objects from jndi registry by writing jndi lookup code...
Appl.java (Target class) IndiRegistry
or
label [er Svar
+ vmain(ting rest 4a source aif
1] create tnitalContext object denendencr lun
InitialContext ie=new initiatcontext(); ~~ ee esas
‘perform lookup operation
DataSource ds=(OataSource]ic.
Huse ds initiate
initialContext obj represents connectivity
b/w Java App and Jndi registry... Its ike
r Jdbe con object that represents connection
; b/w java App and Db s/w
note:: In dependency lookup target pulls the dependent from different places... and keeps it ready
for taget to use..
pros and cons of Dependency lookup
pres
‘= Target can search and get only required dependent class objs
‘>The Target class should write some logic and should spend some to search and get.
Depdendent class objects.
bb) Depdency injection
‘Here the undelrying server /container/framework /JVM and etc... assigns/ injects depedent class
object to target class object...dynamically.
=> Here Dependent is pushed to target by underlying server/container/1VM/ framework and ete...\
‘STudent getting course material the momnent he joins for the course..
ServietContainer injects/assigns Servietcontig object to our serviet class object the moment
Servlet class object created
eg3:: JVM calls constructor automatically to assign initial values to object by calling constructor
the moment object is created
@Resource(-) annotation gets Dependent obj from Indi registry and assigns/Injects to
‘our servlet class object dynamically.
ros
‘= Target class need not to write logics or need not spend time to get the dependents.
‘> The undeluing server /container/framwork/IVM and etc...may inject both neccessary and
unnecessary dependents...
note: Spring supports both Dependency lookup and injection...