Search in sources :

Example 6 with IClassInfo

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

the class PermissionService method getPermissionsFromInventory.

/**
 * @return Permission classes from class inventory. By default all direct subclasses of {@link Permission} and
 *         {@link BasicPermission} that are available in the {@link ClassInventory} are returned.
 */
protected Set<IClassInfo> getPermissionsFromInventory() {
    IClassInventory inv = ClassInventory.get();
    // get BasicPermssion subclasses are not found directly, because jdk is not scanned by jandex.
    Set<IClassInfo> classes = inv.getAllKnownSubClasses(Permission.class);
    classes.addAll(inv.getAllKnownSubClasses(BasicPermission.class));
    return classes;
}
Also used : BasicPermission(java.security.BasicPermission) IClassInventory(org.eclipse.scout.rt.platform.inventory.IClassInventory) IClassInfo(org.eclipse.scout.rt.platform.inventory.IClassInfo)

Example 7 with IClassInfo

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

the class PermissionService method checkCache.

private void checkCache() {
    synchronized (m_permissionClassesLock) {
        // null-check with lock (valid check)
        if (m_permissionClasses == null) {
            Set<IClassInfo> allKnownPermissions = getPermissionsFromInventory();
            Set<Class<? extends Permission>> discoveredPermissions = new HashSet<>(allKnownPermissions.size());
            for (IClassInfo permInfo : allKnownPermissions) {
                if (acceptClass(permInfo)) {
                    try {
                        @SuppressWarnings("unchecked") Class<? extends Permission> permClass = (Class<? extends Permission>) permInfo.resolveClass();
                        discoveredPermissions.add(permClass);
                    } catch (Exception e) {
                        LOG.error("Unable to load permission.", e);
                    }
                }
            }
            m_permissionClasses = CollectionUtility.hashSet(discoveredPermissions);
        }
    }
}
Also used : IClassInfo(org.eclipse.scout.rt.platform.inventory.IClassInfo) BasicPermission(java.security.BasicPermission) Permission(java.security.Permission) HashSet(java.util.HashSet)

Example 8 with IClassInfo

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

the class RegisterTunnelToServerPlatformListener method registerTunnelToServerProxies.

protected void registerTunnelToServerProxies(final IBeanManager beanManager, final IClassInventory classInventory) {
    for (IClassInfo ci : classInventory.getKnownAnnotatedTypes(TunnelToServer.class)) {
        if (!ci.isInterface() || !ci.isPublic()) {
            LOG.error("The annotation @{} can only be used on public interfaces, not on {}", TunnelToServer.class.getSimpleName(), ci.name());
            continue;
        }
        try {
            Class<?> c = ci.resolveClass();
            registerTunnelToServerProxy(beanManager, c);
        } catch (Exception e) {
            LOG.warn("could not load class [{}]", ci.name(), e);
        }
    }
    LOG.info("Tunnel to server proxies registered.");
}
Also used : TunnelToServer(org.eclipse.scout.rt.shared.TunnelToServer) 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