/** * Find the root {@link WebApplicationContext} for this web app, typically * loaded via {@link org.springframework.web.context.ContextLoaderListener}. * <p>Will rethrow an exception that happened on root context startup, * to differentiate between a failed context startup and no context at all. * @param fc the FacesContext to find the web application context for * @return the root WebApplicationContext for this web app, or {@code null} if none * @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE */ @Nullable public static WebApplicationContext getWebApplicationContext(FacesContext fc) { Assert.notNull(fc, "FacesContext must not be null"); Object attr = fc.getExternalContext().getApplicationMap().get( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (attr == null) { return null; } if (attr instanceof RuntimeException) { throw (RuntimeException) attr; } if (attr instanceof Error) { throw (Error) attr; } if (!(attr instanceof WebApplicationContext)) { throw new IllegalStateException("Root context attribute is not of type WebApplicationContext: " + attr); } return (WebApplicationContext) attr; }
public static Map<Class<? extends Annotation>, Set<Class<?>>> get(final ExternalContext extContext) { Map<String, Object> appMap = extContext.getApplicationMap(); if (appMap.get(ANNOTATION_MAP_CONVERTED) != null) { return (Map<Class<? extends Annotation>, Set<Class<?>>>)appMap.get(FACES_ANNOTATIONS_SC_ATTR); } else { appMap.put(ANNOTATION_MAP_CONVERTED, Boolean.TRUE); return convert((Map<Class<? extends Annotation>, Set<Class<?>>>)appMap.get(FACES_ANNOTATIONS_SC_ATTR)); } }
public static void setCurrentInstance(final PrimeApplicationContext context, final FacesContext facesContext) { facesContext.getExternalContext().getApplicationMap().put(INSTANCE_KEY, context); if (facesContext.getExternalContext().getContext() instanceof ServletContext) { ((ServletContext) facesContext.getExternalContext().getContext()).setAttribute(INSTANCE_KEY, context); } }
public RepositoryNode() { ExternalContext externalContext = FacesContext.getCurrentInstance() .getExternalContext(); Map<String, Object> applicationMap = externalContext .getApplicationMap(); this.repository = (ReportRepository) applicationMap .get("reportRepository"); }
public static void setStateCacheProviderFactory(ExternalContext ctx, StateCacheProviderFactory instance) { ctx.getApplicationMap().put(FACTORY_KEY, instance); }
/** * <p> This method clears the cached global {@link ComponentType}s.</p> */ public static void clearGlobalComponentTypes(FacesContext ctx) { if (ctx == null) { ctx = FacesContext.getCurrentInstance(); } if (ctx != null) { ctx.getExternalContext().getApplicationMap().remove(CT_MAP); } }
public PrimeEnvironment(FacesContext context) { this(); this.mojarra = context.getExternalContext().getApplicationMap().containsKey("com.sun.faces.ApplicationAssociate"); Class<?> portletContext = LangUtils.tryToLoadClassForName("javax.portlet.PortletContext"); if (portletContext != null) { portlet = portletContext.isInstance(context.getExternalContext().getContext()); } }
public static void setInjectionProviderFactory(InjectionProviderFactory instance) { FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().put(FACTORY_KEY, instance); }
@SuppressWarnings("unchecked") private Map<Class<?>, Object> getFactoryExtensionCache(ExternalContext externalContext) { Map<String, Object> applicationMap = externalContext.getApplicationMap(); Map<Class<?>, Object> factoryExtensionCache = (Map<Class<?>, Object>) applicationMap.get( FACTORY_EXTENSION_CACHE); if (factoryExtensionCache == null) { factoryExtensionCache = new HashMap<Class<?>, Object>(); applicationMap.put(FACTORY_EXTENSION_CACHE, factoryExtensionCache); } return factoryExtensionCache; }
/** * Find the root {@link WebApplicationContext} for this web app, typically * loaded via {@link org.springframework.web.context.ContextLoaderListener}. * <p>Will rethrow an exception that happened on root context startup, * to differentiate between a failed context startup and no context at all. * @param fc the FacesContext to find the web application context for * @return the root WebApplicationContext for this web app, or {@code null} if none * @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE */ @Nullable public static WebApplicationContext getWebApplicationContext(FacesContext fc) { Assert.notNull(fc, "FacesContext must not be null"); Object attr = fc.getExternalContext().getApplicationMap().get( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (attr == null) { return null; } if (attr instanceof RuntimeException) { throw (RuntimeException) attr; } if (attr instanceof Error) { throw (Error) attr; } if (!(attr instanceof WebApplicationContext)) { throw new IllegalStateException("Root context attribute is not of type WebApplicationContext: " + attr); } return (WebApplicationContext) attr; }
/** * <p> Setter for the debug flag. Sets {@link #DEBUG_FLAG} equal to * <code>flag</code> in application scope.</p> */ public static void setDebug(FacesContext ctx, boolean flag) { ctx.getExternalContext().getApplicationMap(). put(DEBUG_FLAG, flag); }
/** * <p> This method clears cached global application * {@link HandlerDefinition}s.</p> */ public static void clearGlobalHandlerDefinitions(FacesContext ctx) { if (ctx == null) { ctx = FacesContext.getCurrentInstance(); } if (ctx != null) { ctx.getExternalContext().getApplicationMap().remove(HD_MAP); } }
public static void setLifecycleProviderFactory(LifecycleProviderFactory instance) { FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().put(FACTORY_KEY, instance); }
public static MyfacesConfig getCurrentInstance(ExternalContext extCtx) { MyfacesConfig myfacesConfig = (MyfacesConfig) extCtx .getApplicationMap().get(APPLICATION_MAP_PARAM_NAME); if (myfacesConfig == null) { myfacesConfig = createAndInitializeMyFacesConfig(extCtx); extCtx.getApplicationMap().put(APPLICATION_MAP_PARAM_NAME, myfacesConfig); } return myfacesConfig; }
public static PrimeApplicationContext getCurrentInstance(FacesContext facesContext) { if (facesContext == null || facesContext.getExternalContext() == null) { return null; } PrimeApplicationContext applicationContext = (PrimeApplicationContext) facesContext.getExternalContext().getApplicationMap().get(INSTANCE_KEY); if (applicationContext == null) { applicationContext = new PrimeApplicationContext(facesContext); setCurrentInstance(applicationContext, facesContext); } return applicationContext; }
public void saveToScope(FacesContext context, String key, Object value) { Map applicationMap = context.getExternalContext().getApplicationMap(); applicationMap.put(key, value); }
/** * <p> This method clears the cached global {@link Resource}s.</p> */ public static void clearGlobalResources(FacesContext ctx) { if (ctx == null) { ctx = FacesContext.getCurrentInstance(); } if (ctx != null) { ctx.getExternalContext().getApplicationMap().remove(RES_MAP); } }
public static AuxUploadSetup getInstance() { ExternalContext externalContext = FacesContext.getCurrentInstance() .getExternalContext(); AuxUploadSetup auxUpload = (AuxUploadSetup) externalContext .getApplicationMap().get(AUX_UPLOAD); return auxUpload; }
@Override public StateCacheProvider getStateCacheProvider(ExternalContext externalContext) { StateCacheProvider stateCacheProvider = (StateCacheProvider) externalContext.getApplicationMap().get(STATE_CACHE_PROVIDER_INSTANCE); if (stateCacheProvider == null) { stateCacheProvider = createStateCacheProvider(externalContext); externalContext.getApplicationMap().put(STATE_CACHE_PROVIDER_INSTANCE, stateCacheProvider); } return stateCacheProvider; }
protected void initValidateEmptyFields(FacesContext context, PrimeEnvironment environment) { ExternalContext externalContext = context.getExternalContext(); String param = externalContext.getInitParameter(UIInput.VALIDATE_EMPTY_FIELDS_PARAM_NAME); if (param == null && externalContext.getApplicationMap().containsKey(UIInput.VALIDATE_EMPTY_FIELDS_PARAM_NAME)) { Object applicationMapValue = externalContext.getApplicationMap().get(UIInput.VALIDATE_EMPTY_FIELDS_PARAM_NAME); if (applicationMapValue instanceof String) { param = (String) applicationMapValue; } else if (applicationMapValue instanceof Boolean) { validateEmptyFields = (Boolean) applicationMapValue; // already initialized - skip further processing return; } } if (param == null) { // null means the same as auto. param = "auto"; } else { // The environment variables are case insensitive. param = param.toLowerCase(); } validateEmptyFields = (param.equals("auto") && environment.isBeanValidationAvailable()) || param.equals("true"); }