mirror of
https://github.com/OtusTeam/Spring.git
synced 2026-05-30 10:50:42 +00:00
2024-01 spring-04-aop
This commit is contained in:
-25
@@ -1,25 +0,0 @@
|
||||
package ru.otus.spring.dao;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class DaoConfig {
|
||||
|
||||
@Bean
|
||||
Object getObject() {
|
||||
Object o = new Object();
|
||||
System.out.println("Create new: " + o);
|
||||
return o;
|
||||
}
|
||||
|
||||
@Bean
|
||||
PersonDao getPersonDao1() {
|
||||
return new PersonDaoObject(this.getObject());
|
||||
}
|
||||
|
||||
@Bean
|
||||
PersonDao getPersonDao2() {
|
||||
return new PersonDaoObject(this.getObject());
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package ru.otus.spring.dao;
|
||||
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import ru.otus.spring.domain.Person;
|
||||
|
||||
@Primary
|
||||
@Repository
|
||||
public class PersonDaoObject implements PersonDao {
|
||||
public PersonDaoObject() {
|
||||
}
|
||||
|
||||
public PersonDaoObject(Object object) {
|
||||
System.out.println("Create dao: " + this + " with " + object);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Person findByName(String name) {
|
||||
Person person = new Person(name, 18);
|
||||
System.out.println("Dao findByName: " + name + ", person: " + person);
|
||||
return person;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Person p) {
|
||||
Person byName = findByName(p.getName());
|
||||
System.out.println("Dao save: " + p + ", findByName: " + byName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user