Author: kylem
Date: Fri Aug 20 06:32:54 2004
New Revision: 36662
Added:
incubator/beehive/trunk/controls/drt/controls/org/apache/beehive/controls/test/beaninfo/
incubator/beehive/trunk/controls/drt/controls/org/apache/beehive/controls/test/beaninfo/InfoTest.java
incubator/beehive/trunk/controls/drt/controls/org/apache/beehive/controls/test/beaninfo/InfoTestImpl.jcs
incubator/beehive/trunk/controls/drt/tests/org/apache/beehive/controls/test/beaninfo/
incubator/beehive/trunk/controls/drt/tests/org/apache/beehive/controls/test/beaninfo/BeanInfoTest.java
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/FeatureAttribute.java
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/FeatureInfo.java
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/ManifestAttribute.java
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/ManifestAttributes.java
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/PropertyInfo.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBeanInfo.vm
Modified:
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
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlInterface.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlManifest.vm
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlProperty.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlInterface.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptProperty.java
Log:
First cut at generation of META-INF/MANIFEST.MF entries and customized
java.beans.BeanInfo
classes for Control JavaBeans to support an enhanced packaging model. JSR-175
attributes on the
control public or extension interface can be used to inject manifest entries
for the bean class
or customized BeanInfo descriptor elements. The JSR-175 annotation types for
this can be found
in controls/src/api/packaging/*, and include:
ManifestAttribute - sets a META-INF/MANIFEST.MF name/value attribute for
the bean class
ManifestAttributes - enables a collection of attributes to be set for a
bean class
PropertyInfo - describes elements to be written to
java.beans.PropertyDescriptor for the class.
This annotation can be used on control PropertySet element declarations
FeatureInfo - describes elements to be written to
java.beans.FeatureDescriptor for the class
and/or properties of the class. Currently supported on the interface
(to modify the
BeanDescriptor) or property declarations (to modify the
PropertyDescriptor).
FeatureAttribute - describes a name/value attribute for a FeatureDescriptor
(an array of these
may be nested inside FeatureInfo annotations)
Still remaining to be done is the annotation model for control operations and
events descriptor
elements, but it will follow the same basic pattern. A mechanism for
indirecting BeanInfo string
values through resource bundles (to enable localization) will also be supported
later.
There is a DRT sample and a skeleton test case that use java.beans.Introspector
to retrieve
the BeanInfo for the sample.
Added:
incubator/beehive/trunk/controls/drt/controls/org/apache/beehive/controls/test/beaninfo/InfoTest.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/drt/controls/org/apache/beehive/controls/test/beaninfo/InfoTest.java
Fri Aug 20 06:32:54 2004
@@ -0,0 +1,53 @@
+package org.apache.beehive.controls.test.beaninfo;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.packaging.FeatureAttribute;
+import org.apache.beehive.controls.api.packaging.FeatureInfo;
+import org.apache.beehive.controls.api.packaging.PropertyInfo;
+import org.apache.beehive.controls.api.packaging.ManifestAttribute;
+import org.apache.beehive.controls.api.packaging.ManifestAttributes;
+import org.apache.beehive.controls.api.properties.PropertySet;
+
+/**
+ * A simple test class that tests using JSR-175 annotations to inject BeanInfo
attributes
+ * for a Control type.
+ */
[EMAIL PROTECTED]
+/* THE B51 VANILLA APT PROCESSOR BARFS ON THIS RIGHT NOW
[EMAIL PROTECTED] (value={
+ @ManifestAttribute(name="Attribute1", value="Value1"),
+ @ManifestAttribute(name="Attribute2", value="Value2"),
+ @ManifestAttribute(name="Attribute3", value="Value3")
+}) */
[EMAIL PROTECTED](name="Attribute1", value="Value1")
[EMAIL PROTECTED](
+ name="InfoTest name",
+ displayName="InfoTest display name"
+ /*
+ attributes=
+ {
+ @FeatureAttribute(name="fa1", value="fv1"),
+ @FeatureAttribute(name="fa2", value="fv2")
+ }
+ */
+)
+public interface InfoTest
+{
+ @PropertySet
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target( {ElementType.TYPE, ElementType.FIELD} )
+ public @interface TestProps
+ {
+ @PropertyInfo(bound=true, constrained=false)
+ @FeatureInfo(name="InfoTest prop1", displayName="InfoTest prop1")
+ public int prop1();
+
+ public boolean prop2();
+ }
+
+}
Added:
incubator/beehive/trunk/controls/drt/controls/org/apache/beehive/controls/test/beaninfo/InfoTestImpl.jcs
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/drt/controls/org/apache/beehive/controls/test/beaninfo/InfoTestImpl.jcs
Fri Aug 20 06:32:54 2004
@@ -0,0 +1,13 @@
+package org.apache.beehive.controls.test.beaninfo;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+
+/**
+ * A simple test impl that tests using JSR-175 annotations to inject BeanInfo
attributes
+ * for a Control type.
+ */
[EMAIL PROTECTED]
+public class InfoTestImpl implements InfoTest
+{
+
+}
Added:
incubator/beehive/trunk/controls/drt/tests/org/apache/beehive/controls/test/beaninfo/BeanInfoTest.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/drt/tests/org/apache/beehive/controls/test/beaninfo/BeanInfoTest.java
Fri Aug 20 06:32:54 2004
@@ -0,0 +1,41 @@
+package org.apache.beehive.controls.test.beaninfo;
+
+import java.beans.Beans;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+
+import org.apache.beehive.controls.api.bean.ControlBean;
+import org.apache.beehive.controls.api.properties.BeanPropertyMap;
+import org.apache.beehive.controls.api.properties.PropertyKey;
+import org.apache.beehive.controls.api.properties.PropertyMap;
+
+import junit.framework.TestCase;
+
+import org.apache.beehive.controls.test.util.TestBeanContext;
+import org.apache.beehive.controls.test.beaninfo.InfoTestBean;
+
+import org.apache.beehive.controls.test.properties.Props;
+import org.apache.beehive.controls.test.properties.Props.ArrayProps;
+import org.apache.beehive.controls.test.properties.Props.SimpleEnum;
+import org.apache.beehive.controls.test.properties.Props.SimpleProps;
+import org.apache.beehive.controls.test.properties.Props.TestAnnot;
+import org.apache.beehive.controls.test.properties.PropsBean;
+import org.apache.beehive.controls.test.properties.PropsExtension;
+import org.apache.beehive.controls.test.properties.PropsExtensionBean;
+import org.apache.beehive.controls.test.properties.NestPropsBean;
+
+public class BeanInfoTest extends TestCase
+{
+ public BeanInfoTest( String s ) { super( s ); }
+
+ public void setUp() { }
+
+ /**
+ * Test the reading of BeanInfo data
+ */
+ public void testBeanInfo() throws Exception
+ {
+ BeanInfo beanInfo = Introspector.getBeanInfo(InfoTestBean.class);
+ // TODO: Additional validation beanInfo contents
+ }
+}
Added:
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/FeatureAttribute.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/FeatureAttribute.java
Fri Aug 20 06:32:54 2004
@@ -0,0 +1,38 @@
+package org.apache.beehive.controls.api.packaging;
+
+/*
+ * B E A S Y S T E M S
+ * Copyright 2001-2004 BEA Systems, Inc.
+ *
+ * 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.Target;
+
+/**
+ * The FeatureAttribute annotation type defines a JSR-175 syntax for
specifying JavaBean
+ * FeatureDescriptor attributes associated with a Control.
+ *
+ * @see org.apache.beehive.controls.api.packaging.FeatureInfo
+ */
+public @interface FeatureAttribute
+{
+ /* Specifies the feature attribute name */
+ public String name();
+
+ /* Specifies the feature attribute value */
+ public String value();
+}
Added:
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/FeatureInfo.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/FeatureInfo.java
Fri Aug 20 06:32:54 2004
@@ -0,0 +1,45 @@
+package org.apache.beehive.controls.api.packaging;
+
+/*
+ * B E A S Y S T E M S
+ * Copyright 2001-2004 BEA Systems, Inc.
+ *
+ * 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.Target;
+
+/**
+ * The FeatureInfo annotation type defines a JSR-175 syntax for annotating a
Control to
+ * provide BeanInfo FeatureDescriptor information for the bean, its
properties, methods,
+ * or events.
+ * <p>
+ * The elements of FeatureInfo correspond 1-to-1 with the information exposed
by the
+ * <code>java.beans.FeatureDescriptor</code> class.
+ *
+ * @see java.beans.FeatureDescriptor
+ */
[EMAIL PROTECTED]({ElementType.TYPE, ElementType.METHOD})
+public @interface FeatureInfo
+{
+ public String displayName() default ""; // default: use
reflection name
+ public String name() default ""; // default: use
reflection name
+ public String shortDescription() default "";
+ public boolean isExpert() default false;
+ public boolean isHidden() default false;
+ public boolean isPreferred() default false;
+ public FeatureAttribute [] attributes() default {};
+}
Added:
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/ManifestAttribute.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/ManifestAttribute.java
Fri Aug 20 06:32:54 2004
@@ -0,0 +1,39 @@
+package org.apache.beehive.controls.api.packaging;
+
+/*
+ * B E A S Y S T E M S
+ * Copyright 2001-2004 BEA Systems, Inc.
+ *
+ * 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.Target;
+
+/**
+ * The ManifestAttribute annotation type defines a JSR-175 syntax for
specifying JAR
+ * manifest attributes associated with a control type. The Beehive Controls
packaging
+ * support will process these annotation during the construction of a JAR file
that
+ * contains Controls.
+ */
[EMAIL PROTECTED]({ElementType.TYPE})
+public @interface ManifestAttribute
+{
+ /* Specifies the manifest attribute name */
+ public String name();
+
+ /* Specifies the manifest attribute value */
+ public String value();
+}
Added:
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/ManifestAttributes.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/ManifestAttributes.java
Fri Aug 20 06:32:54 2004
@@ -0,0 +1,36 @@
+package org.apache.beehive.controls.api.packaging;
+
+/*
+ * B E A S Y S T E M S
+ * Copyright 2001-2004 BEA Systems, Inc.
+ *
+ * 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.Target;
+
+/**
+ * The ManifestAttributes annotation type enables a set of manifest attributes
attributes
+ * to be defined for a given control type.
+ *
+ * @see org.apache.beehive.controls.api.packaging.ManifestAttribute
+ */
[EMAIL PROTECTED]({ElementType.TYPE})
+public @interface ManifestAttributes
+{
+ /* Specifies the set of ManifestAttribute annotation values */
+ public ManifestAttribute [] value();
+}
Added:
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/PropertyInfo.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/packaging/PropertyInfo.java
Fri Aug 20 06:32:54 2004
@@ -0,0 +1,40 @@
+package org.apache.beehive.controls.api.packaging;
+
+/*
+ * B E A S Y S T E M S
+ * Copyright 2001-2004 BEA Systems, Inc.
+ *
+ * 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.Target;
+
+/**
+ * The PropertyInfo annotation type defines a JSR-175 syntax for annotating a
Control
+ * property declaration to provide java.beans.PropertyDescriptor information.
Generic
+ * feature information is defined using the <code>FeatureInfo</code>
annotation type
+ * <p>
+ * The elements of PropertyInfo correspond 1-to-1 with the information exposed
by the
+ * <code>java.beans.PropertyDescriptor</code> class.
+ *
+ * @see java.beans.PropertyDescriptor
+ */
[EMAIL PROTECTED]({ElementType.METHOD}) // appears on PropertySet method
declaration (i.e. properties)
+public @interface PropertyInfo
+{
+ public boolean bound() default false; // Sends PropertyChange
events
+ public boolean constrained() default false; // Sends VetoableChange
events
+}
Modified:
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.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.java
Fri Aug 20 06:32:54 2004
@@ -65,6 +65,14 @@
public String getClassName() { return _className; }
/**
+ * Returns the fully qualified classname of the ControlBean BeanInfo
class. The
+ * standard JavaBean naming convention is used to enable automatic
location by
+ * the JavaBean introspector.
+ */
+ public String getBeanInfoName() { return _className + "BeanInfo"; }
+
+
+ /**
* Returns the class as a Jar Manifest Name attribute
*/
public String getManifestName() { return _className.replace('.','/') +
".class"; }
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm
==============================================================================
---
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
Fri Aug 20 06:32:54 2004
@@ -200,7 +200,11 @@
}
#end
+ #if ($property.getType().equals("boolean"))
+ public $property.type is${property.name}()
+ #else
public $property.type get${property.name}()
+ #end
{
## Remove toObject/toPrimitive once auto-boxing can be assumed
return
((#toObject($property.type))getControlProperty($property.keyName))#toPrimitive($property.type);
Added:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBeanInfo.vm
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBeanInfo.vm
Fri Aug 20 06:32:54 2004
@@ -0,0 +1,105 @@
+##
+## The Velocity code generation template for the JavaBean BeanInfo generated
from a Control public
+## or extension interface.
+##
+## B E A S Y S T E M S
+## Copyright 2001-2004 BEA Systems, Inc.
+##
+## 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:$
+##
+## The following context variables are used by this template:
+## $bean - a ControlBean instance that defines the attributes of the bean
+## $intf - a ControlInterface instance that defines the attributes of the
public interface
+##
+## The initFeatureDescriptor macro will initialize the contents of a
FeatureDescriptor using
+## a FeatureInfo annotation instance.
+##
+#macro (initFeatureDescriptor $featureDesc $featureInfo $defaultName)
+#if (! $featureInfo.name().equals(""))
+${featureDesc}.setName("$featureInfo.name()");
+#else
+${featureDesc}.setName("$defaultName");
+#end
+#if (! $featureInfo.displayName().equals(""))
+${featureDesc}.setDisplayName("$featureInfo.displayName()");
+#else
+${featureDesc}.setDisplayName("$defaultName");
+#end
+${featureDesc}.setShortDescription("$featureInfo.shortDescription()");
+${featureDesc}.setExpert($featureInfo.isExpert());
+${featureDesc}.setHidden($featureInfo.isHidden());
+${featureDesc}.setPreferred($featureInfo.isPreferred());
+##
+## Reading arrays of annotation type instances is broken under JDK1.5.0b51
+##
+###foreach ($featureAttr in $featureInfo.attributes())
+##${featureDesc}.setValue("$featureAttr.name()","$featureAttr.value()");
+###end
+#end
+##
+## Begin - Main body for ControlBeanInfo class template
+##
+package $bean.package;
+
+import java.beans.BeanDescriptor;
+import java.beans.PropertyDescriptor;
+
+import org.apache.beehive.controls.api.ControlException;
+
+public class ${bean.shortName}BeanInfo extends java.beans.SimpleBeanInfo
+{
+ public BeanDescriptor getBeanDescriptor()
+ {
+ BeanDescriptor bd = new BeanDescriptor(${bean.className}.class);
+ #set ($featureInfo = $intf.featureInfo)
+ #if ($featureInfo)
+ #initFeatureDescriptor("bd" $featureInfo $bean.shortName)
+ #else
+ bd.setName("$bean.shortName");
+ bd.setDisplayName("$bean.shortName");
+ #end
+ return bd;
+ }
+
+ #if ($intf.needsCustomPropertyDescriptors())
+ public PropertyDescriptor [] getPropertyDescriptors()
+ {
+ PropertyDescriptor [] propDescs = new
PropertyDescriptor[$intf.propertyCount];
+ int i = 0;
+ try
+ {
+ PropertyDescriptor pd;
+ #foreach ($propertySet in $intf.propertySets)
+ #foreach ($property in $propertySet.properties)
+ pd = new PropertyDescriptor("$property.memberName",
${bean.className}.class);
+ #if ($property.propertyInfo)
+ pd.setBound($property.propertyInfo.bound());
+
pd.setConstrained($property.propertyInfo.constrained());
+ #end
+ #if ($property.featureInfo)
+ #initFeatureDescriptor("pd" $property.featureInfo
$property.memberName);
+ #end
+ propDescs[i++] = pd;
+ #end
+ #end
+ }
+ catch (java.beans.IntrospectionException ie)
+ {
+ throw new ControlException("Unable to create PropertyDescriptor",
ie);
+ }
+ return propDescs;
+ }
+ #end
+}
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlInterface.java
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlInterface.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlInterface.java
Fri Aug 20 06:32:54 2004
@@ -27,6 +27,9 @@
import com.sun.mirror.apt.Filer;
+import org.apache.beehive.controls.api.packaging.FeatureInfo;
+import org.apache.beehive.controls.api.packaging.ManifestAttribute;
+
/**
* The ControlInterface class is an abstract base class that represents the
interface (base or
* extension) associated with a ControlBean type.
@@ -66,6 +69,8 @@
_eventSets = initEventSets();
+ _featureInfo = initFeatureInfo();
+
//
// Construct a bean instance for this interface
//
@@ -77,7 +82,7 @@
//
if (isExtension())
- runChecker();
+ check();
}
/**
@@ -122,9 +127,9 @@
abstract public ClassLoader getExternalClassLoader();
/**
- * Runs control-specific checker class (if specified)
+ * Perform any type-specific checking associated with a control-extension
type.
*/
- abstract public void runChecker();
+ abstract public void check();
/**
* Returns the super interface for this interface
@@ -158,6 +163,56 @@
}
/**
+ * Returns the array of ManifestAttributes associated with the
ControlInterface
+ */
+ abstract public HashMap<String,String> getManifestAttributes();
+
+ /**
+ * Returns the FeatureInfo annotation instance for this control interface
(or null
+ * if the annotation is not found).
+ */
+ abstract public FeatureInfo initFeatureInfo();
+
+ /**
+ * Returns the FeatureInfo attributes for this control interface
+ */
+ public FeatureInfo getFeatureInfo() { return _featureInfo; }
+
+ /**
+ * Returns the total number of properties for this control interface
+ */
+ public int getPropertyCount()
+ {
+ int count = 0;
+ for (ControlPropertySet propertySet : _propertySets)
+ for (ControlProperty property : propertySet.getProperties())
+ count++;
+ return count;
+ }
+
+ /**
+ * Returns true if the control BeanInfo needs a customized set of
PropertyDescriptors
+ * code generated or false if standard introspection via reflection is ok.
+ */
+ public boolean needsCustomPropertyDescriptors()
+ {
+ //
+ // The algorithm here is pretty simple.. if any individual property
needs a customized
+ // descriptor, then you have to generate them all. Reflection-driven
introspection is
+ // an all-or-nothing deal as implemented by java.beans.Introspector.
+ //
+ for (ControlPropertySet propertySet : _propertySets)
+ {
+ for (ControlProperty property : propertySet.getProperties())
+ {
+ if (property.needsCustomPropertyDescriptor())
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Returns the list of fully qualified class names for types that are
derived
* from this GenClass
*/
@@ -178,12 +233,27 @@
ArrayList<GeneratorOutput> genList = new ArrayList();
+ //
+ // the ControlBean class
+ //
Writer beanWriter = new
IndentingWriter(filer.createSourceFile(_bean.getClassName()));
GeneratorOutput beanSource =
new GeneratorOutput(beanWriter,
"org/apache/beehive/controls/runtime/generator/ControlBean.vm", map);
genList.add(beanSource);
+ //
+ // the ControlBean BeanInfo class
+ //
+ Writer beanInfoWriter = new
IndentingWriter(filer.createSourceFile(_bean.getBeanInfoName()));
+ GeneratorOutput beanInfoSource =
+ new GeneratorOutput(beanInfoWriter,
+
"org/apache/beehive/controls/runtime/generator/ControlBeanInfo.vm", map);
+ genList.add(beanInfoSource);
+
+ //
+ // the ControlBean MANIFEST.MF section
+ //
Writer manifestWriter =
filer.createTextFile(Filer.Location.CLASS_TREE, _bean.getPackage(),
new
File(_bean.getShortName() + ".class.manifest"),
null);
@@ -201,4 +271,5 @@
ArrayList<ControlPropertySet> _propertySets;
ArrayList<ControlEventSet> _eventSets;
ControlBean _bean;
+ FeatureInfo _featureInfo;
}
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlManifest.vm
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlManifest.vm
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlManifest.vm
Fri Aug 20 06:32:54 2004
@@ -35,3 +35,7 @@
Name: $bean.manifestName
JavaBean: true
+#set ($attrs = $intf.manifestAttributes)
+#foreach ($name in $attrs.keySet())
+${name}: ${attrs.get($name)}
+#end
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlProperty.java
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlProperty.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlProperty.java
Fri Aug 20 06:32:54 2004
@@ -18,6 +18,9 @@
* $Header:$
*/
+import org.apache.beehive.controls.api.packaging.FeatureInfo;
+import org.apache.beehive.controls.api.packaging.PropertyInfo;
+
/**
* The ControlProperty class is an abstract base class that represents an
Event declared within an
* EventSet interface of a ControlBean type.
@@ -81,6 +84,24 @@
* Returns true if the property is an annotation type, false otherwise
*/
abstract public boolean isAnnotation();
+
+ /**
+ * Returns any PropertyInfo associated with the property (or null if none)
+ */
+ abstract public PropertyInfo getPropertyInfo();
+
+ /**
+ * Returns any FeatureInfo associated with the property (or null if none)
+ */
+ abstract public FeatureInfo getFeatureInfo();
+
+ /**
+ * Returns true if the property needs a custom-generated
PropertyDescriptor, false otherwise
+ */
+ public boolean needsCustomPropertyDescriptor()
+ {
+ return getPropertyInfo() != null || getFeatureInfo() != null;
+ }
private ControlPropertySet _propertySet;
}
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlInterface.java
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlInterface.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlInterface.java
Fri Aug 20 06:32:54 2004
@@ -38,6 +38,9 @@
import org.apache.beehive.controls.api.bean.ControlChecker;
import org.apache.beehive.controls.api.events.EventSet;
+import org.apache.beehive.controls.api.packaging.FeatureInfo;
+import org.apache.beehive.controls.api.packaging.ManifestAttribute;
+import org.apache.beehive.controls.api.packaging.ManifestAttributes;
import org.apache.beehive.controls.api.properties.PropertySet;
import org.apache.beehive.controls.runtime.generator.ControlEventSet;
@@ -326,9 +329,42 @@
}
/**
+ * Returns the array of ManifestAttributes associated with the
ControlInterface
+ */
+ public HashMap<String, String> getManifestAttributes()
+ {
+ HashMap<String,String> attributes = new HashMap<String,String>();
+try
+{
+ ManifestAttributes annotAttrs
=_intfDecl.getAnnotation(ManifestAttributes.class);
+ if (annotAttrs != null)
+ {
+ ManifestAttribute [] attrs = (ManifestAttribute
[])annotAttrs.value();
+ for (int i = 0; i < attrs.length; i++)
+ attributes.put(attrs[i].name(), attrs[i].value());
+ }
+ ManifestAttribute annotAttr
=_intfDecl.getAnnotation(ManifestAttribute.class);
+ if (annotAttr != null)
+ {
+ attributes.put(annotAttr.name(), annotAttr.value());
+ }
+ return attributes;
+}
+catch (Exception e) { e.printStackTrace(); return attributes; }
+ }
+
+ /**
+ * Returns the FeatureInfo annotation for this control interface, or null
if there is none.
+ */
+ public FeatureInfo initFeatureInfo()
+ {
+ return _intfDecl.getAnnotation(FeatureInfo.class);
+ }
+
+ /**
* Runs control-specific checker class (if specified)
*/
- public void runChecker()
+ public void check()
{
//
// Find the nearest @ControlInterface, which is where the relevant
control checker
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptProperty.java
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptProperty.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptProperty.java
Fri Aug 20 06:32:54 2004
@@ -22,6 +22,8 @@
import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
import com.sun.mirror.type.AnnotationType;
+import org.apache.beehive.controls.api.packaging.FeatureInfo;
+import org.apache.beehive.controls.api.packaging.PropertyInfo;
import org.apache.beehive.controls.runtime.generator.ControlProperty;
/**
@@ -68,6 +70,22 @@
public boolean isAnnotation()
{
return _propDecl.getReturnType() instanceof AnnotationType;
+ }
+
+ /**
+ * Returns any PropertyInfo associated with the property (or null if none)
+ */
+ public PropertyInfo getPropertyInfo()
+ {
+ return _propDecl.getAnnotation(PropertyInfo.class);
+ }
+
+ /**
+ * Returns any FeatureInfo associated with the property (or null if none)
+ */
+ public FeatureInfo getFeatureInfo()
+ {
+ return _propDecl.getAnnotation(FeatureInfo.class);
}
AnnotationTypeElementDeclaration _propDecl;