Author: kylem
Date: Wed Apr 27 15:37:57 2005
New Revision: 165060
URL: http://svn.apache.org/viewcvs?rev=165060&view=rev
Log:
Added some additional validation for ControlInterfaces/Extensions, per
BEEHIVE-118. In particular, the following cases are now caught and rejected:
- Attempting to define properties (@PropertySet or @ExternalPropertySets) from
within a ControlExtension interface. Extensions are consumers, not declarers,
of property annotation syntax.
- Extending a ControlExtension with a ControlInterface. The following are the
only valid inheritance/extension models:
+ ControlInterface (extends nothing)
+ ControlInterface extends ControlInterface
+ ControlExtension extends ControlInterface
+ ControlExtension extends ControlExtension
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java?rev=165060&r1=165059&r2=165060&view=diff
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java
Wed Apr 27 15:37:57 2005
@@ -170,7 +170,14 @@
superDecl.getAnnotation(ControlInterface.class) != null)
{
_superDecl = superDecl;
- return new AptControlInterface(_superDecl, _env);
+ AptControlInterface superIntf = new
AptControlInterface(_superDecl, _env);
+
+ if (!isExtension() && superIntf.isExtension())
+ {
+ _env.getMessager().printError(_intfDecl.getPosition(),
+ "An interface annotated with @ControlInterface can
only extend another ControlInterface. It is not valid for a ControlInterface
to extend a ControlExtension");
+ }
+ return superIntf;
}
}
@@ -284,6 +291,12 @@
ExternalPropertySets extPropsAnnotation =
_intfDecl.getAnnotation(ExternalPropertySets.class);
if ( extPropsAnnotation != null )
{
+ if (isExtension())
+ {
+ _env.getMessager().printError(_intfDecl.getPosition(),
+ "The @ExternalPropertySets annotation should only be used
on an interface annotated with @ControlInterface, never @ControlExtension. An
extension can only use existing properties, not declare new ones");
+ }
+
try
{
Class[] extProps = extPropsAnnotation.value();
@@ -341,6 +354,12 @@
_env.getMessager().printError(innerDecl.getPosition(),
"The PropertySet annotation must be used in conjuction
with @Retention(RetentionPolicy.RUNTIME)");
fError = true;
+ }
+
+ if (isExtension())
+ {
+ _env.getMessager().printError(innerDecl.getPosition(),
+ "The @PropertySet annotation should only be used
within an interface annotated with @ControlInterface, never @ControlExtension.
An extension can only use existing properties, not declare new ones");
}
if ( !fError )