List of usage examples for java.util.concurrent.locks Lock unlock
void unlock();
From source file:com.netprogs.minecraft.plugins.social.SocialPerson.java
public String getName() { Lock lock = rwNameLock.readLock(); lock.lock();//from www. java2 s . c om try { return person.getName(); } finally { lock.unlock(); } }
From source file:com.netprogs.minecraft.plugins.social.SocialPerson.java
public SocialMarriage getMarriage() { Lock lock = rwMarriageLock.readLock(); lock.lock();/*from ww w.ja v a2s . c o m*/ try { return socialMarriage; } finally { lock.unlock(); } }
From source file:jenkins.plugins.git.GitSCMFileSystem.java
@Override public boolean changesSince(@CheckForNull SCMRevision revision, @NonNull OutputStream changeLogStream) throws UnsupportedOperationException, IOException, InterruptedException { AbstractGitSCMSource.SCMRevisionImpl rev = getRevision(); if (rev == null ? revision == null : rev.equals(revision)) { // special case where somebody is asking one of two stupid questions: // 1. what has changed between the latest and the latest // 2. what has changed between the current revision and the current revision return false; }//from www . j ava 2s.c o m Lock cacheLock = AbstractGitSCMSource.getCacheLock(cacheEntry); cacheLock.lock(); try { File cacheDir = AbstractGitSCMSource.getCacheDir(cacheEntry); if (cacheDir == null || !cacheDir.isDirectory()) { throw new IOException("Closed"); } boolean executed = false; ChangelogCommand changelog = client.changelog(); try (Writer out = new OutputStreamWriter(changeLogStream, "UTF-8")) { changelog.includes(commitId); ObjectId fromCommitId; if (revision instanceof AbstractGitSCMSource.SCMRevisionImpl) { fromCommitId = ObjectId.fromString(((AbstractGitSCMSource.SCMRevisionImpl) revision).getHash()); changelog.excludes(fromCommitId); } else { fromCommitId = null; } changelog.to(out).max(GitSCM.MAX_CHANGELOG).execute(); executed = true; return !commitId.equals(fromCommitId); } catch (GitException ge) { throw new IOException("Unable to retrieve changes", ge); } finally { if (!executed) { changelog.abort(); } changeLogStream.close(); } } finally { cacheLock.unlock(); } }
From source file:edu.internet2.middleware.shibboleth.common.config.BaseService.java
/** * Loads the service context./*from ww w.jav a 2 s .c om*/ * * @throws ServiceException thrown if the configuration for this service could not be loaded */ protected void loadContext() throws ServiceException { log.info("Loading new configuration for service {}", getId()); if (serviceConfigurations == null || serviceConfigurations.isEmpty()) { setInitialized(true); return; } GenericApplicationContext newServiceContext = new GenericApplicationContext(getApplicationContext()); newServiceContext.setDisplayName("ApplicationContext:" + getId()); Lock writeLock = getReadWriteLock().writeLock(); writeLock.lock(); try { SpringConfigurationUtils.populateRegistry(newServiceContext, getServiceConfigurations()); newServiceContext.refresh(); GenericApplicationContext replacedServiceContext = serviceContext; onNewContextCreated(newServiceContext); setServiceContext(newServiceContext); setInitialized(true); if (replacedServiceContext != null) { replacedServiceContext.close(); } log.info("{} service loaded new configuration", getId()); } catch (Throwable e) { // Here we catch all the other exceptions thrown by Spring when it starts up the context setInitialized(false); Throwable rootCause = e; while (rootCause.getCause() != null) { rootCause = rootCause.getCause(); } log.error("Configuration was not loaded for " + getId() + " service, error creating components. The root cause of this error was: " + rootCause.getClass().getCanonicalName() + ": " + rootCause.getMessage()); log.trace("Full stacktrace is: ", e); throw new ServiceException( "Configuration was not loaded for " + getId() + " service, error creating components.", rootCause); } finally { writeLock.unlock(); } }
From source file:com.netprogs.minecraft.plugins.social.SocialPerson.java
public boolean isLawyer() { Lock lock = rwLawyerLock.readLock(); lock.lock();//from www.j a va 2 s . c om try { return person.isLawyer(); } finally { lock.unlock(); } }
From source file:com.netprogs.minecraft.plugins.social.SocialPerson.java
public boolean isPriest() { Lock lock = rwPriestLock.readLock(); lock.lock();/*from w w w.j a va2 s .com*/ try { return person.isPriest(); } finally { lock.unlock(); } }
From source file:com.netprogs.minecraft.plugins.social.SocialPerson.java
public Gender getGender() { Lock lock = rwGenderLock.readLock(); lock.lock();/*w ww . ja va 2 s. c o m*/ try { return person.getGender(); } finally { lock.unlock(); } }
From source file:com.netprogs.minecraft.plugins.social.SocialPerson.java
public void setGender(Gender gender) { Lock lock = rwGenderLock.writeLock(); lock.lock();/* ww w .j a v a2s .c om*/ try { person.setGender(gender); } finally { lock.unlock(); } }
From source file:com.netprogs.minecraft.plugins.social.SocialPerson.java
public void setLawyer(boolean lawyer) { Lock lock = rwLawyerLock.writeLock(); lock.lock();//w ww . j ava 2s . co m try { person.setLawyer(lawyer); } finally { lock.unlock(); } }
From source file:com.netprogs.minecraft.plugins.social.SocialPerson.java
public void setPriest(boolean priest) { Lock lock = rwPriestLock.writeLock(); lock.lock();/*from w ww . j ava 2s . co m*/ try { person.setPriest(priest); } finally { lock.unlock(); } }