Example #1
0
  public static void setCurrentInstance(ApplicationAssociate associate) {

    if (associate == null) {
      instance.remove();
    } else {
      instance.set(associate);
    }
  }
Example #2
0
  public static ApplicationAssociate getCurrentInstance() {

    ApplicationAssociate associate = instance.get();
    if (associate == null) {
      // Fallback to ExternalContext lookup
      FacesContext fc = FacesContext.getCurrentInstance();
      if (fc != null) {
        ExternalContext extContext = fc.getExternalContext();
        if (extContext != null) {
          return ApplicationAssociate.getInstance(extContext);
        }
      }
    }

    return associate;
  }