@RequiresPermissions("bankAccount:create")
    public long createNewAccount(String anOwnerName) {
        assertServiceState();
        LOGGER.info("Creating new account for " + anOwnerName);

        synchronized (accounts) {
            Account account = new Account(anOwnerName);
            account.setCreatedBy(getCurrentUsername());
            accounts.add(account);
            accountsById.put(account.getId(), account);

            LOGGER.debug("Created new account: " + account);
            return account.getId();
        }
    }
Internal utility method that validate the internal state of this service.
samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/SecureBankService.java