ro.isdc.wro.model.resource.locator
Class ServletContextUriLocator

java.lang.Object
  extended by ro.isdc.wro.model.resource.locator.wildcard.WildcardUriLocatorSupport
      extended by ro.isdc.wro.model.resource.locator.ServletContextUriLocator
All Implemented Interfaces:
UriLocator

public class ServletContextUriLocator
extends WildcardUriLocatorSupport

UriLocator capable to read the resources relative to servlet context. The resource reader will attempt to locate a physic resource under the servlet context and if the resource does not exist, will try to use requestDispatcher. This kind of resources will be accepted if their prefix is '/'.

Author:
Alex Objelean

Field Summary
static String PREFIX
          Prefix for url resources.
 
Constructor Summary
ServletContextUriLocator()
           
 
Method Summary
 boolean accept(String uri)
          Check if this uri can be located by concrete implementation.
static boolean isProtectedResource(String uri)
          Check If the uri of the resource is protected: it cannot be accessed by accessing the url directly (WEB-INF folder).
static boolean isValid(String uri)
          Check if a uri is a servletContext resource.
 InputStream locate(String uri)
          Locates the uri by retrieving the InputStream.
 
Methods inherited from class ro.isdc.wro.model.resource.locator.wildcard.WildcardUriLocatorSupport
disableWildcards, getWildcardStreamLocator, newWildcardStreamLocator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFIX

public static final String PREFIX
Prefix for url resources.

See Also:
Constant Field Values
Constructor Detail

ServletContextUriLocator

public ServletContextUriLocator()
Method Detail

accept

public boolean accept(String uri)
Check if this uri can be located by concrete implementation.

Parameters:
uri - to read.
Returns:
true if UriLocator is able to return an InputStream of this uri.

isValid

public static boolean isValid(String uri)
Check if a uri is a servletContext resource.

Parameters:
uri - to check.
Returns:
true if the uri is a servletContext resource.

isProtectedResource

public static boolean isProtectedResource(String uri)
Check If the uri of the resource is protected: it cannot be accessed by accessing the url directly (WEB-INF folder).

Parameters:
uri - the uri to check.
Returns:
true if the uri is a protected resource.

locate

public InputStream locate(String uri)
                   throws IOException
Locates the uri by retrieving the InputStream. The client is responsible for closing the InputStream.

Parameters:
uri - uri to read.
Returns:
InputStream for the provided uri.
Throws:
IOException - if the resource cannot be read for some reason.


Copyright © 2008-2011. All Rights Reserved.