List of usage examples for java.util.concurrent CopyOnWriteArraySet CopyOnWriteArraySet
public CopyOnWriteArraySet()
From source file:org.springframework.data.gemfire.config.annotation.support.GemFireComponentClassTypeScanner.java
/** * Scans the {@link Set} of base packages searching for GemFire application components * accepted by the filters of this scanner. * * @return a {@link Set} of GemFire application component {@link Class} types found on the classpath. * @see #newClassPathScanningCandidateComponentProvider(boolean) * @see java.util.Set/*from ww w . jav a 2 s. c o m*/ */ public Set<Class<?>> scan() { Set<Class<?>> componentClasses = new CopyOnWriteArraySet<>(); ClassLoader entityClassLoader = getEntityClassLoader(); ClassPathScanningCandidateComponentProvider componentProvider = newClassPathScanningCandidateComponentProvider(); stream(this.spliterator(), true) .flatMap(packageName -> componentProvider.findCandidateComponents(packageName).stream()) .forEach(beanDefinition -> { Optional.ofNullable(beanDefinition.getBeanClassName()).filter(StringUtils::hasText) .ifPresent(beanClassName -> { try { componentClasses.add(ClassUtils.forName(beanClassName, entityClassLoader)); } catch (ClassNotFoundException ignore) { log.warn(String.format("Class for component type [%s] not found", beanDefinition.getBeanClassName())); } }); }); return componentClasses; }
From source file:org.apache.axis2.engine.AxisConfiguration.java
/** * Constructor AxisConfiguration.//from www. jav a 2 s .c om */ public AxisConfiguration() { moduleConfigmap = new HashMap<String, ModuleConfiguration>(); globalModuleList = new ArrayList<String>(); messageReceivers = new HashMap<String, MessageReceiver>(); messageBuilders = new HashMap<String, Builder>(); messageFormatters = new HashMap<String, MessageFormatter>(); outPhases = new ArrayList<Phase>(); inFaultPhases = new ArrayList<Phase>(); outFaultPhases = new ArrayList<Phase>(); faultyServices = new Hashtable<String, String>(); faultyModules = new Hashtable<String, String>(); observerSet = new CopyOnWriteArraySet<AxisObserver>(); inPhasesUptoAndIncludingPostDispatch = new ArrayList<Phase>(); systemClassLoader = org.apache.axis2.java.security.AccessController .doPrivileged(new PrivilegedAction<ClassLoader>() { public ClassLoader run() { return Thread.currentThread().getContextClassLoader(); } }); serviceClassLoader = systemClassLoader; moduleClassLoader = systemClassLoader; this.phasesinfo = new PhasesInfo(); targetResolvers = new ArrayList<TargetResolver>(); }
From source file:sx.blah.discord.handle.impl.obj.User.java
/** * CACHES a role to the user./*from w ww .j a v a2 s . c o m*/ * * @param guildID The guild the role is for. * @param role The role. */ public void addRole(long guildID, IRole role) { roles.putIfAbsent(guildID, () -> new RolesHolder(guildID, new CopyOnWriteArraySet<>())); roles.get(guildID).getObject().add(role); }
From source file:org.opendaylight.netvirt.dhcpservice.DhcpExternalTunnelManager.java
private void initilizeCaches() { LOG.trace("Loading designatedDpnsToTunnelIpElanNameCache"); InstanceIdentifier<DesignatedSwitchesForExternalTunnels> instanceIdentifier = InstanceIdentifier .builder(DesignatedSwitchesForExternalTunnels.class).build(); Optional<DesignatedSwitchesForExternalTunnels> designatedSwitchForTunnelOptional = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, instanceIdentifier); if (designatedSwitchForTunnelOptional.isPresent()) { List<DesignatedSwitchForTunnel> list = designatedSwitchForTunnelOptional.get() .getDesignatedSwitchForTunnel(); for (DesignatedSwitchForTunnel designatedSwitchForTunnel : list) { Set<Pair<IpAddress, String>> setOfTunnelIpElanNamePair = designatedDpnsToTunnelIpElanNameCache .get(BigInteger.valueOf(designatedSwitchForTunnel.getDpId())); if (setOfTunnelIpElanNamePair == null) { setOfTunnelIpElanNamePair = new CopyOnWriteArraySet<>(); }/*from w w w. j ava 2 s. co m*/ Pair<IpAddress, String> tunnelIpElanNamePair = new ImmutablePair<>( designatedSwitchForTunnel.getTunnelRemoteIpAddress(), designatedSwitchForTunnel.getElanInstanceName()); setOfTunnelIpElanNamePair.add(tunnelIpElanNamePair); designatedDpnsToTunnelIpElanNameCache.put(BigInteger.valueOf(designatedSwitchForTunnel.getDpId()), setOfTunnelIpElanNamePair); } } LOG.trace("Loading vniMacAddressToPortCache"); InstanceIdentifier<Ports> inst = InstanceIdentifier.builder(Neutron.class).child(Ports.class).build(); Optional<Ports> optionalPorts = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, inst); if (optionalPorts.isPresent()) { List<Port> list = optionalPorts.get().getPort(); for (Port port : list) { if (NeutronUtils.isPortVnicTypeNormal(port)) { continue; } String macAddress = port.getMacAddress().getValue(); Uuid networkId = port.getNetworkId(); String segmentationId = DhcpServiceUtils.getSegmentationId(networkId, broker); if (segmentationId == null) { return; } updateVniMacToPortCache(new BigInteger(segmentationId), macAddress, port); } } }
From source file:org.openanzo.activemq.internal.SecurityBroker.java
@Override public void addConnection(ConnectionContext connectionContext, ConnectionInfo info) throws Exception { if (connectionContext.getSecurityContext() == null) { IOperationContext context = null; try {//from ww w .j av a 2s .com context = new BaseOperationContext(ADD_CONNECTION, info.getConnectionId().toString(), principal); context.setMDC(); AnzoPrincipal principal = authenticationService.authenticateUser(context, info.getUserName(), info.getPassword()); if (principal != null) { idToUser.put(info.getUserName(), principal.getUserURI()); ServerSecurityContext securityContext = userSecurityContextMap.get(principal.getName()); if (securityContext == null) { securityContext = new ServerSecurityContext(principal); userSecurityContextMap.put(principal.getName(), securityContext); securityContexts.add(securityContext); } connectionContext.setSecurityContext(securityContext); Set<ConnectionContext> conns = userConnection.get(info.getUserName()); if (conns == null) { conns = new CopyOnWriteArraySet<ConnectionContext>(); userConnection.put(info.getUserName(), conns); } conns.add(connectionContext); connectionContext.setProducerFlowControl(false); } else { MDC.put(LogUtils.REMOTE_ADDRESS, connectionContext.getConnection().getRemoteAddress()); MDC.put(LogUtils.USER, info.getUserName()); String errorMsg = Messages.getString(ExceptionConstants.COMBUS.ERROR_LOGGING_IN); log.error(LogUtils.SECURITY_MARKER, errorMsg); MDC.clear(); throw new SecurityException(errorMsg); } } finally { if (context != null) { context.clearMDC(); } } } connections.add(info.getConnectionId().getValue()); super.addConnection(connectionContext, info); }
From source file:org.alfresco.repo.dictionary.DictionaryModelType.java
@SuppressWarnings("unchecked") private void queueModel(NodeRef nodeRef) { Set<NodeRef> pendingModels = (Set<NodeRef>) AlfrescoTransactionSupport.getResource(KEY_PENDING_MODELS); if (pendingModels == null) { //pendingModels = Collections.newSetFromMap(new ConcurrentHashMap()); // Java 6 pendingModels = new CopyOnWriteArraySet<NodeRef>(); AlfrescoTransactionSupport.bindResource(KEY_PENDING_MODELS, pendingModels); }/* w ww . j a v a 2 s. co m*/ pendingModels.add(tenantService.getName(nodeRef)); AlfrescoTransactionSupport.bindListener(this.transactionListener); }
From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.GeneManiaSubInspector.java
@Override public void handleEvent(Gene g) { if (g != null) { Set gs = new CopyOnWriteArraySet<Gene>(); gs.add(g);/* w w w. j a v a 2 s .co m*/ setGenes(gs); } }
From source file:com.espertech.esper.epl.variable.VariableServiceImpl.java
public void registerCallback(int variableNumber, VariableChangeCallback variableChangeCallback) { Set<VariableChangeCallback> callbacks = changeCallbacks.get(variableNumber); if (callbacks == null) { callbacks = new CopyOnWriteArraySet<VariableChangeCallback>(); changeCallbacks.set(variableNumber, callbacks); }/*from w w w.java 2s . c om*/ callbacks.add(variableChangeCallback); }
From source file:com.cburch.logisim.circuit.CircuitWires.java
void propagate(CircuitState circState, Set<Location> points) { BundleMap map = getBundleMap();/*from w w w . j a v a 2 s . c om*/ CopyOnWriteArraySet<WireThread> dirtyThreads = new CopyOnWriteArraySet<WireThread>(); // affected threads // get state, or create a new one if current state is outdated State s = circState.getWireData(); if (s == null || s.bundleMap != map) { // if it is outdated, we need to compute for all threads s = new State(map); for (WireBundle b : map.getBundles()) { WireThread[] th = b.threads; if (b.isValid() && th != null) { for (WireThread t : th) { dirtyThreads.add(t); } } } circState.setWireData(s); } // determine affected threads, and set values for unwired points for (Location p : points) { WireBundle pb = map.getBundleAt(p); if (pb == null) { // point is not wired circState.setValueByWire(p, circState.getComponentOutputAt(p)); } else { WireThread[] th = pb.threads; if (!pb.isValid() || th == null) { // immediately propagate NILs across invalid bundles CopyOnWriteArraySet<Location> pbPoints = pb.points; if (pbPoints == null) { circState.setValueByWire(p, Value.NIL); } else { for (Location loc2 : pbPoints) { circState.setValueByWire(loc2, Value.NIL); } } } else { for (WireThread t : th) { dirtyThreads.add(t); } } } } if (dirtyThreads.isEmpty()) return; // determine values of affected threads HashSet<ThreadBundle> bundles = new HashSet<ThreadBundle>(); for (WireThread t : dirtyThreads) { Value v = getThreadValue(circState, t); s.thr_values.put(t, v); bundles.addAll(t.getBundles()); } // now propagate values through circuit for (ThreadBundle tb : bundles) { WireBundle b = tb.b; Value bv = null; if (!b.isValid() || b.threads == null) { ; // do nothing } else if (b.threads.length == 1) { bv = s.thr_values.get(b.threads[0]); } else { Value[] tvs = new Value[b.threads.length]; boolean tvs_valid = true; for (int i = 0; i < tvs.length; i++) { Value tv = s.thr_values.get(b.threads[i]); if (tv == null) { tvs_valid = false; break; } tvs[i] = tv; } if (tvs_valid) bv = Value.create(tvs); } if (bv != null) { for (Location p : b.points) { circState.setValueByWire(p, bv); } } } }
From source file:net.padlocksoftware.padlock.validator.Validator.java
/** * Create a new empty Validator instance with the License and PublicKey set. These are not changeable once * created, so every License/KeyPair combination will need its own Validator instance. When created, the * Validator contains only the build in Padlock plugins, which are fixed. New custom plugins can be added * by calling {@link #addPlugin(net.padlocksoftware.padlock.validator.ValidatorPlugin) addPlugin()}. * /*from ww w. j av a2 s . c o m*/ * @param license The license instance to validate. * @param publicKey The PublicKey corresponding to the PrivateKey used to sign the license. */ public Validator(License license, String publicKey) { logger = Logger.getLogger(getClass().getName()); this.license = license; // Try DSA first this.publicKey = convertPublicKey(publicKey, false); if (this.publicKey == null) { this.publicKey = convertPublicKey(publicKey, true); isRSA = true; } logger.fine("Using RSA Key: " + isRSA); sigValidator = isRSA ? new RsaValidator() : new DsaValidator(); // If the public Key is still null, throw a runtime exception if (this.publicKey == null) { throw new RuntimeException("Cannot create PublicKey object"); } plugins = new CopyOnWriteArrayList<ValidatorPlugin>(); // Default plugins expiredPlugin = new ExpiredPlugin(); plugins.add(expiredPlugin); plugins.add(new PriorPlugin()); plugins.add(new BlacklistPlugin()); plugins.add(new HardwarePlugin()); blacklist = new CopyOnWriteArraySet<String>(); ignoreFloatTime = false; checkClockTurnback = true; }