Spring
Spring
Application Context -> represents IOC Container , also has bean factory
->> ***ClassPathXMLApplicationContext*** -- it searches for xml config. in
java classPath
->> AnnotationConfigApplicationContext
->> FileSystemXMLApplicationContext
Q. Where we declare beans and its dependency -> in XML file , <beans> </beans>
/*
--> adding dependecies
in the pom.xml file --
declare all the dependecies , like spring-core , spring-context(version
should be same for both
*/
/* creating beans --> these are made in configuration.xml file ( refer docs of
spring)
** beans is like object -> when we need some object in some class throught this
bean it is automatically passed
or
<bean class="" name="objectName" p:dataMemberName="its value"/>
*/
/*
pulling object in main class using beans
-----------------------------------------------------
------------------------------------------------------
init() -> ........ -> destroy(); // can change names of these methods
*** Annotation
@PostConstruct
@PreDestroy
***
----------------AutoWiring-----------------------
-> only works for object types(automaticaly inject depedencies/without xml
files)
-> not works on primitive and string
can be done in two ways ->
XML -> (does not autorewire)(default), byName, byType, constructor
Annotations -> @Autowired
@Autowired
used before will be called , ( constructor , setter, property)
@Qualifier("objectName") // name of injecting object
--------------------------------------------------------------------
Ex.
<util:List id="" class="java.util.LinkedList">
<value></value>
</util:List>
-> in bean <property name="" ref="idName"/>
------------------------------------------------------------
**************stereotype annotations*********************
----------------------------------------------------------------------
*******************************Bean Scope******************
Syntax -> @Component , @Scope("prototype")
1. Singleton
2. prototype
3.request // web
4.session // web
5.globalsession // portlet application
1. Singleton -> every time spring gives same object when bean is called
2. proptotype -> create a new object every time
****************************************************************
***************************************************************
**********************************************************************
Spring JDBC
It is API to perform operation with database , class JdbcTemplate
***********************************************************************************
***********************************************************************************
**
**********************************************************************************
***********************************************************************************
**********