/** * Logs a warning that JMS API is available but Push/JMS integration is not enabled */ private void logWarningWhenConnectionFactoryPresent() { try { Class.forName("javax.jms.ConnectionFactory"); LOGGER.warn("JMS API was found on the classpath; if you want to enable RichFaces Push JMS integration, set context-param 'org.richfaces.push.jms.enabled' in web.xml"); } catch (ClassNotFoundException e) { } }
public void addQueue(String clientName, UIComponent component) { if (!containsQueue(clientName)) { queuesData.put(clientName, component); } else { LOGGER.warn("Queue with name '" + clientName + "' has already been registered"); } }
private void logPushFilterWarning(ServletContext servletContext) { String message; if (servletContext.getMajorVersion() >= 3) { message = "PushFilter has been deprecated, you can remove its declaration in Servlets 3 environment"; } else { message = "PushFilter has been deprecated, you should use PushServlet instead"; } LOGGER.warn(message); }
/** * Initializes AWT for dynamic image rendering */ private void initializeAWT() { try { AWTInitializer.initialize(); } catch (NoClassDefFoundError e) { LOGGER.warn(MessageFormat.format("There were problems loading class: {0} - AWTInitializer won't be run", e.getMessage())); } }
public void addQueue(String clientName, UIComponent component) { if (!containsQueue(clientName)) { queuesData.put(clientName, component); } else { LOGGER.warn("Queue with name '" + clientName + "' has already been registered"); } }
private static String getResourcePathFromRequest(FacesContext context) { String resourceName = ResourceUtils.decodeResourceURL(context); if (resourceName != null) { if (resourceName.startsWith(RICHFACES_RESOURCE_IDENTIFIER)) { return resourceName.substring(RICHFACES_RESOURCE_IDENTIFIER.length()); } else { return null; } } else { LOGGER.warn("Resource key not found" + resourceName); return null; } }
public void addQueue(String clientName, UIComponent component) { if (!containsQueue(clientName)) { queuesData.put(clientName, component); } else { LOGGER.warn("Queue with name '" + clientName + "' has already been registered"); } }
private synchronized File createOutputFile(String path) throws IOException { File outFile = new File(resourceContentsDir, path); outFile.getParentFile().mkdirs(); if (outFile.exists()) { if (outFile.lastModified() > currentTime) { log.debug(MessageFormat.format("File {0} already exists and will be overwritten", outFile.getPath())); } outFile.delete(); } if (!outFile.createNewFile()) { log.warn(MessageFormat.format("Could not create {0} file", outFile.getPath())); } return outFile; }
private void logNotFound(FacesContext context, String id) { String message = FocusManager.class.getSimpleName() + ": Component with ID '" + id + "' was not found"; LOG.warn(message); context.addMessage(null, new FacesMessage(message)); } }
private Collection<ResourceProcessor> getDefaultResourceProcessors() { Charset charset = Charset.defaultCharset(); if (!Strings.isNullOrEmpty(encoding)) { charset = Charset.forName(encoding); } else { log.warn( "Encoding is not set explicitly, CDK resources plugin will use default platform encoding for processing char-based resources"); } if (compress) { return Arrays.<ResourceProcessor>asList(new JavaScriptCompressingProcessor(charset, log), new CSSCompressingProcessor( charset)); } else { return Arrays.<ResourceProcessor>asList(new JavaScriptPackagingProcessor(charset), new CSSPackagingProcessor(charset)); } }
private void logResourceProblem(FacesContext context, Throwable throwable, String messagePattern, Object... arguments) { boolean isProductionStage = context.isProjectStage(ProjectStage.Production); if (LOGGER.isWarnEnabled() || (!isProductionStage && LOGGER.isInfoEnabled())) { String formattedMessage = MessageFormat.format(messagePattern, arguments); if (throwable != null) { LOGGER.warn(formattedMessage, throwable); } else { if (isProductionStage) { LOGGER.info(formattedMessage); } else { LOGGER.warn(formattedMessage); } } } }
public String imageUrl(String resourceName) { if ("plain".equals(getName())){ return "none"; } FacesContext facesContext = FacesContext.getCurrentInstance(); Resource resource = facesContext.getApplication().getResourceHandler().createResource(resourceName, IMAGE_LIBRARY); String resourcePath; if (resource != null) { resourcePath = resource.getRequestPath(); } else { resourcePath = "RES_NOT_FOUND"; LOG.warn("Unable to find or serve resource '" + ResourceKey.create(resourceName, IMAGE_LIBRARY) + "'"); } return String.format("url(%s)", resourcePath); }
private void logException(CSSParseException e) { String formattedMessage = MessageFormat.format("Problem parsing ''{0}'' resource: {1}", getResourceLocator(), e.getMessage()); if (LOGGER.isDebugEnabled()) { LOGGER.debug(formattedMessage, e); } else { LOGGER.warn(formattedMessage); } }
@Override public void init() { final Map<ResourceKey, ResourceMapping> result = Maps.newHashMap(); final List<String> mappingFiles = PropertiesMappingConfiguration.getMappingFiles(); for (String mappingFile : mappingFiles) { if (classpathResourceExistsForLocation(mappingFile)) { for (Entry<String, String> entry : PropertiesUtil.loadProperties(mappingFile).entrySet()) { final ResourceKey resourceKey = ResourceKey.create(entry.getKey()); final ResourcePath resourceLocation = new ResourcePath(entry.getValue()); result.put(resourceKey, new LocationBasedResourceMapping(resourceLocation)); } } else { if (!isDefaultStaticResourceMappingLocation(mappingFile)) { LOGGER.warn("Resource mapping is configured to load non-existent resource: '" + mappingFile + "'"); } } } mappings = result; }
static Map<Class<?>, LibraryFunction> parse(ClassLoader loader, URL url) { Map<Class<?>, LibraryFunction> result = Maps.newHashMap(); try { ClientSideScripts clientSideScripts = JAXB.unmarshal(url, ClientSideScripts.class); for (Component component : clientSideScripts.getComponent()) { try { Class<?> componentClass = loader.loadClass(component.getType()); Iterable<ResourceKey> resources = Iterables.transform(component.getResource(), new Function<Resource, ResourceKey>() { public ResourceKey apply(Resource from) { return ResourceKey.create(from.getName(), from.getLibrary()); } }); LibraryFunctionImplementation function = new LibraryFunctionImplementation(component.getFunction(), resources); result.put(componentClass, function); } catch (ClassNotFoundException e) { // throw new FacesException("Class for component not found", e); LOG.warn("Found JavaScript function definition for class " + component.getType() + ", but that class is not presented"); } } } catch (Exception e) { throw new FacesException("Error parsing config file " + url, e); } return result; } }
static Map<Class<?>, LibraryFunction> parse(ClassLoader loader, URL url) { Map<Class<?>, LibraryFunction> result = Maps.newHashMap(); try { ClientSideScripts clientSideScripts = JAXB.unmarshal(url, ClientSideScripts.class); for (Component component : clientSideScripts.getComponent()) { try { Class<?> componentClass = loader.loadClass(component.getType()); Iterable<ResourceKey> resources = Iterables.transform(component.getResource(), new Function<Resource, ResourceKey>() { public ResourceKey apply(Resource from) { return ResourceKey.create(from.getName(), from.getLibrary()); } }); LibraryFunctionImplementation function = new LibraryFunctionImplementation(component.getFunction(), resources); result.put(componentClass, function); } catch (ClassNotFoundException e) { // throw new FacesException("Class for component not found", e); LOG.warn("Found JavaScript function definition for class " + component.getType() + ", but that class is not presented"); } } } catch (Exception e) { throw new FacesException("Error parsing config file " + url, e); } return result; } }
@Override public void focus(String componentId) { FacesContext context = FacesContext.getCurrentInstance(); if (context == null) { throw new IllegalStateException(FocusManager.class.getSimpleName() + " can't be used without FacesContext available"); } if (componentId == null) { setContextAttribute(context, null); } else { UIComponent currentComponent = UIComponent.getCurrentComponent(context); if (currentComponent == null) { currentComponent = context.getViewRoot(); } currentComponent.findComponent(componentId); UIComponent component = RendererUtils.getInstance().findComponentFor(currentComponent, componentId); if (component == null) { String message = FocusManager.class.getSimpleName() + ": Component with ID '" + componentId + "' was not found"; LOG.warn(message); context.addMessage(null, new FacesMessage(message)); } else { String clientId = component.getClientId(context); setContextAttribute(context, clientId); JavaScriptService javaScriptService = ServiceTracker.getService(context, JavaScriptService.class); javaScriptService.addPageReadyScript(context, new JSLiteral(String.format(SCRIPT, clientId))); } } }
@Override public void focus(String componentId) { FacesContext context = FacesContext.getCurrentInstance(); if (context == null) { throw new IllegalStateException(FocusManager.class.getSimpleName() + " can't be used without FacesContext available"); } if (componentId == null) { setContextAttribute(context, null); } else { UIComponent currentComponent = UIComponent.getCurrentComponent(context); if (currentComponent == null) { currentComponent = context.getViewRoot(); } currentComponent.findComponent(componentId); UIComponent component = RendererUtils.getInstance().findComponentFor(currentComponent, componentId); if (component == null) { String message = FocusManager.class.getSimpleName() + ": Component with ID '" + componentId + "' was not found"; LOG.warn(message); context.addMessage(null, new FacesMessage(message)); } else { String clientId = component.getClientId(context); setContextAttribute(context, clientId); JavaScriptService javaScriptService = ServiceTracker.getService(context, JavaScriptService.class); javaScriptService.addPageReadyScript(context, new JSLiteral(String.format(SCRIPT, clientId))); } } }
@Override public void focus(String componentId) { FacesContext context = FacesContext.getCurrentInstance(); if (context == null) { throw new IllegalStateException(FocusManager.class.getSimpleName() + " can't be used without FacesContext available"); } if (componentId == null) { setContextAttribute(context, null); } else { UIComponent currentComponent = UIComponent.getCurrentComponent(context); if (currentComponent == null) { currentComponent = context.getViewRoot(); } currentComponent.findComponent(componentId); UIComponent component = RendererUtils.getInstance().findComponentFor(currentComponent, componentId); if (component == null) { String message = FocusManager.class.getSimpleName() + ": Component with ID '" + componentId + "' was not found"; LOG.warn(message); context.addMessage(null, new FacesMessage(message)); } else { String clientId = component.getClientId(context); setContextAttribute(context, clientId); JavaScriptService javaScriptService = ServiceTracker.getService(context, JavaScriptService.class); javaScriptService.addPageReadyScript(context, new JSLiteral(String.format(SCRIPT, clientId))); } } }
@Override public void configure(ServicesFactory factory) { factory.setInstance(ConfigurationService.class, new ConfigurationServiceImpl()); factory.setInstance(SkinFactory.class, new SkinFactoryImpl()); factory.setInstance(AjaxDataSerializer.class, new AjaxDataSerializerImpl()); factory.setInstance(ResourceCodec.class, ServiceLoader.loadService(ResourceCodec.class, DefaultResourceCodec.class)); factory.setInstance(Cache.class, new CacheProvider()); factory.setInstance(Uptime.class, new Uptime()); factory.setInstance(DependencyInjector.class, new DependencyInjectorImpl()); factory.setInstance(MessageFactory.class, new MessageFactoryImpl(new BundleLoader())); factory.setInstance(ResourceLibraryFactory.class, new ResourceLibraryFactoryImpl()); factory.setInstance(PushContextFactory.class, ServiceLoader.loadService(PushContextFactory.class, PushContextFactoryImpl.class)); factory.setInstance(JavaScriptService.class, new JavaScriptServiceImpl()); factory.setInstance(GenericsIntrospectionService.class, new GenericsIntrospectionServiceImpl()); factory.setInstance(ResourceTracker.class, new ResourceTrackerImpl()); factory.setInstance(MappedResourceFactory.class, new MappedResourceFactoryImpl()); // factory.setInstance(FocusManager.class, ServiceLoader.loadService(FocusManager.class, FocusManagerImpl.class)); factory.setInstance(ResourceMappingConfiguration.class, new ResourceMappingConfiguration()); // workaround for loading service from richfaces module (needs to be bypassed during tests) FocusManager focusManager = ServiceLoader.loadService(FocusManager.class); if (focusManager == null) { LOG.warn("There was no service " + FocusManager.class.getName() + " found"); } else { factory.setInstance(FocusManager.class, focusManager); } } }