List of usage examples for java.util.concurrent CopyOnWriteArrayList CopyOnWriteArrayList
public CopyOnWriteArrayList(E[] toCopyIn)
From source file:org.netbeans.jbpmn.modeler.specification.bpmn.model.conversation.util.BPMNConversationUtil.java
@Override public void loadModelerFile(ModelerFile file) { try {//from w w w .j av a 2 s. com IModelerScene scene = file.getModelerScene(); File savedFile = file.getFile(); if (bpmnConversationContext == null) { bpmnConversationContext = JAXBContext .newInstance(new Class<?>[] { ShapeDesign.class, TDefinitions.class }); } if (bpmnConversationUnmarshaller == null) { bpmnConversationUnmarshaller = bpmnConversationContext.createUnmarshaller(); } bpmnConversationUnmarshaller.setEventHandler(new ValidateJAXB()); TDefinitions definition_Load = bpmnConversationUnmarshaller .unmarshal(new StreamSource(savedFile), TDefinitions.class).getValue(); // TDefinitions definition_Load = (TDefinitions) JAXBIntrospector.getValue(bpmnConversationUnmarshaller.unmarshal(savedFile)); TCollaboration collaboration = new TCollaboration(); for (TRootElement element : new CopyOnWriteArrayList<TRootElement>(definition_Load.getRootElement())) { if (element instanceof TCollaboration) { TCollaboration collaboration_Tmp = ((TCollaboration) element); String name = collaboration_Tmp.getName(); if (name != null && !name.trim().isEmpty()) { collaboration.setName(name); } String id = collaboration_Tmp.getId(); if (id != null && !id.trim().isEmpty()) { collaboration.setId(id); } collaboration.getConversationLink().addAll(collaboration_Tmp.getConversationLink()); collaboration.getMessageFlow().addAll(collaboration_Tmp.getMessageFlow()); collaboration.getConversationNode().addAll(collaboration_Tmp.getConversationNode()); collaboration.getParticipant().addAll(collaboration_Tmp.getParticipant()); collaboration.getArtifact().addAll(collaboration_Tmp.getArtifact()); definition_Load.getRootElement().remove(collaboration_Tmp); } else if (element instanceof TProcess) { TProcess process_Tmp = (TProcess) element; collaboration.getArtifact().addAll(process_Tmp.getArtifact()); definition_Load.getRootElement().remove(process_Tmp); } } definition_Load.getRootElement().add(collaboration); scene.setRootElementSpec(collaboration); BPMNDiagram diagram = new BPMNDiagram(); diagram.setId(NBModelerUtil.getAutoGeneratedStringId()); BPMNPlane plane = new BPMNPlane(); plane.setId(NBModelerUtil.getAutoGeneratedStringId()); diagram.setBPMNPlane(plane); for (BPMNDiagram diagram_Tmp : definition_Load.getBPMNDiagram()) { if (diagram_Tmp instanceof BPMNDiagram) { BPMNPlane tmpPlane = diagram_Tmp.getBPMNPlane(); for (DiagramElement element : tmpPlane.getDiagramElement()) { plane.getDiagramElement().add(element); } } } definition_Load.getBPMNDiagram().removeAll(definition_Load.getBPMNDiagram()); definition_Load.getBPMNDiagram().add(diagram); file.getModelerDiagramModel().setDefinitionElement(definition_Load); file.getModelerDiagramModel().setRootElement(collaboration); file.getModelerDiagramModel().setDiagramElement(diagram); //ELEMENT_UPGRADE for (IFlowNode flowNode : new CopyOnWriteArrayList<IFlowNode>(collaboration.getConversationNode())) { loadNode(scene, (Widget) scene, flowNode); } for (IFlowNode flowNode : new CopyOnWriteArrayList<IFlowNode>(collaboration.getParticipant())) { loadNode(scene, (Widget) scene, flowNode); } for (IFlowEdge flowEdge : new CopyOnWriteArrayList<IFlowEdge>(collaboration.getConversationLink())) { loadEdge(scene, flowEdge); } for (IFlowEdge flowEdge : new CopyOnWriteArrayList<IFlowEdge>(collaboration.getMessageFlow())) { loadEdge(scene, flowEdge); } for (IArtifact artifact_Load : new CopyOnWriteArrayList<IArtifact>(collaboration.getArtifact())) { loadArtifact(scene, artifact_Load); } for (DiagramElement diagramElement_Tmp : diagram.getBPMNPlane().getDiagramElement()) { loadDiagram(scene, diagram, diagramElement_Tmp); } } catch (JAXBException e) { io.getOut().println("Exception: " + e.toString()); e.printStackTrace(); // Exceptions.printStackTrace(e); System.out.println("Document XML Not Exist"); } }
From source file:org.apache.hive.ptest.execution.PTest.java
public PTest(final TestConfiguration configuration, final ExecutionContext executionContext, final String buildTag, final File logDir, final LocalCommandFactory localCommandFactory, final SSHCommandExecutor sshCommandExecutor, final RSyncCommandExecutor rsyncCommandExecutor, final Logger logger) throws Exception { mConfiguration = configuration;//from ww w .ja va2 s .com mLogger = logger; mBuildTag = buildTag; mExecutedTests = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); mFailedTests = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); mAddedTests = new HashSet<String>(); mExecutionContext = executionContext; mSshCommandExecutor = sshCommandExecutor; mRsyncCommandExecutor = rsyncCommandExecutor; mExecutor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool( new ThreadFactoryBuilder().setDaemon(true).setNameFormat("HostExecutor %d").build())); final File failedLogDir = Dirs.create(new File(logDir, "failed")); final File succeededLogDir = Dirs.create(new File(logDir, "succeeded")); final File scratchDir = Dirs.createEmpty(new File(mExecutionContext.getLocalWorkingDirectory(), "scratch")); File patchDir = Dirs.createEmpty(new File(logDir, "patches")); File patchFile = null; if (!configuration.getPatch().isEmpty()) { patchFile = new File(patchDir, buildTag + ".patch"); Files.write(Resources.toByteArray(new URL(configuration.getPatch())), patchFile); } ImmutableMap.Builder<String, String> templateDefaultsBuilder = ImmutableMap.builder(); templateDefaultsBuilder.put("repository", configuration.getRepository()) .put("repositoryName", configuration.getRepositoryName()) .put("repositoryType", configuration.getRepositoryType()) .put("buildTool", configuration.getBuildTool()).put("branch", configuration.getBranch()) .put("clearLibraryCache", String.valueOf(configuration.isClearLibraryCache())) .put("workingDir", mExecutionContext.getLocalWorkingDirectory()).put("buildTag", buildTag) .put("logDir", logDir.getAbsolutePath()).put("javaHome", configuration.getJavaHome()) .put("javaHomeForTests", configuration.getJavaHomeForTests()) .put("antEnvOpts", configuration.getAntEnvOpts()).put("antArgs", configuration.getAntArgs()) .put("antTestArgs", configuration.getAntTestArgs()) .put("antTestTarget", configuration.getAntTestTarget()) .put("mavenEnvOpts", configuration.getMavenEnvOpts()).put("mavenArgs", configuration.getMavenArgs()) .put("mavenBuildArgs", configuration.getMavenBuildArgs()) .put("mavenTestArgs", configuration.getMavenTestArgs()); if (!Strings.isNullOrEmpty(configuration.getAdditionalProfiles())) { templateDefaultsBuilder.put("additionalProfiles", configuration.getAdditionalProfiles()); } templateDefaults = templateDefaultsBuilder.build(); TestParser testParser = new TestParser(configuration.getContext(), new AtomicInteger(1), configuration.getTestCasePropertyName(), new File(mExecutionContext.getLocalWorkingDirectory(), configuration.getRepositoryName() + "-source"), logger); HostExecutorBuilder hostExecutorBuilder = new HostExecutorBuilder() { @Override public HostExecutor build(Host host) { return new HostExecutor(host, executionContext.getPrivateKey(), mExecutor, sshCommandExecutor, rsyncCommandExecutor, templateDefaults, scratchDir, succeededLogDir, failedLogDir, 10, configuration.shouldFetchLogsForSuccessfulTests(), logger); } }; List<HostExecutor> hostExecutors = new ArrayList<HostExecutor>(); for (Host host : mExecutionContext.getHosts()) { hostExecutors.add(hostExecutorBuilder.build(host)); } mHostExecutors = new CopyOnWriteArrayList<HostExecutor>(hostExecutors); mPhases = Lists.newArrayList(); mPhases.add(new TestCheckPhase(mHostExecutors, localCommandFactory, templateDefaults, patchFile, logger, mAddedTests)); mPhases.add(new PrepPhase(mHostExecutors, localCommandFactory, templateDefaults, scratchDir, patchFile, logger)); mPhases.add(new ExecutionPhase(mHostExecutors, mExecutionContext, hostExecutorBuilder, localCommandFactory, templateDefaults, succeededLogDir, failedLogDir, testParser.parse(), mExecutedTests, mFailedTests, logger)); mPhases.add(new ReportingPhase(mHostExecutors, localCommandFactory, templateDefaults, logger)); }
From source file:edu.temple.cis3238.wiki.vo.TopicVO.java
/** * * @param _topicID/*from w w w . j av a 2 s . c om*/ * @param _topicName * @param _topicContent * @param _topicCreated * @param _topicModified * @param _revisions * @param _tagsCollection * @param _topicHistoryCollection */ public TopicVO(int _topicID, String _topicName, String _topicContent, String _topicCreated, String _topicModified, int _revisions, ArrayList<TagsVO> _tagsCollection, ArrayList<TopicHistoryVO> _topicHistoryCollection) { this.topicID = _topicID; this.topicName = _topicName; this.topicContent = _topicContent; this.topicCreated = _topicCreated; this.topicModified = _topicModified; this.revisions = _revisions; if (_tagsCollection != null && !_tagsCollection.isEmpty()) { try { this.tagsCollection = new CopyOnWriteArrayList<TagsVO>(_tagsCollection); } catch (Exception e) { } } this.topicHistoryCollection = _topicHistoryCollection; }
From source file:it.tidalwave.northernwind.core.impl.model.DefaultSite.java
/******************************************************************************************************************* * * {@inheritDoc}/*from w ww. j a v a 2 s . c o m*/ * ******************************************************************************************************************/ @Override @Nonnull public List<Locale> getConfiguredLocales() { return new CopyOnWriteArrayList<>(configuredLocales); }
From source file:com.freedomotic.core.TriggerCheck.java
/** * * * @param trigger/*from w w w. j a v a2 s .c o m*/ * @param event */ private void executeTriggeredAutomations(final Trigger trigger, final EventTemplate event) { AUTOMATION_EXECUTOR.execute(() -> { //Searching for reactions using this trigger Iterator<Reaction> reactIterator = new CopyOnWriteArrayList<Reaction>(reactionRepository.findAll()) .listIterator(); while (reactIterator.hasNext()) { Reaction reaction = reactIterator.next(); Trigger reactionTrigger = reaction.getTrigger(); //found a related reaction. This must be executed if (trigger.equals(reactionTrigger) && !reaction.getCommands().isEmpty()) { if (!checkAdditionalConditions(reaction)) { LOG.info("Additional conditions test failed in reaction \"{}\"", reaction.getShortDescription()); return; } reactionTrigger.setExecuted(); LOG.debug("Try to execute reaction \"{}\"", reaction.toString()); //executes the commands in sequence (only the first sequence is used) //if more then one sequence is needed it can be done with two reactions with the same trigger Resolver commandResolver = new Resolver(); event.getPayload().addStatement("description", trigger.getDescription()); //embedd the trigger description to the event payload commandResolver.addContext("event.", event.getPayload()); if (!this.processReactionCommands(event, reaction, commandResolver)) return; String info = "Executing automation \"" + reaction.toString() + "\" takes " + (System.currentTimeMillis() - event.getCreation()) + "ms."; LOG.info(info); MessageEvent message = new MessageEvent(null, info); message.setType("callout"); //display as callout on frontends busService.send(message); } else { LOG.info("No valid reaction {} bound to trigger \"{}\"", reaction.getShortDescription(), trigger.getName()); } } trigger.getPayload().clear(); event.getPayload().clear(); }); }
From source file:com.adobe.acs.commons.httpcache.engine.impl.HttpCacheEngineImpl.java
/** * Binds cache config. Cache config could come and go at run time. * * @param cacheConfig/* w w w. j a v a2 s .c o m*/ * @param configs */ protected void bindHttpCacheConfig(final HttpCacheConfig cacheConfig, final Map<String, Object> configs) { // Validate cache config object if (!cacheConfig.isValid()) { log.info("Http cache config rejected as the request uri is absent."); return; } // Check if the same object is already there in the map. if (cacheConfigs.contains(cacheConfig)) { log.trace("Http cache config object already exists in the cacheConfigs map and hence ignored."); return; } // Sort cacheConfigs by order final CopyOnWriteArrayList<HttpCacheConfig> tmp = new CopyOnWriteArrayList<HttpCacheConfig>( this.cacheConfigs); tmp.add(cacheConfig); Collections.sort(tmp, new HttpCacheConfigComparator()); this.cacheConfigs = tmp; this.cacheConfigConfigs.put(cacheConfig, configs); log.debug("Total number of cache configs added: {}", cacheConfigs.size()); }
From source file:org.jboss.windup.bootstrap.Bootstrap.java
private void run(List<String> args) { try {// w w w .j a va 2s .c o m furnace = FurnaceFactory.getInstance(); furnace.setServerMode(true); CopyOnWriteArrayList<Command> commands = new CopyOnWriteArrayList<>(processArguments(args)); if (!executePhase(CommandPhase.PRE_CONFIGURATION, commands)) return; if (!executePhase(CommandPhase.CONFIGURATION, commands)) return; if (commands.isEmpty()) { // no commands are available, just print the help and exit new DisplayHelpCommand().execute(); return; } if (!containsMutableRepository(furnace.getRepositories())) { furnace.addRepository(AddonRepositoryMode.MUTABLE, getUserAddonsDir()); } if (!executePhase(CommandPhase.POST_CONFIGURATION, commands) || commands.isEmpty()) return; try { Future<Furnace> future = furnace.startAsync(); future.get(); // use future.get() to wait until it is started } catch (Exception e) { System.out.println("Failed to start " + Util.WINDUP_BRAND_NAME_ACRONYM + "!"); if (e.getMessage() != null) System.out.println("Failure reason: " + e.getMessage()); e.printStackTrace(); } if (!executePhase(CommandPhase.PRE_EXECUTION, commands) || commands.isEmpty()) return; furnace.addContainerLifecycleListener(new GreetingListener()); if (!executePhase(CommandPhase.EXECUTION, commands) || commands.isEmpty()) return; if (!executePhase(CommandPhase.POST_EXECUTION, commands) || commands.isEmpty()) return; } catch (Throwable t) { System.err.println(Util.WINDUP_BRAND_NAME_ACRONYM + " execution failed due to: " + t.getMessage()); t.printStackTrace(); } }
From source file:org.nuxeo.ecm.core.storage.mem.MemRepository.java
/** * Applies a {@link ListDiff} onto an array or {@link List}, and returns the * resulting value.//from w w w .j a v a2s . com * <p> * Uses thread-safe datastructures. */ public static Serializable applyDiff(Serializable value, ListDiff listDiff) { // internally work on a list // TODO this is costly, use a separate code path for arrays if (listDiff.isArray && value != null) { if (!(value instanceof Object[])) { throw new UnsupportedOperationException("Cannot apply ListDiff on non-array: " + value); } value = new CopyOnWriteArrayList<>(Arrays.asList((Object[]) value)); } if (value == null) { value = new CopyOnWriteArrayList<>(); } if (!(value instanceof List)) { throw new UnsupportedOperationException("Cannot apply ListDiff on non-List: " + value); } @SuppressWarnings("unchecked") List<Serializable> list = (List<Serializable>) value; if (listDiff.diff != null) { int i = 0; for (Object diffElem : listDiff.diff) { if (i >= list.size()) { // TODO log error applying diff to shorter list break; } if (diffElem instanceof StateDiff) { applyDiff((State) list.get(i), (StateDiff) diffElem); } else if (diffElem != NOP) { list.set(i, StateHelper.deepCopy(diffElem, true)); // thread-safe } i++; } } if (listDiff.rpush != null) { // deepCopy of what we'll add List<Serializable> add = new ArrayList<>(listDiff.rpush.size()); for (Object v : listDiff.rpush) { add.add(StateHelper.deepCopy(v, true)); // thread-safe } // update CopyOnWriteArrayList in one step list.addAll(add); } // convert back to array if needed if (listDiff.isArray) { return list.isEmpty() ? null : list.toArray(new Object[0]); } else { return list.isEmpty() ? null : (Serializable) list; } }
From source file:org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.java
/** * Set the name of the queue(s) to receive messages from. * @param queueName the desired queueName(s) (can not be <code>null</code>) *///from ww w . j a v a 2s . com public void setQueueNames(String... queueName) { Assert.noNullElements(queueName, "Queue name(s) cannot be null"); this.queueNames = new CopyOnWriteArrayList<>(Arrays.asList(queueName)); }
From source file:org.nuxeo.ecm.core.io.registry.context.RenderingContextImpl.java
@Override public void setParameterListValues(String name, List<Object> values) { if (StringUtils.isEmpty(name)) { return;/*from www . j a va 2s . c o m*/ } String realName = name.toLowerCase().trim(); if (values == null) { parameters.remove(realName); } parameters.put(realName, new CopyOnWriteArrayList<Object>(values)); }