Class DefaultEmailAddressFetchStrategy

  • All Implemented Interfaces:
    EmailAddressFetchStrategy

    public class DefaultEmailAddressFetchStrategy
    extends java.lang.Object
    implements EmailAddressFetchStrategy
    Default strategy for fetching EmailAddressModel for given address. The implementation executes in a transaction which uses fetch-create if needed-fetch approach which is important in multi threaded environment.
    See Also:
    EmailAddressModel
    • Constructor Detail

      • DefaultEmailAddressFetchStrategy

        public DefaultEmailAddressFetchStrategy()
    • Method Detail

      • fetch

        public EmailAddressModel fetch​(java.lang.String emailAddress,
                                       java.lang.String displayName)
        Specified by:
        fetch in interface EmailAddressFetchStrategy
        Parameters:
        emailAddress - email for which the email address object should be fetched
        displayName - display name for which the email address object should be fetched
        Returns:
        email address instance
      • loadEmailAddressFromDatabase

        protected EmailAddressModel loadEmailAddressFromDatabase​(java.lang.String emailAddress,
                                                                 java.lang.String displayName)
      • handleEmailAddressCreation

        protected EmailAddressModel handleEmailAddressCreation​(java.lang.String emailAddress,
                                                               java.lang.String displayName,
                                                               Transaction tx,
                                                               boolean txRollbackOnlyBefore)
      • isIgnorableConstraintViolationException

        protected boolean isIgnorableConstraintViolationException​(java.lang.Exception exception)
      • isInsertConditionException

        protected boolean isInsertConditionException​(java.lang.Exception exception)
      • disableNestedTransactions

        protected void disableNestedTransactions​(SessionContext loclCtx)
      • setEmailAddressDao

        public void setEmailAddressDao​(EmailAddressDao emailAddressDao)
      • getModelService

        protected ModelService getModelService()
      • setModelService

        public void setModelService​(ModelService modelService)
      • handleMissingEmailAfterInsertConflict

        protected EmailAddressModel handleMissingEmailAfterInsertConflict​(ModelSavingException e,
                                                                          java.lang.String emailAddress,
                                                                          java.lang.String displayName)
        Tries to fetch the given email address 10 times with 10 ms interval. It tries to recover from an exception thrown scenario where multi threads tried to insert the same row to the database.
        Parameters:
        e -
        emailAddress -
        displayName -
        Returns:
        addr the EmailAddressModel