title: Spring equivalent of EJB Singleton to maintain the state
body: <p>Currently I'm working on a JSF2 + Spring application. And I need to have one component, which I would be able to autowire when needed and read/write the state (safely) from/to it.</p>
  
  <p>In EJB I would do it as follows:</p>
  
  <pre><code>@Singleton
  @ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
  public class LocaleManager {
  
    private String currentLanguage;
  
    @Lock(LockType.READ)
    public String getCurrentLanguage() {
      return currentLanguage;
    }
  
    @Lock(LockType.WRITE)
    public void setCurrentLanguage(String currentLanguage) {
      this.currentLanguage  = currentLanguage;
    }
  
  }  
  </code></pre>
  
  <p>How can I achieve this in Spring? Thanks!</p>
  
  <p><strong>EDIT:</strong> One important thing is that application has multiple Maven modules and I need this in "core" module which doesn't depend on spring-web. I need the language information in DTO assemblers, where I would like to use only string values relevant to the current locale set in JSF. Entity has a set of translations for various languages (each DB table has own translation table). In the corresponding DTO I would like to have just e.g. "String description", instead of "Set<code>&lt;ItemTranslation&gt;</code> description".</p>