You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by le...@apache.org on 2003/12/28 21:43:50 UTC

cvs commit: jakarta-commons-sandbox/attributes/api/src/java/org/apache/commons/attributes Attributes.java

leosutic    2003/12/28 12:43:49

  Modified:    attributes/api/src/java/org/apache/commons/attributes
                        Attributes.java
  Log:
  Improved Javadoc
  
  Revision  Changes    Path
  1.7       +24 -0     jakarta-commons-sandbox/attributes/api/src/java/org/apache/commons/attributes/Attributes.java
  
  Index: Attributes.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/attributes/api/src/java/org/apache/commons/attributes/Attributes.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Attributes.java	12 Oct 2003 09:07:30 -0000	1.6
  +++ Attributes.java	28 Dec 2003 20:43:49 -0000	1.7
  @@ -387,4 +387,28 @@
       public static boolean hasReturnAttribute (Method method, Object attribute) {
           return hasAttribute (getReturnAttributes (method), attribute);
       }
  +    
  +    /**
  +     * Set attributes for a given class. The class must not have attributes set for it already
  +     * (i.e. you can't redefine the attributes of a class at runtime). This because it
  +     * really messes up the concept of inheritable attributes, and because the attribute set
  +     * associated with a class is immutable, like the set of methods and fields.
  +     *
  +     * @param repo The repository. The repository will be sealed before any attributes are
  +     *             set. This to guarantee that the repository remains constant
  +     *             during setting.
  +     * @throws IllegalStateException if the class whose attributes are defined already have
  +     *         attributes defined for it (even if it has no attributes).
  +     */
  +    public static synchronized void setAttributes (RuntimeAttributeRepository repo) throws IllegalStateException {
  +        repo.seal ();
  +        
  +        Class clazz = repo.getDefinedClass ();
  +        if (classRepositories.get (clazz) != null) {
  +            throw new IllegalStateException (clazz.getName ());
  +        }
  +        
  +        DefaultCachedRepository cached = new DefaultCachedRepository (clazz, repo);
  +        classRepositories.put (clazz, cached);
  +    }
   }
  
  
  

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