Author: dblevins
Date: Wed Jul 2 18:52:40 2008
New Revision: 673563
URL: http://svn.apache.org/viewvc?rev=673563&view=rev
Log:
OPENEJB-844: Validation: Singleton @Lock annotation not used with Bean-Managed
Concurrency
OPENEJB-848: Validation: @TransactionAttribute mistakenly used on beans with
Bean-Managed Transactions
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=673563&r1=673562&r2=673563&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
Wed Jul 2 18:52:40 2008
@@ -711,6 +711,8 @@
if (bean.getTransactionType() == TransactionType.CONTAINER) {
processAttributes(new
TransactionAttributeHandler(assemblyDescriptor, ejbName), clazz,
inheritedClassFinder);
+ } else {
+ checkAttributes(new
TransactionAttributeHandler(assemblyDescriptor, ejbName), ejbName, ejbModule,
classFinder, "invalidTransactionAttribute");
}
processSecurityAnnotations(clazz, ejbName, ejbModule,
inheritedClassFinder, bean);
@@ -852,6 +854,8 @@
if (sessionBean.getConcurrencyType() ==
ConcurrencyType.CONTAINER) {
processAttributes(new
ConcurrencyAttributeHandler(assemblyDescriptor, ejbName), clazz,
inheritedClassFinder);
+ } else {
+ checkAttributes(new
ConcurrencyAttributeHandler(assemblyDescriptor, ejbName), ejbName, ejbModule,
classFinder, "invalidConcurrencyAttribute");
}
}
}
@@ -1308,6 +1312,28 @@
}
}
+ private <A extends Annotation> void
checkAttributes(AnnotationHandler<A> handler, String ejbName, EjbModule
ejbModule, ClassFinder classFinder, String messageKey) {
+ Map<String, List<MethodAttribute>> existingDeclarations =
handler.getExistingDeclarations();
+
+ int xml = 0;
+ for (List<MethodAttribute> methodAttributes :
existingDeclarations.values()) {
+ xml += methodAttributes.size();
+ }
+
+ if (xml > 0){
+ ejbModule.getValidation().warn(ejbName, "xml."+messageKey,
xml);
+ }
+
+ int ann =
classFinder.findAnnotatedClasses(handler.getAnnotationClass()).size();
+ ann +=
classFinder.findAnnotatedMethods(handler.getAnnotationClass()).size();
+
+ if (ann > 0){
+ ejbModule.getValidation().warn(ejbName, "ann."+messageKey,
ann);
+ }
+
+
+ }
+
private <A extends Annotation> void
processAttributes(AnnotationHandler<A> handler, Class<?> clazz, ClassFinder
classFinder) {
Map<String, List<MethodAttribute>> existingDeclarations =
handler.getExistingDeclarations();
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties?rev=673563&r1=673562&r2=673563&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties
Wed Jul 2 18:52:40 2008
@@ -547,4 +547,25 @@
# fail(ejbName, "conflictingSecurityAnnotations", method.getName(), join(" and
", annotations), method.getDeclaringClass());
1.conflictingSecurityAnnotations = Method has conflicting security annotations.
2.conflictingSecurityAnnotations = Method has conflicting security
annotations: "{0}" uses {1}
-3.conflictingSecurityAnnotations = The {1} annotations are mutually exclussive
and cannot be used together on the same method. Choose the security annotation
you want and delete the others from method {0} in class {2}. @RolesAllowed
will restrict access to the listed authenticated roles. @PermitAll will allow
access to anyone authenticated or not. @DenyAll will deny access to anyone
authenticated or not.
\ No newline at end of file
+3.conflictingSecurityAnnotations = The {1} annotations are mutually exclussive
and cannot be used together on the same method. Choose the security annotation
you want and delete the others from method {0} in class {2}. @RolesAllowed
will restrict access to the listed authenticated roles. @PermitAll will allow
access to anyone authenticated or not. @DenyAll will deny access to anyone
authenticated or not.
+
+# warn(ejbName, "xml.invalidTransactionAttribute", count);
+1.xml.invalidTransactionAttribute = Ignoring invalid <container-transaction>
declarations. Bean not using Container-Managed Transactions.
+2.xml.invalidTransactionAttribute = Ignoring {0} invalid
<container-transaction> declarations. Bean not using Container-Managed
Transactions.
+3.xml.invalidTransactionAttribute = The <container-transaction> element
applies only to beans using Container-Managed Transactions. Beans marked as
<transaction-type>Bean</transaction-type> are responsible for thier own
transactions and may not use the <container-transaction> element. There are
{0} such invalid declarations in the deployment descriptor that will be ignored
and should be removed.
+
+# warn(ejbName, "ann.invalidTransactionAttribute", count);
+1.ann.invalidTransactionAttribute = Ignoring invalid @TransactionAttribute
annotations. Bean not using Container-Managed Transactions.
+2.ann.invalidTransactionAttribute = Ignoring {0} invalid @TransactionAttribute
annotations. Bean not using Container-Managed Transactions.
+3.ann.invalidTransactionAttribute = The @TransactionAttribute annotation
applies only to beans using Container-Managed Transactions. Beans marked as
@TransactionManagement(BEAN) are responsible for thier own transactions and may
not use the @TransactionAttribute annotation. There are {0} such invalid
annotations in the bean class that will be ignored and should be removed.
+
+# warn(ejbName, "xml.invalidConcurrencyAttribute", count);
+1.xml.invalidConcurrencyAttribute = Ignoring invalid <container-concurrency>
declarations. Bean not using Container-Managed Concurrency.
+2.xml.invalidConcurrencyAttribute = Ignoring {0} invalid
<container-concurrency> declarations. Bean not using Container-Managed
Concurrency.
+3.xml.invalidConcurrencyAttribute = The <container-concurrency> element
applies only to beans using Container-Managed Concurrency. Beans marked as
<concurrency-type>Bean</concurrency-type> are responsible for thier own
concurrency and may not use the <container-concurrency> element. There are {0}
such invalid declarations in the deployment descriptor that will be ignored and
should be removed.
+
+# warn(ejbName, "ann.invalidConcurrencyAttribute", count);
+1.ann.invalidConcurrencyAttribute = Ignoring invalid @Lock annotations. Bean
not using Container-Managed Concurrencys.
+2.ann.invalidConcurrencyAttribute = Ignoring {0} invalid @Lock annotations.
Bean not using Container-Managed Concurrencys.
+3.ann.invalidConcurrencyAttribute = The @Lock annotation applies only to beans
using Container-Managed Concurrencys. Beans marked as
@ConcurrencyManagement(BEAN) are responsible for thier own concurrency and may
not use the @Lock annotation. There are {0} such invalid annotations in the
bean class that will be ignored and should be removed.
+