The instance method gets all sub menus and commands and adds them to this
menu instance via method {@link #add(long)}.

@see #readFromDB
@see #add(long)
@throws CacheReloadException on error during load
17290
private void readFromDB4Childs()
        throws CacheReloadException
    {
        try {
            final QueryBuilder queryBldr = new QueryBuilder(CIAdminUserInterface.Menu2Command);
            queryBldr.addWhereAttrEqValue(CIAdminUserInterface.Menu2Command.FromMenu, getId());
            final MultiPrintQuery multi = queryBldr.getPrint();
            multi.addAttribute(CIAdminUserInterface.Menu2Command.ToCommand);
            multi.executeWithoutAccessCheck();

            while (multi.next()) {
                final long commandId = multi.<Long> getAttribute(CIAdminUserInterface.Menu2Command.ToCommand);
                add(multi.getCurrentInstance().getId(), commandId);
            }
        } catch (final EFapsException e) {
            throw new CacheReloadException("could not read childs for menu '" + getName() + "'", e);
        }
    }
214674
private void readLinks2AccessTypes()
        throws CacheReloadException
    {
        Connection con = null;
        try {
            final List<Long> values = new ArrayList<>();
            con = Context.getConnection();
            PreparedStatement stmt = null;
            try {
                stmt = con.prepareStatement(AccessSet.SQL_SET2TYPE);
                stmt.setObject(1, getId());
                final ResultSet rs = stmt.executeQuery();
                while (rs.next()) {
                    values.add(rs.getLong(1));
                }
                rs.close();
            } finally {
                if (stmt != null) {
                    stmt.close();
                }
            }
            con.commit();
            for (final Long accessTypeId : values) {
                final AccessType accessType = AccessType.getAccessType(accessTypeId);
                if (accessType == null) {
                    AccessSet.LOG.error("could not found access type with id " + "'" + accessTypeId + "'");
                } else {
                    AccessSet.LOG.debug(
                            "read link from AccessSet '{}' (id = {}, uuid = {}) to AccessType '{}' (id = {} uuid = {})",
                                    getName(), getId(), getUUID(), accessType.getName(), accessType.getId(),
                                    accessType.getUUID());
                    getAccessTypes().add(accessType);
                }
            }
        } catch (final SQLException e) {
            throw new CacheReloadException("could not read roles", e);
        } catch (final EFapsException e) {
            throw new CacheReloadException("could not read roles", e);
        } finally {
            try {
                if (con != null && !con.isClosed()) {
                    con.close();
                }
            } catch (final SQLException e) {
                throw new CacheReloadException("Cannot read a type for an attribute.", e);
            }
        }
    }
140641
public static void initialize(final Class<?> _class)
        throws CacheReloadException
    {
        if (InfinispanCache.get().exists(NumberGenerator.UUIDCACHE)) {
            InfinispanCache.get().<UUID, NumberGenerator>getCache(NumberGenerator.UUIDCACHE).clear();
        } else {
            InfinispanCache.get().<UUID, NumberGenerator>getCache(NumberGenerator.UUIDCACHE)
                            .addListener(new CacheLogListener(NumberGenerator.LOG));
        }
        if (InfinispanCache.get().exists(NumberGenerator.IDCACHE)) {
            InfinispanCache.get().<Long, NumberGenerator>getCache(NumberGenerator.IDCACHE).clear();
        } else {
            InfinispanCache.get().<Long, NumberGenerator>getCache(NumberGenerator.IDCACHE)
                            .addListener(new CacheLogListener(NumberGenerator.LOG));
        }
        if (InfinispanCache.get().exists(NumberGenerator.NAMECACHE)) {
            InfinispanCache.get().<String, NumberGenerator>getCache(NumberGenerator.NAMECACHE).clear();
        } else {
            InfinispanCache.get().<String, NumberGenerator>getCache(NumberGenerator.NAMECACHE)
                            .addListener(new CacheLogListener(NumberGenerator.LOG));
        }
    }
657478
public synchronized void addAll(T... nodes) {
        for (T node : nodes)
            addInternal(node,defaultReplication);
        refreshTable();
    }

    /**
     * 
     */
    public synchronized void addAll(Collection<? extends T> nodes) {
        for (T node : nodes)
            addInternal(node,defaultReplication);
        refreshTable();
    }

    /**
     * Calls {@link #add(Object,int)} with all the arguments.
     */
    public synchronized void addAll(Map<? extends T,Integer> nodes) {
        for (Map.Entry<? extends T,Integer> node : nodes.entrySet())
            addInternal(node.getKey(),node.getValue());
        refreshTable();
    }

    /**
     * Removes the node entirely. This is the same as {@code add(node,0)}
     */
    public synchronized void remove(T node) {
        add(node, 0);
    }

    /**
     * Adds a new node with the given number of replica.
     */
    public synchronized void add(T node, int replica) {
        addInternal(node, replica);
        refreshTable();
    }

    private synchronized void addInternal(T node, int replica) {
        if (replica==0) {
            items.remove(node);
        } else {
            Point[] points = new Point[replica];
            String seed = hash.hash(node);
            for (int i=0; i<replica; i++)
                points[i] = new Point(md5(seed+':'+i),node);
            items.put(node,points);
        }
    }

    private synchronized void refreshTable() {
        table = new Table();
    }

    /**
     * Compresses a string into an integer with MD5.
     */
    private int md5(String s) {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(s.getBytes());
            byte[] digest = md5.digest();

            // 16 bytes -> 4 bytes
            for (int i=0; i<4; i++)
                digest[i] ^= digest[i+4]+digest[i+8]+digest[i+12];
            return (b2i(digest[0])<< 24)|(b2i(digest[1])<<16)|(b2i(digest[2])<< 8)|b2i(digest[3]);
        } catch (GeneralSecurityException e) {
            throw new RuntimeException("Could not generate MD5 hash", e);
        }
    }

    /**
     * unsigned byte->int.
     */
    private int b2i(byte b) {
        return ((int)b)&0xFF;
    }

    /**
     * Looks up a consistent hash with the given data point.
     *
     * <p>
     * The whole point of this class is that if the same query point is given,
     * it's likely to return the same result even when other nodes are added/removed,
     * or the # of replicas for the given node is changed.
     *
     * @return
     *      null if the consistent hash is empty. Otherwise always non-null.
     */
    public T lookup(int queryPoint) {
        return table.lookup(queryPoint);
    }

    /**
     * Takes a string, hash it with MD5, then calls {@link #lookup(int)}. 
     */
    public T lookup(String queryPoint) {
        return lookup(md5(queryPoint));
    }

    /**
     * Creates a permutation of all the nodes for the given data point.
     *
     * <p>
     * The returned permutation is consistent, in the sense that small change
     * to the consistent hash (like addition/removal/change of replicas) only
     * creates a small change in the permutation.
     *
     * <p>
     * Nodes with more replicas are more likely to show up early in the list
     */
    public Iterable<T> list(final int queryPoint) {
        return new Iterable<T>() {
            public Iterator<T> iterator() {
                return table.list(queryPoint);
            }
        };
    }

    /**
     * Takes a string, hash it with MD5, then calls {@link #list(int)}.
     */
    public Iterable<T> list(String queryPoint) {
        return list(md5(queryPoint));
    }
}
1065677
@Override
    public <T> T loadDataFromCache(Class<T> clazz, Object cacheKey, long maxTimeInCacheBeforeExpiry) throws CacheLoadingException, CacheCreationException {
        return getObjectPersister(clazz).loadDataFromCache(cacheKey, maxTimeInCacheBeforeExpiry);
    }
488328
public static Table get(final String _name)
        throws CacheReloadException
    {
        return AbstractUserInterfaceObject.<Table>get(_name, Table.class, CIAdminUserInterface.Table.getType());
    }
245393
private void readObject(java.io.ObjectInputStream in)
        throws IOException, ClassNotFoundException
    {
        in.defaultReadObject();
        _cache=new HashMap();
    }
45853
public long addAndGet(long delta)
      throws MemcachedException, InterruptedException, TimeoutException {
    if (delta >= 0) {
      return this.memcachedClient.incr(this.key, delta, this.initialValue);
    } else {
      return this.memcachedClient.decr(this.key, -delta, this.initialValue);
    }
  }
793952
public void add(DnsQuery query, DnsResponse response) {
		assert eventloop.inEventloopThread() : "Concurrent cache adds are not allowed";
		long expirationTime = now.currentTimeMillis();
		if (response.isSuccessful()) {
			assert response.getRecord() != null; // where are my advanced contracts so that Intellj would know it's true here without an assert?
			long minTtl = response.getRecord().getMinTtl() * 1000;
			if (minTtl == 0) {
				return;
			}
			expirationTime += Math.min(minTtl, maxTtl);
		} else {
			expirationTime += response.getErrorCode() == ResponseErrorCode.TIMED_OUT ?
					timedOutExceptionTtl :
					errorCacheExpiration;
		}
		CachedDnsQueryResult cachedResult = new CachedDnsQueryResult(response, expirationTime);
		CachedDnsQueryResult old = cache.put(query, cachedResult);
		expirations.add(cachedResult);

		if (old != null) {
			old.response = null; // mark old cache response as refreshed (see performCleanup)
			logger.trace("Refreshed cache entry for {}", query);
		} else {
			logger.trace("Added cache entry for {}", query);
		}
	}
358292
public synchronized void initialize() {

        List<I_CmsContextMenuItem> result = Lists.newArrayList();
        for (I_CmsContextMenuItemProvider provider : m_providerMap.values()) {
            result.addAll(provider.getMenuItems());
        }
        m_itemCache = result;
    }
433668
public static void initialize()
        throws CacheReloadException
    {
        if (InfinispanCache.get().exists(Store.UUIDCACHE)) {
            InfinispanCache.get().<UUID, Store>getCache(Store.UUIDCACHE).clear();
        } else {
            InfinispanCache.get().<UUID, Store>getCache(Store.UUIDCACHE).addListener(new CacheLogListener(Store.LOG));
        }
        if (InfinispanCache.get().exists(Store.IDCACHE)) {
            InfinispanCache.get().<Long, Store>getCache(Store.IDCACHE).clear();
        } else {
            InfinispanCache.get().<Long, Store>getCache(Store.IDCACHE).addListener(new CacheLogListener(Store.LOG));
        }
        if (InfinispanCache.get().exists(Store.NAMECACHE)) {
            InfinispanCache.get().<String, Store>getCache(Store.NAMECACHE).clear();
        } else {
            InfinispanCache.get().<String, Store>getCache(Store.NAMECACHE).addListener(new CacheLogListener(Store.LOG));
        }
    }
1136770
public function loadCommands()
    {
        $slickModules = $this->filterSlickModules();
        $classes = $this->getCommandClasses($slickModules);
        foreach ($classes as $class) {
            if (is_subclass_of($class, Command::class)) {
                $this->application->add(new $class());
            }
        }
    }
1017540
private synchronized static void loadAll() throws DaoManagerException {
		if (setImpl ==null) {
			long implLastModifiedTime=impl.getLastModified();
				
			if (lastModified<implLastModifiedTime){
				Map<String,PropertyDescriptor> staticValues=impl.getAll();
				// to avoid reading while cleaning
				synchronized (cache) {
					cache.clear();
					cache.putAll(staticValues);
				}
				lastModified=System.currentTimeMillis();
				notifyPropertiesChangedListers(lastModified);	
			}
		} else {
			long implLastModifiedTime=impl.getLastModified();
			long setImplLastModifiedTime=setImpl.getLastModified();
		
			if (lastModified<implLastModifiedTime || lastModified<setImplLastModifiedTime){
				Map<String,PropertyDescriptor> staticValues=impl.getAll();
				Map<String,PropertyDescriptor> dynamicValues=setImpl.getAll();
				// to avoid reading while cleaning
				synchronized (cache) {
					cache.clear();
					cache.putAll(staticValues);
					cache.putAll(dynamicValues);
				}
				lastModified=System.currentTimeMillis();
				notifyPropertiesChangedListers(lastModified);
			}
		}
	}
1359289
public static AccessSet get(final long _id)
        throws CacheReloadException
    {
        final Cache<Long, AccessSet> cache = InfinispanCache.get().<Long, AccessSet>getCache(AccessSet.IDCACHE);
        if (!cache.containsKey(_id)) {
            AccessSet.getAccessSetFromDB(AccessSet.SQL_ID, _id);
        }
        return cache.get(_id);
    }
689426
private void readFromDB4Fields()
        throws CacheReloadException
    {
        try {

            final QueryBuilder queryBldr = new QueryBuilder(CIAdminUserInterface.Field);
            queryBldr.addWhereAttrEqValue(CIAdminUserInterface.Field.Collection, getId());
            final MultiPrintQuery multi = queryBldr.getPrint();
            multi.addAttribute(CIAdminUserInterface.Field.Type,
                               CIAdminUserInterface.Field.Name);
            multi.executeWithoutAccessCheck();

            while (multi.next()) {
                final long id = multi.getCurrentInstance().getId();
                final String name =  multi.<String>getAttribute(CIAdminUserInterface.Field.Name);
                final Type type = multi.<Type>getAttribute(CIAdminUserInterface.Field.Type);
                final Field field;
                if (type.equals(CIAdminUserInterface.FieldCommand.getType())) {
                    field = new FieldCommand(id, null, name);
                } else if (type.equals(CIAdminUserInterface.FieldHeading.getType())) {
                    field = new FieldHeading(id, null, name);
                } else if (type.equals(CIAdminUserInterface.FieldTable.getType())) {
                    field = new FieldTable(id, null, name);
                } else if (type.equals(CIAdminUserInterface.FieldGroup.getType())) {
                    field = new FieldGroup(id, null, name);
                } else if (type.equals(CIAdminUserInterface.FieldSet.getType())) {
                    field = new FieldSet(id, null, name);
                } else if (type.equals(CIAdminUserInterface.FieldClassification.getType())) {
                    field = new FieldClassification(id, null, name);
                } else if (type.equals(CIAdminUserInterface.FieldPicker.getType())) {
                    field = new FieldPicker(id, null, name);
                } else {
                    field = new Field(id, null, name);
                }
                field.readFromDB();
                add(field);
            }
        } catch (final EFapsException e) {
            throw new CacheReloadException("could not read fields for '" + getName() + "'", e);
        }
    }
110874
public static Menu get(final long _id)
        throws CacheReloadException
    {
        return AbstractUserInterfaceObject.<Menu>get(_id, Menu.class, CIAdminUserInterface.Menu.getType());
    }
1349498
private ObjectResult addOrUpdateObject(DBObject                          dbObj,
                                           Map<String, String>               currScalarMap,
                                           Map<String, Map<String, Integer>> targObjShardNos)
            throws IOException {
        ObjectUpdater objUpdater = new ObjectUpdater(m_tableDef);
        if (targObjShardNos.size() > 0) {
            objUpdater.setTargetObjectShardNumbers(targObjShardNos);
        }
        if (currScalarMap == null || currScalarMap.size() == 0) {
            return objUpdater.addNewObject(m_parentTran, dbObj);
        } else {
            return objUpdater.updateObject(m_parentTran, dbObj, currScalarMap);
        }
    }