protected Map < String , AbstractServer > createServices ( ServerSetup [ ] config , Managers mgr ) { Map < String , AbstractServer > srvc = new HashMap <> ( ) ; for ( ServerSetup setup : config ) { if ( srvc . containsKey ( setup . getProtocol ( ) ) ) { throw new IllegalArgumentException ( "Server '" + setup . getProtocol ( ) + "' was found at least twice in the array" ) ; } final String protocol = setup . getProtocol ( ) ; if ( protocol . startsWith ( ServerSetup . PROTOCOL_SMTP ) ) { srvc . put ( protocol , new SmtpServer ( setup , mgr ) ) ; } else if ( protocol . startsWith ( ServerSetup . PROTOCOL_POP3 ) ) { srvc . put ( protocol , new Pop3Server ( setup , mgr ) ) ; } else if ( protocol . startsWith ( ServerSetup . PROTOCOL_IMAP ) ) { srvc . put ( protocol , new ImapServer ( setup , mgr ) ) ; } } return srvc ; }
Create the required services according to the server setup