List of usage examples for java.util.concurrent.locks Lock unlock
void unlock();
From source file:de.hoegertn.demo.cxfsimple.SpringStarter.java
public final void doStop() throws Exception { try {//from w w w. j a va 2 s. c o m this.doBeforeSpringStop(); } catch (Exception e) { throw new RuntimeException("Before spring stop failed", e); } Lock writeLock = this.rwLock.writeLock(); try { writeLock.lock(); if (this.context.get() == null) { throw new RuntimeException("Not yet started"); } this.context.get().stop(); this.context.get().close(); this.context.set(null); } catch (Exception e) { throw new RuntimeException("spring stop failed", e); } finally { writeLock.unlock(); } try { this.doAfterSpringStop(); } catch (Exception e) { throw new RuntimeException("After spring stop failed", e); } }
From source file:edu.internet2.middleware.shibboleth.common.attribute.filtering.provider.ShibbolethAttributeFilteringEngine.java
/** {@inheritDoc} */ public Map<String, BaseAttribute> filterAttributes(Map<String, BaseAttribute> attributes, SAMLProfileRequestContext context) throws AttributeFilteringException { log.debug(getId() + " filtering {} attributes for principal {}", attributes.size(), context.getPrincipalName()); if (attributes.size() == 0) { return new HashMap<String, BaseAttribute>(); }/*from ww w . ja va 2 s.c o m*/ if (getFilterPolicies() == null) { log.debug("No filter policies were loaded in {}, filtering out all attributes for {}", getId(), context.getPrincipalName()); return new HashMap<String, BaseAttribute>(); } ShibbolethFilteringContext filterContext = new ShibbolethFilteringContext(attributes, context); Lock readLock = getReadWriteLock().readLock(); readLock.lock(); try { for (AttributeFilterPolicy filterPolicy : filterPolicies) { filterAttributes(filterContext, filterPolicy); runDenyRules(filterContext); } } finally { readLock.unlock(); } Iterator<Entry<String, BaseAttribute>> attributeEntryItr = attributes.entrySet().iterator(); Entry<String, BaseAttribute> attributeEntry; BaseAttribute attribute; Collection retainedValues; while (attributeEntryItr.hasNext()) { attributeEntry = attributeEntryItr.next(); attribute = attributeEntry.getValue(); retainedValues = filterContext.getRetainedValues(attribute.getId(), false); attribute.getValues().clear(); attribute.getValues().addAll(retainedValues); if (attribute.getValues().size() == 0) { log.debug("Removing attribute from return set, no more values: {}", attribute.getId()); attributeEntryItr.remove(); } else { log.debug("Attribute {} has {} values after filtering", attribute.getId(), attribute.getValues().size()); } } log.debug("Filtered attributes for principal {}. The following attributes remain: {}", context.getPrincipalName(), attributes.keySet()); return attributes; }
From source file:org.grails.datastore.mapping.gemfire.engine.GemfireEntityPersister.java
@Override public void unlock(Object o) { final Lock lock = distributedLocksHeld.get(o); if (lock != null) { lock.unlock(); }//w w w. jav a 2 s. c o m }
From source file:org.mule.util.queue.DualRandomAccessFileQueueStoreDelegate.java
@Override protected Serializable getFirst() throws InterruptedException { if (isEmpty()) { return null; }/*from w w w .j a v a2 s . co m*/ Lock lock = filesLock.readLock(); lock.lock(); byte[] bytes; try { if (readFile.isEmpty()) { readFile.clear(); switchReadFile(); } bytes = readFile.getFirst(); } finally { lock.unlock(); } return deserialize(bytes); }
From source file:org.orbeon.oxf.xforms.state.XFormsStateManager.java
/** * Release the given document lock. Must be called after afterUpdate() in a finally block. * * @param lock lock to release/*from w w w . j a va 2 s . c o m*/ */ public void releaseDocumentLock(Lock lock) { lock.unlock(); }
From source file:com.github.jrh3k5.habitat4j.rest.CachingAccessTokenProvider.java
/** * Gets a new access token./*w w w . j a v a 2 s . c o m*/ * * @return An {@link AccessToken} representing the new access token. */ private AccessToken getNewAccessToken() { final Lock writeLock = storeLock.writeLock(); writeLock.lock(); try { final AccessToken currentAccessToken = accessTokenStore.getValue(); if (currentAccessToken != null && !needsRefresh(currentAccessToken)) { return currentAccessToken; } final AccessToken newAccessToken = sourceProvider.getAccessToken(); accessTokenStore.setValue(newAccessToken); return newAccessToken; } finally { writeLock.unlock(); } }
From source file:org.mule.service.oauth.internal.AbstractOAuthDancer.java
/** * Updates the resource owner oauth context information * * @param resourceOwnerOAuthContext/*from ww w .j a va 2s .co m*/ */ protected void updateResourceOwnerOAuthContext(DefaultResourceOwnerOAuthContext resourceOwnerOAuthContext) { final Lock resourceOwnerContextLock = resourceOwnerOAuthContext.getRefreshUserOAuthContextLock(); resourceOwnerContextLock.lock(); try { tokensStore.put(resourceOwnerIdTransformer.apply(resourceOwnerOAuthContext.getResourceOwnerId()), resourceOwnerOAuthContext); } finally { resourceOwnerContextLock.unlock(); } }
From source file:org.eclipse.gyrex.context.internal.registry.ContextRegistryImpl.java
public boolean hasRealContext(IPath contextPath) throws IllegalArgumentException { checkClosed();//from w ww . j av a2s.c o m contextPath = sanitize(contextPath); final Lock readLock = contextRegistryLock.readLock(); readLock.lock(); try { return contexts.containsKey(contextPath); } finally { readLock.unlock(); } }
From source file:de.taimos.daemon.spring.SpringDaemonAdapter.java
@Override public final void doStop() throws Exception { try {/* ww w . ja v a2s. com*/ this.doBeforeSpringStop(); } catch (Exception e) { throw new RuntimeException("Before spring stop failed", e); } Lock writeLock = this.rwLock.writeLock(); try { writeLock.lock(); if (this.context.get() == null) { throw new RuntimeException("Not yet started"); } this.context.get().stop(); this.context.get().close(); this.context.set(null); } catch (Exception e) { throw new RuntimeException("spring stop failed", e); } finally { writeLock.unlock(); } try { this.doAfterSpringStop(); } catch (Exception e) { throw new RuntimeException("After spring stop failed", e); } super.doStop(); }
From source file:com.cloudera.oryx.ml.serving.als.model.ALSServingModel.java
public float[] getUserVector(String user) { Lock lock = xLock.readLock(); lock.lock();/*from w w w.j av a2 s .com*/ try { return X.get(user); } finally { lock.unlock(); } }