BeanNameAware and BeanFactoryAware

This commit is contained in:
mherbaghinyan 2018-04-25 22:13:50 +04:00
parent c1e0b884de
commit 4b91a76d8f
5 changed files with 50 additions and 0 deletions

View File

@ -74,6 +74,11 @@
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
<build>

View File

@ -4,4 +4,8 @@ package com.baeldung.aware;
* Created by Gebruiker on 4/24/2018.
*/
public class AwareExample {
public static void main(String[] args) {
}
}

View File

@ -0,0 +1,7 @@
package com.baeldung.aware;
import org.springframework.context.annotation.Configuration;
@Configuration
public class Config {
}

View File

@ -0,0 +1,20 @@
package com.baeldung.aware;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
/**
* Created by Gebruiker on 4/25/2018.
*/
public class MyBeanFactory implements BeanFactoryAware {
private BeanFactory beanFactory;
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
System.out.println(beanFactory);
}
}

View File

@ -0,0 +1,14 @@
package com.baeldung.aware;
import org.springframework.beans.factory.BeanNameAware;
/**
* Created by Gebruiker on 4/25/2018.
*/
public class MyBeanName implements BeanNameAware {
@Override
public void setBeanName(String beanName) {
System.out.println(beanName);
}
}