@Nonnull @MustBeLocked (ELockType.WRITE) private ServletStatus _getOrCreateServletStatus (@Nonnull final Class <? extends GenericServlet> aServletClass) { ValueEnforcer.notNull (aServletClass, "Servlet class"); if (Modifier.isAbstract (aServletClass.getModifiers ())) throw new IllegalStateException ("Passed servlet class is abstract: " + aServletClass); final String sKey = _getKey (aServletClass); return m_aMap.computeIfAbsent (sKey, k -> new ServletStatus (aServletClass.getName ())); }
/** * Get or create a new state for the provided app ID. * * @param sAppID * The app ID to get the state for. May neither be <code>null</code> * nor empty. * @return Never <code>null</code>. */ @Nonnull public PhotonSessionStatePerApp state (@Nonnull @Nonempty final String sAppID) { ValueEnforcer.notEmpty (sAppID, "AppID"); return m_aStateMap.computeIfAbsent (sAppID, k -> new PhotonSessionStatePerApp ()); }
/** * Registers a new control for the passed tree ID * * @param sStateID * the ID of the state in register. May neither be <code>null</code> * nor empty. * @param aNewState * The state to set. May not be <code>null</code>. * @return {@link EChange#CHANGED} if the control was registered<br> * {@link EChange#UNCHANGED} if an illegal argument was passed or a * control has already been registered for that ID */ @Nonnull @SuppressFBWarnings ("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") public EChange registerState (@Nonnull @Nonempty final String sStateID, @Nonnull final IHasUIState aNewState) { ValueEnforcer.notEmpty (sStateID, "StateID"); ValueEnforcer.notNull (aNewState, "NewState"); final ObjectType aOT = aNewState.getObjectType (); if (aOT == null) throw new IllegalStateException ("Object has no typeID: " + aNewState); return m_aRWLock.writeLocked ( () -> { final Map <String, IHasUIState> aMap = m_aMap.computeIfAbsent (aOT, k -> new CommonsHashMap<> ()); if (LOGGER.isDebugEnabled () && aMap.containsKey (sStateID)) LOGGER.debug ("Overwriting " + aOT.getName () + " with ID " + sStateID + " with new object"); aMap.put (sStateID, aNewState); return EChange.CHANGED; }); }
@Nonnull private MapBasedNamespaceContext _addMapping (@Nonnull final String sPrefix, @Nonnull final String sNamespaceURI, final boolean bAllowOverwrite) { ValueEnforcer.notNull (sPrefix, "Prefix"); ValueEnforcer.notNull (sNamespaceURI, "NamespaceURI"); if (!bAllowOverwrite && m_aPrefix2NS.containsKey (sPrefix)) throw new IllegalArgumentException ("The prefix '" + sPrefix + "' is already registered to '" + m_aPrefix2NS.get (sPrefix) + "'!"); if (sPrefix.equals (XMLConstants.DEFAULT_NS_PREFIX)) m_sDefaultNamespaceURI = sNamespaceURI; m_aPrefix2NS.put (sPrefix, sNamespaceURI); m_aNS2Prefix.computeIfAbsent (sNamespaceURI, x -> new CommonsHashSet <> ()).add (sPrefix); return this; }
@Nonnull public static PhotonGlobalStatePerApp state (@Nonnull @Nonempty final String sAppID) { ValueEnforcer.notEmpty (sAppID, "AppID"); final PhotonGlobalState aGlobalState = getInstance (); return aGlobalState.m_aStateMap.computeIfAbsent (sAppID, k -> { // By default set first app ID as default if (!aGlobalState.hasDefaultApplicationID ()) aGlobalState.setDefaultApplicationID (sAppID); return new PhotonGlobalStatePerApp (); }); }
@Nonnull @ReturnsMutableCopy private ICommonsMap <State, ICommonsNavigableSet <Long>> _getStateMap () { // Group threads by state final ICommonsMap <State, ICommonsNavigableSet <Long>> aStateMap = new CommonsEnumMap <> (State.class); for (final ThreadDescriptor aDescriptor : m_aList) { final State eState = aDescriptor.getThreadState (); final ICommonsNavigableSet <Long> aThreadIDs = aStateMap.computeIfAbsent (eState, k -> new CommonsTreeSet <> ()); aThreadIDs.add (Long.valueOf (aDescriptor.getThreadID ())); } return aStateMap; }
@Nonnull public static XMLSchemaCache getInstanceOfClassLoader (@Nullable final ClassLoader aClassLoader) { if (aClassLoader == null) { // Use default instance return getInstance (); } final String sKey = String.valueOf (aClassLoader); XMLSchemaCache aCache = s_aRWLock.readLocked ( () -> s_aPerClassLoaderCache.get (sKey)); if (aCache == null) { // Not found in read-lock // Try again in write lock aCache = s_aRWLock.writeLocked ( () -> s_aPerClassLoaderCache.computeIfAbsent (sKey, x -> new XMLSchemaCache (new SimpleLSResourceResolver (aClassLoader)))); } return aCache; }
return s_aRWLock.writeLocked ( () -> s_aMap.computeIfAbsent (sCacheKey, k -> new WebSiteResource (eResourceType, sPath,
final MutableInt aMI = s_aRWLock.writeLocked ( () -> s_aIntErrCache.computeIfAbsent (sThrowableStackTrace, k -> new MutableInt (-1))); aMI.inc ();
final DirectoryData aBaseDirData = aFiles.computeIfAbsent (_getKeyFile (aBaseDir), DirectoryData::new); if (aRes.isDirectory ()) aBaseDirData.addDir (sName);