You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ra...@apache.org on 2002/10/30 16:52:39 UTC

cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/rundata DefaultJetspeedRunData.java JetspeedRunData.java

raphael     2002/10/30 07:52:39

  Modified:    src/java/org/apache/jetspeed/services Registry.java
               src/java/org/apache/jetspeed/services/registry
                        CastorRegistryService.java
                        DatabaseRegistryService.java RegistryFragment.java
                        RegistryService.java TestMarshallRegistry.java
               src/java/org/apache/jetspeed/services/rundata
                        DefaultJetspeedRunData.java JetspeedRunData.java
  Log:
  - Add a configurable Client registry to store user-agent capabilities
  - Fix an issue with the BaseRegistry implementation that prevented the elements
    being added directly in this instance from being persisted
  - Add a factory like method in Registry to ease creation of suitable entries
  - Fix some code style issues
  
  Revision  Changes    Path
  1.7       +39 -21    jakarta-jetspeed/src/java/org/apache/jetspeed/services/Registry.java
  
  Index: Registry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/Registry.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Registry.java	28 Jun 2002 05:37:32 -0000	1.6
  +++ Registry.java	30 Oct 2002 15:52:39 -0000	1.7
  @@ -54,21 +54,23 @@
   
   package org.apache.jetspeed.services;
   
  -import org.apache.jetspeed.om.registry.*;
  -import org.apache.jetspeed.services.registry.*;
  +import org.apache.jetspeed.om.registry.RegistryEntry;
  +import org.apache.jetspeed.om.registry.RegistryException;
  +import org.apache.jetspeed.services.registry.RegistryService;
   import org.apache.turbine.services.TurbineServices;
   import java.util.Enumeration;
   
   /**
  - * <P>This is a commodity static accessor class around the 
  + * <P>This is a commodity static accessor class around the
    * <code>RegistryService</code></P>
  - * 
  + *
    * @see org.apache.jetspeed.services.registry.RegistryService
    * @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
    * @version $Id$
    */
  -public class Registry {
  - 
  +public class Registry
  +{
  +
       /** Default Portlet Registry name */
       public static String PORTLET = "Portlet";
   
  @@ -81,56 +83,72 @@
       /** Default MediaType Registry name */
       public static String MEDIA_TYPE = "MediaType";
   
  +    /** Default Client Registry name */
  +    public static String CLIENT = "Client";
  +
       /** Default Security Registry name */
       public static String SECURITY = "Security";
   
       /** Default Skin Registry name */
       public static String SKIN = "Skin";
   
  -    /** 
  +    /**
        * Commodity method for getting a reference to the service
        * singleton
        */
  -    private static RegistryService getService() {
  +    private static RegistryService getService()
  +    {
           return (RegistryService)TurbineServices
                   .getInstance()
  -                .getService(RegistryService.SERVICE_NAME);     
  +                .getService(RegistryService.SERVICE_NAME);
       }
  -    
  +
       /**
        * @see RegistryService#getNames
        */
  -    public static Enumeration getNames() {
  +    public static Enumeration getNames()
  +    {
           return getService().getNames();
       }
  -    
  +
       /**
        * @see RegistryService#get
        */
  -    public static org.apache.jetspeed.om.registry.Registry get( String regName ) {
  +    public static org.apache.jetspeed.om.registry.Registry get( String regName )
  +    {
           return getService().get( regName );
       }
  -    
  +
  +    /**
  +     * @see RegistryService#createEntry
  +     */
  +    public static RegistryEntry createEntry( String regName )
  +    {
  +        return getService().createEntry( regName );
  +	}
  +
       /**
        * @see RegistryService#getEntry
        */
  -    public static RegistryEntry getEntry( String regName, String entryName ) {
  +    public static RegistryEntry getEntry( String regName, String entryName )
  +    {
           return getService().getEntry( regName, entryName );
       }
  -    
  +
       /**
        * @see RegistryService#addEntry
        */
       public static void addEntry( String regName, RegistryEntry value )
  -        throws RegistryException {
  +        throws RegistryException
  +    {
           getService().addEntry( regName, value );
       }
  -    
  +
       /**
        * @see RegistryService#removeEntry
        */
  -    public static void removeEntry( String regName, String entryName ) {
  +    public static void removeEntry( String regName, String entryName )
  +    {
           getService().removeEntry( regName, entryName );
       }
  -        
   }
  
  
  
  1.22      +158 -102  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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- CastorRegistryService.java	8 Oct 2002 15:18:07 -0000	1.21
  +++ CastorRegistryService.java	30 Oct 2002 15:52:39 -0000	1.22
  @@ -104,14 +104,14 @@
    *
    * <p>This service expects the following properties to be set for correct operation:
    * <dl>
  - *    <dt>directory</dt><dd>The directory where the Registry will look for 
  + *    <dt>directory</dt><dd>The directory where the Registry will look for
    *    fragment files</dd>
  - *    <dt>extension</dt><dd>The extension used for identifying the registry fragment 
  + *    <dt>extension</dt><dd>The extension used for identifying the registry fragment
    *    files. Default .xreg</dd>
    *    <dt>mapping</dt><dd>the Castor object mapping file path</dd>
    *    <dt>registries</dt><dd>a comma separated list of registry names to load
    *     from this file</dd>
  - *    <dt>refreshRate</dt><dd>Optional. The manager will check every 
  + *    <dt>refreshRate</dt><dd>Optional. The manager will check every
    *     refreshRate seconds if the config has changed and if true will refresh
    *     all the registries. A value of 0 or negative will disable the
    *     automatic refresh operation. Default: 300 (5 minutes)</dd>
  @@ -124,16 +124,16 @@
    */
   public class CastorRegistryService
       extends TurbineBaseService
  -    implements RegistryService, FileRegistry 
  +    implements RegistryService, FileRegistry
   {
  -             
  +
       public static final int DEFAULT_REFRESH = 300;
       public static final String DEFAULT_EXTENSION = ".xreg";
       public static final String DEFAULT_MAPPING = "${webappRoot}/WEB-INF/conf/mapping.xml";
   
       /** regsitry type keyed list of entries */
       private Hashtable registries = new Hashtable();
  -    
  +
       /** The Castor generated RegsitryFragment objects */
       private Hashtable fragments = new Hashtable();
   
  @@ -145,19 +145,19 @@
   
       /** the Watcher object which monitors the regsitry directory */
       private RegistryWatcher watcher = null;
  -        
  +
       /** the Castor mapping file name */
       private Mapping mapping = null;
  -        
  +
       /** the output format for pretty printing when saving registries */
       private OutputFormat format = null;
  -        
  +
       /** the base regsitry directory */
       private String directory = null;
  -    
  +
       /** the extension for registry files */
       private String extension = null;
  -    
  +
       /**
        * Returns a Registry object for further manipulation
        *
  @@ -166,51 +166,74 @@
        */
       public Registry get(String regName)
       {
  -        return (Registry) registries.get(regName);       
  +        return (Registry) registries.get(regName);
       }
   
       /**
        *  List all the registry currently available to this service
  -     * 
  +     *
        * @return an Enumeration of registry names.
        */
       public Enumeration getNames()
       {
           return registries.keys();
       }
  -    
  +
  +    /**
  +     * Creates a new RegistryEntry instance compatible with the current
  +     * Registry instance implementation
  +     *
  +     * @param regName the name of the registry to use
  +     * @return the newly created RegistryEntry
  +     */
  +    public RegistryEntry createEntry(String regName)
  +    {
  +		RegistryEntry entry = null;
  +        Registry registry = (Registry) registries.get(regName);
  +
  +        if (registry != null)
  +        {
  +			entry = registry.createEntry();
  +        }
  +
  +		return entry;
  +	}
  +
       /**
        * Returns a RegistryEntry from the named Registry.
  -     * This is a convenience wrapper around {@link 
  +     * This is a convenience wrapper around {@link
        * org.apache.jetspeed.om.registry.Registry#getEntry }
        *
        * @param regName the name of the registry
  -     * @param entryName the name of the entry to retrieve from the 
  +     * @param entryName the name of the entry to retrieve from the
        *                  registry
        * @return a RegistryEntry object if the key is found or null
        */
       public RegistryEntry getEntry(String regName, String entryName)
       {
  -        try 
  +        try
           {
               return ((Registry) registries.get(regName)).getEntry(entryName);
           }
           catch (RegistryException e)
           {
  -            Log.info("Failed to retrieve " + entryName + " from " + regName);
  +	        if (Log.getLogger().isInfoEnabled())
  +	        {
  +	            Log.info("Failed to retrieve " + entryName + " from " + regName);
  +			}
           }
           catch (NullPointerException e)
           {
               Log.error(regName + " registry is not known ");
               Log.error(e);
           }
  -            
  +
           return null;
       }
  -    
  +
       /**
        * Add a new RegistryEntry in the named Registry.
  -     * This is a convenience wrapper around {@link 
  +     * This is a convenience wrapper around {@link
        * org.apache.jetspeed.om.registry.Registry#addEntry }
        *
        * @param regName the name of the registry
  @@ -220,24 +243,24 @@
        */
       public void addEntry(String regName, RegistryEntry entry) throws RegistryException
       {
  -        if (entry == null) 
  +        if (entry == null)
           {
               return;
           }
  -        
  -        Registry registry = (Registry) registries.get(regName);
  -        
  +
  +        BaseRegistry registry = (BaseRegistry) registries.get(regName);
  +
           if (registry != null)
           {
               String fragmentName = (String) entryIndex.get(entry.getName());
  -            
  +
               if (fragmentName == null)
               {
                   // either the entry was deleted or it does not exist
  -                // in both cases, use the default fragment                
  +                // in both cases, use the default fragment
                   fragmentName = (String) defaults.get(regName);
               }
  -                
  +
               RegistryFragment fragment = (RegistryFragment) fragments.get(fragmentName);
   
               //Fragment can be (and sometimes is, but should not be) null
  @@ -255,20 +278,20 @@
                       fragment.put(regName, new Vector());
                   }
               }
  -            
  +
               synchronized (entryIndex)
               {
                   if (registry.hasEntry(entry.getName()))
                   {
                       fragment.setEntry(regName, entry);
  -                    registry.setEntry(entry);
  +                    registry.setLocalEntry(entry);
                   }
                   else
                   {
                       fragment.addEntry(regName, entry);
  -                    registry.addEntry(entry);
  +                    registry.addLocalEntry(entry);
                   }
  -                
  +
                   entryIndex.put(entry.getName(), fragmentName);
               }
   
  @@ -276,10 +299,10 @@
               saveFragment(fragmentName);
           }
       }
  -    
  +
       /**
        * Deletes a RegistryEntry from the named Registry
  -     * This is a convenience wrapper around {@link 
  +     * This is a convenience wrapper around {@link
        * org.apache.jetspeed.om.registry.Registry#removeEntry }
        *
        * @param regName the name of the registry
  @@ -291,35 +314,35 @@
           {
               return;
           }
  -        
  -        Registry registry = (Registry) registries.get(regName);
  -        
  +
  +        BaseRegistry registry = (BaseRegistry) registries.get(regName);
  +
           if (registry != null)
           {
               String fragmentName = (String) entryIndex.get(entryName);
  -            
  +
               if (fragmentName != null)
               {
                   RegistryFragment fragment = (RegistryFragment) fragments.get(fragmentName);
  -            
  +
                   synchronized (entryIndex)
                   {
                       fragment.removeEntry(regName, entryName);
                       entryIndex.remove(entryName);
                   }
               }
  -            
  +
               // the entry is physically removed, remove the dangling reference
  -            registry.removeEntry(entryName);
  +            registry.removeLocalEntry(entryName);
   
               //As the fragment has changed...
               saveFragment(fragmentName);
   
  -        }        
  +        }
       }
  -        
  +
       /**
  -     * This is the early initialization method called by the 
  +     * This is the early initialization method called by the
        * Turbine <code>Service</code> framework
        */
       public void init(ServletConfig conf) throws InitializationException
  @@ -333,7 +356,7 @@
           String mapFile = null;
           Vector names = new Vector();
           int refreshRate = 0;
  -        
  +
           // read the configuration keys
           try
           {
  @@ -349,8 +372,8 @@
           {
               throw new InitializationException("Unable to initialize CastorRegistryService, missing config keys");
           }
  -            
  -        // build the map of default fragments, eahc registry must be associated 
  +
  +        // build the map of default fragments, eahc registry must be associated
           // with at least one fragment
           try
           {
  @@ -360,11 +383,11 @@
               {
                   String name = (String) i.next();
                   String fragmentFileName = defaults.getString(name);
  -                
  +
                   String absFileName = new File(directory, fragmentFileName + extension).getAbsolutePath();
                   // add this name in the list of available registries
                   names.add(name);
  -                
  +
                   // store the default file mapping
                   this.defaults.put(name, absFileName);
               }
  @@ -374,14 +397,14 @@
               Log.error("Registry init error", e);
               throw new InitializationException("Unable to initialize CastorRegistryService, invalid registries definition");
           }
  -        
  -        // create the serializer output format        
  +
  +        // create the serializer output format
           this.format = new OutputFormat();
           format.setIndenting(true);
           format.setIndent(4);
   
           // test the mapping file and create the mapping object
  -        
  +
           if (mapFile != null)
           {
               File map = new File(mapFile);
  @@ -406,7 +429,7 @@
               }
           }
   
  -        // Set directory watcher if directory exists        
  +        // Set directory watcher if directory exists
           File base = new File(directory);
           File[] files = null;
   
  @@ -415,7 +438,7 @@
               this.watcher = new RegistryWatcher();
               this.watcher.setSubscriber(this);
               this.watcher.setFilter(new ExtFileFilter(extension));
  -            if (refreshRate == 0) 
  +            if (refreshRate == 0)
               {
                   this.watcher.setDone();
               }
  @@ -431,7 +454,7 @@
           setInit(true);
   
           // load the registries
  -        Enumeration en = names.elements();        
  +        Enumeration en = names.elements();
   
           while (en.hasMoreElements())
           {
  @@ -440,23 +463,36 @@
   
               if (registry == null)
               {
  -                if (name.equals(org.apache.jetspeed.services.Registry.PORTLET))
  -                {
  -                    registry = new BasePortletRegistry();
  -                }
  -                else
  +				String registryClass = null;
  +                try
                   {
  +					registryClass =
  +						"org.apache.jetspeed.om.registry.base.Base"
  +						+ name
  +						+ "Registry";
  +
  +					registry = (Registry)Class.forName(registryClass).newInstance();
  +				}
  +				catch (Exception e)
  +                {
  +					if (Log.getLogger().isWarnEnabled())
  +					{
  +						Log.warn("CastorRegistryService: Class "
  +							+ registryClass
  +							+ " not found, reverting to default Registry");
  +					}
                       registry = new BaseRegistry();
                   }
  +
                   registries.put(name, registry);
               }
  -                    
  +
               refresh(name);
           }
  -        
  +
           // Refresh the registry to make sure all <portlet-entry ... ref=""> are loaded.
           Log.info("CasterRegistryService: Refreshing registry to insure entries are loaded");
  -        refresh();                    
  +        refresh();
   
           //Mark that we are done
           setInit(true);
  @@ -467,14 +503,21 @@
               this.watcher.start();
           }
   
  -        Log.debug("Registry early init()....end!, this.getInit()= " + getInit());
  +        if (Log.getLogger().isDebugEnabled())
  +        {
  +	        Log.debug("Registry early init()....end!, this.getInit()= " + getInit());
  +		}
       }
   
   
       /** Late init method from Turbine Service model */
       public void init() throws InitializationException
       {
  -        Log.debug("Late init for Registry called");
  +        if (Log.getLogger().isDebugEnabled())
  +        {
  +	        Log.debug("Late init for Registry called");
  +		}
  +
           while (!getInit())
           {
               //Not yet...
  @@ -488,18 +531,22 @@
                   Log.error(ie);
               }
           }
  -        Log.debug("We are done! (Registry)");
  +
  +        if (Log.getLogger().isDebugEnabled())
  +        {
  +	        Log.debug("We are done! (Registry)");
  +		}
       }
   
  -    
  +
       /**
  -     * This is the shutdown method called by the 
  +     * This is the shutdown method called by the
        * Turbine <code>Service</code> framework
        */
       public void shutdown()
       {
           this.watcher.setDone();
  -        
  +
           Iterator i = fragments.keySet().iterator();
           while (i.hasNext())
           {
  @@ -509,7 +556,7 @@
   
       // FileRegistry interface
   
  -    /** Refresh the state of the registry implementation. Should be called 
  +    /** Refresh the state of the registry implementation. Should be called
        *   whenever the underlying fragments are modified
        */
       public void refresh()
  @@ -537,17 +584,17 @@
               Unmarshaller unmarshaller = new Unmarshaller(this.mapping);
               RegistryFragment fragment = (RegistryFragment) unmarshaller.unmarshal((Node) d);
   
  -            // if we get here, we successfully loaded the new fragment            
  +            // if we get here, we successfully loaded the new fragment
               updateFragment(file, fragment);
  -            
  +
           }
           catch (Throwable t)
           {
               Log.error("Could not unmarshal: " + file, t);
           }
  -        
  +
       }
  -    
  +
       /**
        * Read and unmarshal a fragment in memory
        * @param name the name of this fragment
  @@ -585,11 +632,11 @@
                   Log.error(e);  // At least log the exception.
               }
           }
  -        
  +
           // refresh all regsitries to take the new entries into account
           refresh();
       }
  -    
  +
       /**
        * Marshal and save a RegistryFragment to disk
        * @param file the absolute file path storing this fragment
  @@ -599,7 +646,7 @@
           OutputStreamWriter writer = null;
           String encoding = new String("UTF-8");
           RegistryFragment fragment = (RegistryFragment) fragments.get(file);
  -        
  +
           if (fragment != null)
           {
               try
  @@ -627,7 +674,7 @@
                   }
               }
           }
  -    }    
  +    }
   
       /**
        * Remove a fragment from storage
  @@ -636,7 +683,7 @@
       public void removeFragment(String file)
       {
           RegistryFragment fragment = (RegistryFragment) fragments.get(file);
  -        
  +
           if (fragment != null)
           {
               synchronized (entryIndex)
  @@ -650,7 +697,7 @@
                           i.remove();
                       }
                   }
  -                
  +
                   // make sure the keys & entries are freed for this fragment
                   // only the entries not replaced by the next registry refresh will
                   // stay in memory
  @@ -659,10 +706,10 @@
                   fragments.remove(file);
               }
           }
  -    }    
  +    }
   
       // Implementation specific methods
  -    
  +
       /**
        * Updates a fragment in storage and the associated entryIndex
        */
  @@ -679,10 +726,10 @@
                       i.remove();
                   }
               }
  -            
  +
               // store the new fragment
               fragments.put(name, fragment);
  -            
  +
               // recreate the index entries (only this fragment)
   
               Enumeration enum = fragment.keys();
  @@ -690,16 +737,16 @@
               {
                   String strReg = (String) enum.nextElement();
                   Vector v = fragment.getEntries(strReg);
  -                
  +
                   for (int counter = 0; counter < v.size(); counter++)
                   {
                       RegistryEntry str = (RegistryEntry) v.elementAt(counter);
                       entryIndex.put(str.getName(), name);
                   }
               }
  -        }            
  +        }
       }
  -    
  +
       /**
        * Scan all the registry fragments for new entries relevant to
        * this registry and update its definition.
  @@ -709,11 +756,14 @@
       protected void refresh(String regName)
       {
   
  -        Log.debug("Updating the " + regName + " registry"); 
  +        if (Log.getLogger().isDebugEnabled())
  +        {
  +	        Log.debug("Updating the " + regName + " registry");
  +		}
   
           int count = 0;
           Registry registry = get(regName);
  -        
  +
           if (registry == null)
           {
               Log.error("Null " + name + " registry in refresh");
  @@ -737,15 +787,18 @@
                   {
                       RegistryEntry entry = (RegistryEntry) en2.nextElement();
                       // update or add the entry in the registry
  -                    try 
  +                    try
                       {
  -                        Log.debug("Adding entry " + entry.getName() + " of class " + entry.getClass() + " to registry " + name);
  +				        if (Log.getLogger().isDebugEnabled())
  +				        {
  +	                        Log.debug("Adding entry " + entry.getName() + " of class " + entry.getClass() + " to registry " + name);
  +						}
   
                           if (registry.hasEntry(entry.getName()))
                           {
                               registry.setEntry(entry);
  -                        } 
  -                        else 
  +                        }
  +                        else
                           {
                               registry.addEntry(entry);
                           }
  @@ -757,27 +810,30 @@
                       {
                           Log.error("RegistryException while adding " + entry.getName() + "from " + location, e);
                       }
  -                }    
  +                }
               }
           }
  -        
  -        Log.debug("Merged " + count + " entries into the " + name); 
  -    }        
   
  -    
  +        if (Log.getLogger().isDebugEnabled())
  +        {
  +        	Log.debug("Merged " + count + " entries into the " + name);
  +		}
  +    }
  +
  +
       /** FileFilter implementing a file extension based filter */
       class ExtFileFilter implements FileFilter
       {
           private String extension = null;
  -        
  +
           ExtFileFilter(String extension)
           {
               this.extension = extension;
           }
  -        
  +
           public boolean accept(File f)
           {
  -            return f.toString().endsWith(extension);   
  +            return f.toString().endsWith(extension);
           }
       }
   
  
  
  
  1.2       +67 -40    jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/DatabaseRegistryService.java
  
  Index: DatabaseRegistryService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/DatabaseRegistryService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DatabaseRegistryService.java	1 Apr 2002 23:16:53 -0000	1.1
  +++ DatabaseRegistryService.java	30 Oct 2002 15:52:39 -0000	1.2
  @@ -73,7 +73,7 @@
    * <p>This service expects the following properties to be set for correct operation:
    * <dl>
    *    <dt>none</dt><dd></dd>
  - *    
  + *
    * </dl>
    * </p>
    *
  @@ -82,58 +82,86 @@
    */
   public class DatabaseRegistryService
           extends TurbineBaseService
  -        implements RegistryService 
  +        implements RegistryService
   {
   
       /** regsitry type keyed list of entries */
       private Hashtable registries = new Hashtable();
  -               
  -    
  +
  +
       /**
        * Returns a Registry object for further manipulation
        *
        * @param regName the name of the registry to fetch
        * @return a Registry object if found by the manager or null
        */
  -    public Registry get( String regName ) {
  -        return (Registry)registries.get( regName );       
  +    public Registry get( String regName )
  +    {
  +        return (Registry)registries.get( regName );
       }
   
       /**
        *  List all the registry currently available to this service
  -     * 
  +     *
        * @return an Enumeration of registry names.
        */
  -    public Enumeration getNames() {
  +    public Enumeration getNames()
  +    {
           return registries.keys();
       }
  -    
  +
  +    /**
  +     * Creates a new RegistryEntry instance compatible with the current
  +     * Registry instance implementation
  +     *
  +     * @param regName the name of the registry to use
  +     * @return the newly created RegistryEntry
  +     */
  +    public RegistryEntry createEntry(String regName)
  +    {
  +		RegistryEntry entry = null;
  +        Registry registry = (Registry) registries.get(regName);
  +
  +        if (registry != null)
  +        {
  +			entry = registry.createEntry();
  +        }
  +
  +		return entry;
  +	}
  +
       /**
        * Returns a RegistryEntry from the named Registry.
  -     * This is a convenience wrapper around {@link 
  +     * This is a convenience wrapper around {@link
        * org.apache.jetspeed.om.registry.Registry#getEntry }
        *
        * @param regName the name of the registry
  -     * @param entryName the name of the entry to retrieve from the 
  +     * @param entryName the name of the entry to retrieve from the
        *                  registry
        * @return a RegistryEntry object if the key is found or null
        */
  -    public RegistryEntry getEntry( String regName, String entryName ) {
  -        try {   
  +    public RegistryEntry getEntry( String regName, String entryName )
  +    {
  +        try
  +        {
               return ((Registry)registries.get( regName )).getEntry( entryName );
  -        } catch ( RegistryException e ) {
  +        }
  +        catch ( RegistryException e )
  +        {
               Log.info("Failed to retrieve "+entryName+" from "+regName);
  -        } catch ( NullPointerException e ) {
  +        }
  +        catch ( NullPointerException e )
  +        {
               Log.error(regName + " registry is not known ");
               Log.error( e );
           }
  -            
  +
           return null;
       }
  -    
  +
       /**
        * Add a new RegistryEntry in the named Registry.
  -     * This is a convenience wrapper around {@link 
  +     * This is a convenience wrapper around {@link
        * org.apache.jetspeed.om.registry.Registry#addEntry }
        *
        * @param regName the name of the registry
  @@ -143,29 +171,29 @@
        */
       public void addEntry(String regName, RegistryEntry entry) throws RegistryException
       {
  -        if (entry == null) 
  +        if (entry == null)
           {
               return;
           }
  -        
  -        Registry registry = (Registry)registries.get( regName );
  -        
  +
  +        BaseRegistry registry = (BaseRegistry)registries.get( regName );
  +
           if (registry!=null)
           {
               if (this.getEntry(regName, entry.getName())!=null)
               {
  -                registry.setEntry(entry);
  +                registry.setLocalEntry(entry);
               }
               else
               {
  -                registry.addEntry(entry);
  +                registry.addLocalEntry(entry);
               }
           }
       }
  -    
  +
       /**
        * Deletes a RegistryEntry from the named Registry
  -     * This is a convenience wrapper around {@link 
  +     * This is a convenience wrapper around {@link
        * org.apache.jetspeed.om.registry.Registry#removeEntry }
        *
        * @param regName the name of the registry
  @@ -177,18 +205,18 @@
           {
               return;
           }
  -        
  -        Registry registry = (Registry)registries.get( regName );
  -        
  +
  +        BaseRegistry registry = (BaseRegistry)registries.get( regName );
  +
           if (registry!=null)
  -        {           
  +        {
               // the entry is physically removed, remove the dangling reference
  -            registry.removeEntry( entryName );
  -        }        
  +            registry.removeLocalEntry( entryName );
  +        }
       }
  -        
  +
       /**
  -     * This is the early initialization method called by the 
  +     * This is the early initialization method called by the
        * Turbine <code>Service</code> framework
        */
       public void init( ServletConfig conf ) throws InitializationException
  @@ -196,7 +224,7 @@
   
           ResourceService serviceConf = ((TurbineServices)TurbineServices.getInstance())
                                                        .getResources(RegistryService.SERVICE_NAME);
  -        
  +
           // read the configuration keys
           try
           {
  @@ -206,7 +234,7 @@
           {
               throw new InitializationException( "Unable to initialize DatabaseRegistryService, missing config keys");
           }
  -                    
  +
           //Mark that we are done
           setInit(true);
   
  @@ -235,14 +263,13 @@
           Log.debug( "We are done! (Registry)" );
       }
   
  -    
  +
       /**
  -     * This is the shutdown method called by the 
  +     * This is the shutdown method called by the
        * Turbine <code>Service</code> framework
        */
       public void shutdown()
       {
       }
   
  -    
   }
  
  
  
  1.8       +36 -23    jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/RegistryFragment.java
  
  Index: RegistryFragment.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/RegistryFragment.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RegistryFragment.java	28 Jun 2002 05:37:33 -0000	1.7
  +++ RegistryFragment.java	30 Oct 2002 15:52:39 -0000	1.8
  @@ -69,27 +69,27 @@
    */
   public class RegistryFragment extends Hashtable implements java.io.Serializable {
   
  -    /** @return the entries stored in this Fragment that are suitable 
  +    /** @return the entries stored in this Fragment that are suitable
        *  for the requested registry
  -     * 
  +     *
        *  @param name a valid Registry name.
        */
       public Vector getEntries(String name)
       {
  -        
  +
           if (name != null)
           {
               Vector registry = (Vector)get(name);
  -            
  +
               if (registry != null)
               {
                   return registry;
               }
           }
  -        
  +
           return new Vector();
       }
  -             
  +
       /** Add a new entry in the fragment. It does not check for name
        *  duplication
        *  @param name a valid Registry name.
  @@ -100,14 +100,14 @@
           if ( (name != null) && (entry != null) )
           {
               Vector registry = (Vector)get(name);
  -            
  +
               if (registry != null)
               {
                   registry.add(entry);
               }
           }
       }
  -             
  +
       /** Remove an existing entry in the fragment.
        *  @param name a valid Registry name.
        *  @param entryName the name of the entry to remove
  @@ -131,7 +131,7 @@
               }
           }
       }
  -    
  +
       /** Modify an existing entry in the fragment.
        *  @param name a valid Registry name.
        *  @param entry the entry to add
  @@ -144,14 +144,14 @@
               addEntry(name,entry);
           }
       }
  -                          
  +
       // Castor serialization support methods
  -    
  +
       public Vector getPortlets()
       {
           return (Vector)get(Registry.PORTLET);
       }
  -    
  +
       public void setPortlets(Vector portlets)
       {
           if (portlets!=null)
  @@ -159,12 +159,12 @@
               put(Registry.PORTLET,portlets);
           }
       }
  -    
  +
       public Vector getControls()
       {
           return (Vector)get(Registry.PORTLET_CONTROL);
       }
  -    
  +
       public void setControls(Vector controls)
       {
           if (controls!=null)
  @@ -172,12 +172,12 @@
               put(Registry.PORTLET_CONTROL,controls);
           }
       }
  -    
  +
       public Vector getControllers()
       {
           return (Vector)get(Registry.PORTLET_CONTROLLER);
       }
  -    
  +
       public void setControllers(Vector controllers)
       {
           if (controllers!=null)
  @@ -185,12 +185,12 @@
               put(Registry.PORTLET_CONTROLLER,controllers);
           }
       }
  -    
  +
       public Vector getMedias()
       {
           return (Vector)get(Registry.MEDIA_TYPE);
       }
  -    
  +
       public void setMedias(Vector medias)
       {
           if (medias!=null)
  @@ -198,12 +198,12 @@
               put(Registry.MEDIA_TYPE,medias);
           }
       }
  -               
  +
       public Vector getSkins()
       {
           return (Vector)get(Registry.SKIN);
       }
  -    
  +
       public void setSkins(Vector skins)
       {
           if (skins!=null)
  @@ -211,17 +211,30 @@
               put(Registry.SKIN,skins);
           }
       }
  -               
  +
       public Vector getSecurityEntries()
       {
           return (Vector)get(Registry.SECURITY);
       }
  -    
  +
       public void setSecurityEntries(Vector securityEntries)
       {
           if (securityEntries!=null)
           {
               put(Registry.SECURITY, securityEntries);
  +        }
  +    }
  +
  +    public Vector getClients()
  +    {
  +        return (Vector)get(Registry.CLIENT);
  +    }
  +
  +    public void setClients(Vector clients)
  +    {
  +        if (clients!=null)
  +        {
  +            put(Registry.CLIENT, clients);
           }
       }
   }
  
  
  
  1.3       +27 -15    jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/RegistryService.java
  
  Index: RegistryService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/RegistryService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RegistryService.java	29 Jul 2001 13:42:00 -0000	1.2
  +++ RegistryService.java	30 Oct 2002 15:52:39 -0000	1.3
  @@ -54,22 +54,25 @@
   
   package org.apache.jetspeed.services.registry;
   
  -import org.apache.jetspeed.om.registry.*;
  +import org.apache.jetspeed.om.registry.Registry;
  +import org.apache.jetspeed.om.registry.RegistryEntry;
  +import org.apache.jetspeed.om.registry.RegistryException;
   import org.apache.turbine.services.Service;
   import java.util.Enumeration;
   
   /**
    * <P>This service is a facade for all registry related operations</P>
  - * 
  + *
    * @see org.apache.jetspeed.om.registry.Registry
    * @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
    * @version $Id$
    */
  -public interface RegistryService extends Service {
  - 
  +public interface RegistryService extends Service
  +{
  +
       /** The name of this service */
       public String SERVICE_NAME = "Registry";
  -    
  +
       /**
        * Returns a Registry object for further manipulation
        *
  @@ -77,22 +80,31 @@
        * @return a Registry object if found by the manager or null
        */
       public Registry get( String regName );
  -    
  +
  +    /**
  +     * Creates a new RegistryEntry instance compatible with the current
  +     * Registry instance implementation
  +     *
  +     * @param regName the name of the registry to use
  +     * @return the newly created RegistryEntry
  +     */
  +    public RegistryEntry createEntry( String regName );
  +
       /**
        * Returns a RegistryEntry from the named Registry.
  -     * This is a convenience wrapper around {@link 
  +     * This is a convenience wrapper around {@link
        * org.apache.jetspeed.om.registry.Registry#getEntry }
        *
        * @param regName the name of the registry
  -     * @param entryName the name of the entry to retrieve from the 
  +     * @param entryName the name of the entry to retrieve from the
        *                  registry
        * @return a RegistryEntry object if the key is found or null
        */
       public RegistryEntry getEntry( String regName, String entryName );
  -    
  +
       /**
        * Add a new RegistryEntry in the named Registry.
  -     * This is a convenience wrapper around {@link 
  +     * This is a convenience wrapper around {@link
        * org.apache.jetspeed.om.registry.Registry#addEntry }
        *
        * @param regName the name of the registry
  @@ -102,20 +114,20 @@
        */
       public void addEntry( String regName, RegistryEntry entry )
           throws RegistryException;
  -    
  +
       /**
        * Deletes a RegistryEntry from the named Registry
  -     * This is a convenience wrapper around {@link 
  +     * This is a convenience wrapper around {@link
        * org.apache.jetspeed.om.registry.Registry#removeEntry }
        *
        * @param regName the name of the registry
        * @param entryName the name of the entry to remove
        */
       public void removeEntry( String regName, String entryName );
  -        
  +
       /**
        *  List all the registry currently available to this service
  -     * 
  +     *
        * @return an Enumeration of registry names.
        */
       public Enumeration getNames();
  
  
  
  1.7       +26 -26    jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/TestMarshallRegistry.java
  
  Index: TestMarshallRegistry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/TestMarshallRegistry.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestMarshallRegistry.java	25 Aug 2002 21:12:44 -0000	1.6
  +++ TestMarshallRegistry.java	30 Oct 2002 15:52:39 -0000	1.7
  @@ -96,7 +96,7 @@
    */
   
   public class TestMarshallRegistry extends TestCase
  -{    
  +{
   
       /**
        * Defines the testcase name for JUnit.
  @@ -107,7 +107,7 @@
       {
           super(name);
       }
  -    
  +
       /**
        * Start the tests.
        *
  @@ -117,7 +117,7 @@
       {
           junit.awtui.TestRunner.main(new String[] { TestMarshallRegistry.class.getName() });
       }
  - 
  +
       public void setup()
       {
           System.out.println("Setup: Testing marshalling of Registry");
  @@ -144,7 +144,7 @@
        * Tests unmarshaling registry fragment
        * @throws Exception
        */
  -    public void testUnmarshallRegistry() throws Exception 
  +    public void testUnmarshallRegistry() throws Exception
       {
           System.out.println("Testing marshalling of Registry");
   
  @@ -165,7 +165,7 @@
                   Unmarshaller unmarshaller = new Unmarshaller(mapping);
                   RegistryFragment fragment = (RegistryFragment) unmarshaller.unmarshal(reader);
                   assertNotNull(fragment);
  -                Vector portlets = fragment.getPortlets();                
  +                Vector portlets = fragment.getPortlets();
   
                   // test abstract
   
  @@ -178,7 +178,7 @@
                   assertTrue(!rss.isApplication());
                   assertTrue(rss.getClassname().equals("org.apache.jetspeed.portal.portlets.NewRSSPortlet"));
                   // params
  -                Iterator it = rss.getParameterNames();    
  +                Iterator it = rss.getParameterNames();
                   HashMap mapParams = new HashMap();
                   while (it.hasNext())
                   {
  @@ -192,7 +192,7 @@
                   assertTrue(mapParams.containsKey("stylesheet"));
                   assertTrue(mapParams.containsKey("itemdisplayed"));
   
  -                // test ref 
  +                // test ref
                   PortletEntry hack = (PortletEntry) portlets.elementAt(2);
                   assertNotNull(hack);
                   assertTrue(hack.getName().equals("XMLHack"));
  @@ -230,7 +230,7 @@
                   String v15 = (String) pMap.get("itemdisplayed");
                   assertTrue(v15.equals("15"));
   
  -                // test falling back on meta info               
  +                // test falling back on meta info
   
                   PortletEntry mp = (PortletEntry) portlets.elementAt(5);
                   assertNotNull(mp);
  @@ -260,7 +260,7 @@
                   assertTrue(mpMap.containsKey("wml"));
                   assertTrue(mpMap.containsKey("xml"));
                   assertTrue(mp.hasMediaType("wml"));
  -                
  +
                   PortletEntry mt = (PortletEntry) portlets.elementAt(6);
                   assertNotNull(mt);
                   assertTrue(mt.getName().equals("NoMediaType"));
  @@ -270,7 +270,7 @@
                   assertTrue(mti.hasNext());
                   String s = (String) mti.next();
                   assertTrue(s.equals("html"));
  -             
  +
                   assertTrue(hack.getURL().equals("http://www.xmlhack.com/rss.php"));
                   assertTrue(hack.isCachedOnURL());
   
  @@ -297,7 +297,7 @@
                   cp = (CachedParameter) mpMap.get("sportsid");
                   assertNotNull(cp);
                   assertTrue(cp.isCachedOnName() == true);
  -                assertTrue(cp.isCachedOnValue() == false);                             
  +                assertTrue(cp.isCachedOnValue() == false);
                   cp = (CachedParameter) mpMap.get("contact2");
                   assertNotNull(cp);
                   assertTrue(cp.isCachedOnName() == true);
  @@ -341,15 +341,15 @@
               String errmsg = "Registy Mapping not found or not a file or unreadable: ";
               System.err.println(errmsg);
               assertNotNull(errmsg, null);
  -        }  
  +        }
       }
   
  -    
  +
       /**
        * Tests unmarshaling registry fragment
        * @throws Exception
        */
  -    public void testUnmarshallSecurityRegistry() throws Exception 
  +    public void testUnmarshallSecurityRegistry() throws Exception
       {
           boolean entryFound = false;
           System.out.println("Testing marshalling of Registry security-entry");
  @@ -371,19 +371,19 @@
               assertNotNull(fragment);
               Vector securityEntries = fragment.getSecurityEntries();
               assertTrue("Security Entries exist", !securityEntries.isEmpty());
  -            
  +
               // test abstract
               SecurityEntry securityEntry = (SecurityEntry) securityEntries.firstElement();
               assertNotNull("Got first Security Entry", securityEntry);
               assertTrue("Getting expect security entry", securityEntry.getName().equals("basic_testcase"));
  -            
  +
               // Get the action
               Vector securityAccesses = securityEntry.getAccesses();
               assertNotNull("Got SecurityAccesses", securityAccesses);
               SecurityAccess securityAccess = (SecurityAccess) securityAccesses.firstElement();
               assertNotNull("Got SecurityAccess", securityAccess);
               assertEquals("Verify action", "view", securityAccess.getAction());
  -            
  +
               // Get allows
               Vector securityAllows = securityAccess.getAllows();
               assertNotNull("Got SecurityAllows", securityAllows);
  @@ -391,12 +391,12 @@
               assertNotNull("Got SecurityAllow", securityAllow);
               assertEquals("Verify role", "clerk", securityAllow.getRole());
               assertNull("Verify user" , securityAllow.getUser());
  -            
  +
               securityAllow = (SecurityAllow) securityAllows.elementAt(1);
               assertNotNull("Got SecurityAllow", securityAllow);
               assertNull("Verify role", securityAllow.getRole());
               assertEquals("Verify user", "joe", securityAllow.getUser());
  -            
  +
               securityAllow = (SecurityAllow) securityAllows.elementAt(2);
               assertNotNull("Got SecurityAllow", securityAllow);
               assertEquals("Verify role", "manager", securityAllow.getRole());
  @@ -456,7 +456,7 @@
           }
       }
   
  -    public void testUnmarshallSecurityReference() throws Exception 
  +    public void testUnmarshallSecurityReference() throws Exception
       {
           System.out.println("Testing marshalling of Registry security-ref");
   
  @@ -509,7 +509,7 @@
               assertEquals("Found user_only security entry", true, entryFound);
           }
       }
  -            
  +
       /**
        * Tests IdentityElement unmarshaling entryset base stuff
        * @throws Exception
  @@ -521,8 +521,8 @@
         ( uses turbine.properties )
       */
       private static TurbineConfig config = null;
  -    
  -    /*    
  +
  +    /*
         Sets up TurbineConfig using the system property:
         <pre>turbine.properties</pre>
       */
  @@ -540,7 +540,7 @@
       }
   
   
  -    public void testUnmarshallURL() throws Exception 
  +    public void testUnmarshallURL() throws Exception
       {
           System.out.println("Testing marshalling of Registry, URL");
   
  @@ -578,7 +578,7 @@
               String errmsg = "Registy Mapping not found or not a file or unreadable: ";
               System.err.println(errmsg);
               assertNotNull(errmsg, null);
  -        }  
  +        }
   
       }
   }
  
  
  
  1.17      +18 -18    jakarta-jetspeed/src/java/org/apache/jetspeed/services/rundata/DefaultJetspeedRunData.java
  
  Index: DefaultJetspeedRunData.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/rundata/DefaultJetspeedRunData.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DefaultJetspeedRunData.java	27 Sep 2002 17:02:29 -0000	1.16
  +++ DefaultJetspeedRunData.java	30 Oct 2002 15:52:39 -0000	1.17
  @@ -70,7 +70,7 @@
   import java.util.Stack;
   
   /**
  - * This interface extends the RunData interface with methods 
  + * This interface extends the RunData interface with methods
    * specific to the needs of a Jetspeed like portal implementation.
    *
    * <note>Several of these properties may be put in the base RunData
  @@ -91,7 +91,7 @@
       private String pid = null;
       private int mode = NORMAL;
       private String template = null;
  -    
  +
       /**
        * Returns the portlet id referenced in this request
        *
  @@ -129,8 +129,8 @@
           {
               p = (Portlet)stack.peek();
           }
  -        
  -        /** 
  +
  +        /**
            * Save the title of this currently selected portlet
            * --------------------------------------------------------------------------
            * last modified: 11/06/01
  @@ -138,7 +138,7 @@
            */
           if ((p != null) && (stack.size() > 1))
             customizationState.setAttribute ("customize-paneName", (String)p.getTitle());
  -        else  
  +        else
             customizationState.setAttribute ("customize-paneName", "*");
   
           return (Portlet)p;
  @@ -159,7 +159,7 @@
               stack = new Stack();
               customizationState.setAttribute("customize-stack", stack);
           }
  -        
  +
           if (p==null)
           {
               if (!stack.empty()) stack.pop();
  @@ -171,8 +171,8 @@
             if (stack.size () > 0)
             {
               Portlet last = (Portlet)stack.peek();
  -          
  -            
  +
  +
               if ((last!=null) && (p.getName().equals(last.getName())) && (p.getTitle().equals(last.getTitle())))
               {
                   //System.out.println ("Portlet already used!!!");
  @@ -182,15 +182,15 @@
             }
             else
               stack.push(p);
  -            
   
  -          /** 
  +
  +          /**
              * Save the title of this currently selected portlet
              * --------------------------------------------------------------------------
              * last modified: 11/06/01
              * Andreas Kempf, Siemens ICM S CP PE, Munich
              */
  -            
  +
              customizationState.setAttribute ("customize-paneName", (String)p.getTitle());
           }
       }
  @@ -310,7 +310,7 @@
           {
               map = CapabilityMapFactory.getCapabilityMap(this);
           }
  -        
  +
           return map;
       }
   
  @@ -343,10 +343,10 @@
           pid = null;
           profile = null;
           template = null;
  -        
  +
           super.dispose();
       }
  -    
  +
       /**
        * Returns the portlet id (PEID) referenced in this request
        *
  @@ -356,7 +356,7 @@
       {
           return peid;
       }
  -    
  +
       /**
        * Sets the portlet id (PEID) referenced for this request
        *
  @@ -366,7 +366,7 @@
       {
           this.peid = peid;
       }
  -    
  +
       /**
        * Get the user id for the current user.
        * This method is provided as an abstraction to the very implementation
  @@ -414,7 +414,7 @@
           {
               Log.warn("DefaultJetspeedRunData.getPageSessionId: no profile");
           }
  -        
  +
           return sessionId + profileId;
   
       }   // getPageSessionId
  
  
  
  1.9       +3 -3      jakarta-jetspeed/src/java/org/apache/jetspeed/services/rundata/JetspeedRunData.java
  
  Index: JetspeedRunData.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/rundata/JetspeedRunData.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JetspeedRunData.java	27 Sep 2002 17:02:29 -0000	1.8
  +++ JetspeedRunData.java	30 Oct 2002 15:52:39 -0000	1.9
  @@ -62,7 +62,7 @@
   import org.apache.jetspeed.om.security.JetspeedUser;
   
   /**
  - * This interface extends the RunData interface with methods 
  + * This interface extends the RunData interface with methods
    * specific to the needs of a Jetspeed like portal implementation.
    *
    * <note>Several of these properties may be put in the base RunData
  @@ -77,7 +77,7 @@
       public int NORMAL = 0;
       public int CUSTOMIZE = 1;
       public int MAXIMIZE = 2;
  -    
  +
       /**
        * Returns the Jetspeed User (same as getUser without cast)
        *
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>