Example usage for java.util Collections synchronizedSet

List of usage examples for java.util Collections synchronizedSet

Introduction

In this page you can find the example usage for java.util Collections synchronizedSet.

Prototype

public static <T> Set<T> synchronizedSet(Set<T> s) 

Source Link

Document

Returns a synchronized (thread-safe) set backed by the specified set.

Usage

From source file:org.codehaus.mojo.aspectj.AjcHelper.java

/**
 * Constructs AspectJ compiler classpath string
 * //from   w  w  w. j a va  2s .  c  o m
 * @param project the Maven Project
 * @param pluginArtifacts the plugin Artifacts
 * @param outDirs the outputDirectories
 * @return a os spesific classpath string
 */
public static String createClassPath(MavenProject project, List pluginArtifacts, List outDirs) {
    String cp = new String();
    Set classPathElements = Collections.synchronizedSet(new LinkedHashSet());
    classPathElements.addAll(project.getDependencyArtifacts());
    classPathElements.addAll(project.getArtifacts());
    classPathElements.addAll(pluginArtifacts == null ? Collections.EMPTY_LIST : pluginArtifacts);
    Iterator iter = classPathElements.iterator();
    while (iter.hasNext()) {
        Artifact classPathElement = (Artifact) iter.next();
        File artifact = classPathElement.getFile();
        if (null != artifact) {
            cp += classPathElement.getFile().getAbsolutePath();
            cp += File.pathSeparatorChar;
        }
    }
    Iterator outIter = outDirs.iterator();
    while (outIter.hasNext()) {
        cp += outIter.next();
        cp += File.pathSeparatorChar;
    }

    if (cp.endsWith("" + File.pathSeparatorChar)) {
        cp = cp.substring(0, cp.length() - 1);
    }

    cp = StringUtils.replace(cp, "//", "/");
    return cp;
}

From source file:org.arrow.runtime.execution.MultipleEventExecution.java

/**
 * Adds the given received event id.// ww  w .ja v a2 s .c  o m
 * 
 * @param eventId the event id value
 */
public void addReceivedEventId(String eventId) {

    Assert.notNull(eventId);
    if (receivedEventIds == null) {
        receivedEventIds = Collections.synchronizedSet(new HashSet<>());
    }

    receivedEventIds.add(eventId);
    evaluateExecutionState();
}

From source file:fr.aliasource.webmail.pool.Pool.java

public Pool(String poolId, IPoolableObjectFactory<T> factory, int poolSize, String destroyMethodName,
        long keepAlivePeriod) {
    this.logger = LogFactory.getLog(getClass());
    this.poolId = poolId;
    this.objectsInUse = Collections.synchronizedSet(new HashSet<T>());
    this.destroyMethod = destroyMethodName;
    this.availableObjects = new LinkedBlockingQueue<T>(poolSize);

    for (int i = 0; i < poolSize; i++) {
        logger.info(poolId + ": Adding pooled object...");
        availableObjects.add(factory.createNewObject());
        logger.info(poolId + ": Pooled object added.");
    }//  w ww  .j a  v a  2  s . c o m

    keepAliveTimer = new Timer(poolId + "-keepalive-timer", true);
    KeepAliveTask<T> kaTsk = new KeepAliveTask<T>(availableObjects, factory, this);
    keepAliveTimer.scheduleAtFixedRate(kaTsk, 10000, keepAlivePeriod);
}

From source file:net.ymate.platform.module.search.support.IndexHelper.java

public IndexHelper(ISearchConfig config) {
    __isBuildWorkingSet = Collections.synchronizedSet(new HashSet<String>());
    // ??30/* w w w . j  a  v a 2 s.c  o  m*/
    long _period = config.getScheduledPeriod() * 1000L;
    if (_period <= 0) {
        _period = 30L * 1000L;
    }
    // commit?Reopen
    __scheduler = Executors.newSingleThreadScheduledExecutor();
    // ??
    __scheduler.scheduleAtFixedRate(new Runnable() {

        public void run() {
            if (__isWorking) {
                return;
            }
            __isWorking = true;
            try {
                _LOG.debug("Start Reopen Working...");
                for (Map.Entry<String, IndexSearcher> entry : Searchs.__SEARCH_CACHES.entrySet()) {
                    IndexReader _reader = entry.getValue().getIndexReader();
                    try {
                        IndexReader _reOpenedReader = DirectoryReader.openIfChanged((DirectoryReader) _reader);
                        if (_reOpenedReader != null && _reOpenedReader != _reader) {
                            _reader.decRef();
                            Searchs.__SEARCH_CACHES.put(entry.getKey(), new IndexSearcher(_reOpenedReader));
                        }
                    } catch (IOException ex) {
                        _LOG.error("Reopen And DecRef IndexReader Error:", ex);
                    }
                }
            } finally {
                _LOG.debug("End Reopen Working...");
                __isWorking = false;
            }
        }
    }, _period, _period, TimeUnit.MILLISECONDS);
}

From source file:enumsupport.reverselookupmapfactory.DeduplicatdeNumberSetFactory.java

/**
 *
 * @param numberRange ???//from w ww  .  j a  v  a 2s.c om
 * @param number  null??
 * @param numbers ??????null??????
 * @return ????(??)
 * @throws NullPointerException ?????null?????
 * @throws IllegalArgumentException ??numberrange???????
 */
public Set<T> makeSet(Range<T> numberRange, T number, T... numbers)
        throws NullPointerException, IllegalArgumentException {

    List<T> t = new ArrayList<>();
    t.add(number);

    if (numbers != null) {
        t.addAll(Arrays.asList(numbers));
    }
    for (T num : t) {
        if (num == null) {
            throw new IllegalArgumentException("?null???????");
        }
        if (!numberRange.contains(num)) {
            MessageFormat msg = new MessageFormat(
                    "????????????={0}");
            Object[] parameters = { num };
            throw new IllegalArgumentException(msg.format(parameters));
        }
    }
    Set<T> numberSet_t = Collections.synchronizedSet(new HashSet<>());
    numberSet_t.addAll(t);
    return Collections.unmodifiableSet(numberSet_t);
}

From source file:hku.fyp14017.blencode.utils.DownloadUtil.java

private DownloadUtil() {
    programDownloadQueue = Collections.synchronizedSet(new HashSet<String>());
}

From source file:cc.kune.core.server.manager.impl.SocialNetworkCache.java

/**
 * Instantiates a new social network cache.
 *///from  ww  w . j a  v a  2  s  . c  om
public SocialNetworkCache() {
    super(100);
    expiredGroups = Collections.synchronizedSet(new HashSet<Group>());
}

From source file:epgtools.dumpepgfromts.dataextractor.AbstractDataExtractor.java

/**
 * <br>// w  w w .  ja  v  a2  s.  c  om
 * ??ID???<br>
 *
 * @param tableId ????ID
 * @param tablsIds ????ID
 * @throws IllegalArgumentException<br>
 * 1:???
 */
protected AbstractDataExtractor(TABLE_ID tableId, TABLE_ID... tablsIds) throws IllegalArgumentException {

    Set<TABLE_ID> tidset = Collections.synchronizedSet(new HashSet<>());
    if (tableId == null) {
        throw new IllegalArgumentException("ID?????");
    }
    tidset.add(tableId);

    int l = tablsIds.length;
    for (int x = 0; x < l; x++) {
        TABLE_ID y = tablsIds[x];
        if (y != null) {
            tidset.add(y);
        } else {
            LOG.error(
                    "ID??null???????null?????");
        }
    }
    this.tableIds = Collections.unmodifiableSet(tidset);

}

From source file:mitm.djigzo.web.components.MultiSelectCertificateGrid.java

public Set<String> getSelected() {
    if (selected == null) {
        selected = Collections.synchronizedSet(new HashSet<String>());
    }/*from  ww  w  . j a  v  a  2 s  .c o m*/

    return selected;
}

From source file:strat.mining.multipool.stats.service.impl.middlecoin.RequestStatsLoggingServiceImpl.java

public RequestStatsLoggingServiceImpl() {
    nbAllGlobal = new AtomicInteger(0);
    nbLastGlobal = new AtomicInteger(0);
    nbAllAddress = new AtomicInteger(0);
    nbLastAddress = new AtomicInteger(0);
    nbPaidout = new AtomicInteger(0);
    nbSuggestion = new AtomicInteger(0);

    uniqueAddressesAllStats = Collections.synchronizedSet(new HashSet<String>());
    uniqueAddressesLastStats = Collections.synchronizedSet(new HashSet<String>());
    uniqueAddressesPaidout = Collections.synchronizedSet(new HashSet<String>());
}