public OAuth2Client getClient(final String gadgetUri, final String serviceName) throws GadgetException { final boolean isLogging = BasicOAuth2Store.LOG.isLoggable(); if (isLogging) { BasicOAuth2Store.LOG.entering(BasicOAuth2Store.LOG_CLASS, "getClient", new Object[] { gadgetUri, serviceName }); } OAuth2Client client = this.cache.getClient(gadgetUri, serviceName); if (isLogging) { BasicOAuth2Store.LOG.log("client from cache = {0}", client); } if (client == null) { try { client = this.persister.findClient(gadgetUri, serviceName); if (client != null) { this.cache.storeClient(client); } } catch (final OAuth2PersistenceException e) { if (isLogging) { BasicOAuth2Store.LOG.log("Error loading OAuth2 client ", e); } throw new GadgetException(Code.OAUTH_STORAGE_ERROR, "Error loading OAuth2 client " + serviceName, e); } } if (isLogging) { BasicOAuth2Store.LOG.exiting(BasicOAuth2Store.LOG_CLASS, "getClient", client); } return client; }