Search in sources :

Example 1 with IClassInfo

use of org.eclipse.scout.rt.platform.inventory.IClassInfo in project scout.rt by eclipse.

the class BeanFilter method collect.

/**
 * @return all {@link Bean} annotated classes
 *         <p>
 *         Includes all classes that implement an interface that has a {@link Bean} annotation
 */
public Set<Class> collect(IClassInventory classInventory) {
    Set<Class> allBeans = new HashSet<>();
    // 1. collect all annotations annotated with @Bean and register all classes that are directly annotated with @Bean
    Set<IClassInfo> beanAnnotations = new HashSet<>();
    for (IClassInfo ci : classInventory.getKnownAnnotatedTypes(Bean.class)) {
        if (ci.isAnnotation()) {
            beanAnnotations.add(ci);
        } else {
            collectWithSubClasses(classInventory, ci, allBeans);
        }
    }
    // 2. register all classes that are somehow annotated with @Bean
    for (IClassInfo annotation : beanAnnotations) {
        try {
            for (IClassInfo ci : classInventory.getKnownAnnotatedTypes(annotation)) {
                collectWithSubClasses(classInventory, ci, allBeans);
            }
        } catch (Exception e) {
            LOG.warn("Could not resolve known annotated types for [{}]", annotation.name(), e);
        }
    }
    return allBeans;
}
Also used : IClassInfo(org.eclipse.scout.rt.platform.inventory.IClassInfo) HashSet(java.util.HashSet)

Example 2 with IClassInfo

use of org.eclipse.scout.rt.platform.inventory.IClassInfo in project scout.rt by eclipse.

the class JandexClassInventory method getClassInfo.

public IClassInfo getClassInfo(Class<?> queryClass) {
    Assertions.assertNotNull(queryClass);
    ClassInfo ci = m_index.getClassByName(DotName.createSimple(queryClass.getName()));
    if (ci == null) {
        return null;
    }
    return new JandexClassInfo(ci);
}
Also used : IClassInfo(org.eclipse.scout.rt.platform.inventory.IClassInfo) ClassInfo(org.jboss.jandex.ClassInfo)

Example 3 with IClassInfo

use of org.eclipse.scout.rt.platform.inventory.IClassInfo in project scout.rt by eclipse.

the class JandexClassInventory method getClassInfo.

public IClassInfo getClassInfo(String queryClassName) {
    Assertions.assertNotNull(queryClassName);
    ClassInfo ci = m_index.getClassByName(DotName.createSimple(queryClassName));
    if (ci == null) {
        return null;
    }
    return new JandexClassInfo(ci);
}
Also used : IClassInfo(org.eclipse.scout.rt.platform.inventory.IClassInfo) ClassInfo(org.jboss.jandex.ClassInfo)

Example 4 with IClassInfo

use of org.eclipse.scout.rt.platform.inventory.IClassInfo in project scout.rt by eclipse.

the class JandexTypeNameIdResolver method getDescForKnownTypeIds.

@Override
public String getDescForKnownTypeIds() {
    Set<IClassInfo> subClasses = ClassInventory.get().getAllKnownSubClasses(m_baseType.getRawClass());
    StringBuilder sb = new StringBuilder(m_baseType.getRawClass().getName()).append(",");
    for (IClassInfo subClass : subClasses) {
        sb.append(",").append(subClass.name());
    }
    return sb.toString();
}
Also used : IClassInfo(org.eclipse.scout.rt.platform.inventory.IClassInfo)

Example 5 with IClassInfo

use of org.eclipse.scout.rt.platform.inventory.IClassInfo in project scout.rt by eclipse.

the class RegisterTunnelToServerPlatformListenerTest method registerTunnelToServerBeans.

private void registerTunnelToServerBeans(Class<?>... classes) {
    Set<IClassInfo> classInfos = new LinkedHashSet<>();
    for (Class<?> c : classes) {
        classInfos.add(s_classInventory.getClassInfo(c));
    }
    IClassInventory classInventory = mock(IClassInventory.class);
    when(classInventory.getKnownAnnotatedTypes(TunnelToServer.class)).thenReturn(classInfos);
    m_registrator.registerTunnelToServerProxies(m_beanManager, classInventory);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IClassInventory(org.eclipse.scout.rt.platform.inventory.IClassInventory) IClassInfo(org.eclipse.scout.rt.platform.inventory.IClassInfo)

Aggregations

IClassInfo (org.eclipse.scout.rt.platform.inventory.IClassInfo)8 BasicPermission (java.security.BasicPermission)2 HashSet (java.util.HashSet)2 IClassInventory (org.eclipse.scout.rt.platform.inventory.IClassInventory)2 ClassInfo (org.jboss.jandex.ClassInfo)2 Permission (java.security.Permission)1 LinkedHashSet (java.util.LinkedHashSet)1 TunnelToServer (org.eclipse.scout.rt.shared.TunnelToServer)1