private boolean checkResourceMarker(String resourceName) { ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); URL resourceMarkerUrl = contextClassLoader.getResource("META-INF/" + resourceName + ".resource.properties"); boolean result = (resourceMarkerUrl != null); if (LOGGER.isDebugEnabled()) { if (result) { LOGGER.debug(MessageFormat.format("Marker file for {0} resource found in classpath", resourceName)); } else { LOGGER.debug(MessageFormat.format("Marker file for {0} resource does not exist", resourceName)); } } return result; }
public ResourceHandlerImpl(ResourceHandler defaultHandler) { this.defaultHandler = defaultHandler; this.resourceFactory = new ResourceFactoryImpl(defaultHandler); if (LOGGER.isDebugEnabled()) { LOGGER.debug(MessageFormat.format("Instance of {0} resource handler created", getClass().getName())); } }
private static void sendNotModified(FacesContext context) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("User agent has actual resource copy - sending 304 status code"); } // TODO send cacheable resource headers (ETag + LastModified)? context.getExternalContext().setResponseStatus(HttpServletResponse.SC_NOT_MODIFIED); }
protected boolean isThisHandlerResourceRequest(FacesContext context) { Boolean resourceRequest = BooleanRequestStateVariable.ResourceRequest.get(context); if (resourceRequest == null) { String resourcePath = getResourcePathFromRequest(context); // TODO handle exclusions resourceRequest = (resourcePath != null) && (resourcePath.length() > 0); BooleanRequestStateVariable.ResourceRequest.set(context, resourceRequest); if (LOGGER.isDebugEnabled() && resourceRequest) { LOGGER.debug(MessageFormat.format("Resource request detected: {0}", resourcePath)); } } return resourceRequest; }
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 String getRequestPath() { FacesContext context = FacesContext.getCurrentInstance(); ResourceCodec resourceCodec = ServiceTracker.getService(context, ResourceCodec.class); String libraryName = getLibraryName(); String resourceName = getResourceName(); Object resourceData = ResourceUtils.saveResourceState(context, this); String resourceVersion = getResourceVersion(); String resourceUri = resourceCodec.encodeResourceRequestPath(context, libraryName, resourceName, resourceData, resourceVersion); resourceUri = resourceCodec.encodeJSFMapping(context, resourceUri); if (LOGGER.isDebugEnabled()) { LOGGER.debug(MessageFormat.format("Request path for {0} resource is: {1}", String.valueOf(resourceName), String.valueOf(resourceUri))); } return resourceUri; }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { // Test for correct parameters. checkForCorrectParams(context, component, "encodeEnd"); if (component.isRendered()) { ResponseWriter writer = context.getResponseWriter(); doEncodeEnd(writer, context, component); } if (LOG.isDebugEnabled()) { LOG.debug(Messages.getMessage(Messages.FINISH_ENCODING_COMPONENT_INFO, component.getClientId(context), component .getClass().getName())); } }
@Override public final void encodeChildren(FacesContext context, UIComponent component) throws IOException { // Test for correct parameters. checkForCorrectParams(context, component, "encodeBegin"); if (LOG.isDebugEnabled()) { LOG.debug(Messages.getMessage(Messages.CHILDREN_ENCODING_COMPONENT_INFO, component.getClientId(context), component .getClass().getName())); } if (component.isRendered()) { ResponseWriter writer = context.getResponseWriter(); doEncodeChildren(writer, context, component); } }
@Override public void encodeChildren(FacesContext context, UIComponent component) throws IOException { // Test for correct parameters. checkForCorrectParams(context, component, "encodeBegin"); if (LOG.isDebugEnabled()) { LOG.debug(Messages.getMessage(Messages.CHILDREN_ENCODING_COMPONENT_INFO, component.getClientId(context), component .getClass().getName())); } if (component.isRendered()) { ResponseWriter writer = context.getResponseWriter(); doEncodeChildren(writer, context, component); } }
/** * TODO optimize/review? * * @return Returns the lastModified. */ protected Date getLastModified(FacesContext context) { if (lastModified == null) { lastModified = getLastModifiedBySource(); } // TODO - originally lastModified was set during resource creation. // as resources can be managed beans this approach does not seem good if (lastModified == null) { lastModified = ServiceTracker.getService(Uptime.class).getStartTime(); if (LOGGER.isDebugEnabled()) { LOGGER .debug(MessageFormat.format( "Using resource handler start time as last modified date: {0,date,dd MMM yyyy HH:mm:ss zzz}", lastModified)); } } return lastModified; }
private Resource createMappedResource(ResourceKey resourceKey) { final FacesContext context = FacesContext.getCurrentInstance(); // do not map resources for ResourceServlet requests (they should be already mapped) if (context.getExternalContext().getRequestMap().get(ResourceServlet.RESOURCE_SERVLET_REQUEST_FLAG) == Boolean.TRUE) { return null; } Resource mappedResource = resolveMappedResource(context, resourceKey); if (mappedResource == null) { return null; } resourceTracker.markResourceRendered(context, resourceKey); ResourcePath path = new ResourcePath(mappedResource.getRequestPath()); Set<ResourceKey> aggregatedResources = mappedResourceFactory.getAggregatedResources(path); for (ResourceKey key : aggregatedResources) { resourceTracker.markResourceRendered(context, key); } if (LOGGER.isDebugEnabled()) { LOGGER.debug(String.format("Resource '%s' is redirected to following resource path: %s", resourceKey, path)); if (aggregatedResources.size() >= 1) { LOGGER.debug(String.format("Following resources are marked as rendered: %s", resourceKey, aggregatedResources)); } } return mappedResource; }
@Override public void encodeChildren(FacesContext context, UIComponent component) throws IOException { // Test for correct parameters. checkForCorrectParams(context, component, "encodeBegin"); if (LOG.isDebugEnabled()) { LOG.debug(Messages.getMessage(Messages.CHILDREN_ENCODING_COMPONENT_INFO, component.getClientId(context), component .getClass().getName())); } if (component.isRendered()) { ResponseWriter writer = context.getResponseWriter(); doEncodeChildren(writer, context, component); } }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { // Test for correct parameters. checkForCorrectParams(context, component, "encodeEnd"); if (component.isRendered()) { ResponseWriter writer = context.getResponseWriter(); doEncodeEnd(writer, context, component); } if (LOG.isDebugEnabled()) { LOG.debug(Messages.getMessage(Messages.FINISH_ENCODING_COMPONENT_INFO, component.getClientId(context), component .getClass().getName())); } }
private Resource lookupInCache(Cache cache, String resourceKey) { if (cache == null) { LOGGER.debug("No cache was provided"); return null; } Resource resource = (Resource) cache.get(resourceKey); if (LOGGER.isDebugEnabled()) { if (resource == null) { LOGGER.debug("Resource was not located in cache"); } else { LOGGER.debug("Resource was located in cache"); } } return resource; }
@Override public final void encodeEnd(FacesContext context, UIComponent component) throws IOException { // Test for correct parameters. checkForCorrectParams(context, component, "encodeEnd"); if (component.isRendered() && !isAlreadyRendered(component)) { ResponseWriter writer = context.getResponseWriter(); doEncodeEnd(writer, context, component); } if (LOG.isDebugEnabled()) { LOG.debug(Messages.getMessage(Messages.FINISH_ENCODING_COMPONENT_INFO, component.getClientId(context), component .getClass().getName())); } }
@Override public final void encodeBegin(FacesContext context, UIComponent component) throws IOException { // Test for correct parameters. checkForCorrectParams(context, component, "encodeBegin"); if (LOG.isDebugEnabled()) { LOG.debug(Messages.getMessage(Messages.START_ENCODING_COMPONENT_INFO, component.getClientId(context), component .getClass().getName())); } preEncodeBegin(context, component); if (component.isRendered()) { ResponseWriter writer = context.getResponseWriter(); doEncodeBegin(writer, context, component); } }
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { // Test for correct parameters. checkForCorrectParams(context, component, "encodeBegin"); if (LOG.isDebugEnabled()) { LOG.debug(Messages.getMessage(Messages.START_ENCODING_COMPONENT_INFO, component.getClientId(context), component .getClass().getName())); } preEncodeBegin(context, component); if (component.isRendered()) { ResponseWriter writer = context.getResponseWriter(); doEncodeBegin(writer, context, component); } }
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { // Test for correct parameters. checkForCorrectParams(context, component, "encodeBegin"); if (LOG.isDebugEnabled()) { LOG.debug(Messages.getMessage(Messages.START_ENCODING_COMPONENT_INFO, component.getClientId(context), component .getClass().getName())); } preEncodeBegin(context, component); if (component.isRendered()) { ResponseWriter writer = context.getResponseWriter(); doEncodeBegin(writer, context, component); } }
@Override public final void decode(FacesContext context, UIComponent component) { // Test for correct parameters. checkNull(context, component, "decode"); if (!getComponentClass().isInstance(component)) { throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR, "", getComponentClass() .getName())); } if (LOG.isDebugEnabled()) { LOG.debug(Messages.getMessage(Messages.START_DECODING_COMPONENT_INFO, component.getClientId(context), component .getClass().getName())); } preDecode(context, component); // TODO - create set od common decoders ( UIInput, ActionSource etc. ) for process decoding. if (component.isRendered()) { String behaviorEventName = RenderKitUtils.decodeBehaviors(context, component); if (behaviorEventName != null) { queueComponentEventForBehaviorEvent(context, component, behaviorEventName); } doDecode(context, component); } }
@Override public void decode(FacesContext context, UIComponent component) { // Test for correct parameters. checkNull(context, component, "decode"); if (!getComponentClass().isInstance(component)) { throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR, "", getComponentClass() .getName())); } if (LOG.isDebugEnabled()) { LOG.debug(Messages.getMessage(Messages.START_DECODING_COMPONENT_INFO, component.getClientId(context), component .getClass().getName())); } preDecode(context, component); // TODO - create set od common decoders ( UIInput, ActionSource etc. ) for process decoding. if (component.isRendered()) { String behaviorEventName = RenderKitUtils.decodeBehaviors(context, component); if (behaviorEventName != null) { queueComponentEventForBehaviorEvent(context, component, behaviorEventName); } doDecode(context, component); } }