private Lock getLock(String key) { return this.oauthManager.getMuleContext() .getLockFactory() .createLock(String.format("OAuthTokenKeyLock-%s", key)); }
/** * Cache identifier to catch duplicate usage. * * @param ident * @return <code>true</code> if new, <code>false</code> if previously cached */ public boolean cacheIdentifier(String ident) { Lock lock = lockFactory.createLock(ident); try { if (lock.tryLock(LOCK_WAIT_SECONDS, TimeUnit.SECONDS)) { try { if (counterObjectStore.contains(ident)) { return false; } counterObjectStore.store(ident, ""); return true; } catch (ObjectStoreException e) { throw new RuntimeException("Could not cache identifier " + ident, e); } finally { lock.unlock(); } } else { throw new RuntimeException("Could not acquire lock to cache identifier " + ident); } } catch (InterruptedException e) { throw new RuntimeException("Failed acquiring lock to cache identifier " + ident); } }
Lock lock = lockFactory.createLock(key); try { if (lock.tryLock(LOCK_WAIT_SECONDS, TimeUnit.SECONDS)) {
Lock lock = lockFactory.createLock(key); try { if (lock.tryLock(LOCK_WAIT_SECONDS, TimeUnit.SECONDS)) {
Lock lock = lockFactory.createLock(key); try { if (lock.tryLock(LOCK_WAIT_SECONDS, TimeUnit.SECONDS)) {
/** * {@inheritDoc} This implementation uses a lock to guarantee that no refresh * token is consumed more than once * * @see org.mule.security.oauth.RefreshTokenManager#refreshToken(org.mule.security.oauth.OAuth2Adapter, * java.lang.String) */ @Override public void refreshToken(OAuth2Adapter adapter, String accessTokenId) throws Exception { if (StringUtils.isEmpty(accessTokenId)) { throw new IllegalArgumentException("Cannot refresh a blank accessTokenId"); } String id = String.format("%s:%s:%s", this.getClass().getCanonicalName(), adapter.getName(), accessTokenId); Lock lock = this.muleContext.getLockFactory().createLock(id); lock.lock(); try { if (!this.getRefreshedTokens().contains(id)) { adapter.refreshAccessToken(accessTokenId); this.getRefreshedTokens().store(id, true); } } finally { lock.unlock(); } }
Lock lock = muleContext.getLockFactory().createLock(sharedObjectStoreLockId); lock.lock(); try {
Lock fileLock = lockFactory.createLock(file.getName()); if (fileLock.tryLock())
Lock lock = muleContext.getLockFactory().createLock(sharedObjectStoreLockId); lock.lock(); try {
MuleMessage muleMessage) throws ObjectStoreException { Lock lock = muleContext.getLockFactory().createLock(sharedObjectStoreLockId); lock.lock();
Lock lock = lockFactory.createLock(idrId + "-" + messageId); lock.lock(); try
MuleMessage muleMessage) throws ObjectStoreException { Lock lock = muleContext.getLockFactory().createLock(sharedObjectStoreLockId); lock.lock(); Object ret;
Lock lock = muleContext.getLockFactory().createLock(sharedObjectStoreLockId); lock.lock(); try {