-
1. Re: JBoss extention doesn't find custom annotation
ctomc Jul 25, 2013 6:24 AM (in response to ansur)Hi,
annotations are not pressent on classes you must process it as part of annotation processing phase.
all annotations are part of jandex.
take a look at https://github.com/wildfly/wildfly/blob/master/mail/src/main/java/org/jboss/as/mail/extension/MailSubsystemAdd.java
--
tomaz
-
2. Re: JBoss extention doesn't find custom annotation
jaikiran Jul 25, 2013 6:24 AM (in response to ansur)What does your code look like which checks for the annotation and what does the EJB code which has that annotation look like (including import statements)?
By the way, which version of AS7 are you using to write this against?
-
3. Re: JBoss extention doesn't find custom annotation
ansur Jul 25, 2013 9:35 AM (in response to ansur)Ok so based on the Mail examples given by Tomaz, I've got something like this:
- one DeploymentProcessor which registers information about my annotation and registers it within a EEModuleClassDescription:
/** * {@inheritDoc} */ @Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); final CompositeIndex compositeIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX); final List<AnnotationInstance> annotationInstances = compositeIndex.getAnnotations(SERVICEABILITY_DEFINITION); for(final AnnotationInstance annotationInstance : annotationInstances) { final AnnotationTarget annotationTarget = annotationInstance.target(); final ClassInfo classInfo = (ClassInfo) annotationTarget; final String className = classInfo.name().toString(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(className); final Map<String, ClassAnnotationInformation<Serviceable, ServiceabilityInformation>> annotationInformationMap = this.factory.createAnnotationInformation(compositeIndex); if(annotationInformationMap.containsKey(className)) { classDescription.addAnnotationInformation(annotationInformationMap.get(className)); } } }
... and later on I can retrieve that information the same way I register it here, using the class name of the implementation.
This is a little bit different than what I saw in the mail example, so just to verify - is this the 'good' way of processing an annotation?
FYI I'm using JBoss 7.2.0
-
4. Re: JBoss extention doesn't find custom annotation
ansur Jul 25, 2013 11:37 AM (in response to ansur)Maybe just an additional question - it's working like a charm now, but what I'm also wondering - what's the best way to (unit) test this without mocking - i.e. to get the proper behaviour derived from the JBoss modules as well?
Or isn't there a way and is the preferred way integration tests?
-
5. Re: JBoss extention doesn't find custom annotation
sfcoy Jul 25, 2013 8:34 PM (in response to ansur)Use Arquillian for running in-container integration tests without mocking.
A large portion of the AS7/WildFly codebase is tested using this tool.
-
6. Re: JBoss extention doesn't find custom annotation
ansur Jul 26, 2013 2:06 AM (in response to sfcoy)I thought as much. Thanks!