Author: scabanovich
Date: 2012-05-24 17:25:18 -0400 (Thu, 24 May 2012)
New Revision: 41390
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeExceptionExtension.java
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeSeverityPreferences.java
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/validation/DeltaspikeValidationMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/validation/messages.properties
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/ui/preferences/DeltaspikeConfigBlockDescriptionProvider.java
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/ui/preferences/DeltaspikePreferencesMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/ui/preferences/DeltaspikePreferencesMessages.properties
Log:
JBIDE-11552
https://issues.jboss.org/browse/JBIDE-11552
Validation of handler method is implemented.
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeExceptionExtension.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeExceptionExtension.java 2012-05-24
21:11:09 UTC (rev 41389)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeExceptionExtension.java 2012-05-24
21:25:18 UTC (rev 41390)
@@ -27,6 +27,7 @@
import org.jboss.tools.cdi.core.extension.ICDIExtension;
import org.jboss.tools.cdi.core.extension.feature.IProcessAnnotatedMemberFeature;
import org.jboss.tools.cdi.core.extension.feature.IValidatorFeature;
+import org.jboss.tools.cdi.deltaspike.core.validation.DeltaspikeValidationMessages;
import org.jboss.tools.cdi.internal.core.impl.definition.AbstractMemberDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.BeanMemberDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.ParameterDefinition;
@@ -34,6 +35,7 @@
import org.jboss.tools.common.java.IAnnotated;
import org.jboss.tools.common.java.IAnnotationDeclaration;
import org.jboss.tools.common.java.IJavaAnnotation;
+import org.jboss.tools.common.java.IJavaSourceReference;
import org.jboss.tools.common.java.impl.AnnotationLiteral;
import org.jboss.tools.common.preferences.SeverityPreferences;
@@ -70,17 +72,27 @@
for (IBean b: beans) {
if(b instanceof IClassBean) {
IClassBean cb = (IClassBean)b;
- if(cb.getAnnotation(EXCEPTION_HANDLER_ANNOTATION_TYPE_NAME) != null) {
- Set<IBeanMethod> ms = cb.getAllMethods();
- for (IBeanMethod m: ms) {
- for (IParameter p: m.getParameters()) {
- if(isHandler(p)) {
- IType t = p.getType().getType();
- if(t != null &&
!EXCEPTION_EVENT_TYPE_NAME.equals(t.getFullyQualifiedName())) {
- //TODO add error marker
- System.out.println("wrong handler");
- }
+ boolean isExceptionHandler =
cb.isAnnotationPresent(EXCEPTION_HANDLER_ANNOTATION_TYPE_NAME);
+ Set<IBeanMethod> ms = cb.getAllMethods();
+ for (IBeanMethod m: ms) {
+ for (IParameter p: m.getParameters()) {
+ if(isHandler(p)) {
+ if(!isExceptionHandler) {
+ IJavaSourceReference s = p.getAnnotation(HANDLES_ANNOTATION_TYPE_NAME);
+ if(s == null) s = p.getAnnotation(BEFORE_HANDLES_ANNOTATION_TYPE_NAME);
+ if(s == null) s = p;
+ validator.addError(DeltaspikeValidationMessages.NOT_A_HANDLER_BEAN,
+ DeltaspikeSeverityPreferences.NOT_A_HANDLER_BEAN,
+ new String[]{},
+ s, file);
}
+ IType t = p.getType().getType();
+ if(t != null &&
!EXCEPTION_EVENT_TYPE_NAME.equals(t.getFullyQualifiedName())) {
+ validator.addError(DeltaspikeValidationMessages.INVALID_HANDLER_TYPE,
+ DeltaspikeSeverityPreferences.INVALID_HANDLER_TYPE,
+ new String[]{},
+ p, file);
+ }
}
}
}
@@ -111,10 +123,9 @@
}
return result;
}
+
@Override
public SeverityPreferences getSeverityPreferences() {
- // TODO Auto-generated method stub
- return null;
+ return DeltaspikeSeverityPreferences.getInstance();
}
-
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeSeverityPreferences.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeSeverityPreferences.java 2012-05-24
21:11:09 UTC (rev 41389)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/DeltaspikeSeverityPreferences.java 2012-05-24
21:25:18 UTC (rev 41390)
@@ -28,6 +28,10 @@
public static final Set<String> SEVERITY_OPTION_NAMES = new
HashSet<String>();
public static final String WARNING_GROUP_ID = "deltaspike"; //$NON-NLS-1$
+
+ public static final String INVALID_HANDLER_TYPE =
INSTANCE.createSeverityOption("invalidHandlerType",
"invalid-handler"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final String NOT_A_HANDLER_BEAN =
INSTANCE.createSeverityOption("notAHandlerBean", "invalid-handler");
//$NON-NLS-1$ //$NON-NLS-2$
+
public static final String AMBIGUOUS_AUTHORIZER =
INSTANCE.createSeverityOption("ambiguousAuthorizer",
"ambiguous-authorizer"); //$NON-NLS-1$ //$NON-NLS-2$
public static final String UNRESOLVED_AUTHORIZER =
INSTANCE.createSeverityOption("unresolvedAuthorizer",
"unresolved-authorizer"); //$NON-NLS-1$ //$NON-NLS-2$
public static final String INVALID_AUTHORIZER =
INSTANCE.createSeverityOption("invalidAuthorizer",
"invalid-authorizer"); //$NON-NLS-1$ //$NON-NLS-2$
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/validation/DeltaspikeValidationMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/validation/DeltaspikeValidationMessages.java 2012-05-24
21:11:09 UTC (rev 41389)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/validation/DeltaspikeValidationMessages.java 2012-05-24
21:25:18 UTC (rev 41390)
@@ -20,6 +20,9 @@
public class DeltaspikeValidationMessages extends NLS {
private static final String BUNDLE_NAME =
DeltaspikeValidationMessages.class.getPackage().getName() + ".messages";
//$NON-NLS-1$
+ public static String NOT_A_HANDLER_BEAN;
+ public static String INVALID_HANDLER_TYPE;
+
public static String AMBIGUOUS_AUTHORIZER;
public static String UNRESOLVED_AUTHORIZER;
public static String INVALID_AUTHORIZER_MULTIPLE_BINDINGS;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/validation/messages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/validation/messages.properties 2012-05-24
21:11:09 UTC (rev 41389)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/core/validation/messages.properties 2012-05-24
21:25:18 UTC (rev 41390)
@@ -1,3 +1,6 @@
+NOT_A_HANDLER_BEAN=Exception handler methods must be registered on beans annotated with
@ExceptionHandler
+INVALID_HANDLER_TYPE=Parameter of a handler method must be a ExceptionEvent
+
AMBIGUOUS_AUTHORIZER=Ambiguous authorizers found for security binding type {0} on method
{1}
UNRESOLVED_AUTHORIZER=No matching authorizer found for security binding type {0} on
method {1}
INVALID_AUTHORIZER_MULTIPLE_BINDINGS=Authorizer method {0} declares multiple security
binding types
@@ -2,2 +5,2 @@
INVALID_AUTHORIZER_NO_BINDINGS=Authorizer method {0} does not declare a security binding
type
-INVALID_AUTHORIZER_NOT_BOOLEAN=Authorizer method {0} does not return a boolean
\ No newline at end of file
+INVALID_AUTHORIZER_NOT_BOOLEAN=Authorizer method {0} does not return a boolean
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/ui/preferences/DeltaspikeConfigBlockDescriptionProvider.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/ui/preferences/DeltaspikeConfigBlockDescriptionProvider.java 2012-05-24
21:11:09 UTC (rev 41389)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/ui/preferences/DeltaspikeConfigBlockDescriptionProvider.java 2012-05-24
21:25:18 UTC (rev 41390)
@@ -23,6 +23,8 @@
private static SectionDescription SECTION_DELTASPIKE = new SectionDescription(
DeltaspikePreferencesMessages.CDIValidatorConfigurationBlock_section_deltaspike,
new String[][]{
+ {DeltaspikeSeverityPreferences.NOT_A_HANDLER_BEAN,
DeltaspikePreferencesMessages.CDIValidatorConfigurationBlock_pb_notAHandlerBean_label},
+ {DeltaspikeSeverityPreferences.INVALID_HANDLER_TYPE,
DeltaspikePreferencesMessages.CDIValidatorConfigurationBlock_pb_invalidHandlerType_label},
{DeltaspikeSeverityPreferences.AMBIGUOUS_AUTHORIZER,
DeltaspikePreferencesMessages.CDIValidatorConfigurationBlock_pb_ambiguousAuthorizer_label},
{DeltaspikeSeverityPreferences.UNRESOLVED_AUTHORIZER,
DeltaspikePreferencesMessages.CDIValidatorConfigurationBlock_pb_unresolvedAuthorizer_label},
{DeltaspikeSeverityPreferences.INVALID_AUTHORIZER,
DeltaspikePreferencesMessages.CDIValidatorConfigurationBlock_pb_invalidAuthorizer_label},
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/ui/preferences/DeltaspikePreferencesMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/ui/preferences/DeltaspikePreferencesMessages.java 2012-05-24
21:11:09 UTC (rev 41389)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/ui/preferences/DeltaspikePreferencesMessages.java 2012-05-24
21:25:18 UTC (rev 41390)
@@ -20,6 +20,8 @@
//Section Deltaspike
public static String CDIValidatorConfigurationBlock_section_deltaspike;
+ public static String CDIValidatorConfigurationBlock_pb_notAHandlerBean_label;
+ public static String CDIValidatorConfigurationBlock_pb_invalidHandlerType_label;
public static String CDIValidatorConfigurationBlock_pb_ambiguousAuthorizer_label;
public static String CDIValidatorConfigurationBlock_pb_unresolvedAuthorizer_label;
public static String CDIValidatorConfigurationBlock_pb_invalidAuthorizer_label;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/ui/preferences/DeltaspikePreferencesMessages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/ui/preferences/DeltaspikePreferencesMessages.properties 2012-05-24
21:11:09 UTC (rev 41389)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.deltaspike.core/src/org/jboss/tools/cdi/deltaspike/ui/preferences/DeltaspikePreferencesMessages.properties 2012-05-24
21:25:18 UTC (rev 41390)
@@ -1,6 +1,10 @@
##Section Deltaspike
CDIValidatorConfigurationBlock_section_deltaspike=Deltaspike
+
+CDIValidatorConfigurationBlock_pb_notAHandlerBean_label=Bean is not annotated
@ExceptionHandler:
+CDIValidatorConfigurationBlock_pb_invalidHandlerType_label=Invalid hander method
parameter type:
+
CDIValidatorConfigurationBlock_pb_ambiguousAuthorizer_label=Umbiguous authorizer for a
secured method:
CDIValidatorConfigurationBlock_pb_unresolvedAuthorizer_label=Unresolved authorizer for a
secured method:
-CDIValidatorConfigurationBlock_pb_invalidAuthorizer_label=Invalid authorizer:
\ No newline at end of file
+CDIValidatorConfigurationBlock_pb_invalidAuthorizer_label=Invalid authorizer: