private static boolean isCDIApp() { ServletContext ctx = (ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext(); return Boolean.parseBoolean(ctx.getInitParameter(JSFDependencyProcessor.IS_CDI_PARAM)); }
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 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 PrimeApplicationContext(FacesContext context) { this.environment = new PrimeEnvironment(context); this.config = new PrimeConfiguration(context, environment); if (this.config.isBeanValidationEnabled()) { this.validatorFactory = Validation.buildDefaultValidatorFactory(); this.validator = validatorFactory.getValidator(); } enumCacheMap = new ConcurrentHashMap<>(); constantsCacheMap = new ConcurrentHashMap<>(); if (environment.isPortlet()) { //the method is new in Porlets3.x, so we can't use it now //applicationClassLoader = ((PortletContext) context.getExternalContext().getContext()).getClassLoader(); applicationClassLoader = LangUtils.getContextClassLoader(); } else if (context.getExternalContext().getContext() instanceof ServletContext) { applicationClassLoader = ((ServletContext) context.getExternalContext().getContext()).getClassLoader(); } }
return getExternalContext().getContext();
return getExternalContext().getContext();
this.uniqueImageFileName = getOrGenerateItSomehow(); byte[] imageContent = convertBase64ToByteArraySomehow(); ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); ServletContext sc = (ServletContext) ec.getContext(); File image = new File(sc.getRealPath("/images"), uniqueImageFileName); // Write byte[] to FileOutputStream on that file the usual way (and close!)
@Bean("application") @ConditionalOnMissingBean(name = "application") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS) public Object application() { return FacesContext.getCurrentInstance().getExternalContext().getContext(); }
public static void setCurrentInstance(final ApplicationContext 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); } }
/** * <p>The default behavior of this method is to * call {@link ExternalContext#getContext} * on the wrapped {@link ExternalContext} object.</p> * * @see javax.faces.context.ExternalContext#getContext() */ @Override public Object getContext() { return getWrapped().getContext(); }
@Override public Object getContext() { return getWrapped().getContext(); }
/** * <p>The default behavior of this method is to * call {@link ExternalContext#getContext} * on the wrapped {@link ExternalContext} object.</p> * * @see javax.faces.context.ExternalContext#getContext() */ @Override public Object getContext() { return getWrapped().getContext(); }
public void handle(String name, Object bean, FacesContext context) { synchronized (context.getExternalContext().getContext()) { context.getExternalContext().getApplicationMap().put(name, bean); } }
@Override public Object getValue(ELContext context) { return externalContext(context).getContext(); }
/** * <p>The default behavior of this method is to * call {@link ExternalContext#getContext} * on the wrapped {@link ExternalContext} object.</p> * * @see javax.faces.context.ExternalContext#getContext() */ @Override public Object getContext() { return getWrapped().getContext(); }
FactoryManagerCacheKey(FacesContext facesContext, ClassLoader cl, Map<FactoryManagerCacheKey,FactoryFinderInstance> factoryMap) { ExternalContext extContext = (null != facesContext) ? facesContext.getExternalContext() : null; Object servletContext = (null != extContext) ? extContext.getContext() : null; if (null == facesContext || null == extContext || null == servletContext) { initFromFactoryMap(cl, factoryMap); } else { initFromAppMap(extContext, cl); } }
FactoryManagerCacheKey(FacesContext facesContext, ClassLoader cl, Map<FactoryManagerCacheKey,FactoryFinderInstance> factoryMap) { ExternalContext extContext = (null != facesContext) ? facesContext.getExternalContext() : null; Object servletContext = (null != extContext) ? extContext.getContext() : null; if (null == facesContext || null == extContext || null == servletContext) { initFromFactoryMap(cl, factoryMap); } else { initFromAppMap(extContext, cl); } }
public CDIManagedBeanHandlerImpl() { ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); beanManager = CDIUtils.getBeanManager(externalContext); Object context = externalContext.getContext(); if (context instanceof ServletContext) { JsfApplicationArtifactHolder appBean = CDIUtils.lookup(beanManager, JsfApplicationArtifactHolder.class); appBean.setServletContext((ServletContext) context); } }
public ApplicationProducer() { super.name("application") .scope(ApplicationScoped.class) .create(e -> FacesContext.getCurrentInstance().getExternalContext().getContext()); }
FactoryFinderCacheKey(FacesContext facesContext, ClassLoader classLoaderIn, Map<FactoryFinderCacheKey, FactoryFinderInstance> factoryMap) { ExternalContext extContext = facesContext != null ? facesContext.getExternalContext() : null; Object servletContext = extContext != null ? extContext.getContext() : null; if (isAnyNull(facesContext, extContext, servletContext)) { initFromFactoryMap(classLoaderIn, factoryMap); } else { initFromApplicationMap(extContext, classLoaderIn); } }