Author: kylem
Date: Wed Mar 2 15:03:12 2005
New Revision: 155969
URL: http://svn.apache.org/viewcvs?view=rev&rev=155969
Log:
Fixed some issues with control interface/extension subclassing, when generic
formal type
parameters are bound as part of the interface declaration.
Added:
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/generic/ExtendedSimpleControl.java
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/generic/ExtendedSimpleControlImpl.jcs
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm
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?view=diff&r1=155968&r2=155969
==============================================================================
---
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 Mar 2 15:03:12 2005
@@ -112,15 +112,11 @@
}
/**
- * Initializes the super interface that this ControlInterface extends (or
sets it to null
- * if a base interface)
+ * Returns the parent control interface or extension type from which the
control
+ * interface is derived (or null, if it is at the root of the interface
hierarchy)
*/
- private AptControlInterface initSuperClass()
+ public InterfaceType getSuperType()
{
- //
- // Look for a super interface that is either a control interface or
extension.
- // If found, return it.
- //
if ( _intfDecl.getSuperinterfaces() == null )
return null;
@@ -133,24 +129,53 @@
superDecl.getAnnotation(ControlInterface.class) != null)
{
_superDecl = superDecl;
- return new AptControlInterface(_superDecl, _env);
+ return intfType;
}
}
}
- // At this point, we're processing the root of the interface heirarchy,
- // which is not permitted to be a ControlExtension (that would imply a
- // ControlExtension that wasn't actually extending a ControlInterface).
- if ( isExtension() )
+ return null;
+ }
+
+ /**
+ * Initializes the super interface that this ControlInterface extends (or
sets it to null
+ * if a base interface)
+ */
+ private AptControlInterface initSuperClass()
+ {
+ //
+ // Look for a super interface that is either a control interface or
extension.
+ // If found, return it.
+ //
+ InterfaceType superType = getSuperType();
+ if (superType == null)
+ {
+ // At this point, we're processing the root of the interface
heirarchy,
+ // which is not permitted to be a ControlExtension (that would
imply a
+ // ControlExtension that wasn't actually extending a
ControlInterface).
+ if ( isExtension() )
+ {
+ _env.getMessager().printError(_intfDecl.getPosition(),
+ "Interfaces annotated with ControlExtension must extend an
interface " +
+ " annotated with ControlInterface");
+ }
+
+ return null;
+ }
+
+ InterfaceDeclaration superDecl = superType.getDeclaration();
+ if ( superDecl != null )
{
- _env.getMessager().printError(_intfDecl.getPosition(),
- "Interfaces annotated with ControlExtension must extend an
interface annotated with " +
- "ControlInterface");
+ if (superDecl.getAnnotation(ControlExtension.class) != null ||
+ superDecl.getAnnotation(ControlInterface.class) != null)
+ {
+ _superDecl = superDecl;
+ return new AptControlInterface(_superDecl, _env);
+ }
}
return null;
}
-
/**
* Returns the super interface for this interface
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.java?view=diff&r1=155968&r2=155969
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.java
Wed Mar 2 15:03:12 2005
@@ -17,6 +17,8 @@
* $Header:$
*/
+import com.sun.mirror.type.InterfaceType;
+
/**
* The ControlBean class is an class representing a generated JavaBean class
that can host
* control implementation types associated with a particular control public or
extension
@@ -95,6 +97,23 @@
* Returns the super class for this ControlBean
*/
public ControlBean getSuperClass() { return _superClass; }
+
+ /**
+ * Returns any formal type parameters that should be bound for the bean's
superclass,
+ * based upon any type bindings that occur on the original interface.
+ */
+ public String getSuperTypeBinding()
+ {
+ InterfaceType superType = _controlIntf.getSuperType();
+ if (superType != null)
+ {
+ String typeStr = superType.toString();
+ int paramIndex = typeStr.indexOf('<');
+ if (paramIndex > 0)
+ return typeStr.substring(paramIndex);
+ }
+ return "";
+ }
String _packageName;
String _shortName;
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm?view=diff&r1=155968&r2=155969
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm
Wed Mar 2 15:03:12 2005
@@ -589,7 +589,7 @@
import org.apache.beehive.controls.api.versioning.*;
public class ${bean.classDeclaration}
- extends $bean.superClass.className
+ extends ${bean.superClass.className}${bean.superTypeBinding}
implements ${intf.formalClassName}
{
#if ($intf.operations.size() != 0)
Added:
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/generic/ExtendedSimpleControl.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/generic/ExtendedSimpleControl.java?view=auto&rev=155969
==============================================================================
---
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/generic/ExtendedSimpleControl.java
(added)
+++
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/generic/ExtendedSimpleControl.java
Wed Mar 2 15:03:12 2005
@@ -0,0 +1,19 @@
+package org.apache.beehive.controls.test.controls.generic;
+
+import java.util.Vector;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+
+/**
+ * This test interface does an extension of a generic type while binding some
of the
+ * formal type parameters. This ensures that the type binding is properly
applied
+ * to the code-generated bean types.
+ */
[EMAIL PROTECTED]
+public interface ExtendedSimpleControl extends SimpleControl<Integer>
+{
+}
Added:
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/generic/ExtendedSimpleControlImpl.jcs
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/generic/ExtendedSimpleControlImpl.jcs?view=auto&rev=155969
==============================================================================
---
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/generic/ExtendedSimpleControlImpl.jcs
(added)
+++
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/generic/ExtendedSimpleControlImpl.jcs
Wed Mar 2 15:03:12 2005
@@ -0,0 +1,13 @@
+package org.apache.beehive.controls.test.controls.generic;
+
+import java.util.Vector;
+import java.lang.reflect.Method;
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.bean.Extensible;
+
[EMAIL PROTECTED]
+public class ExtendedSimpleControlImpl
+ extends SimpleControlImpl<Integer>
+ implements ExtendedSimpleControl
+{
+}