Wednesday, February 2, 2011

Gin, SingleInstanceProvider?

I writing over and over again the same code:

@Inject
public Provider<Foo> provider;

private Foo foo;

Foo assertFoo() {
    if (foo == null) {
        foo = provider.get();
    }
    return foo;
}

Basically I inject a provider to delay the object instantiation, but in most cases I only need one instance of the object.
Am I missing some built-in feature of gin? Is there any SingleInstanceProvider hidded out there? or any easier way of doing this?

Thanks

--
Guit: Elegant, beautiful, modular and *production ready* gwt applications.

http://code.google.com/p/guit/




--
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 google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate