Example usage for java.util.concurrent CopyOnWriteArrayList CopyOnWriteArrayList

List of usage examples for java.util.concurrent CopyOnWriteArrayList CopyOnWriteArrayList

Introduction

In this page you can find the example usage for java.util.concurrent CopyOnWriteArrayList CopyOnWriteArrayList.

Prototype

public CopyOnWriteArrayList() 

Source Link

Document

Creates an empty list.

Usage

From source file:hudson.model.Actionable.java

/**
 * Gets actions contributed to this build.
 *
 * <p>//from  w ww . j  ava2  s  . com
 * A new {@link Action} can be added by {@code getActions().add(...)}.
 *
 * @return
 *      may be empty but never null.
 */
@Exported
public List<Action> getActions() {
    if (actions == null) {
        synchronized (this) {
            if (actions == null) {
                actions = new CopyOnWriteArrayList<Action>();
            }
        }
    }
    return actions;
}

From source file:com.cognifide.aet.runner.distribution.dispatch.CollectionResultsRouter.java

@Inject
public CollectionResultsRouter(TimeoutWatch timeoutWatch, JmsConnection jmsConnection,
        @Named("messageTimeToLive") Long messageTimeToLive, CollectorJobScheduler collectorJobScheduler,
        SuiteIndexWrapper suite) throws JMSException {
    super(timeoutWatch, jmsConnection, suite.get().getCorrelationId(), messageTimeToLive);
    this.collectorJobScheduler = collectorJobScheduler;
    this.suite = suite;
    this.messagesToReceive.getAndSet(countUrls());
    this.changeListeners = new CopyOnWriteArrayList<>();
}

From source file:org.exoplatform.services.wcm.search.PaginatedQueryResult.java

@SuppressWarnings({ "unchecked", "deprecation" })
protected void populateCurrentPage(int page) throws Exception {
    if (page == currentPage_ && (currentListPage_ != null && !currentListPage_.isEmpty())) {
        return;/*from www . j  a va  2s.c om*/
    }
    checkAndSetPosition(page);
    currentListPage_ = new CopyOnWriteArrayList<ResultNode>();
    int count = 0;
    RowIterator iterator = queryResult.getRows();
    while (nodeIterator.hasNext()) {
        Node node = nodeIterator.nextNode();
        Node viewNode = filterNodeToDisplay(node);

        if (viewNode != null) {
            //Skip back 1 position to get current row mapping to the node
            long position = nodeIterator.getPosition();
            long rowPosition = iterator.getPosition();
            long skipNum = position - rowPosition;
            iterator.skip(skipNum - 1);
            Row row = iterator.nextRow();
            ResultNode resultNode = new ResultNode(viewNode, row);
            currentListPage_.add(resultNode);
            count++;
            if (count == getPageSize())
                break;
        }
    }
    currentPage_ = page;
}

From source file:org.codehaus.wadi.servicespace.basic.BasicServiceMonitor.java

public BasicServiceMonitor(ServiceSpace serviceSpace, ServiceName serviceName) {
    if (null == serviceSpace) {
        throw new IllegalArgumentException("serviceSpace is required");
    } else if (null == serviceName) {
        throw new IllegalArgumentException("serviceName is required");
    }//from  w  ww.  j  a  v  a 2 s. c  o  m
    this.serviceSpace = serviceSpace;
    this.serviceName = serviceName;

    dispatcher = serviceSpace.getDispatcher();
    localPeer = dispatcher.getCluster().getLocalPeer();
    listeners = new CopyOnWriteArrayList<ServiceListener>();
    hostingPeers = new HashSet<Peer>();
    lifecycleEndpoint = new ServiceLifecycleEndpoint();
    hostingServiceSpaceFailure = new HostingServiceSpaceFailure();
}

From source file:lineage2.gameserver.network.clientpackets.SetPrivateStoreSellList.java

/**
 * Method runImpl.//from ww w. j a v  a2  s .c o  m
 */
@Override
protected void runImpl() {
    Player seller = getClient().getActiveChar();
    if ((seller == null) || (_count == 0)) {
        return;
    }
    if (!TradeHelper.checksIfCanOpenStore(seller,
            _package ? Player.STORE_PRIVATE_SELL_PACKAGE : Player.STORE_PRIVATE_SELL)) {
        seller.sendActionFailed();
        return;
    }
    TradeItem temp;
    List<TradeItem> sellList = new CopyOnWriteArrayList<>();
    seller.getInventory().writeLock();
    try {
        for (int i = 0; i < _count; i++) {
            int objectId = _items[i];
            long count = _itemQ[i];
            long price = _itemP[i];
            ItemInstance item = seller.getInventory().getItemByObjectId(objectId);
            if ((item == null) || (item.getCount() < count) || !item.canBeTraded(seller)
                    || (item.getItemId() == ItemTemplate.ITEM_ID_ADENA)) {
                continue;
            }
            temp = new TradeItem(item);
            temp.setCount(count);
            temp.setOwnersPrice(price);
            sellList.add(temp);
        }
    } finally {
        seller.getInventory().writeUnlock();
    }
    if (sellList.size() > seller.getTradeLimit()) {
        seller.sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
        seller.sendPacket(new PrivateStoreManageListSell(seller, _package));
        return;
    }
    if (!sellList.isEmpty()) {
        seller.setSellList(_package, sellList);
        seller.saveTradeList();
        seller.setPrivateStoreType(_package ? Player.STORE_PRIVATE_SELL_PACKAGE : Player.STORE_PRIVATE_SELL);
        seller.broadcastPacket(new PrivateStoreMsgSell(seller));
        seller.sitDown(null);
        seller.broadcastCharInfo();
    }
    seller.sendActionFailed();
}

From source file:com.connectsdk.discovery.provider.CastDiscoveryProvider.java

public CastDiscoveryProvider(Context context) {
    mMediaRouter = MediaRouter.getInstance(context);
    mMediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory(CastMediaControlIntent
            .categoryForCast(CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)).build();

    mMediaRouterCallback = new MediaRouterCallback();

    foundServices = new ConcurrentHashMap<String, ServiceDescription>(8, 0.75f, 2);
    serviceListeners = new CopyOnWriteArrayList<DiscoveryProviderListener>();
}

From source file:java_lang_programming.com.android_layout_demo.article81.CalendarFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_calendar, container, false);
    days = new CopyOnWriteArrayList<>();

    // Set the adapter
    if (view instanceof RecyclerView) {
        Context context = view.getContext();
        RecyclerView recyclerView = (RecyclerView) view;
        gridLayoutManager = new GridLayoutManager(context, COLUMN_NUM);
        recyclerView.setLayoutManager(gridLayoutManager);
        recyclerViewFragmentAdapter = new CalendarFragmentAdapter(getActivity().getApplicationContext(), days,
                callback);/*w w w. j  av  a 2 s . c  o m*/
        recyclerView.setAdapter(recyclerViewFragmentAdapter);
        RecyclerView.ItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
                gridLayoutManager.getOrientation());
        recyclerView.addItemDecoration(dividerItemDecoration);
    }
    return view;
}

From source file:com.twitter.ambrose.hive.reporter.AmbroseHiveProgressReporter.java

private void init() {
    jobIdToProgress = new ConcurrentHashMap<String, Integer>();
    jobIdToNodeId = new ConcurrentHashMap<String, String>();
    jobs = new CopyOnWriteArrayList<Job>();
    completedJobIds = new CopyOnWriteArraySet<String>();
    totalMRJobs = 0;//from w  ww . j  a  v  a 2 s  .  c  o m
    workflowVersion = null;
}

From source file:com.connectsdk.discovery.provider.SSDPDiscoveryProvider.java

public SSDPDiscoveryProvider(Context context) {
    this.context = context;

    uuidReg = Pattern.compile("(?<=uuid:)(.+?)(?=(::)|$)");

    serviceListeners = new CopyOnWriteArrayList<DiscoveryProviderListener>();
    serviceFilters = new ArrayList<JSONObject>();
}

From source file:dk.dma.msiproxy.model.MessageFilter.java

/**
 * Filters the list of messages according to the current filter
 * @param messages the list of messages to filter
 * @return the filtered list of messages
 */// w  w  w  .  j av  a  2  s .  com
public List<Message> filter(List<Message> messages) {
    if (messages == null || isEmpty()) {
        return messages;
    }

    List<Message> result = new CopyOnWriteArrayList<>();
    result.addAll(messages.stream().filter(this::filterMessage).map(msg -> new Message(msg, this))
            .filter(msg -> msg.getDescs() != null && msg.getDescs().size() > 0).collect(Collectors.toList()));
    return result;
}