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;
}
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);
}
}
}
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.");
}
Aggregations