All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kapil.framework.email.EmailDispatcherFactory Maven / Gradle / Ivy

Go to download

This is a set of utilities and classes that I have found useful over the years. In my career spanning over a decade, I have time and again written the same code or some part of the code over and over again. I never found the time to collate the details in a reusable library. This project will be a collection of such files. The work that I have been doing is more than 5 years old, however the project has been conceived in 2011.

The newest version!
package com.kapil.framework.email;


/**
 * Factory for creating email processors.
 */
public final class EmailDispatcherFactory
{
    public static final String DUMMY_DISPATCHER = "DUMMY_DISPATCHER";
    
    public static final String DIRECT_DISPATCHER = "DIRECT_DISPATCHER";

    private static final EmailDispatcherFactory INSTANCE = new EmailDispatcherFactory();


    /**
     * Made private to enforce Singleton pattern.
     */
    public static EmailDispatcherFactory getInstance()
    {
        return INSTANCE;
    }


    /**
     * Creates an object implementing {@link IEmailDispatcher}.
     * 
     * @param emailTypeName A {@link java.lang.String} containing name of the email for which a processor is required.
     * @return An {@link IEmailDispatcher} object.
     */
    public IEmailDispatcher getDispatcher(EmailServer server, String emailTypeName)
    {
        IEmailDispatcher emailDispatcher = null;
        
        if (emailTypeName.equals(DUMMY_DISPATCHER))
        {
            emailDispatcher = new DummyEmailDispatcher();
        }
        else if (emailTypeName.equals(DIRECT_DISPATCHER))
        {
            emailDispatcher = new DirectEmailDispatcher(server);
        }
        else
        {
            emailDispatcher = new DirectEmailDispatcher(server);
        }

        return emailDispatcher;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy