/** * Create a new {@link EntityManager} when required. * * @return The created {@link EntityManager}. Never <code>null</code>. */ @Nonnull @IsLocked (ELockType.WRITE) protected abstract EntityManager createEntityManager ();
/** * This abstract method is invoked, once a new value needs to be put into the * cache. This method is invoked within a locked section. * * @param aKey * The key for which the value to cache is required. May be * <code>null</code>able or not - depends upon the implementation. * @return The value to be cached. May not be <code>null</code>. */ @Nonnull @IsLocked (ELockType.WRITE) protected abstract VALUETYPE getValueToCache (KEYTYPE aKey);
@Override @Nullable @IsLocked (ELockType.WRITE) protected Pattern getValueToCache (@Nullable @RegEx final RegExPattern aRegEx) { return aRegEx == null ? null : aRegEx.getAsPattern (); }
@Override @Nullable @IsLocked (ELockType.WRITE) public JAXBContext getValueToCache (@Nullable final Package aPackage) { if (aPackage == null) return null; if (GlobalDebug.isDebugMode ()) s_aLogger.info ("Creating JAXB context for package " + aPackage.getName ()); try { // When using "-npa" on JAXB no package-info class is created! if (aPackage.getAnnotation (XmlSchema.class) == null && GenericReflection.getClassFromNameSafe (aPackage.getName () + ".ObjectFactory") == null) s_aLogger.warn ("The package " + aPackage.getName () + " does not seem to be JAXB generated!"); return JAXBContext.newInstance (aPackage.getName ()); } catch (final JAXBException ex) { final String sMsg = "Failed to create JAXB context for package " + aPackage.getName (); s_aLogger.error (sMsg); throw new IllegalArgumentException (sMsg, ex); } }
@Override @Nonnull @IsLocked (ELockType.WRITE) protected Schema getValueToCache (final List <? extends IReadableResource> aKey) { ValueEnforcer.notEmptyNoNullValue (aKey, "Resources"); // Collect all sources final Source [] aSources = new Source [aKey.size ()]; for (int i = 0; i < aKey.size (); ++i) aSources[i] = TransformSourceFactory.create (aKey.get (i)); try { final Schema ret = m_aSchemaFactory.newSchema (aSources); if (ret == null) throw new IllegalStateException ("Failed to create " + m_sSchemaTypeName + " schema from " + Arrays.toString (aSources)); return ret; } catch (final SAXException ex) { throw new IllegalArgumentException ("Failed to parse " + m_sSchemaTypeName + " from " + Arrays.toString (aSources), ex); } }
@Override @Nullable @IsLocked (ELockType.WRITE) protected List <Locale> getValueToCache (@Nullable final Locale aBaseLocale) { if (aBaseLocale == null) return null; // List has a maximum of 3 entries final List <Locale> ret = new ArrayList <Locale> (3); final String sLanguage = aBaseLocale.getLanguage (); if (sLanguage.length () > 0) { // Use only the language ret.add (0, LocaleCache.getLocale (sLanguage)); final String sCountry = aBaseLocale.getCountry (); if (sCountry.length () > 0) { // Use language + country ret.add (0, LocaleCache.getLocale (sLanguage, sCountry)); final String sVariant = aBaseLocale.getVariant (); if (sVariant.length () > 0) { // Use language + country + variant ret.add (0, LocaleCache.getLocale (sLanguage, sCountry, sVariant)); } } } return ContainerHelper.makeUnmodifiable (ret); } }
@Override @Nonnull @IsLocked (ELockType.WRITE) @SuppressFBWarnings ("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") protected Collator getValueToCache (@Nullable final Locale aLocale)