Author: akazakov
Date: 2009-03-20 12:50:18 -0400 (Fri, 20 Mar 2009)
New Revision: 14284
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponent.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.9
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3957 Change "Only Component class can have
@Destroy method" Seam validator rule to "Only JavaBeans and stateful session
beans support @Destroy methods" - Fixed
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponent.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponent.java 2009-03-20
14:35:00 UTC (rev 14283)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponent.java 2009-03-20
16:50:18 UTC (rev 14284)
@@ -76,11 +76,16 @@
public Set<IBijectedAttribute> getBijectedAttributesByType(BijectedAttributeType
type);
/**
- * @return true if component marked as Stateful
+ * @return true if component marked as stateful sessian bean
*/
public boolean isStateful();
/**
+ * @return true if component marked as stateless session bean
+ */
+ public boolean isStateless();
+
+ /**
* @return true if component marked as Entity
*/
public boolean isEntity();
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamJavaComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamJavaComponentDeclaration.java 2009-03-20
14:35:00 UTC (rev 14283)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamJavaComponentDeclaration.java 2009-03-20
16:50:18 UTC (rev 14284)
@@ -67,11 +67,16 @@
public boolean isOfType(BeanType type);
/**
- * @return true if class marked as Stateful
+ * @return true if class marked as stateful session bean
*/
public boolean isStateful();
/**
+ * @return true if class marked as stateless session bean
+ */
+ public boolean isStateless();
+
+ /**
* @return true if class marked as Entity
*/
public boolean isEntity();
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java 2009-03-20
14:35:00 UTC (rev 14283)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java 2009-03-20
16:50:18 UTC (rev 14284)
@@ -84,7 +84,7 @@
// Mark duplicated @Unwrap methods within one component.
public static final String DUPLICATE_UNWRAP =
createSeverityOption("duplicateUnwrap"); //$NON-NLS-1$
// Mark all @Destroy methods which are not declared in components' classes.
- public static final String DESTROY_DOESNT_BELONG_TO_COMPONENT =
createSeverityOption("destroyDoesNotBelongToComponent"); //$NON-NLS-1$
+ public static final String DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN =
createSeverityOption("destroyMethodBelongsToStatelessSessionBean");
//$NON-NLS-1$
// Mark all @Create methods which are not declared in components' classes.
public static final String CREATE_DOESNT_BELONG_TO_COMPONENT =
createSeverityOption("createDoesNotBelongToComponent"); //$NON-NLS-1$
// Mark all @Unwrap methods which are not declared in components' classes.
@@ -185,7 +185,7 @@
SeamPreferences.IGNORE.equals(getProjectPreference(project, DUPLICATE_DESTROY))
&&
SeamPreferences.IGNORE.equals(getProjectPreference(project, DUPLICATE_CREATE))
&&
SeamPreferences.IGNORE.equals(getProjectPreference(project, DUPLICATE_UNWRAP))
&&
- SeamPreferences.IGNORE.equals(getProjectPreference(project,
DESTROY_DOESNT_BELONG_TO_COMPONENT)) &&
+ SeamPreferences.IGNORE.equals(getProjectPreference(project,
DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN)) &&
SeamPreferences.IGNORE.equals(getProjectPreference(project,
CREATE_DOESNT_BELONG_TO_COMPONENT)) &&
SeamPreferences.IGNORE.equals(getProjectPreference(project,
UNWRAP_DOESNT_BELONG_TO_COMPONENT)) &&
SeamPreferences.IGNORE.equals(getProjectPreference(project,
OBSERVER_DOESNT_BELONG_TO_COMPONENT)) &&
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2009-03-20
14:35:00 UTC (rev 14283)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2009-03-20
16:50:18 UTC (rev 14284)
@@ -164,6 +164,14 @@
}
/**
+ * @see org.jboss.tools.seam.core.ISeamComponent#isStateless()
+ */
+ public boolean isStateless() {
+ ISeamJavaComponentDeclaration javaDeclaration = getJavaDeclaration();
+ return (javaDeclaration != null) && javaDeclaration.isStateless();
+ }
+
+ /**
* @see org.jboss.tools.seam.core.ISeamContextVariable#getName()
*/
public String getName() {
@@ -371,5 +379,4 @@
}
}
}
-
-}
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2009-03-20
14:35:00 UTC (rev 14283)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2009-03-20
16:50:18 UTC (rev 14284)
@@ -219,7 +219,11 @@
public boolean isStateful() {
return isOfType(BeanType.STATEFUL);
}
-
+
+ public boolean isStateless() {
+ return isOfType(BeanType.STATELESS);
+ }
+
public void removeBijectedAttribute(IBijectedAttribute attribute) {
bijectedAttributes.remove(attribute);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2009-03-20
14:35:00 UTC (rev 14283)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2009-03-20
16:50:18 UTC (rev 14284)
@@ -75,6 +75,7 @@
protected static final String CREATE_METHOD_SUFIX_MESSAGE_ID = "CREATE";
//$NON-NLS-1$
protected static final String UNWRAP_METHOD_SUFIX_MESSAGE_ID = "UNWRAP";
//$NON-NLS-1$
protected static final String OBSERVER_METHOD_SUFIX_MESSAGE_ID = "OBSERVER";
//$NON-NLS-1$
+ protected static final String DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN_ID =
"DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN"; //$NON-NLS-1$
protected static final String NONCOMPONENTS_METHOD_SUFIX_MESSAGE_ID =
"_DOESNT_BELONG_TO_COMPONENT"; //$NON-NLS-1$
protected static final String STATEFUL_COMPONENT_WRONG_SCOPE_MESSAGE_ID =
"STATEFUL_COMPONENT_WRONG_SCOPE"; //$NON-NLS-1$
protected static final String ENTITY_COMPONENT_WRONG_SCOPE_MESSAGE_ID =
"ENTITY_COMPONENT_WRONG_SCOPE"; //$NON-NLS-1$
@@ -621,6 +622,7 @@
validateStatefulComponent(component);
validateDuplicateComponentMethods(component);
validateEntityComponent(component);
+ validateDestroyMethod(component);
}
private void validateBijections(ISeamJavaComponentDeclaration declaration) {
@@ -702,7 +704,6 @@
IMember member = declaration.getSourceMember();
try {
if(member!=null && !Flags.isAbstract(member.getFlags())) {
- validateMethodOfUnknownComponent(SeamComponentMethodType.DESTROY, declaration,
DESTROY_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.DESTROY_DOESNT_BELONG_TO_COMPONENT);
validateMethodOfUnknownComponent(SeamComponentMethodType.CREATE, declaration,
CREATE_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.CREATE_DOESNT_BELONG_TO_COMPONENT);
validateMethodOfUnknownComponent(SeamComponentMethodType.UNWRAP, declaration,
UNWRAP_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.UNWRAP_DOESNT_BELONG_TO_COMPONENT);
validateMethodOfUnknownComponent(SeamComponentMethodType.OBSERVER, declaration,
OBSERVER_METHOD_SUFIX_MESSAGE_ID, SeamPreferences.OBSERVER_DOESNT_BELONG_TO_COMPONENT);
@@ -714,6 +715,22 @@
validationContext.removeUnnamedCoreResource(declaration.getSourcePath());
}
+ private void validateDestroyMethod(ISeamComponent component) {
+ if(component.isStateless()) {
+ ISeamJavaComponentDeclaration javaDeclaration = component.getJavaDeclaration();
+ Set<ISeamComponentMethod> methods =
javaDeclaration.getMethodsByType(SeamComponentMethodType.DESTROY);
+ for (ISeamComponentMethod method : methods) {
+ IMethod javaMethod = (IMethod)method.getSourceMember();
+ String methodName = javaMethod.getElementName();
+ if(javaDeclaration.getSourcePath().equals(javaMethod.getPath())) {
+ validationContext.addLinkedCoreResource(component.getName(),
javaDeclaration.getSourcePath());
+ ISeamTextSourceReference methodNameLocation = getNameLocation(method);
+ addError(DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN_ID,
SeamPreferences.DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN, new
String[]{methodName}, methodNameLocation, method.getResource());
+ }
+ }
+ }
+ }
+
private void validateMethodOfUnknownComponent(SeamComponentMethodType methodType,
ISeamJavaComponentDeclaration declaration, String sufixMessageId, String preferenceKey) {
Set<ISeamComponentMethod> methods = declaration.getMethodsByType(methodType);
if(methods!=null && methods.size()>0) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties 2009-03-20
14:35:00 UTC (rev 14283)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties 2009-03-20
16:50:18 UTC (rev 14284)
@@ -24,7 +24,7 @@
DUPLICATE_DESTROY=Duplicate @Destroy method "{0}"
DUPLICATE_CREATE=Duplicate @Create method "{0}"
DUPLICATE_UNWRAP=Duplicate @Unwrap method "{0}"
-DESTROY_DOESNT_BELONG_TO_COMPONENT=Only component class can have @Destroy method
"{0}"
+DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN=Only JavaBeans and stateful session
beans support @Destroy methods "{0}"
CREATE_DOESNT_BELONG_TO_COMPONENT=Only component class can have @Create method
"{0}"
UNWRAP_DOESNT_BELONG_TO_COMPONENT=Only component class can have @Unwrap method
"{0}"
OBSERVER_DOESNT_BELONG_TO_COMPONENT=Only component class can have @Observer method
"{0}"
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java 2009-03-20
14:35:00 UTC (rev 14283)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java 2009-03-20
16:50:18 UTC (rev 14284)
@@ -123,7 +123,7 @@
public static String SeamValidatorConfigurationBlock_pb_duplicateDestroy_label;
public static String SeamValidatorConfigurationBlock_pb_duplicateCreate_label;
public static String SeamValidatorConfigurationBlock_pb_duplicateUnwrap_label;
- public static String
SeamValidatorConfigurationBlock_pb_destroyDoesNotBelongToComponent_label;
+ public static String
SeamValidatorConfigurationBlock_pb_destroyMethodBelongsToStatelessSessionBean_label;
public static String
SeamValidatorConfigurationBlock_pb_createDoesNotBelongToComponent_label;
public static String
SeamValidatorConfigurationBlock_pb_unwrapDoesNotBelongToComponent_label;
public static String
SeamValidatorConfigurationBlock_pb_observerDoesNotBelongToComponent_label;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties 2009-03-20
14:35:00 UTC (rev 14283)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties 2009-03-20
16:50:18 UTC (rev 14284)
@@ -35,10 +35,10 @@
SeamValidatorConfigurationBlock_pb_duplicateDestroy_label=Duplicate @Destroy method:
SeamValidatorConfigurationBlock_pb_duplicateCreate_label=Duplicate @Create method:
SeamValidatorConfigurationBlock_pb_duplicateUnwrap_label=Duplicate @Unwrap method:
-SeamValidatorConfigurationBlock_pb_destroyDoesNotBelongToComponent_label=Only component
class can have @Destroy method
-SeamValidatorConfigurationBlock_pb_createDoesNotBelongToComponent_label=Only component
class can have @Create method
-SeamValidatorConfigurationBlock_pb_unwrapDoesNotBelongToComponent_label=Only component
class can have @Unwrap method
-SeamValidatorConfigurationBlock_pb_observerDoesNotBelongToComponent_label=Only component
class can have @Observer method
+SeamValidatorConfigurationBlock_pb_destroyMethodBelongsToStatelessSessionBean_label=Only
JavaBeans and stateful session beans support @Destroy methods:
+SeamValidatorConfigurationBlock_pb_createDoesNotBelongToComponent_label=Only component
class can have @Create method:
+SeamValidatorConfigurationBlock_pb_unwrapDoesNotBelongToComponent_label=Only component
class can have @Unwrap method:
+SeamValidatorConfigurationBlock_pb_observerDoesNotBelongToComponent_label=Only component
class can have @Observer method:
##Section Factories
SeamValidatorConfigurationBlock_section_factory=Factories
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java 2009-03-20
14:35:00 UTC (rev 14283)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java 2009-03-20
16:50:18 UTC (rev 14284)
@@ -89,7 +89,7 @@
{SeamPreferences.DUPLICATE_DESTROY,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_duplicateDestroy_label},
{SeamPreferences.DUPLICATE_CREATE,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_duplicateCreate_label},
{SeamPreferences.DUPLICATE_UNWRAP,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_duplicateUnwrap_label},
- {SeamPreferences.DESTROY_DOESNT_BELONG_TO_COMPONENT,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_destroyDoesNotBelongToComponent_label},
+ {SeamPreferences.DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_destroyMethodBelongsToStatelessSessionBean_label},
{SeamPreferences.CREATE_DOESNT_BELONG_TO_COMPONENT,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_createDoesNotBelongToComponent_label},
{SeamPreferences.UNWRAP_DOESNT_BELONG_TO_COMPONENT,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_unwrapDoesNotBelongToComponent_label},
{SeamPreferences.OBSERVER_DOESNT_BELONG_TO_COMPONENT,
SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_observerDoesNotBelongToComponent_label},
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.9
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.9 2009-03-20
14:35:00 UTC (rev 14283)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.9 2009-03-20
16:50:18 UTC (rev 14284)
@@ -1,10 +1,10 @@
package org.domain.SeamWebWarTestProject.session;
-
-
+import javax.ejb.Stateless;
+import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Destroy;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.log.Log;
-
+@Stateless @Name("statelessComponentWithDestroyMethod")
public class StatefulComponent {
private String abc;
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2009-03-20
14:35:00 UTC (rev 14283)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2009-03-20
16:50:18 UTC (rev 14284)
@@ -384,8 +384,8 @@
}
refreshProject(project);
- // Only component class can have @Destroy method
- System.out.println("Test - Only component class can have @Destroy method");
+ // Only JavaBeans and stateful session beans support @Destroy methods
+ System.out.println("Test - Only JavaBeans and stateful session beans support
@Destroy methods");
final String NEW_CONTENT_FILE_NAME9 =
"src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.9";
assertMarkerIsCreated(