use of org.jboss.jandex.AnnotationTarget in project wildfly by wildfly.
the class ServletContainerInitializerDeploymentProcessor method processHandlesType.
private Set<ClassInfo> processHandlesType(DotName typeName, Class<?> type, CompositeIndex index) throws DeploymentUnitProcessingException {
Set<ClassInfo> classes = new HashSet<ClassInfo>();
if (type.isAnnotation()) {
List<AnnotationInstance> instances = index.getAnnotations(typeName);
for (AnnotationInstance instance : instances) {
AnnotationTarget annotationTarget = instance.target();
if (annotationTarget instanceof ClassInfo) {
classes.add((ClassInfo) annotationTarget);
} else if (annotationTarget instanceof FieldInfo) {
classes.add(((FieldInfo) annotationTarget).declaringClass());
} else if (annotationTarget instanceof MethodInfo) {
classes.add(((MethodInfo) annotationTarget).declaringClass());
} else if (annotationTarget instanceof MethodParameterInfo) {
classes.add(((MethodParameterInfo) annotationTarget).method().declaringClass());
}
}
} else {
classes.addAll(index.getAllKnownSubclasses(typeName));
classes.addAll(index.getAllKnownImplementors(typeName));
}
return classes;
}
use of org.jboss.jandex.AnnotationTarget in project wildfly by wildfly.
the class WSRefAnnotationProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit unit = phaseContext.getDeploymentUnit();
// Process @WebServiceRef annotations
final List<AnnotationInstance> webServiceRefAnnotations = getAnnotations(unit, WEB_SERVICE_REF_ANNOTATION);
for (final AnnotationInstance annotation : webServiceRefAnnotations) {
final AnnotationTarget annotationTarget = annotation.target();
final WSRefAnnotationWrapper annotationWrapper = new WSRefAnnotationWrapper(annotation);
if (annotationTarget instanceof FieldInfo) {
processFieldRef(unit, annotationWrapper, (FieldInfo) annotationTarget);
} else if (annotationTarget instanceof MethodInfo) {
processMethodRef(unit, annotationWrapper, (MethodInfo) annotationTarget);
} else if (annotationTarget instanceof ClassInfo) {
processClassRef(unit, annotationWrapper, (ClassInfo) annotationTarget);
}
}
// Process @WebServiceRefs annotations
final List<AnnotationInstance> webServiceRefsAnnotations = getAnnotations(unit, WEB_SERVICE_REFS_ANNOTATION);
for (final AnnotationInstance outerAnnotation : webServiceRefsAnnotations) {
final AnnotationTarget annotationTarget = outerAnnotation.target();
if (annotationTarget instanceof ClassInfo) {
final AnnotationInstance[] values = outerAnnotation.value("value").asNestedArray();
for (final AnnotationInstance annotation : values) {
final WSRefAnnotationWrapper annotationWrapper = new WSRefAnnotationWrapper(annotation);
processClassRef(unit, annotationWrapper, (ClassInfo) annotationTarget);
}
}
}
}
use of org.jboss.jandex.AnnotationTarget in project wildfly by wildfly.
the class SessionBeanComponentDescriptionFactory method processSessionBeans.
private void processSessionBeans(final DeploymentUnit deploymentUnit, final List<AnnotationInstance> sessionBeanAnnotations, final SessionBeanComponentDescription.SessionBeanType annotatedSessionBeanType) {
final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
final ServiceName deploymentUnitServiceName = deploymentUnit.getServiceName();
PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
// process these session bean annotations and create component descriptions out of it
for (final AnnotationInstance sessionBeanAnnotation : sessionBeanAnnotations) {
final AnnotationTarget target = sessionBeanAnnotation.target();
if (!(target instanceof ClassInfo)) {
// Let's just WARN and move on. No need to throw an error
EjbLogger.DEPLOYMENT_LOGGER.warn(EjbLogger.ROOT_LOGGER.annotationOnlyAllowedOnClass(sessionBeanAnnotation.name().toString(), target).getMessage());
continue;
}
final ClassInfo sessionBeanClassInfo = (ClassInfo) target;
// skip if it's not a valid class for session bean
if (!assertSessionBeanClassValidity(sessionBeanClassInfo)) {
continue;
}
final String ejbName = sessionBeanClassInfo.name().local();
final AnnotationValue nameValue = sessionBeanAnnotation.value("name");
final String beanName = (nameValue == null || nameValue.asString().isEmpty()) ? ejbName : propertyReplacer.replaceProperties(nameValue.asString());
final SessionBeanMetaData beanMetaData = getEnterpriseBeanMetaData(deploymentUnit, beanName, SessionBeanMetaData.class);
final SessionBeanComponentDescription.SessionBeanType sessionBeanType;
final String beanClassName;
if (beanMetaData != null) {
beanClassName = override(sessionBeanClassInfo.name().toString(), beanMetaData.getEjbClass());
sessionBeanType = override(annotatedSessionBeanType, descriptionOf(((SessionBeanMetaData) beanMetaData).getSessionType()));
} else {
beanClassName = sessionBeanClassInfo.name().toString();
sessionBeanType = annotatedSessionBeanType;
}
final SessionBeanComponentDescription sessionBeanDescription;
switch(sessionBeanType) {
case STATELESS:
sessionBeanDescription = new StatelessComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnitServiceName, beanMetaData);
break;
case STATEFUL:
sessionBeanDescription = new StatefulComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnitServiceName, beanMetaData);
// If passivation is disabled for the SFSB, either via annotation or via DD, then setup the component
// description appropriately
final boolean passivationCapableAnnotationValue = sessionBeanAnnotation.value("passivationCapable") == null ? true : sessionBeanAnnotation.value("passivationCapable").asBoolean();
final Boolean passivationCapableDeploymentDescriptorValue;
if ((beanMetaData instanceof SessionBean32MetaData)) {
passivationCapableDeploymentDescriptorValue = ((SessionBean32MetaData) beanMetaData).isPassivationCapable();
} else {
passivationCapableDeploymentDescriptorValue = null;
}
final boolean passivationApplicable = override(passivationCapableDeploymentDescriptorValue, passivationCapableAnnotationValue);
((StatefulComponentDescription) sessionBeanDescription).setPassivationApplicable(passivationApplicable);
break;
case SINGLETON:
sessionBeanDescription = new SingletonComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnitServiceName, beanMetaData);
break;
default:
throw EjbLogger.ROOT_LOGGER.unknownSessionBeanType(sessionBeanType.name());
}
addComponent(deploymentUnit, sessionBeanDescription);
}
EjbDeploymentMarker.mark(deploymentUnit);
}
Aggregations