public long[] searchAccountIdsByOwner(String anOwnerName) {
        assertServiceState();
        LOGGER.info("Searching existing accounts for " + anOwnerName);

        ArrayList<Account> matchAccounts = new ArrayList<Account>();
        synchronized (accounts) {
            for (Account a : accounts) {
                if (a.getOwnerName().toLowerCase().contains(anOwnerName.toLowerCase())) {
                    matchAccounts.add(a);
                }
            }
        }

        long[] accountIds = new long[matchAccounts.size()];
        int index = 0;
        for (Account a : matchAccounts) {
            accountIds[index++] = a.getId();
        }

        LOGGER.debug("Found " + accountIds.length + " account(s) matching the name " + anOwnerName);
        return accountIds;
    }
Internal utility method that validate the internal state of this service.
samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/SecureBankService.java