Author: kentam
Date: Thu Jul 29 18:51:39 2004
New Revision: 30956

Added:
   
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/bean/AnnotationConstraints.java
   (contents, props changed)
   
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/bean/AnnotationMemberTypes.java
   (contents, props changed)
Modified:
   
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/bean/Control.java
   
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlImplementation.java
Log:
Add meta-annotations that allow the declarative specification of additional 
constraints on annotation and annotation member types.  For example, you can 
declare an annotation member type to be a URI, or an int that is 
range-restricted.  You may also declare relationships between annotation 
members, such as "at most one".  An apt-based implementation of these 
constraints coming soon..

Some misc doc changes.



Added: 
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/bean/AnnotationConstraints.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/bean/AnnotationConstraints.java
    Thu Jul 29 18:51:39 2004
@@ -0,0 +1,87 @@
+package org.apache.beehive.controls.api.bean;
+
+/*
+ * Copyright 2004  The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+
+import java.lang.annotation.*;
+
+/**
+ * AnnotationConstraints defines meta-annotations that allow
+ * specification of additional constraints that aren't
+ * expressible using J2SE 5.0 meta-annotations.
+ *
+ * Actual enforcement of these semantics is implementation dependent.
+ * An <code>apt</code>-based reference implementation is provided by
+ * <code>AnnotationConstraintsValidator</code>.
+ *
+ * @see AnnotationConstraintsValidator
+ */
+public interface AnnotationConstraints
+{
+    /**
+     * Defines a number of simple constraints on the way annotation members
+     * can be used together.
+     *
+     * @see #MembershipRule
+     */
+    public enum MembershipRuleValues
+    {
+        AT_LEAST_ONE,
+        AT_MOST_ONE,
+        EXACTLY_ONE,
+        ALL_IF_ANY
+    }
+
+    /**
+     * Provides a mechanism for enforcing constraints between members of
+     * an annotation (such a mechanism is absent from J2SE 5.0; for example,
+     * given an annotation with members 'a' and 'b' there is no way to say
+     * that they are mutually exclusive).
+     *
+     * @see #MembershipRuleValues
+     */
+    @Target({ElementType.ANNOTATION_TYPE})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface MembershipRule
+    {
+        /** Required, the membership rule.*/
+        MembershipRuleValues value();
+        /** Optional list of member names to apply rule against.  Empty array 
implies all members. */
+        String[] memberNames() default {};
+    }
+
+    /**
+     * Defines whether the annotation decorated by this
+     * annotation can overriden externally (a marker interface).
+     */
+    @Target({ElementType.ANNOTATION_TYPE})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface AllowExternalOverride
+    {
+    }
+
+    /**
+     * Specifies the version of the control runtime required by this 
annotation.
+     */
+    @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface RequiredRuntimeVersion
+    {
+        String value(); // no default
+    }
+}

Added: 
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/bean/AnnotationMemberTypes.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/bean/AnnotationMemberTypes.java
    Thu Jul 29 18:51:39 2004
@@ -0,0 +1,205 @@
+package org.apache.beehive.controls.api.bean;
+
+/*
+ * Copyright 2004  The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * AnnotationMemberTypes defines a set of annotations meant to used on
+ * annotation members to specify additional syntatic and semantic behaviour
+ * or constraints.
+ *
+ * J2SE 5 annotation members provide a very weak level of syntactic and
+ * semantic enforcement.  Annotation members may only be a certain type
+ * (mostly primitives, arrays, plus java.lang.String and a few other classes);
+ * it is often useful to be more specific than those types permit.
+ *
+ * Consider the following example:
+ * <code>
+ * public @interface LastChanged
+ * {
+ *     @AnnotationMemberTypes.Date()
+ *     public String date();
+ * }
+ * </code>
+ *
+ * The use of <code>@AnnotationMemberTypes.Date</code> means that the
+ * value of the <code>date</code> string must be a date in some standard
+ * form.
+ *
+ * AnnotationMemberTypes defines a set of annotations and their semantics,
+ * but actual enforcement of those semantics is implementation dependent.
+ * An <code>apt</code>-based reference implementation is provided by
+ * <code>AnnotationConstraintsValidator</code>.
+ *
+ * @see AnnotationConstraintsValidator
+ */
+public interface AnnotationMemberTypes
+{
+    public final static String OPTIONAL_STRING = "";
+    public final static double OPTIONAL_DOUBLE = Double.MIN_VALUE;
+    public final static float  OPTIONAL_FLOAT  = Float.MIN_VALUE;
+    public final static int    OPTIONAL_INT    = Integer.MIN_VALUE;
+    public final static long   OPTIONAL_LONG   = Long.MIN_VALUE;
+    public final static short  OPTIONAL_SHORT  = Short.MIN_VALUE;
+    public final static char   OPTIONAL_CHAR   = Character.MIN_VALUE;
+
+    /**
+     * Marks a member as optional.  Member must have
+     * a default value.
+     */
+    @Target({ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface Optional
+    {
+    }
+
+    /**
+     * Member must be a String value.
+     */
+    @Target({ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface Text
+    {
+        boolean isLong() default false;
+        int maxLength()  default 0;
+    }
+
+    /**
+     * Member is a Decimal Value.
+     * Member must be a String
+     * REVIEW: should allow floats
+     */
+    @Target({ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface Decimal
+    {
+        int places()      default 0;
+        String minValue() default "";
+        String maxValue() default "";
+    }
+
+    /**
+     * Member is an Integer value.
+     * Can be applied to a member that returns String or int.
+     */
+    @Target({ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface Int
+    {
+        int minValue() default  Integer.MIN_VALUE;
+        int maxValue() default Integer.MAX_VALUE;
+    }
+
+    /**
+     * Member is a Date is the Form of:YYYY/MM/DD
+     * Only valid on a member that returns String
+     * Note: JSR175 does not allow java.util.Date as
+     * a member type.
+     */
+    @Target({ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface Date
+    {
+        String minValue() default "";
+        String maxValue() default "";
+    }
+
+    /**
+     * Member is a URI
+     * Only valid on a member that returns String
+     */
+    @Target({ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface URI
+    {
+    }
+
+    /**
+     * Member is a URN
+     * Only valid on a member that returns String
+     */
+    @Target({ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface URN
+    {
+    }
+
+    /**
+     * Member is a URL
+     * Only valid on a member that returns String
+     */
+    @Target({ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface URL
+    {
+    }
+
+    /**
+     * Member is a QName
+     * Only valid on a member that returns String
+     */
+    @Target({ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface QName
+    {
+    }
+
+    /**
+     * Member contains well formed XML
+     * Only valid on a member that returns String
+     */
+    @Target({ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface XML
+    {
+    }
+
+    /**
+     * Member is a File Path
+     * Compiler MUST validate that value points
+     * to a <code>readable</code> file.
+     * Only valid on a member that returns String.
+     */
+    @Target({ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface FilePath
+    {
+    }
+
+    @Target({ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface JndiName
+    {
+        public enum ResourceType
+        {
+            DATASOURCE,
+            EJB,
+            JMS_TOPIC,
+            JMS_QUEUE ,
+            OTHER
+        }
+
+        ResourceType resourceType();
+    }
+}

Modified: 
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/bean/Control.java
==============================================================================
--- 
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/bean/Control.java
  (original)
+++ 
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/bean/Control.java
  Thu Jul 29 18:51:39 2004
@@ -1,7 +1,6 @@
 package org.apache.beehive.controls.api.bean;
 /*
- * B E A   S Y S T E M S
- * Copyright 2001-2004  BEA Systems, Inc.
+ * Copyright 2004  The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

Modified: 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlImplementation.java
==============================================================================
--- 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlImplementation.java
        (original)
+++ 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlImplementation.java
        Thu Jul 29 18:51:39 2004
@@ -50,7 +50,7 @@
     /**
      * Constructs a new ControlImpl instance where information is derived
      * from APT metadata
-     * @param typeDecl the annotated declaration
+     * @param decl the annotated declaration
      */
     public AptControlImplementation(Declaration decl, 
AnnotationProcessorEnvironment env)
     {

Reply via email to