Author: kentam
Date: Tue Aug 24 12:07:27 2004
New Revision: 36820
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBean.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptContextField.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlField.java
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/AptControlInterface.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptEventSet.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptFieldHelper.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptMethodHelper.java
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/AptPropertySet.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlAnnotationProcessor.java
Log:
Robustify controls build code w/ null checks.
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBean.java
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBean.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/bean/ControlBean.java
Tue Aug 24 12:07:27 2004
@@ -60,6 +60,10 @@
public static final char IDSeparator = '/';
public static final char FactorySeparator = ':';
+ /*
+ * TODO: replace private Mutex impl w/ JDK 1.5 mutx
+ */
+
/**
* The Mutex class provides a basic mutex implementation. It does lock
counting, so the owner
* can call lock() multiple times, but will be required to call unlock()
an equivalent
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptContextField.java
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptContextField.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptContextField.java
Tue Aug 24 12:07:27 2004
@@ -56,7 +56,7 @@
*/
protected ControlInterface initControlInterface()
{
- TypeMirror fieldType = _fieldDecl.getType();
+ TypeMirror fieldType = _fieldDecl.getType();
if (! (fieldType instanceof InterfaceType))
{
_env.getMessager().printError(_fieldDecl.getPosition(),
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlField.java
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlField.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlField.java
Tue Aug 24 12:07:27 2004
@@ -74,6 +74,10 @@
// type it implements.
//
TypeDeclaration typeDecl =
((DeclaredType)controlType).getDeclaration();
+
+ if ( typeDecl == null )
+ return null;
+
InterfaceDeclaration controlIntf = null;
if (typeDecl instanceof ClassDeclaration)
{
@@ -81,6 +85,10 @@
for (InterfaceType intfType : implIntfs)
{
InterfaceDeclaration intfDecl = intfType.getDeclaration();
+
+ if ( intfDecl == null )
+ return null;
+
if
(intfDecl.getAnnotation(org.apache.beehive.controls.api.bean.ControlInterface.class)
!= null||
intfDecl.getAnnotation(org.apache.beehive.controls.api.bean.ControlExtension.class)
!= null)
{
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
Tue Aug 24 12:07:27 2004
@@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
@@ -55,6 +56,7 @@
public AptControlImplementation(Declaration decl,
AnnotationProcessorEnvironment env)
{
super();
+ _env = env;
if (! (decl instanceof ClassDeclaration))
{
env.getMessager().printError(decl.getPosition(),
@@ -63,7 +65,6 @@
}
_implDecl = (ClassDeclaration)decl;
- _env = env;
init();
}
@@ -74,6 +75,9 @@
*/
protected ControlImpl initSuperClass()
{
+ if ( _implDecl == null || _implDecl.getSuperclass() == null )
+ return null;
+
ClassDeclaration superDecl =
_implDecl.getSuperclass().getDeclaration();
if (superDecl != null &&
superDecl.getAnnotation(org.apache.beehive.controls.api.bean.ControlImplementation.class)
!= null)
@@ -89,6 +93,9 @@
*/
public ControlInterface getControlInterface()
{
+ if ( _implDecl == null || _implDecl.getSuperinterfaces() == null )
+ return null;
+
Collection<InterfaceType> superInterfaces =
_implDecl.getSuperinterfaces();
for (InterfaceType intfType : superInterfaces)
{
@@ -106,6 +113,9 @@
*/
public String getPackage()
{
+ if ( _implDecl == null || _implDecl.getPackage() == null )
+ return null;
+
return _implDecl.getPackage().getQualifiedName();
}
@@ -114,6 +124,9 @@
*/
public String getShortName()
{
+ if ( _implDecl == null )
+ return null;
+
return _implDecl.getSimpleName();
}
@@ -122,8 +135,11 @@
*/
public String getClassName()
{
+ if ( _implDecl == null )
+ return null;
+
assert _implDecl.getQualifiedName().equals( getPackage() + "." +
getShortName() );
-
+
return _implDecl.getQualifiedName();
}
@@ -133,6 +149,10 @@
protected ArrayList<ControlField> initControls()
{
ArrayList<ControlField> controls = new ArrayList<ControlField>();
+
+ if ( _implDecl == null || _implDecl.getFields() == null )
+ return controls;
+
Collection<FieldDeclaration> declaredFields = _implDecl.getFields();
for (FieldDeclaration fieldDecl : declaredFields)
{
@@ -148,6 +168,10 @@
protected ArrayList<ContextField> initContexts()
{
ArrayList<ContextField> contexts = new ArrayList<ContextField>();
+
+ if ( _implDecl == null || _implDecl.getFields() == null )
+ return contexts;
+
Collection<FieldDeclaration> declaredFields = _implDecl.getFields();
for (FieldDeclaration fieldDecl : declaredFields)
{
@@ -163,6 +187,10 @@
protected ArrayList<ClientField> initClients()
{
ArrayList<ClientField> clients = new ArrayList<ClientField>();
+
+ if ( _implDecl == null || _implDecl.getFields() == null )
+ return clients;
+
Collection<FieldDeclaration> declaredFields = _implDecl.getFields();
for (FieldDeclaration fieldDecl : declaredFields)
{
@@ -177,6 +205,9 @@
*/
protected void initEventAdaptors()
{
+ if ( _implDecl == null || _implDecl.getMethods() == null )
+ return;
+
for (MethodDeclaration implMethod : _implDecl.getMethods())
{
//
@@ -192,7 +223,13 @@
AnnotationMirror handlerMirror = null;
for (AnnotationMirror annot : implMethod.getAnnotationMirrors())
{
- if
(annot.getAnnotationType().getDeclaration().getQualifiedName().equals(
+ if ( annot == null ||
+ annot.getAnnotationType() == null ||
+ annot.getAnnotationType().getDeclaration() == null ||
+
annot.getAnnotationType().getDeclaration().getQualifiedName() == null )
+ return;
+
+ if (
annot.getAnnotationType().getDeclaration().getQualifiedName().equals(
"org.apache.beehive.controls.api.events.EventHandler"))
{
handlerMirror = annot;
@@ -222,11 +259,15 @@
//
// Locate the EventSet based upon the eventSet element value
//
- String setName =
((TypeMirror)handlerAnnot.getObjectValue("eventSet")).toString();
+ TypeMirror tm = (TypeMirror)(
handlerAnnot.getObjectValue("eventSet") );
+ if ( tm == null )
+ continue;
+ String setName = tm.toString();
+
ControlInterface controlIntf = eventField.getControlInterface();
ControlEventSet eventSet = controlIntf.getEventSet(setName);
if (eventSet == null)
- {
+ {
_env.getMessager().printError(implMethod.getPosition(),
"Cannot find EventSet interface: " + setName);
continue;
@@ -251,7 +292,9 @@
AptMethodHelper handlerMethod = new AptMethodHelper(implMethod);
for (ControlEvent controlEvent : eventSet.getEvents())
{
- if (!controlEvent.getName().equals(eventName))
+ if (controlEvent == null || controlEvent.getName() == null |
!controlEvent.getName().equals(eventName))
+ continue;
+ if ( controlEvent.getArgTypes() == null )
continue;
if
(controlEvent.getArgTypes().equals(handlerMethod.getArgTypes()))
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
Tue Aug 24 12:07:27 2004
@@ -64,17 +64,15 @@
public AptControlInterface(Declaration decl,
AnnotationProcessorEnvironment env)
{
super();
-
+ _env = env;
if (! (decl instanceof InterfaceDeclaration))
{
env.getMessager().printError(decl.getPosition(),
"The ControlInterface or ControlExtension annotation may only be
used on a Java interface");
return;
}
-
_intfDecl = (InterfaceDeclaration)decl;
- _env = env;
init();
}
@@ -89,14 +87,20 @@
// Look for a super interface that is either a control interface or
extension.
// If found, return it.
//
+ if ( _intfDecl.getSuperinterfaces() == null )
+ return null;
+
for (InterfaceType intfType : _intfDecl.getSuperinterfaces())
{
InterfaceDeclaration superDecl = intfType.getDeclaration();
- if
(superDecl.getAnnotation(org.apache.beehive.controls.api.bean.ControlExtension.class)
!= null ||
-
superDecl.getAnnotation(org.apache.beehive.controls.api.bean.ControlInterface.class)
!= null)
+ if ( superDecl != null )
{
- _superDecl = superDecl;
- return new AptControlInterface(_superDecl, _env);
+ if
(superDecl.getAnnotation(org.apache.beehive.controls.api.bean.ControlExtension.class)
!= null ||
+
superDecl.getAnnotation(org.apache.beehive.controls.api.bean.ControlInterface.class)
!= null)
+ {
+ _superDecl = superDecl;
+ return new AptControlInterface(_superDecl, _env);
+ }
}
}
@@ -119,7 +123,10 @@
protected ArrayList<ControlOperation> initOperations()
{
ArrayList<ControlOperation> operList = new
ArrayList<ControlOperation>();
-
+
+ if ( _intfDecl == null )
+ return operList;
+
//
// Add the methods from the current interface and all super interfaces
*other*
// than the one from which control inheritance or extension is
defined. These
@@ -143,13 +150,19 @@
if (intfDecl.equals(_superDecl))
continue;
+ if ( intfDecl.getMethods() == null )
+ continue;
+
for (MethodDeclaration methodDecl : intfDecl.getMethods())
operList.add(new AptOperation(this, methodDecl, _env));
+ if ( intfDecl.getSuperinterfaces() == null )
+ continue;
+
for (InterfaceType superType : intfDecl.getSuperinterfaces())
{
InterfaceDeclaration superDecl = superType.getDeclaration();
- if (!checkIntfs.contains(superDecl))
+ if (superDecl != null && !checkIntfs.contains(superDecl))
checkIntfs.add(superDecl);
}
}
@@ -163,6 +176,9 @@
protected ArrayList<ControlPropertySet> initPropertySets()
{
ArrayList<ControlPropertySet> propSets = new
ArrayList<ControlPropertySet>();
+
+ if ( _intfDecl == null || _intfDecl.getNestedTypes() == null )
+ return propSets;
// TODO: enforce presence of prefixes when multiple property sets w/
the same
// property name exist
@@ -200,6 +216,9 @@
protected ArrayList<ControlEventSet> initEventSets()
{
ArrayList<ControlEventSet> eventSets = new
ArrayList<ControlEventSet>();
+
+ if ( _intfDecl == null || _intfDecl.getNestedTypes() == null )
+ return eventSets;
for (TypeDeclaration innerDecl : _intfDecl.getNestedTypes())
{
@@ -233,6 +252,8 @@
*/
public String getPackage()
{
+ if ( _intfDecl == null || _intfDecl.getPackage() == null )
+ return "";
return _intfDecl.getPackage().getQualifiedName();
}
@@ -241,6 +262,8 @@
*/
public String getShortName()
{
+ if ( _intfDecl == null )
+ return "";
return _intfDecl.getSimpleName();
}
@@ -249,6 +272,9 @@
*/
public String getClassName()
{
+ if ( _intfDecl == null || _intfDecl.getQualifiedName() == null )
+ return "";
+
assert _intfDecl.getQualifiedName().equals( getPackage() + "." +
getShortName() );
return _intfDecl.getQualifiedName();
@@ -260,6 +286,9 @@
*/
public boolean isExtension()
{
+ if ( _intfDecl == null )
+ return false;
+
return
_intfDecl.getAnnotation(org.apache.beehive.controls.api.bean.ControlExtension.class)
!= null;
}
@@ -334,23 +363,27 @@
public HashMap<String, String> getManifestAttributes()
{
HashMap<String,String> attributes = new HashMap<String,String>();
-try
-{
- ManifestAttributes annotAttrs
=_intfDecl.getAnnotation(ManifestAttributes.class);
- if (annotAttrs != null)
+
+ if ( _intfDecl == null )
+ return attributes;
+
+ try
{
- ManifestAttribute [] attrs = (ManifestAttribute
[])annotAttrs.value();
- for (int i = 0; i < attrs.length; i++)
- attributes.put(attrs[i].name(), attrs[i].value());
+ 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;
}
- ManifestAttribute annotAttr
=_intfDecl.getAnnotation(ManifestAttribute.class);
- if (annotAttr != null)
- {
- attributes.put(annotAttr.name(), annotAttr.value());
- }
- return attributes;
-}
-catch (Exception e) { e.printStackTrace(); return attributes; }
+ catch (Exception e) { e.printStackTrace(); return attributes; }
}
/**
@@ -358,6 +391,8 @@
*/
public FeatureInfo initFeatureInfo()
{
+ if ( _intfDecl == null )
+ return null;
return _intfDecl.getAnnotation(FeatureInfo.class);
}
@@ -377,7 +412,11 @@
InterfaceDeclaration intfDecl = mostDerived._intfDecl;
+ if ( intfDecl == null )
+ return;
+
AnnotationMirror controlMirror = null;
+
for (AnnotationMirror annot : intfDecl.getAnnotationMirrors())
{
if
(annot.getAnnotationType().getDeclaration().getQualifiedName().equals(
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptEventSet.java
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptEventSet.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptEventSet.java
Tue Aug 24 12:07:27 2004
@@ -19,7 +19,7 @@
*/
import java.util.ArrayList;
-
+import java.util.Collections;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.declaration.InterfaceDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
@@ -55,6 +55,10 @@
protected ArrayList<ControlEvent> initEvents()
{
ArrayList<ControlEvent> events = new ArrayList<ControlEvent>();
+
+ if ( _eventSet == null || _eventSet.getMethods() == null )
+ return events;
+
for (MethodDeclaration methodDecl : _eventSet.getMethods())
events.add(new AptEvent(this, methodDecl, _env));
@@ -66,6 +70,8 @@
*/
public String getName()
{
+ if ( _eventSet == null )
+ return "";
return _eventSet.getQualifiedName();
}
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptFieldHelper.java
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptFieldHelper.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptFieldHelper.java
Tue Aug 24 12:07:27 2004
@@ -40,6 +40,8 @@
*/
public String getName()
{
+ if ( _fieldDecl == null )
+ return "";
return _fieldDecl.getSimpleName();
}
@@ -48,6 +50,9 @@
*/
public String getType()
{
+ if ( _fieldDecl == null || _fieldDecl.getType() == null )
+ return "";
+
return _fieldDecl.getType().toString();
}
@@ -56,6 +61,9 @@
*/
public String getAccessModifier()
{
+ if ( _fieldDecl == null )
+ return "";
+
Collection<Modifier> modifiers = _fieldDecl.getModifiers();
if (modifiers.contains(Modifier.PRIVATE))
return "private";
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptMethodHelper.java
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptMethodHelper.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptMethodHelper.java
Tue Aug 24 12:07:27 2004
@@ -21,6 +21,7 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import com.sun.mirror.declaration.ClassDeclaration;
@@ -64,6 +65,9 @@
*/
public String getName()
{
+ if ( _methodDecl == null )
+ return "";
+
return _methodDecl.getSimpleName();
}
@@ -74,10 +78,18 @@
{
StringBuffer sb = new StringBuffer();
int i = 0;
+
+ if ( _methodDecl.getParameters() == null )
+ return "";
+
for (ParameterDeclaration paramDecl : _methodDecl.getParameters())
{
+ if ( paramDecl.getType() == null )
+ return "";
+
if (i++ != 0)
sb.append(", ");
+
sb.append(paramDecl.getType().toString());
sb.append(' ');
@@ -99,6 +111,10 @@
{
StringBuffer sb = new StringBuffer();
int i = 0;
+
+ if ( _methodDecl.getParameters() == null )
+ return "";
+
for (ParameterDeclaration paramDecl : _methodDecl.getParameters())
{
if (i++ != 0)
@@ -123,6 +139,10 @@
{
StringBuffer sb = new StringBuffer();
int i = 0;
+
+ if ( _methodDecl == null || _methodDecl.getParameters() == null )
+ return "";
+
for (ParameterDeclaration paramDecl : _methodDecl.getParameters())
{
if (i++ != 0)
@@ -134,6 +154,9 @@
if (argName.equals("arg0"))
argName = "arg" + i;
+ if ( paramDecl.getType() == null )
+ return "";
+
TypeMirror paramType = paramDecl.getType();
if (paramType instanceof PrimitiveType)
{
@@ -156,8 +179,15 @@
{
StringBuffer sb = new StringBuffer();
int i = 0;
+
+ if ( _methodDecl == null || _methodDecl.getParameters() == null )
+ return "";
+
for (ParameterDeclaration paramDecl : _methodDecl.getParameters())
{
+ if ( paramDecl.getType() == null )
+ return "";
+
if (i++ != 0)
sb.append(", ");
sb.append(paramDecl.getType().toString());
@@ -168,6 +198,9 @@
public String getReturnType()
{
+ if ( _methodDecl == null || _methodDecl.getReturnType() == null )
+ return "";
+
return _methodDecl.getReturnType().toString();
}
@@ -176,6 +209,9 @@
*/
public String getThrowsClause()
{
+ if ( _methodDecl == null || _methodDecl.getThrownTypes() == null )
+ return "";
+
Collection<ReferenceType> thrownTypes = _methodDecl.getThrownTypes();
if (thrownTypes.size() == 0)
return "";
@@ -196,8 +232,14 @@
*/
public ArrayList getThrowsList()
{
- Collection<ReferenceType> thrownTypes = _methodDecl.getThrownTypes();
ArrayList throwsList = new ArrayList();
+
+ if ( _methodDecl == null ||
+ _methodDecl.getThrownTypes() == null ||
+ _methodDecl.getThrownTypes().size() == 0 )
+ return throwsList;
+
+ Collection<ReferenceType> thrownTypes = _methodDecl.getThrownTypes();
for (ReferenceType exceptType : thrownTypes)
throwsList.add(exceptType.toString());
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
Tue Aug 24 12:07:27 2004
@@ -53,6 +53,9 @@
*/
public String getMemberName()
{
+ if ( _propDecl == null )
+ return "";
+
return _propDecl.getSimpleName();
}
@@ -61,6 +64,9 @@
*/
public String getType()
{
+ if ( _propDecl == null || _propDecl.getReturnType() == null )
+ return "";
+
return _propDecl.getReturnType().toString();
}
@@ -69,6 +75,9 @@
*/
public boolean isAnnotation()
{
+ if ( _propDecl == null )
+ return false;
+
return _propDecl.getReturnType() instanceof AnnotationType;
}
@@ -77,6 +86,9 @@
*/
public PropertyInfo getPropertyInfo()
{
+ if ( _propDecl == null )
+ return null;
+
return _propDecl.getAnnotation(PropertyInfo.class);
}
@@ -85,6 +97,9 @@
*/
public FeatureInfo getFeatureInfo()
{
+ if ( _propDecl == null )
+ return null;
+
return _propDecl.getAnnotation(FeatureInfo.class);
}
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptPropertySet.java
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptPropertySet.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptPropertySet.java
Tue Aug 24 12:07:27 2004
@@ -61,6 +61,9 @@
{
ArrayList<ControlProperty> properties = new
ArrayList<ControlProperty>();
+ if (_propertySet == null || _propertySet.getMethods() == null )
+ return properties;
+
for (MethodDeclaration methodDecl : _propertySet.getMethods())
properties.add(new
AptProperty(this,(AnnotationTypeElementDeclaration)methodDecl,_env));
@@ -72,6 +75,9 @@
*/
public String getPackage()
{
+ if (_propertySet == null || _propertySet.getPackage() == null )
+ return "";
+
return _propertySet.getPackage().getQualifiedName();
}
@@ -80,6 +86,9 @@
*/
public String getShortName()
{
+ if (_propertySet == null )
+ return "";
+
return _propertySet.getSimpleName();
}
@@ -88,6 +97,9 @@
*/
public String getClassName()
{
+ if (_propertySet == null )
+ return "";
+
return _propertySet.getQualifiedName();
}
@@ -96,6 +108,9 @@
*/
public String getPrefix()
{
+ if (_propertySet == null ||
_propertySet.getAnnotation(PropertySet.class) == null )
+ return "";
+
return _propertySet.getAnnotation(PropertySet.class).prefix();
}
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlAnnotationProcessor.java
==============================================================================
---
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlAnnotationProcessor.java
(original)
+++
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlAnnotationProcessor.java
Tue Aug 24 12:07:27 2004
@@ -67,35 +67,30 @@
{
genClass = new AptControlImplementation(decl, env);
}
- if (genClass != null)
+
+ if ( genClass != null )
{
- _typeMap.put(decl, genClass);
+ try
+ {
+ List<GeneratorOutput> genList =
genClass.getGeneratorOutput(env.getFiler());
+ if (genList == null || genList.size() == 0)
+ return;
+
+ for (GeneratorOutput genOut : genList)
+ {
+ getGenerator().generate(genOut);
+ }
+ }
+ catch (IOException ioe)
+ {
+ throw new CodeGenerationException("Code generation failure: ",
ioe);
+ }
}
}
@Override
public void generate(Declaration decl)
{
- GenClass genClass = _typeMap.get(decl);
- if (genClass == null)
- return;
-
- AnnotationProcessorEnvironment env =
getAnnotationProcessorEnvironment();
- try
- {
- List<GeneratorOutput> genList =
genClass.getGeneratorOutput(env.getFiler());
- if (genList == null || genList.size() == 0)
- return;
-
- for (GeneratorOutput genOut : genList)
- {
- getGenerator().generate(genOut);
- }
- }
- catch (IOException ioe)
- {
- throw new CodeGenerationException("Code generation failure: ",
ioe);
- }
}
/**