@@ -980,13 +980,19 @@ private void processComponent(IDSModel model, TypeDeclaration type, ITypeBinding
980980 }
981981
982982 if (activate == null ) {
983- removeAttribute (component , IDSConstants .ATTRIBUTE_COMPONENT_ACTIVATE , "activate" ); //$NON-NLS-1$
983+ // only remove activate="activate" if method not found
984+ if (!"activate" .equals (component .getActivateMethod ()) //$NON-NLS-1$
985+ || !hasLifeCycleMethod (typeBinding , "activate" )) //$NON-NLS-1$
986+ removeAttribute (component , IDSConstants .ATTRIBUTE_COMPONENT_ACTIVATE , null ); //$NON-NLS-1$
984987 } else {
985988 component .setActivateMethod (activate );
986989 }
987990
988991 if (deactivate == null ) {
989- removeAttribute (component , IDSConstants .ATTRIBUTE_COMPONENT_DEACTIVATE , "deactivate" ); //$NON-NLS-1$
992+ // only remove deactivate="deactivate" if method not found
993+ if (!"deactivate" .equals (component .getDeactivateMethod ()) //$NON-NLS-1$
994+ || !hasLifeCycleMethod (typeBinding , "deactivate" )) //$NON-NLS-1$
995+ removeAttribute (component , IDSConstants .ATTRIBUTE_COMPONENT_DEACTIVATE , null ); //$NON-NLS-1$
990996 } else {
991997 component .setDeactivateMethod (deactivate );
992998 }
@@ -1186,7 +1192,7 @@ private String normalizePropertyElemBody(String content) {
11861192 }
11871193 } catch (IOException e ) {
11881194 if (debug .isDebugging ())
1189- debug .trace ("Error reading property element body." , e );
1195+ debug .trace ("Error reading property element body." , e ); //$NON-NLS-1$
11901196 } finally {
11911197 try {
11921198 reader .close ();
@@ -1329,6 +1335,58 @@ private void validateLifeCycleMethod(Annotation annotation, String methodName, M
13291335 }
13301336 }
13311337
1338+ private boolean hasLifeCycleMethod (ITypeBinding componentClass , String methodName ) {
1339+ for (IMethodBinding methodBinding : componentClass .getDeclaredMethods ()) {
1340+ if (methodName .equals (methodBinding .getName ())
1341+ && Void .TYPE .getName ().equals (methodBinding .getReturnType ().getName ())) {
1342+ ITypeBinding [] paramTypeBindings = methodBinding .getParameterTypes ();
1343+
1344+ // every argument must be either Map, ComponentContext, or BundleContext
1345+ boolean hasMap = false ;
1346+ boolean hasCompCtx = false ;
1347+ boolean hasBundleCtx = false ;
1348+ boolean hasInt = false ;
1349+ boolean isInvalid = false ;
1350+ for (ITypeBinding paramTypeBinding : paramTypeBindings ) {
1351+ String paramTypeName = paramTypeBinding .getErasure ().getQualifiedName ();
1352+
1353+ if (Map .class .getName ().equals (paramTypeName )) {
1354+ if (hasMap )
1355+ isInvalid = true ;
1356+ else
1357+ hasMap = true ;
1358+ } else if (ComponentContext .class .getName ().equals (paramTypeName )) {
1359+ if (hasCompCtx )
1360+ isInvalid = true ;
1361+ else
1362+ hasCompCtx = true ;
1363+ } else if (BundleContext .class .getName ().equals (paramTypeName )) {
1364+ if (hasBundleCtx )
1365+ isInvalid = true ;
1366+ else
1367+ hasBundleCtx = true ;
1368+ } else if ("deactivate" .equals (methodName ) //$NON-NLS-1$
1369+ && (Integer .class .getName ().equals (paramTypeName ) || Integer .TYPE .getName ().equals (paramTypeName ))) {
1370+ if (hasInt )
1371+ isInvalid = true ;
1372+ else
1373+ hasInt = true ;
1374+ } else {
1375+ isInvalid = true ;
1376+ }
1377+
1378+ if (isInvalid )
1379+ break ;
1380+ }
1381+
1382+ if (!isInvalid )
1383+ return true ;
1384+ }
1385+ }
1386+
1387+ return false ;
1388+ }
1389+
13321390 private boolean processReference (MethodDeclaration method , IMethodBinding methodBinding , Annotation annotation , IAnnotationBinding annotationBinding , Map <String , IDSReference > refMap , IDSDocumentFactory factory , Collection <IDSReference > collector , Map <String , Annotation > names , Collection <DSAnnotationProblem > problems ) {
13331391 HashMap <String , Object > params = new HashMap <String , Object >();
13341392 for (IMemberValuePairBinding pair : annotationBinding .getDeclaredMemberValuePairs ()) {
0 commit comments