Java Code Examples for org.jboss.jandex.IndexView#getAllKnownImplementors()
The following examples show how to use
org.jboss.jandex.IndexView#getAllKnownImplementors() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KogitoAssetsProcessor.java From kogito-runtimes with Apache License 2.0 | 6 votes |
private Collection<GeneratedFile> getGeneratedPersistenceFiles( AppPaths appPaths, IndexView index, boolean usePersistence, List<String> parameters ) { GeneratorContext context = buildContext(appPaths, index); Collection<ClassInfo> modelClasses = index .getAllKnownImplementors(createDotName( Model.class.getCanonicalName())); Collection<GeneratedFile> generatedFiles = new ArrayList<>(); for (Path projectPath : appPaths.projectPaths) { PersistenceGenerator persistenceGenerator = new PersistenceGenerator( new File( projectPath.toFile(), "target" ), modelClasses, usePersistence, new JandexProtoGenerator( index, createDotName( Generated.class.getCanonicalName() ), createDotName( VariableInfo.class.getCanonicalName() ) ), parameters ); persistenceGenerator.setDependencyInjection( new CDIDependencyInjectionAnnotator() ); persistenceGenerator.setPackageName( appPackageName ); persistenceGenerator.setContext( context ); generatedFiles.addAll( persistenceGenerator.generate() ); } return generatedFiles; }
Example 2
Source File: HibernateValidatorProcessor.java From quarkus with Apache License 2.0 | 6 votes |
private static void contributeClass(Set<DotName> classNamesCollector, IndexView indexView, DotName className) { classNamesCollector.add(className); for (ClassInfo subclass : indexView.getAllKnownSubclasses(className)) { if (Modifier.isAbstract(subclass.flags())) { // we can avoid adding the abstract classes here: either they are parent classes // and they will be dealt with by Hibernate Validator or they are child classes // without any proper implementation and we can ignore them. continue; } classNamesCollector.add(subclass.name()); } for (ClassInfo implementor : indexView.getAllKnownImplementors(className)) { if (Modifier.isAbstract(implementor.flags())) { // we can avoid adding the abstract classes here: either they are parent classes // and they will be dealt with by Hibernate Validator or they are child classes // without any proper implementation and we can ignore them. continue; } classNamesCollector.add(implementor.name()); } }
Example 3
Source File: FragmentMethodsUtil.java From quarkus with Apache License 2.0 | 6 votes |
/** * Returns the simple expected implementation of a Fragment interface or throws an * exception indicating the problem */ static DotName getImplementationDotName(DotName customInterfaceToImplement, IndexView index) { Collection<ClassInfo> knownImplementors = index.getAllKnownImplementors(customInterfaceToImplement); if (knownImplementors.size() > 1) { DotName previouslyFound = null; for (ClassInfo knownImplementor : knownImplementors) { if (knownImplementor.name().toString().endsWith("Impl")) { // the default suffix that Spring Data JPA looks for is 'Impl' if (previouslyFound != null) { // make sure we don't have multiple implementations suffixed with 'Impl' throw new IllegalArgumentException( "Interface " + customInterfaceToImplement + " must contain a single implementation whose name ends with 'Impl'. Multiple implementations were found: " + previouslyFound + "," + knownImplementor); } previouslyFound = knownImplementor.name(); } } return previouslyFound; } else if (knownImplementors.size() == 1) { return knownImplementors.iterator().next().name(); } else { throw new IllegalArgumentException( "No implementation of interface " + customInterfaceToImplement + " was found"); } }
Example 4
Source File: Types.java From quarkus with Apache License 2.0 | 6 votes |
static boolean isAssignableFrom(DotName class1, DotName class2, IndexView index) { // java.lang.Object is assignable from any type if (class1.equals(DotNames.OBJECT)) { return true; } // type1 is the same as type2 if (class1.equals(class2)) { return true; } // type1 is a superclass Set<DotName> assignables = new HashSet<>(); Collection<ClassInfo> subclasses = index.getAllKnownSubclasses(class1); for (ClassInfo subclass : subclasses) { assignables.add(subclass.name()); } Collection<ClassInfo> implementors = index.getAllKnownImplementors(class1); for (ClassInfo implementor : implementors) { assignables.add(implementor.name()); } return assignables.contains(class2); }
Example 5
Source File: GoogleCloudFunctionsProcessor.java From quarkus with Apache License 2.0 | 6 votes |
@BuildStep public List<CloudFunctionBuildItem> discoverFunctionClass(CombinedIndexBuildItem combinedIndex, BuildProducer<UnremovableBeanBuildItem> unremovableBeans) throws BuildException { IndexView index = combinedIndex.getIndex(); Collection<ClassInfo> httpFunctions = index.getAllKnownImplementors(DOTNAME_HTTP_FUNCTION); Collection<ClassInfo> backgroundFunctions = index.getAllKnownImplementors(DOTNAME_BACKGROUND_FUNCTION); Collection<ClassInfo> rawBackgroundFunctions = index.getAllKnownImplementors(DOTNAME_RAW_BACKGROUND_FUNCTION); List<CloudFunctionBuildItem> cloudFunctions = new ArrayList<>(); cloudFunctions.addAll( registerFunctions(unremovableBeans, httpFunctions, GoogleCloudFunctionInfo.FunctionType.HTTP)); cloudFunctions.addAll( registerFunctions(unremovableBeans, backgroundFunctions, GoogleCloudFunctionInfo.FunctionType.BACKGROUND)); cloudFunctions.addAll( registerFunctions(unremovableBeans, rawBackgroundFunctions, GoogleCloudFunctionInfo.FunctionType.RAW_BACKGROUND)); if (cloudFunctions.isEmpty()) { throw new BuildException("No Google Cloud Function found on the classpath", Collections.emptyList()); } return cloudFunctions; }
Example 6
Source File: RESTEasyExtension.java From quarkus with Apache License 2.0 | 6 votes |
private void scanAsyncResponseProviders(IndexView index) { for (ClassInfo providerClass : index.getAllKnownImplementors(DOTNAME_ASYNC_RESPONSE_PROVIDER)) { for (AnnotationInstance annotation : providerClass.classAnnotations()) { if (annotation.name().equals(DOTNAME_PROVIDER)) { for (Type interf : providerClass.interfaceTypes()) { if (interf.kind() == Type.Kind.PARAMETERIZED_TYPE && interf.name().equals(DOTNAME_ASYNC_RESPONSE_PROVIDER)) { ParameterizedType pType = interf.asParameterizedType(); if (pType.arguments().size() == 1) { Type asyncType = pType.arguments().get(0); asyncTypes.add(asyncType.name()); } } } } } } }
Example 7
Source File: InfinispanEmbeddedProcessor.java From quarkus with Apache License 2.0 | 6 votes |
private void addReflectionForName(String className, boolean isInterface, IndexView indexView, BuildProducer<ReflectiveClassBuildItem> reflectiveClass, boolean methods, boolean fields, Set<DotName> excludedClasses) { Collection<ClassInfo> classInfos; if (isInterface) { classInfos = indexView.getAllKnownImplementors(DotName.createSimple(className)); } else { classInfos = indexView.getAllKnownSubclasses(DotName.createSimple(className)); } classInfos.removeIf(ci -> excludedClasses.contains(ci.name())); if (!classInfos.isEmpty()) { reflectiveClass.produce(new ReflectiveClassBuildItem(methods, fields, classInfos.stream().map(ClassInfo::toString).toArray(String[]::new))); } }
Example 8
Source File: MicroProfileHealthProcessor.java From camel-quarkus with Apache License 2.0 | 5 votes |
@BuildStep List<CamelBeanBuildItem> camelHealthDiscovery( CombinedIndexBuildItem combinedIndex, CamelMicroProfileHealthConfig config) { List<CamelBeanBuildItem> buildItems = new ArrayList<>(); if (config.enabled) { IndexView index = combinedIndex.getIndex(); Collection<ClassInfo> healthChecks = index.getAllKnownImplementors(CAMEL_HEALTH_CHECK_DOTNAME); Collection<ClassInfo> healthCheckRepositories = index .getAllKnownImplementors(CAMEL_HEALTH_CHECK_REPOSITORY_DOTNAME); // Create CamelBeanBuildItem to bind instances of HealthCheck to the camel registry healthChecks.stream() .filter(CamelSupport::isConcrete) .filter(CamelSupport::isPublic) .filter(ClassInfo::hasNoArgsConstructor) .map(classInfo -> new CamelBeanBuildItem(classInfo.simpleName(), classInfo.name().toString())) .forEach(buildItems::add); // Create CamelBeanBuildItem to bind instances of HealthCheckRepository to the camel registry healthCheckRepositories.stream() .filter(CamelSupport::isConcrete) .filter(CamelSupport::isPublic) .filter(ClassInfo::hasNoArgsConstructor) .filter(classInfo -> !classInfo.simpleName().equals(DefaultHealthCheckRegistry.class.getSimpleName())) .map(classInfo -> new CamelBeanBuildItem(classInfo.simpleName(), classInfo.name().toString())) .forEach(buildItems::add); } return buildItems; }
Example 9
Source File: NarayanaSTMProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@BuildStep NativeImageProxyDefinitionBuildItem stmProxies() { final DotName TRANSACTIONAL = DotName.createSimple(Transactional.class.getName()); IndexView index = combinedIndexBuildItem.getIndex(); Collection<String> proxies = new ArrayList<>(); for (AnnotationInstance stm : index.getAnnotations(TRANSACTIONAL)) { if (AnnotationTarget.Kind.CLASS.equals(stm.target().kind())) { DotName name = stm.target().asClass().name(); proxies.add(name.toString()); log.debugf("Registering transactional interface %s%n", name); for (ClassInfo ci : index.getAllKnownImplementors(name)) { reflectiveHierarchyClass.produce( new ReflectiveHierarchyBuildItem(Type.create(ci.name(), Type.Kind.CLASS))); } } } String[] classNames = proxies.toArray(new String[0]); reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, classNames)); return new NativeImageProxyDefinitionBuildItem(classNames); }
Example 10
Source File: PanacheRepositoryEnhancer.java From quarkus with Apache License 2.0 | 5 votes |
public static String[] findEntityTypeArgumentsForPanacheRepository(IndexView indexView, String repositoryClassName, DotName repositoryDotName) { for (ClassInfo classInfo : indexView.getAllKnownImplementors(repositoryDotName)) { if (repositoryClassName.equals(classInfo.name().toString())) { return recursivelyFindEntityTypeArgumentsFromClass(indexView, classInfo.name(), repositoryDotName); } } return null; }
Example 11
Source File: HibernateSearchElasticsearchProcessor.java From quarkus with Apache License 2.0 | 5 votes |
private static void addReflectiveClass(IndexView index, Set<DotName> reflectiveClassCollector, Set<Type> reflectiveTypeCollector, ClassInfo classInfo) { if (skipClass(classInfo.name(), reflectiveClassCollector)) { return; } reflectiveClassCollector.add(classInfo.name()); for (ClassInfo subclass : index.getAllKnownSubclasses(classInfo.name())) { reflectiveClassCollector.add(subclass.name()); } for (ClassInfo implementor : index.getAllKnownImplementors(classInfo.name())) { reflectiveClassCollector.add(implementor.name()); } Type superClassType = classInfo.superClassType(); while (superClassType != null && !superClassType.name().toString().equals("java.lang.Object")) { reflectiveClassCollector.add(superClassType.name()); if (superClassType instanceof ClassType) { superClassType = index.getClassByName(superClassType.name()).superClassType(); } else if (superClassType instanceof ParameterizedType) { ParameterizedType parameterizedType = superClassType.asParameterizedType(); for (Type typeArgument : parameterizedType.arguments()) { addReflectiveType(index, reflectiveClassCollector, reflectiveTypeCollector, typeArgument); } superClassType = parameterizedType.owner(); } } }
Example 12
Source File: DeploymentSupport.java From camel-k-runtime with Apache License 2.0 | 4 votes |
public static Iterable<ClassInfo> getAllKnownImplementors(IndexView view, String name) { return view.getAllKnownImplementors(DotName.createSimple(name)); }
Example 13
Source File: DeploymentSupport.java From camel-k-runtime with Apache License 2.0 | 4 votes |
public static Iterable<ClassInfo> getAllKnownImplementors(IndexView view, Class<?> type) { return view.getAllKnownImplementors(DotName.createSimple(type.getName())); }
Example 14
Source File: DeploymentSupport.java From camel-k-runtime with Apache License 2.0 | 4 votes |
public static Iterable<ClassInfo> getAllKnownImplementors(IndexView view, DotName type) { return view.getAllKnownImplementors(type); }