avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon/src/java/org/apache/avalon/component DefaultRoleManager.java RoleManager.java DefaultRoleInfo.java RoleInfo.java
Date Fri, 06 Apr 2001 13:58:09 GMT
bloritsch    01/04/06 06:58:09

  Added:       src/java/org/apache/avalon/component DefaultRoleManager.java
                        RoleManager.java
  Removed:     src/java/org/apache/avalon/component DefaultRoleInfo.java
                        RoleInfo.java
  Log:
  Reworked ComponentManagement infrastructure a little bit.
  
  Revision  Changes    Path
  1.1                  jakarta-avalon/src/java/org/apache/avalon/component/DefaultRoleManager.java
  
  Index: DefaultRoleManager.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.avalon.component;
  
  import java.util.Map;
  import java.util.Iterator;
  import java.util.HashMap;
  import java.util.Collections;
  
  import org.apache.avalon.configuration.Configurable;
  import org.apache.avalon.configuration.Configuration;
  
  import org.apache.avalon.AbstractLoggable;
  
  import org.apache.avalon.configuration.ConfigurationException;
  
  /**
   * Default RoleManager implementation.  It populates the RoleManager
   * from a configuration file.
   *
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   * @author <a href="mailto:ricardo@apache,org">Ricardo Rocha</a>
   * @author <a href="mailto:giacomo@apache,org">Giacomo Pati</a>
   * @version CVS $Revision: 1.1 $ $Date: 2001/04/06 13:58:08 $
   */
  public class DefaultRoleManager extends AbstractLoggable implements RoleManager, Configurable
{
      private Map shorthands = new HashMap();
      private Map classNames = new HashMap();
  
      public final String getRoleForName(String shorthandName) {
          getLogger().debug("looking up role " + shorthandName + ", returning " + (String)
this.shorthands.get(shorthandName));
          return (String) this.shorthands.get(shorthandName);
      }
  
      public final String getDefaultClassNameForRole(String role) {
          return (String) this.classNames.get(role);
      }
  
      protected final void addRole(String name, String shorthand, String defaultClassName)
{
          this.shorthands.put(shorthand, name);
  
          if (defaultClassName != null) {
              this.classNames.put(name, defaultClassName);
          }
      }
  
      public final void configure(Configuration conf) throws ConfigurationException {
          Configuration[] roles = conf.getChildren("role");
  
          for (int i = 0; i < roles.length; i++) {
              String name = roles[i].getAttribute("name");
              String shorthand = roles[i].getAttribute("shorthand");
              String defaultClassName = roles[i].getAttribute("default-class", null);
  
              this.addRole(name, shorthand, defaultClassName);
              getLogger().debug("added Role " + name + " with shorthand " + shorthand + "
for " + defaultClassName);
          }
  
          this.shorthands = Collections.unmodifiableMap(this.shorthands);
          this.classNames = Collections.unmodifiableMap(this.classNames);
      }
  }
  
  
  1.1                  jakarta-avalon/src/java/org/apache/avalon/component/RoleManager.java
  
  Index: RoleManager.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.avalon.component;
  
  import java.util.Iterator;
  
  /**
   * RoleManager Interface, use this to specify the Roles and how they
   * correspond easy shorthand names.
   *
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   * @author <a href="mailto:ricardo@apache,org">Ricardo Rocha</a>
   * @author <a href="mailto:giacomo@apache,org">Giacomo Pati</a>
   * @version CVS $Revision: 1.1 $ $Date: 2001/04/06 13:58:09 $
   */
  public interface RoleManager {
      /**
       * Find Role name based on shorthand name.  Please note that if
       * this returns <code>null</code> or an empty string, then the
       * shorthand name is assumed to be a "reserved word".  In other
       * words, you should not try to instantiate a class from an empty
       * role.
       */
      public String getRoleForName(String shorthandName);
  
      /**
       * Get the default classname for a given role
       */
      public String getDefaultClassNameForRole(String role);
  }
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message