use of org.jboss.jandex.ClassInfo in project wildfly by wildfly.
the class AroundInvokeAnnotationParsingProcessor method processAroundInvoke.
private void processAroundInvoke(final EEModuleDescription eeModuleDescription, final AnnotationTarget target) throws DeploymentUnitProcessingException {
if (!(target instanceof MethodInfo)) {
throw EeLogger.ROOT_LOGGER.methodOnlyAnnotation(AROUND_INVOKE_ANNOTATION_NAME);
}
final MethodInfo methodInfo = MethodInfo.class.cast(target);
final ClassInfo classInfo = methodInfo.declaringClass();
final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
final List<AnnotationInstance> classAroundInvokes = classInfo.annotations().get(AROUND_INVOKE_ANNOTATION_NAME);
if (classAroundInvokes.size() > 1) {
throw EeLogger.ROOT_LOGGER.aroundInvokeAnnotationUsedTooManyTimes(classInfo.name(), classAroundInvokes.size());
}
validateArgumentType(classInfo, methodInfo);
InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription());
builder.setAroundInvoke(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class));
classDescription.setInterceptorClassDescription(builder.build());
}
use of org.jboss.jandex.ClassInfo in project wildfly by wildfly.
the class JaxrsScanningProcessor method scan.
protected void scan(final DeploymentUnit du, final ClassLoader classLoader, final ResteasyDeploymentData resteasyDeploymentData) throws DeploymentUnitProcessingException, ModuleLoadException {
final CompositeIndex index = du.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
if (!resteasyDeploymentData.shouldScan()) {
return;
}
if (!resteasyDeploymentData.isDispatcherCreated()) {
final Set<ClassInfo> applicationClasses = index.getAllKnownSubclasses(APPLICATION);
try {
for (ClassInfo c : applicationClasses) {
if (Modifier.isAbstract(c.flags()))
continue;
@SuppressWarnings("unchecked") Class<? extends Application> scanned = (Class<? extends Application>) classLoader.loadClass(c.name().toString());
resteasyDeploymentData.getScannedApplicationClasses().add(scanned);
}
} catch (ClassNotFoundException e) {
throw JaxrsLogger.JAXRS_LOGGER.cannotLoadApplicationClass(e);
}
}
List<AnnotationInstance> resources = null;
List<AnnotationInstance> providers = null;
if (resteasyDeploymentData.isScanResources()) {
resources = index.getAnnotations(JaxrsAnnotations.PATH.getDotName());
}
if (resteasyDeploymentData.isScanProviders()) {
providers = index.getAnnotations(JaxrsAnnotations.PROVIDER.getDotName());
}
if ((resources == null || resources.isEmpty()) && (providers == null || providers.isEmpty()))
return;
final Set<ClassInfo> pathInterfaces = new HashSet<ClassInfo>();
if (resources != null) {
for (AnnotationInstance e : resources) {
final ClassInfo info;
if (e.target() instanceof ClassInfo) {
info = (ClassInfo) e.target();
} else if (e.target() instanceof MethodInfo) {
//ignore
continue;
} else {
JAXRS_LOGGER.classOrMethodAnnotationNotFound("@Path", e.target());
continue;
}
if (info.annotations().containsKey(DECORATOR)) {
//we can't pick up on programatically added decorators, but that is such an edge case it should not really matter
continue;
}
if (!Modifier.isInterface(info.flags())) {
resteasyDeploymentData.getScannedResourceClasses().add(info.name().toString());
} else {
pathInterfaces.add(info);
}
}
}
if (providers != null) {
for (AnnotationInstance e : providers) {
if (e.target() instanceof ClassInfo) {
ClassInfo info = (ClassInfo) e.target();
if (info.annotations().containsKey(DECORATOR)) {
//we can't pick up on programatically added decorators, but that is such an edge case it should not really matter
continue;
}
if (!Modifier.isInterface(info.flags())) {
resteasyDeploymentData.getScannedProviderClasses().add(info.name().toString());
}
} else {
JAXRS_LOGGER.classAnnotationNotFound("@Provider", e.target());
}
}
}
// look for all implementations of interfaces annotated @Path
for (final ClassInfo iface : pathInterfaces) {
final Set<ClassInfo> implementors = index.getAllKnownImplementors(iface.name());
for (final ClassInfo implementor : implementors) {
if (implementor.annotations().containsKey(DECORATOR)) {
//we can't pick up on programatically added decorators, but that is such an edge case it should not really matter
continue;
}
resteasyDeploymentData.getScannedResourceClasses().add(implementor.name().toString());
}
}
}
use of org.jboss.jandex.ClassInfo 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);
}
use of org.jboss.jandex.ClassInfo in project wildfly by wildfly.
the class MessageDrivenComponentDescriptionFactory method getMessageListenerInterface.
private String getMessageListenerInterface(final CompositeIndex compositeIndex, final AnnotationInstance messageBeanAnnotation) throws DeploymentUnitProcessingException {
final AnnotationValue value = messageBeanAnnotation.value("messageListenerInterface");
if (value != null)
return value.asClass().name().toString();
final ClassInfo beanClass = (ClassInfo) messageBeanAnnotation.target();
final Set<DotName> interfaces = new HashSet<DotName>(getPotentialViewInterfaces(beanClass));
// check super class(es) of the bean
DotName superClassDotName = beanClass.superName();
while (interfaces.isEmpty() && superClassDotName != null && !superClassDotName.toString().equals(Object.class.getName())) {
final ClassInfo superClass = compositeIndex.getClassByName(superClassDotName);
if (superClass == null) {
break;
}
interfaces.addAll(getPotentialViewInterfaces(superClass));
// move to next super class
superClassDotName = superClass.superName();
}
if (interfaces.size() != 1)
throw EjbLogger.ROOT_LOGGER.mdbDoesNotImplementNorSpecifyMessageListener(beanClass);
return interfaces.iterator().next().toString();
}
use of org.jboss.jandex.ClassInfo in project wildfly by wildfly.
the class JSFManagedBeanProcessor method handleAnnotations.
private void handleAnnotations(final CompositeIndex index, final Set<String> managedBeanClasses) throws DeploymentUnitProcessingException {
final List<AnnotationInstance> annotations = index.getAnnotations(MANAGED_BEAN_ANNOTATION);
if (annotations != null) {
for (final AnnotationInstance annotation : annotations) {
final AnnotationTarget target = annotation.target();
if (target instanceof ClassInfo) {
final String className = ((ClassInfo) target).name().toString();
managedBeanClasses.add(className);
} else {
throw new DeploymentUnitProcessingException(JSFLogger.ROOT_LOGGER.invalidManagedBeanAnnotation(target));
}
}
}
}
Aggregations