Author: ssmiweve
Date: 2008-04-16 11:53:08 +0200 (Wed, 16 Apr 2008)
New Revision: 6466

Modified:
   branches/2.17/
   branches/2.17/site-spi/src/main/java/no/sesat/search/site/Site.java
Log:
Merged revisions 6446-6465 via svnmerge from 
http://sesat.no/svn/sesat-kernel/branches/2.16

........
  r6464 | ssmiweve | 2008-04-16 11:07:07 +0200 (Wed, 16 Apr 2008) | 1 line
  
  SEARCH-4613 - generic.sesam.no configuration files are loaded through apache
........



Property changes on: branches/2.17
___________________________________________________________________
Name: svnmerge-integrated
   - /branches/2.10:1-4690,4692-4745 /branches/2.11:1-4933 
/branches/2.12:1-5051,5053-5106 /branches/2.13:1-5378 /branches/2.14:1-5508 
/branches/2.15:1-5995 /branches/2.16:1-6445 /branches/2.6:1-3877 
/branches/2.7:1-4160 /branches/2.8:1-4446 /branches/2.9:1-4626 
/branches/MAP_SEARCHv2:1-4544
   + /branches/2.10:1-4690,4692-4745 /branches/2.11:1-4933 
/branches/2.12:1-5051,5053-5106 /branches/2.13:1-5378 /branches/2.14:1-5508 
/branches/2.15:1-5995 /branches/2.16:1-6465 /branches/2.6:1-3877 
/branches/2.7:1-4160 /branches/2.8:1-4446 /branches/2.9:1-4626 
/branches/MAP_SEARCHv2:1-4544

Modified: branches/2.17/site-spi/src/main/java/no/sesat/search/site/Site.java
===================================================================
--- branches/2.17/site-spi/src/main/java/no/sesat/search/site/Site.java 
2008-04-16 09:52:22 UTC (rev 6465)
+++ branches/2.17/site-spi/src/main/java/no/sesat/search/site/Site.java 
2008-04-16 09:53:08 UTC (rev 6466)
@@ -34,8 +34,13 @@
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 
-/** A Site object idenetifies an unique SiteSearch implementation.
- * This bean holds nothing more than the name of the virtual host used to 
access this SiteSearch.
+/** 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.
+ * .
  * <b>Immutable</b>.
  *
  * Does a little bit of niggling wiggling to load the DEFAULT site. See static 
constructor.
@@ -45,7 +50,13 @@
  */
 public final class Site implements Serializable {
 
-    /** Not to be confused with the SiteContext.
+    /** During construction of any site we must know who the parent site is 
going to be. 
+     * It will likely be also constructed since leaf sites are those first 
requested.
+     * 
+     * The base level sites, locale variants of the DEFAULT site, are expected 
to have a null parent.
+     * These DEFAULT sites can just pass in a null context instead of 
constructing a context that returns a null parent.
+     * 
+     * Not to be confused with the SiteContext.
      * This is a Context required for constructing a Site.
      * While a SiteContext is a context required to use a Site.
      **/
@@ -88,7 +99,7 @@
      */
     private final String cxtName;
     /**
-     * Holds value of property _locale.
+     * Holds value of property locale.
      */
     private Locale locale;
     /**
@@ -126,9 +137,7 @@
             // siteName must finish with a '\'
             siteName = ensureTrailingSlash(theSiteName);
 
-            cxtName = siteName.indexOf(':') >= 0
-                ? siteName.substring(0, siteName.indexOf(':')) + '/' // don't 
include the port in the cxtName.
-                : siteName;
+            cxtName = ensureTrailingSlash(siteName.replaceAll(":.*$", "")); // 
don't include the port in the cxtName.
             locale = theLocale;
             uniqueName = getUniqueName(siteName, locale);
 
@@ -140,26 +149,32 @@
                 }
             };
 
-            final String parentSiteName = null != cxt ? 
cxt.getParentSiteName(siteContext) : siteName;
+            final String parentSiteName;
+            if(null != cxt){
+                parentSiteName = null != cxt.getParentSiteName(siteContext)
+                        ? 
ensureTrailingSlash(cxt.getParentSiteName(siteContext))
+                        : null;
+            }else{
+                parentSiteName = siteName;
+            }
 
             final String tsParentNameNoPort = null != parentSiteName
                     ? ensureTrailingSlash(parentSiteName.replaceAll(":.*$", 
""))
                     : null;
 
-            LOG.error(siteName + " parent is " + parentSiteName);
+            LOG.debug(siteName + " parent is " + parentSiteName);
 
             if(constructingDefault){
                 parent = null;
 
             }else{
-                LOG.error("Default-check-> " + DEFAULT.getName() + " ?= "
-                        + (null != parentSiteName ? 
ensureTrailingSlash(parentSiteName) : "null"));
+                LOG.debug("Default-check-> " + DEFAULT.getName() + " ?= " + 
parentSiteName);
 
                 final boolean invalidParent = null == parentSiteName
                         // also avoid any incest
                         || siteName.equals(tsParentNameNoPort)
                         // and detect ahead the link to the grandfather of all 
"generic.sesam"
-                        || 
ensureTrailingSlash(parentSiteName).equals(DEFAULT.getName());
+                        || DEFAULT.getName().equals(parentSiteName);
 
                 parent = invalidParent
                     ? DEFAULT
@@ -169,6 +184,7 @@
             assert null != parent || constructingDefault : "Parent must exist 
for all Sites except the DEFAULT";
 
             // register in global pool.
+            LOG.debug("INSTANCES.put(" + uniqueName + ", this)");
             INSTANCES.put(uniqueName, this);
 
         }finally{
@@ -223,15 +239,11 @@
         return locale;
     }
 
-    /** [EMAIL PROTECTED]
-     */
     @Override
     public String toString(){
         return uniqueName;
     }
 
-    /** [EMAIL PROTECTED]
-     */
     @Override
     public boolean equals(final Object obj) {
 
@@ -240,8 +252,6 @@
                 : super.equals(obj);
     }
 
-    /** [EMAIL PROTECTED]
-     */
     @Override
     public int hashCode() {
         return uniqueName.hashCode();
@@ -250,6 +260,9 @@
     /** 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.
+     * 
      * @param cxt the cxt to use during creation. null will prevent 
constructing a new site.
      * @param siteName the virtual host name.
      * @param locale the locale desired
@@ -263,9 +276,11 @@
         final String realSiteName = 
ensureTrailingSlash(siteName.replaceAll("www.", ""));
 
         // Look for existing instances
+        final String uniqueName = getUniqueName(realSiteName,locale);
         try{
             INSTANCES_LOCK.readLock().lock();
-            site = INSTANCES.get(getUniqueName(realSiteName,locale));
+            LOG.debug("INSTANCES.get(" + uniqueName + ")");
+            site = INSTANCES.get(uniqueName);
 
         }finally{
             INSTANCES_LOCK.readLock().unlock();

_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to