no.sesat.search.site.config
Class UrlResourceLoader

java.lang.Object
  extended by no.sesat.search.site.config.AbstractResourceLoader
      extended by no.sesat.search.site.config.UrlResourceLoader
All Implemented Interfaces:
Runnable, BytecodeLoader, DocumentLoader, PropertiesLoader, ResourceLoader

public class UrlResourceLoader
extends AbstractResourceLoader

Loads resources through URL references.

Version:
$Id: UrlResourceLoader.java 7225 2009-04-09 00:32:20Z ssmiweve $

Field Summary
 
Fields inherited from class no.sesat.search.site.config.AbstractResourceLoader
builder, document, jarFileName, props
 
Constructor Summary
protected UrlResourceLoader(SiteContext cxt)
           
 
Method Summary
static boolean doesUrlExist(URL url)
          Calls doesUrlExist(url, "localhost")
static boolean doesUrlExist(URL url, String hostHeader)
          Checks that the url (requested with the given host header) exists.
static String getHostHeader(String resource)
           
protected  InputStream getInputStreamFor(URL url)
           
protected  URL getResource(Site site)
           
static URL getURL(String resource, Site site)
           
static BytecodeLoader newBytecodeLoader(SiteContext siteCxt, String resource, String jar)
          Creates new BytecodeLoader for the given site and resource.
static DocumentLoader newDocumentLoader(SiteContext siteCxt, String resource, DocumentBuilder builder)
          Create a new DocumentLoader for the given resource name/path and load it with the given DocumentBuilder.
static PropertiesLoader newPropertiesLoader(SiteContext siteCxt, String resource, Properties properties)
          Create a new PropertiesLoader for the given resource name/path and load it into the given properties.
protected  String readResourceDebug(URL url)
           
 boolean urlExists(URL url)
           
 
Methods inherited from class no.sesat.search.site.config.AbstractResourceLoader
abut, getBytecode, getContext, getDocument, getProperties, getResource, init, init, initBytecodeLoader, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlResourceLoader

protected UrlResourceLoader(SiteContext cxt)
Method Detail

newPropertiesLoader

public static PropertiesLoader newPropertiesLoader(SiteContext siteCxt,
                                                   String resource,
                                                   Properties properties)
Create a new PropertiesLoader for the given resource name/path and load it into the given properties.

Parameters:
siteCxt - the SiteContext that will tell us which site we are dealing with.
resource - the resource name/path.
properties - the properties to hold the individual properties loaded.
Returns:
the new PropertiesLoader to use.

newDocumentLoader

public static DocumentLoader newDocumentLoader(SiteContext siteCxt,
                                               String resource,
                                               DocumentBuilder builder)
Create a new DocumentLoader for the given resource name/path and load it with the given DocumentBuilder.

Parameters:
siteCxt - the SiteContext that will tell us which site we are dealing with.
resource - the resource name/path.
builder - the DocumentBuilder to build the DOM resource with.
Returns:
the new DocumentLoader to use.

newBytecodeLoader

public static BytecodeLoader newBytecodeLoader(SiteContext siteCxt,
                                               String resource,
                                               String jar)
Creates new BytecodeLoader for the given site and resource.

Parameters:
siteCxt - context telling us which site to use.
resource - the class to load bytecode for.
Returns:
a bytecode loader for resource.

doesUrlExist

public static boolean doesUrlExist(URL url)
Calls doesUrlExist(url, "localhost")


doesUrlExist

public static boolean doesUrlExist(URL url,
                                   String hostHeader)
Checks that the url (requested with the given host header) exists.

Parameters:
url - the url whom's existence is checked
hostHeader - the host header to use on the request (typically localhost)
Returns:
true if in existence

urlExists

public boolean urlExists(URL url)
Specified by:
urlExists in class AbstractResourceLoader

getResource

protected URL getResource(Site site)
Specified by:
getResource in class AbstractResourceLoader

getURL

public static URL getURL(String resource,
                         Site site)

getInputStreamFor

protected InputStream getInputStreamFor(URL url)
Specified by:
getInputStreamFor in class AbstractResourceLoader

getHostHeader

public static String getHostHeader(String resource)

readResourceDebug

protected final String readResourceDebug(URL url)
Overrides:
readResourceDebug in class AbstractResourceLoader


Copyright © 2005-2009 Schibsted ASA. All Rights Reserved.