Monday, September 1, 2014

Re: Rebind / Generate from annotations

Thank you Jens, Thank you Thomas,


Début du message réexpédié :

Objet: Rép : Rebind / Generate from annotations
Date: 1 septembre 2014 17:21:12 UTC+2

I'am working on the Injection framework of PWT, it's gonna be awesome. 

How can it be more awesome than Dagger 2.0 or Gin?

Well, Okay if we are talking about injection framework, PWT will not replace Dagger or Gin. 
But within PWT all the injection will be implicit (making Generation, Injection, Initialisation) without heavy configuration


@Templated // bindAndCreate ContactView.ui.xml
public class ContactView extends Composite implements View {
@InjectService ContactService service// generate RPC proxy and bind it to @AsyncHandler methods
@UiField @Initialize(constantsClass = ContactConstants.class)
Form<Contact> contactEditor// the full form is describe in ui.xml, initialize the driver with a generated model

@PresentHandler // called when the activity start
void present(ContactPlace place) {
contactEditor.edit(new Contact()); // Init the form with all the default values
}
@UiHandler("contactEditor")
void onContactSubmit(FlushSuccessEvent event) {
service.sendContact((Contact) event.getValue());
}
@AsyncHandler // called on service callback
void onSendContact(Void result) {
contactEditor.edit(new Contact());
}
}

 


But actually I am facing a big question:
Is there any way to rebind with a generator a class without implementing any interface or extending any parent class?

At some point the developer must be able to call Blah b = GWT.create(Blah.class) to trigger GWT generators which only works if he/she has an interface or super class available.

I agree and that’s my nightmare, I would really love to drop the implements View and base my generation on one of my annotations.
In by best dreams, I also imagined to pass throw my generators when type was assignable from the object and be able to chain generators. but it was a dream...



My goal is to rebind classes containing some annotions, and if no annotations are found generate or rebind the class with the others generators.

I guess you have to live with the above or try using annotation processors instead of GWT generators.

Yes I guess I am gonna start with my interface. and see later what happen with the issue 1206 shown by Thomas.





No comments:

Post a Comment