Download - Spring and dependency injection
![Page 1: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/1.jpg)
![Page 2: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/2.jpg)
![Page 3: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/3.jpg)
![Page 4: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/4.jpg)
![Page 5: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/5.jpg)
![Page 6: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/6.jpg)
![Page 7: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/7.jpg)
![Page 8: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/8.jpg)
![Page 9: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/9.jpg)
![Page 10: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/10.jpg)
![Page 11: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/11.jpg)
package com.habuma.ejb.session; import javax.ejb.SessionBean; import javax.ejb.SessionContext; public class HelloWorldBean implements SessionBean{ public void ejbActivate(){} public void ejbPassivate(){} public void ejbRemove(){} public void setSessionContext(SessionContextctx){} public void ejbCreate(){} public String sayHello(){ return"HelloWorld"; } }
![Page 12: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/12.jpg)
package com.habuma.spring; public class HelloWorldBean{ public String sayHello(){ return"HelloWorld"; } }
![Page 13: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/13.jpg)
package session.stateless; import javax.ejb.Stateless; import javax.ejb.LocalBean; @Stateless @LocalBean public class ForDemo { public String sayHello() { return "HelloWorld"; } }
![Page 15: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/15.jpg)
1. Spring Aspect-oriented programing(AOP) framework
2. Boilerplate reduction through templates
3. Spring Inverse Of Control (IOC) container
![Page 16: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/16.jpg)
1. Spring Aspect-oriented programing(AOP) framework
2. Boilerplate reduction through templates
3. Spring Inverse Of Control (IOC) container
![Page 17: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/17.jpg)
![Page 18: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/18.jpg)
public EmployeegetEmployeeById(longid){ Connectionconn=null; PreparedStatementstmt=null; ResultSetrs=null; try {
conn =dataSource.getConnection();
stmt =conn.prepareStatement( "select id,firstname,lastname,salaryfrom"+ "employee whereid=?"); stmt.setLong(1,id);
rs =stmt.executeQuery(); Employeeemployee=null;
if (rs.next()){
employee=newEmployee(); employee.setId(rs.getLong("id")); employee.setFirstName(rs.getString("firstname")); employee.setLastName(rs.getString("lastname")); employee.setSalary(rs.getBigDecimal("salary"));
}
return employee;
} catch(SQLExceptione){ } finally{
if(rs!=null){ try {
rs.close(); } catch(SQLExceptione){}
} if(stmt!=null){
try { stmt.close();
} catch(SQLExceptione){} } if(conn!=null){
try { conn.close();
} catch(SQLExceptione){} }
} return null;
}
![Page 19: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/19.jpg)
public EmployeegetEmployeeById(longid) {
return jdbcTemplate.queryForObject( "select id,firstname,lastname,salary"+ "from employeewhereid=?",
new RowMapper<Employee>(){
public EmployeemapRow(ResultSetrs, int rowNum)throwsSQLException{
Employee employee=newEmployee(); employee.setId(rs.getLong("id")); employee.setFirstName(rs.getString("firstname")); employee.setLastName(rs.getString("lastname")); employee.setSalary(rs.getBigDecimal("salary")); return employee;
} }
,id); }
![Page 20: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/20.jpg)
![Page 21: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/21.jpg)
![Page 22: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/22.jpg)
![Page 23: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/23.jpg)
![Page 24: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/24.jpg)
http://www.springsource.org/ - Home page of Spring framework. Contains documentation of how to use Spring
![Page 25: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/25.jpg)
![Page 26: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/26.jpg)
![Page 27: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/27.jpg)
![Page 28: Spring and dependency injection](https://reader030.vdocuments.us/reader030/viewer/2022020207/5558ecb0d8b42ad7138b5447/html5/thumbnails/28.jpg)