portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sg...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry CastorRegistryService.java
Date Tue, 02 Apr 2002 21:59:58 GMT
sgala       02/04/02 13:59:58

  Modified:    src/java/org/apache/jetspeed/services/registry
                        CastorRegistryService.java
  Log:
  Patch from Santa Arevalo (definete.com) to solve problems with the registry, both errors
if fragments don't exist and better persistence of fragments.
  
  Revision  Changes    Path
  1.16      +38 -12    jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/CastorRegistryService.java
  
  Index: CastorRegistryService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/CastorRegistryService.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- CastorRegistryService.java	29 Mar 2002 01:10:16 -0000	1.15
  +++ CastorRegistryService.java	2 Apr 2002 21:59:58 -0000	1.16
  @@ -102,7 +102,8 @@
    * </p>
    *
    * @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
  - * @version $Id: CastorRegistryService.java,v 1.15 2002/03/29 01:10:16 taylor Exp $
  + * @author <a href="mailto:sgala@apache.org">Santiago Gala</a>
  + * @version $Id: CastorRegistryService.java,v 1.16 2002/04/02 21:59:58 sgala Exp $
    */
   public class CastorRegistryService
       extends TurbineBaseService
  @@ -212,10 +213,22 @@
               }
                   
               RegistryFragment fragment = (RegistryFragment)fragments.get( fragmentName );
  +
  +            //Fragment can be (and sometimes is, but should not be) null
  +            if(fragment == null){
  +                fragment = new RegistryFragment();
  +                fragment.put(regName,new Vector());
  +                fragments.put(fragmentName,fragment);
  +            }else{
  +                Vector vectRegistry = (Vector)fragment.get(regName);
  +                if(vectRegistry == null){
  +                    fragment.put(regName,new Vector());
  +                }
  +            }
               
               synchronized (entryIndex)
               {
  -                if (this.getEntry(regName, entry.getName())!=null)
  +                if ( registry.hasEntry( entry.getName() ) )
                   {
                       fragment.setEntry(regName,entry);
                       registry.setEntry(entry);
  @@ -228,6 +241,9 @@
                   
                   entryIndex.put(entry.getName(),fragmentName);
               }
  +
  +            //As it has changed...
  +            saveFragment(fragmentName);
           }
       }
       
  @@ -265,6 +281,10 @@
               
               // the entry is physically removed, remove the dangling reference
               registry.removeEntry( entryName );
  +
  +            //As the fragment has changed...
  +            saveFragment(fragmentName);
  +
           }        
       }
           
  @@ -391,11 +411,14 @@
                       
               refresh( name );
           }
  +                    
  +        //Mark that we are done
  +        setInit(true);
   
           // Start the directory watcher thread
           if (this.watcher!=null) this.watcher.start();
   
  -        Log.debug( "Registry early init()....end!");
  +        Log.debug( "Registry early init()....end!, this.getInit()= " + getInit() );
       }
   
   
  @@ -558,7 +581,7 @@
                   Iterator i = entryIndex.keySet().iterator();
                   while(i.hasNext())
                   {
  -                    if (file.equals(i.next()))
  +                    if (file.equals( entryIndex.get( i.next() ) ) )
                       {
                           i.remove();
                       }
  @@ -587,7 +610,7 @@
               Iterator i = entryIndex.keySet().iterator();
               while(i.hasNext())
               {
  -                if (name.equals(i.next()))
  +                if (name.equals( entryIndex.get( i.next() ) ) )
                   {
                       i.remove();
                   }
  @@ -596,15 +619,18 @@
               // store the new fragment
               fragments.put(name,fragment);
               
  -            // recreate the index entries
  -            
  -            Iterator reg = registries.keySet().iterator();
  -            while(reg.hasNext())
  +            // recreate the index entries (only this fragment)
  +
  +            Enumeration enum = fragment.keys();
  +            while(enum.hasMoreElements() )
               {
  -                i = fragment.getEntries((String)reg.next()).iterator();
  -                while(i.hasNext())
  +                String strReg = (String)enum.nextElement();
  +                Vector v = fragment.getEntries(strReg);
  +                
  +                for(int int_i=0; int_i < v.size(); int_i++)
                   {
  -                    entryIndex.put(i.next(), name);
  +                    RegistryEntry str = (RegistryEntry)v.elementAt(int_i);
  +                    entryIndex.put(str.getName(), name);
                   }
               }
           }            
  
  
  

--
To unsubscribe, e-mail:   <mailto:jetspeed-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@jakarta.apache.org>


Mime
View raw message