List of usage examples for java.util Collections synchronizedList
public static <T> List<T> synchronizedList(List<T> list)
From source file:org.obiba.opal.core.service.TaxonomyServiceImpl.java
@Override @PostConstruct public void start() { taxonomies = Collections.synchronizedList(Lists.newArrayList(taxonomyPersistence.readTaxonomies())); importDefault(false); sort(); }
From source file:org.brushingbits.jnap.email.EmailSender.java
public EmailSender(EmailAccountInfo defaultEmailAccount) { this.toSendList = Collections.synchronizedList(new ArrayList<Email>()); this.toRetryList = new HashMap<Email, Integer>(); this.defaultEmailAccount = defaultEmailAccount; this.defaultMailSender = new JavaMailSenderImpl(); this.mailSenderMap = Collections.synchronizedMap(new HashMap<EmailAccountInfo, JavaMailSenderImpl>()); }
From source file:org.jcf.graphicMessage.GraphicObjectImpl.java
public void addLocation(Location loc) { Assert.notNull(loc);/*from w w w . jav a2s .c o m*/ if (locations == null) locations = Collections.synchronizedList(new ArrayList<Location>()); locations.add(loc); }
From source file:com.appdevper.mediaplayer.app.QueueManager.java
public QueueManager(@NonNull MusicProvider musicProvider, @NonNull Resources resources, @NonNull MetadataUpdateListener listener) { this.mMusicProvider = musicProvider; this.mListener = listener; this.mResources = resources; mPlayingQueue = Collections.synchronizedList(new ArrayList<MediaSessionCompat.QueueItem>()); mCurrentIndex = 0;/*from w ww . j av a 2 s .co m*/ }
From source file:net.jodah.failsafe.internal.actions.DoThrowAction.java
DoThrowAction(ActionRegistry<R>.Expectation expectation, String name, Class<? extends Throwable>... throwables) { super(expectation, name); Validate.notNull(throwables, "invalid null throwables"); Validate.noNullElements(throwables, "invalid null throwable"); this.arguments = Arrays.asList(throwables); this.throwables = Stream.of(throwables).map(t -> ThrowableSupport.instantiate(controller, t)) .collect(Collectors.toCollection(LinkedList::new)); this.current = Collections.synchronizedList(new LinkedList<>(this.throwables)); }
From source file:org.piwik.sdk.dispatcher.DispatcherTest.java
@Test public void testClear_cleanExit() throws InterruptedException { final List<Packet> dryRunData = Collections.synchronizedList(new ArrayList<Packet>()); mDispatcher.setDryRunTarget(dryRunData); mDispatcher.submit(getGuestEvent()); mDispatcher.forceDispatch();/*from w w w . j a v a 2 s. c om*/ Thread.sleep(100); assertFalse(dryRunData.isEmpty()); dryRunData.clear(); when(mConnectivity.isConnected()).thenReturn(false); mDispatcher.submit(getGuestEvent()); assertFalse(mEventCache.isEmpty()); mDispatcher.clear(); when(mConnectivity.isConnected()).thenReturn(true); assertTrue(mEventCache.isEmpty()); verify(mEventCache).clear(); Thread.sleep(100); assertTrue(dryRunData.isEmpty()); }
From source file:com.gemini.provision.loadbalancer.openstack.LoadBalancerProviderOpenStackImpl.java
@Override public List<GeminiLoadBalancer> listAllVIPs(GeminiTenant tenant, GeminiEnvironment env) { List<GeminiLoadBalancer> vips = Collections.synchronizedList(new ArrayList()); //authenticate the session with the OpenStack installation OSClient os = OSFactory.builder().endpoint(env.getEndPoint()) .credentials(env.getAdminUserName(), env.getAdminPassword()).tenantName(tenant.getName()) .authenticate();/*from www .j a v a 2 s . c o m*/ if (os == null) { Logger.error("Failed to authenticate Tenant: {}", ToStringBuilder.reflectionToString(tenant, ToStringStyle.MULTI_LINE_STYLE)); return null; } //try to get the list of VIP's List<? extends Vip> osVips; try { osVips = os.networking().loadbalancers().vip().list(); } catch (ClientResponseException e) { Logger.error("Cloud failure - could not retrieve load balancer Vips. Exception: {}", e); return null; } //copy them to the gemini load balancer objects osVips.stream().filter(v -> v != null).forEach(v -> { GeminiLoadBalancer newLB = new GeminiLoadBalancer(); //the simple stuff newLB.setCloudID(v.getId()); newLB.setVirtualPvtIP(InetAddresses.forString(v.getAddress())); //Load balancer object references a subnet - this subnet must be //previously created and therefore MSUT BE AVAILABLE in the environment //scan the environment networks and find the subnet GeminiSubnet subnet = env.getApplications().stream().map(GeminiApplication::getNetworks) .flatMap(List::stream).map(GeminiNetwork::getSubnets).flatMap(List::stream) .filter(s -> s.getCloudID().equals(v.getId())).findFirst().get(); if (subnet == null) { Logger.info( "Load Balancer cloud ID {} references a subnet not available in environment {} Subnet ID: {}", v.getId(), env.getName(), v.getSubnetId()); } else { newLB.setVirtualPvtSubnet(subnet); } //now the pool String poolID = v.getPoolId(); String protocol = v.getProtocol(); vips.add(newLB); }); return vips; }
From source file:org.jcf.ConnectionImpl.java
/** * Connection class for connection to a jabber server * @param jabberServer chatserver name//from w w w. j ava 2 s . c om * @param userName username in chatserver to connect * @param passwd password on chatserver */ ConnectionImpl(String jabberServer, String userName, String passwd) { Assert.hasLength(jabberServer); Assert.hasLength(userName); Assert.hasLength(passwd); this.jabberServer = jabberServer; this.userName = userName; this.passwd = passwd; invitationListener = Collections.synchronizedList(new ArrayList<MUCInvitationListener>()); }
From source file:com.baifendian.swordfish.execserver.job.AbstractYarnJob.java
public AbstractYarnJob(JobProps props, boolean isLongJob, Logger logger) { super(props, isLongJob, logger); flowDao = DaoFactory.getDaoInstance(FlowDao.class); streamingDao = DaoFactory.getDaoInstance(StreamingDao.class); appLinks = Collections.synchronizedList(new ArrayList<>()); jobLinks = Collections.synchronizedList(new ArrayList<>()); }
From source file:ca.sqlpower.object.SPResolverRegistry.java
/** * Initializes the root of an {@link SPObject} in the resolver and listener * {@link Map}s by creating a new key (if it does not exist) by UUID, and * adds a tree listener to that root {@link SPObject}. * //w w w .j ava 2s .co m * @param treeElement * The {@link SPObject} whose root object is to be initialized. * @return The root {@link SPObject}, or null if the passed in * {@link SPObject} is null. */ public static SPObject init(SPObject treeElement) { if (treeElement == null) { return null; } synchronized (resolvers) { SPObject root = getRoot(treeElement); // No need to init this tree twice. if (!resolvers.containsKey(root.getUUID())) { // Init this placeholder with an empty list resolvers.put(root.getUUID(), Collections.synchronizedList(new ArrayList<SPVariableResolver>())); listeners.put(root.getUUID(), new TreeListener()); // Now listen to the hierarchy for UUID change root.addSPListener(listeners.get(root.getUUID())); } return root; } }