title: How to get the session object in general from within a class?
body: <p>There is a class :</p>
  
  <pre><code>@Configuration
  @ComponentScan("com.ambre.pta")
  @EnableTransactionManagement
  @PropertySources({
      @PropertySource("classpath:fr/global.properties"),
      @PropertySource("classpath:fr/main.properties"),
      @PropertySource("classpath:fr/admin.properties"),
      @PropertySource("classpath:fr/referentiel.properties"),
      @PropertySource("classpath:fr/departement.properties"),
      @PropertySource("classpath:fr/exercice.properties"),
      @PropertySource("classpath:fr/defi.properties")
  })
  public class ApplicationContextConfig {
  
      @Bean
      public static PropertySourcesPlaceholderConfigurer properties() {
          return new PropertySourcesPlaceholderConfigurer();
      }
  
      @Bean(name = "viewResolver")
      public InternalResourceViewResolver getViewResolver() {
          InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
          viewResolver.setPrefix("/WEB-INF/views/");
          viewResolver.setSuffix(".jsp");
          return viewResolver;
      }
  
      @Bean(name = "dataSource")
      public DataSource getDataSource() {
  
          BasicDataSource bds = new BasicDataSource();
  
          bds.setDriverClassName("oracle.jdbc.driver.OracleDriver");
          bds.setUrl("jdbc:oracle:thin:@localhost:1521:xe");
  
          bds.setUsername("pta");
          bds.setPassword("pta");
  
          return bds;
  
      }
  
      @Autowired
      @Bean(name = "sessionFactory")
      public SessionFactory getSessionFactory(DataSource dataSource) {
  
          LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(dataSource);
  
          sessionBuilder.scanPackages("com.ambre.pta.model");
  
          return sessionBuilder.buildSessionFactory();
  
      }
  
      @Autowired
      @Bean(name = "transactionManager")
      public HibernateTransactionManager getTransactionManager(SessionFactory sessionFactory) {
  
          HibernateTransactionManager transactionManager = new HibernateTransactionManager(sessionFactory);
  
          return transactionManager;
  
      }
  
      @Autowired
      @Bean(name = "utilisateurDao")
      public UtilisateurDAO getUtilisateurDao(SessionFactory sessionFactory) {
          return new UtilisateurDAOImpl(sessionFactory);
      }
  
  }
  </code></pre>
  
  <p>We can get the <code>request</code> object within this class by this way :</p>
  
  <pre><code>HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
  </code></pre>
  
  <p>So is there a way to get the <code>session</code> ( HttpSession ) object ?</p>