private Set<String> getImplicitBeanClasses(Index index, ResourceRoot resourceRoot) { Set<String> implicitBeanClasses = new HashSet<String>(); for (AnnotationType beanDefiningAnnotation : beanDefiningAnnotations) { List<AnnotationInstance> annotationInstances = index.getAnnotations(beanDefiningAnnotation.getName()); for (ClassInfo classInfo : Indices.getAnnotatedClasses(annotationInstances)) { implicitBeanClasses.add(Indices.CLASS_INFO_TO_FQCN.apply(classInfo)); } } // Make all explicit components into implicit beans so they will support injection for(ComponentDescription description : components.componentDescriptions.get(resourceRoot)) { if(!components.implicitComponentDescriptions.contains(description)) { implicitBeanClasses.add(description.getComponentClassName()); } } return implicitBeanClasses; }
private Set<String> findPersistenceTypeNames(PersistenceUnitMetadata pu) { synchronized (CACHED_TYPENAMES) { Set<String> typeNames = CACHED_TYPENAMES.get(pu); if (typeNames != null) { return typeNames; } } Set<String> persistenceTypeNames = new HashSet<String>(); for (Map.Entry<URL, Index> entry : pu.getAnnotationIndex().entrySet()) { List<AnnotationInstance> instances = entry.getValue().getAnnotations(DotName.createSimple(Entity.class.getName())); for (AnnotationInstance instance : instances) { AnnotationTarget target = instance.target(); if (target instanceof ClassInfo) { ClassInfo classInfo = (ClassInfo) target; persistenceTypeNames.add(classInfo.name().toString()); } } } synchronized (CACHED_TYPENAMES) { CACHED_TYPENAMES.put(pu, persistenceTypeNames); } return persistenceTypeNames; }
final Index index = resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX); if (index != null) { if (!index.getAnnotations(STATEFUL).isEmpty() || !index.getAnnotations(STATELESS).isEmpty() || !index.getAnnotations(MESSAGE_DRIVEN).isEmpty() || !index.getAnnotations(SINGLETON).isEmpty()) {
List<AnnotationInstance> classesWithAnnotation = index.getAnnotations(annotation); Set<Class<?>> classesForAnnotation = new HashSet<Class<?>>(); for (AnnotationInstance annotationInstance : classesWithAnnotation) {
@Override public Collection<Annotation> getAnnotation(Class<?> annotationClass) { List<AnnotationInstance> instances = backingRepository.getAnnotations(DotName.createSimple(annotationClass .getName())); ArrayList<Annotation> annotations = new ArrayList<Annotation>(instances.size());
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (!DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) { return; } List<ResourceRoot> potentialSubDeployments = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS); for (ResourceRoot resourceRoot : potentialSubDeployments) { if (ModuleRootMarker.isModuleRoot(resourceRoot)) { // module roots cannot be managed bean jars continue; } final Index index = resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX); if (index != null) { if (!index.getAnnotations(MANAGED_BEAN).isEmpty()) { //this is a managed bean deployment SubDeploymentMarker.mark(resourceRoot); ModuleRootMarker.mark(resourceRoot); } } } }
if (!entry.getValue().getAnnotations(annotation.getName()).isEmpty()) { WeldDeploymentMarker.mark(deploymentUnit); return;
final List<AnnotationInstance> webServletAnnotations = index.getAnnotations(webServlet); if (webServletAnnotations != null && webServletAnnotations.size() > 0) { ServletsMetaData servlets = new ServletsMetaData(); final List<AnnotationInstance> webFilterAnnotations = index.getAnnotations(webFilter); if (webFilterAnnotations != null && webFilterAnnotations.size() > 0) { FiltersMetaData filters = new FiltersMetaData(); final List<AnnotationInstance> webListenerAnnotations = index.getAnnotations(webListener); if (webListenerAnnotations != null && webListenerAnnotations.size() > 0) { List<ListenerMetaData> listeners = new ArrayList<ListenerMetaData>(); final List<AnnotationInstance> runAsAnnotations = index.getAnnotations(runAs); if (runAsAnnotations != null && runAsAnnotations.size() > 0) { AnnotationsMetaData annotations = metaData.getAnnotations(); final List<AnnotationInstance> declareRolesAnnotations = index.getAnnotations(declareRoles); if (declareRolesAnnotations != null && declareRolesAnnotations.size() > 0) { SecurityRolesMetaData securityRoles = metaData.getSecurityRoles(); final List<AnnotationInstance> multipartConfigAnnotations = index.getAnnotations(multipartConfig); if (multipartConfigAnnotations != null && multipartConfigAnnotations.size() > 0) { AnnotationsMetaData annotations = metaData.getAnnotations(); final List<AnnotationInstance> servletSecurityAnnotations = index.getAnnotations(servletSecurity); if (servletSecurityAnnotations != null && servletSecurityAnnotations.size() > 0) { AnnotationsMetaData annotations = metaData.getAnnotations();
/** * @see {@link Index#getAnnotations(org.jboss.jandex.DotName)} */ public List<AnnotationInstance> getAnnotations(final DotName annotationName) { final List<AnnotationInstance> allInstances = new ArrayList<AnnotationInstance>(); for (Index index : indexes) { final List<AnnotationInstance> list = index.getAnnotations(annotationName); if (list != null) { allInstances.addAll(list); } } return Collections.unmodifiableList(allInstances); }
/** * @see {@link Index#getAnnotations(org.jboss.jandex.DotName)} */ public List<AnnotationInstance> getAnnotations(final DotName annotationName) { final List<AnnotationInstance> allInstances = new ArrayList<AnnotationInstance>(); for (Index index : indexes) { final List<AnnotationInstance> list = index.getAnnotations(annotationName); if (list != null) { allInstances.addAll(list); } } return Collections.unmodifiableList(allInstances); }
/** * @see {@link Index#getAnnotations(org.jboss.jandex.DotName)} */ public List<AnnotationInstance> getAnnotations(final DotName annotationName) { final List<AnnotationInstance> allInstances = new ArrayList<AnnotationInstance>(); for (Index index : indexes) { final List<AnnotationInstance> list = index.getAnnotations(annotationName); if (list != null) { allInstances.addAll(list); } } return Collections.unmodifiableList(allInstances); }
/** * @see {@link Index#getAnnotations(org.jboss.jandex.DotName)} */ public List<AnnotationInstance> getAnnotations(final DotName annotationName) { final List<AnnotationInstance> allInstances = new ArrayList<AnnotationInstance>(); for (Index index : indexes) { final List<AnnotationInstance> list = index.getAnnotations(annotationName); if (list != null) { allInstances.addAll(list); } } return Collections.unmodifiableList(allInstances); }
private void locateClassesFor(ClassLoader classLoader, Index index, Class<? extends Annotation> annotation, Set<Class<?>> classes) { final DotName annotationName = DotName.createSimple(annotation.getName()); final List<AnnotationInstance> classesWithAnnotation = index.getAnnotations(annotationName); for (final AnnotationInstance annotationInstance : classesWithAnnotation) { // verify that the annotation target is actually a class, since some frameworks // may generate bytecode with annotations placed on methods (see AS7-2559) if (annotationInstance.target() instanceof ClassInfo) { final String className = annotationInstance.target().toString(); try { JBoss7AnnotatedClassLocator.LOG.info("Located persistent {0} class {1}", annotation.getSimpleName(), className); classes.add(classLoader.loadClass(className)); } catch (final ClassNotFoundException e) { throw new RuntimeException("Cannot load persitent class: " + className); } } } } }
private Set<String> findPersistenceTypeNames(PersistenceUnitMetadata pu) { synchronized (CACHED_TYPENAMES) { Set<String> typeNames = CACHED_TYPENAMES.get(pu); if (typeNames != null) { return typeNames; } } Set<String> persistenceTypeNames = new HashSet<String>(); for (Map.Entry<URL, Index> entry : pu.getAnnotationIndex().entrySet()) { List<AnnotationInstance> instances = entry.getValue().getAnnotations(DotName.createSimple(Entity.class.getName())); for (AnnotationInstance instance : instances) { AnnotationTarget target = instance.target(); if (target instanceof ClassInfo) { ClassInfo classInfo = (ClassInfo) target; persistenceTypeNames.add(classInfo.name().toString()); } } } synchronized (CACHED_TYPENAMES) { CACHED_TYPENAMES.put(pu, persistenceTypeNames); } return persistenceTypeNames; }
void collectGlobalConfigurationFromIndex(GlobalAnnotations globalAnnotations) { for ( DotName annName : DefaultConfigurationHelper.GLOBAL_ANNOTATIONS ) { List<AnnotationInstance> annotationInstanceList = index.getAnnotations( annName ); if ( MockHelper.isNotEmpty( annotationInstanceList ) ) { globalAnnotations.addIndexedAnnotationInstance( annotationInstanceList ); } } globalAnnotations.filterIndexedAnnotations(); }
void collectGlobalConfigurationFromIndex(GlobalAnnotations globalAnnotations) { for ( DotName annName : DefaultConfigurationHelper.GLOBAL_ANNOTATIONS ) { List<AnnotationInstance> annotationInstanceList = index.getAnnotations( annName ); if ( MockHelper.isNotEmpty( annotationInstanceList ) ) { globalAnnotations.addIndexedAnnotationInstance( annotationInstanceList ); } } globalAnnotations.filterIndexedAnnotations(); }
/** * Binds {@link org.hibernate.annotations.Tables} and {@link org.hibernate.annotations.Table} annotations to the supplied * metadata. * * @param bindingContext the context for annotation binding */ public static void bind(AnnotationBindingContext bindingContext) { List<AnnotationInstance> annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.TABLE ); for ( AnnotationInstance tableAnnotation : annotations ) { bind( bindingContext.getMetadataImplementor(), tableAnnotation ); } annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.TABLES ); for ( AnnotationInstance tables : annotations ) { for ( AnnotationInstance table : JandexHelper.getValue( tables, "value", AnnotationInstance[].class ) ) { bind( bindingContext.getMetadataImplementor(), table ); } } }
/** * Binds {@link org.hibernate.annotations.Tables} and {@link org.hibernate.annotations.Table} annotations to the supplied * metadata. * * @param bindingContext the context for annotation binding */ public static void bind(AnnotationBindingContext bindingContext) { List<AnnotationInstance> annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.TABLE ); for ( AnnotationInstance tableAnnotation : annotations ) { bind( bindingContext.getMetadataImplementor(), tableAnnotation ); } annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.TABLES ); for ( AnnotationInstance tables : annotations ) { for ( AnnotationInstance table : JandexHelper.getValue( tables, "value", AnnotationInstance[].class ) ) { bind( bindingContext.getMetadataImplementor(), table ); } } }
private static void processHandlerChainAnnotations(final ResourceRoot resourceRoot, final Index index, final WSEndpointHandlersMapping mapping) throws DeploymentUnitProcessingException { final List<AnnotationInstance> handlerChainAnnotations = index.getAnnotations(HANDLER_CHAIN_ANNOTATION); for (final AnnotationInstance handlerChainAnnotation : handlerChainAnnotations) { final AnnotationTarget annotationTarget = handlerChainAnnotation.target(); if (annotationTarget instanceof ClassInfo) { final ClassInfo classInfo = (ClassInfo) annotationTarget; if (isJaxwsEndpoint(classInfo, index)) { final String endpointClass = classInfo.name().toString(); processHandlerChainAnnotation(resourceRoot, handlerChainAnnotation, endpointClass, mapping); } } else { // We ignore fields & methods annotated with @HandlerChain. // These are used always in combination with @WebServiceRef // which are always referencing JAXWS client proxies only. } } }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (!DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) { return; } List<ResourceRoot> potentialSubDeployments = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS); for (ResourceRoot resourceRoot : potentialSubDeployments) { if (ModuleRootMarker.isModuleRoot(resourceRoot)) { // module roots cannot be managed bean jars continue; } final Index index = resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX); if (index != null) { if (!index.getAnnotations(MANAGED_BEAN).isEmpty()) { //this is an managed bean deployment SubDeploymentMarker.mark(resourceRoot); ModuleRootMarker.mark(resourceRoot); } } } }