SMTP/Jar/Java Generic/GWT

1. SMTP
JavaMail has no stmp server self.
1) embedded SMTP server:
It might have the spammer reject issue. like 550 5.7.1
usually it should have the public IP and dns, so that Gmail or other big Mail server can trust this embedded smtp server.

good article:
http://www.oracle.com/technetwork/java/faq-135477.html#smtpauth
http://www.coderanch.com/t/434948/open-source/Aspirin-Cannot-Send-Mails
http://www.coderanch.com/t/435963/java/java/Help-Asprin-set-up-local
http://www.chilkatsoft.com/faq/smtp550.html
http://www.eudora.com/techsupport/kb/1593hq.html

Relay - 中继
Spammer - 垃圾邮件发送者

2) log4j also supports email appender as log destination
but currently it doesn't support SSL email server like gmail.
Have to write GmailAppender by self to extend SMTP Appender

3) Asprin as an embedded SMTP server is not stable enough when sending to multipe recipients. Prove again that multipe threads coding is headache.

2.  Jar file
- remeber to keep two spaces as splitor for each jar file name.
- can define main class and classpath in manifest.txt
used by Jar command. like:
Jar cvfm myJar.jar  Manifest.txt .

good article:
http://forums.sun.com/thread.jspa?threadID=364938
http://hi.baidu.com/hdwt/blog/item/5f99b8c60bd1831c9d163dd9.html
http://nssaiqq.blogbus.com/logs/32078188.html
http://download.oracle.com/javase/tutorial/deployment/jar/appman.html

3. Java Generic
Generic Type cannot be initilized like new() or classforName()
solution: use reflection.

article: http://www.iteye.com/topic/113447

My first Generic code.

//ServiceFactory.java
import java.util.EnumMap;

enum ServiceType {
    UserService,
    LoginService
};

public class ServiceFactory {

    private static EnumMap<ServiceType, Object> 

    servicePool = new EnumMap<ServiceType, Object>(ServiceType.class);
    
    public static <T> T getService(Class<T> asyncService, Class service, ServiceType key) {
        @SuppressWarnings("unchecked")
        T aService = (T) servicePool.get(key);
        if (aService == null) {
            aService = GWT.create(service);
            servicePool.put(key, aService);
        }

        return aService;
    }
    
    public static void main(String args[]) {
        ILoginServiceAsync service = ServiceFactory.getService(
ILoginServiceAsync.class, ILoginService.class, ServiceType.LoginService);
    }  

}


However, this class can only run under Hosted Mode, not runtime mode. because GWT.create() can only work with liberal class - the argument cannot be a var.  Terrible! 
article: http://code.google.com/p/google-web-toolkit/issues/detail?id=1045


But GWT.create() still can dynamically load class in client side. The com.google.core.ext.Generator plays the important part.
GWT Dynamic loading using GWT.create() with String literals instead of Class literals
http://stackoverflow.com/questions/451658/gwt-dynamic-loading-using-gwt-create-with-string-literals-instead-of-class-lite
A Simple GWT Generator Example
http://francisshanahan.com/index.php/2010/a-simple-gwt-generator-example/


4. GWT limit
Gwt doesn't support reflection, serialization, multiple threads, classloading, Util.RegExp etc.
why? because they will be compile to Javascript. JavaScript doesn't support them. that's all.

good articles about reflection in GWT:
http://chenjumin.iteye.com/blog/723991
http://wenku.baidu.com/view/abbab84e852458fb770b566b.html

Solution: GWT ENT
http://code.google.com/p/gwt-ent/

你可能感兴趣的:(java,oracle,Google,gwt,Gmail)