no.sesat.search.site
Class Site

java.lang.Object
  extended by no.sesat.search.site.Site
All Implemented Interfaces:
Serializable

public final class Site
extends Object
implements Serializable

A Site object identifies a Skin + Locale pairing. This bean holds nothing more than the name of the virtual host (siteName) and locale used to access this Skin. It is used as a key to obtain the correct factory instances in the application. There is usually only one Skin per siteName and it is left up to the skin to handle different locales. . Immutable. Does a little bit of niggling wiggling to load the DEFAULT site. See static constructor.

Version:
$Id: Site.java 7225 2009-04-09 00:32:20Z ssmiweve $
See Also:
Serialized Form

Nested Class Summary
static interface Site.Context
          During construction of any site we must know who the parent site is going to be.
 
Field Summary
static String CONFIGURATION_FILE
          Name of the resource to find the PARENT_SITE_KEY property.
static Site DEFAULT
          the default SiteSearch.
static String DEFAULT_SERVER_PORT_KEY
           
static String DEFAULT_SITE_KEY
          Found from the configuration.properties resource found in this class's ClassLoader.
static String DEFAULT_SITE_LOCALE_KEY
           
static String NAME_KEY
          Property key for a site object.
static String PARENT_SITE_KEY
          Property key for site parent's name.
static int SERVER_PORT
          the server's actual port.
 
Method Summary
 boolean equals(Object obj)
           
 String getConfigContext()
          Getter for property cxtName.
 Locale getLocale()
          Getter for property locale.
 String getName()
          Getter for property siteName.
 Site getParent()
          the parent to this site.
 SiteContext getSiteContext()
          Get a SiteContext for this site.
 String getTemplateDir()
          Getter for property (velocity) template directory.
static String getUniqueName(String siteName, Locale locale)
          Get a uniqueName given a pair of siteName and locale.
 int hashCode()
           
 String toString()
           
static Site valueOf(Site.Context cxt, String siteName, Locale locale)
          Get the instance for the given siteName.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SITE_KEY

public static final String DEFAULT_SITE_KEY
Found from the configuration.properties resource found in this class's ClassLoader.

See Also:
Constant Field Values

DEFAULT_SITE_LOCALE_KEY

public static final String DEFAULT_SITE_LOCALE_KEY
See Also:
Constant Field Values

DEFAULT_SERVER_PORT_KEY

public static final String DEFAULT_SERVER_PORT_KEY
See Also:
Constant Field Values

PARENT_SITE_KEY

public static final String PARENT_SITE_KEY
Property key for site parent's name.

See Also:
Constant Field Values

NAME_KEY

public static final String NAME_KEY
Property key for a site object.

See Also:
Constant Field Values

CONFIGURATION_FILE

public static final String CONFIGURATION_FILE
Name of the resource to find the PARENT_SITE_KEY property.

See Also:
Constant Field Values

DEFAULT

public static final Site DEFAULT
the default SiteSearch. For example: "generic.sesam" or "generic.localhost:8080".


SERVER_PORT

public static final int SERVER_PORT
the server's actual port.

Method Detail

getSiteContext

public SiteContext getSiteContext()
Get a SiteContext for this site.

Returns:
SiteContext for this site.

getParent

public Site getParent()
the parent to this site.

Returns:
site null if we are the DEFAULT site.

getName

public String getName()
Getter for property siteName. Guaranteed to have "www." prefix stripped. Guaranteed to finish with '/'.

Returns:
Value of property siteName.

getConfigContext

public String getConfigContext()
Getter for property cxtName. Same as name but without port specification. Guaranteed to finish with '/'.

Returns:
Value of property cxtName.

getTemplateDir

public String getTemplateDir()
Getter for property (velocity) template directory. Absolute URL to directory (velocity) template is found for this site. Does not finish with '/'. Reads nicer in template statements.

Returns:
Value of property (velocity) template directory.

getLocale

public Locale getLocale()
Getter for property locale.

Returns:
Value of property locale.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

valueOf

public static Site valueOf(Site.Context cxt,
                           String siteName,
                           Locale locale)
Get the instance for the given siteName. The port number will be changed if the server has explicitly assigned one port number to use. A "www." prefix will be automatically ignored. TODO refactor to instanceOf(..). it is an instance returned not a primitive.

Parameters:
cxt - the cxt to use during creation. null will prevent constructing a new site.
siteName - the virtual host name.
locale - the locale desired
Returns:
the site instance. never null.
Throws:
IllegalArgumentException - when there exists no skin matching the siteName argument.

getUniqueName

public static String getUniqueName(String siteName,
                                   Locale locale)
Get a uniqueName given a pair of siteName and locale. Used internally and before construction of any new Site.

Parameters:
siteName -
locale -
Returns:


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