Skip to content

Instantly share code, notes, and snippets.

@iifast1
Created December 20, 2021 08:10
Show Gist options
  • Save iifast1/6743d71cf4df24c995fafd26e6f72cf5 to your computer and use it in GitHub Desktop.
Save iifast1/6743d71cf4df24c995fafd26e6f72cf5 to your computer and use it in GitHub Desktop.
La création des beans et la configuration de l’injection de dépendances - par java [ S4 ] : https://github.com/iifast1/TPs-SpringBoot-4SAE8/blob/main/tp1-spring-injection-xml/esponline/config/BeansConfiguration.java
package tn.esprit.esponline.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tn.esprit.esponline.control.UserControlImpl;
import tn.esprit.esponline.dao.UserDAOImpl;
import tn.esprit.esponline.service.UserServiceImpl;
/* Use @Configuration annotation to tell spring AnnotationConfigApplicationContext that this class is bean configuration java class. */
@Configuration
public class BeansConfiguration {
@Bean(name="userControl")
public UserControlImpl getUserControl()
{
UserControlImpl uc = new UserControlImpl();
uc.setUserService(getUserService());
return uc;
}
@Bean(name="userService")
public UserServiceImpl getUserService()
{
UserServiceImpl us = new UserServiceImpl();
us.setUserDAO(getUserDAO());
return us;
}
@Bean(name="userDAO")
public UserDAOImpl getUserDAO()
{
UserDAOImpl ud = new UserDAOImpl();
return ud;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment