I have developed the following class for Service singletons.  It has
three advantages:

1. Service class is not instantiated until the service needs to be
used.
2. _instance is never checked for null, which isn't a necessary use of
time during the life of the app.
3. The static init code is cleaned out by GWT after class init, so the
code doesn't take up memory.

The last two are minor, but in the "death by 1000 cuts" problem of RIA
apps in JS, these are two less cuts.

    static class App
    {
        private static LoaderServiceAsync _I =
GWT.create(MyService.class);

        static
        {
            String ep = GWT.getModuleBaseURL() + "MyService";
            ((ServiceDefTarget) _I).setServiceEntryPoint(ep);
        }

        public static MyServiceAsync get()
        {
            return _I;
        }
    }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to