psmith      2003/06/26 15:59:44

  Modified:    src/java/org/apache/log4j/plugins PluginRegistry.java
  Log:
  added pluginNameExists method to allow Chainsaw (and other clients)
  to determine if a specific plugin name is already in use.
  
  Chainsaw uses this method to suffix an incrementing number
  should the user try and reuse the name.
  
  Revision  Changes    Path
  1.7       +32 -0     
jakarta-log4j/src/java/org/apache/log4j/plugins/PluginRegistry.java
  
  Index: PluginRegistry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/plugins/PluginRegistry.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PluginRegistry.java       24 Jun 2003 08:24:57 -0000      1.6
  +++ PluginRegistry.java       26 Jun 2003 22:59:44 -0000      1.7
  @@ -67,6 +67,7 @@
     plugins for a repository.
   
     @author Mark Womack
  +  @author Paul Smith
     @since 1.3
   */
   public class PluginRegistry {
  @@ -94,6 +95,37 @@
       return startPlugin(plugin, repository);
     }
   
  +  /**
  +   * Returns true if the specified name is already taken by
  +   * an existing Plugin registered for the default Repository.
  +   * @param name The name to check the repository for
  +   * @return true if the name is already in use, otherwise false
  +   */
  +  public static boolean pluginNameExists(String name){
  +    LoggerRepository repository = LogManager.getLoggerRepository();
  +
  +    return pluginNameExists(name, repository);
  +  }
  +  
  +
  +  /**
  +   * Returns true if the specified name is already taken by
  +   * an existing Plugin registered within the scope of the specified 
  +   * LoggerRepository.
  +   * @param name The name to check the repository for
  +   * @param repository the repository to check the name against
  +   * @return true if the name is already in use, otherwise false
  +   */
  +  public static boolean pluginNameExists(String name, LoggerRepository repository){
  +    synchronized(repositoryMap){
  +      Map pluginMap = (Map) repositoryMap.get(repository);
  +      if( pluginMap != null && pluginMap.containsKey(name)){
  +        return true;
  +      }
  +    }
  +    return false;
  +  }
  +  
     /**
       Starts a plugin with a given logger repository.
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to