Teemu Andersén created OWB-737:
----------------------------------
Summary: @specializes @alternative child class disables super
class even when not enabled when using stereotypes
Key: OWB-737
URL: https://issues.apache.org/jira/browse/OWB-737
Project: OpenWebBeans
Issue Type: Bug
Components: Core
Affects Versions: 1.1.6
Environment: OS X 10.7.5 / Tomcat 7.0.22; Windows 7 / IBM WebSphere
Application Server 7.x;
Reporter: Teemu Andersén
Priority: Minor
When using stereotypes to select alternatives the OWB doesn't recognize a Bean
as an alternative when it processes specialized classes. This causes the super
class to be always disabled.
Not sure if this is a bug or not but in most other cases the same class would
be recognized as an alternative even if it was marked as one via stereotype and
not directly using the @Alternative annotation.
Steps to reproduce:
1) create a test alternative stereotype
2) create a service
3) create an alternative test service
- extend the production service
- annotate with test alternative stereotype and specializes
4) Don't enable the test alternative stereotype
Expected:
The production service is enabled
What happens:
Both services are disabled
Example (had an example program but didn't know where to submit it):
@Stereotype
@Alternative
@Retention(RetentionPolicy.RUNTIME)
@Target({ METHOD, FIELD, PARAMETER, TYPE })
public @interface Development {
}
public class ServiceBean implements Serializable {
public String getMessage() {
return "Production";
}
}
/**
* Alternative implementation that is enabled by Development stereotype.
*/
// @Alternative - When this annotation is commented this class is not
recognized as an alternative when processing specialized classes.
@Development
@Specializes
public class DevelopmentService extends Service {
@Override
public String getMessage() {
return "Development";
}
}
====
Problem area:
org.apache.webbeans.util.WebBeansUtil [1477-1486]:
if (!AnnotationUtil.hasClassAnnotation(specializedClass, Alternative.class))
{
//disable superbean if the current bean is not an alternative
((AbstractOwbBean<?>)superBean).setEnabled(false);
}
else if(altManager.isClassAlternative(specializedClass))
{
//disable superbean if the current bean is an enabled alternative
((AbstractOwbBean<?>)superBean).setEnabled(false);
}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira