What is the IoC / "Springy" way of handling MVP in GWT? (Hint may not be Spring Roo 1.1's way)

This is a Spring Roo 1.1 way to make a factory that returns GWT activity (yes, Spring Framework)

 public Activity getActivity(ProxyPlace place) {
    switch (place.getOperation()) {
      case DETAILS:
        return new EmployeeDetailsActivity((EntityProxyId<EmployeeProxy>)place.getProxyId(), requests, 
          placeController, ScaffoldApp.isMobile() ? EmployeeMobileDetailsView.instance() : EmployeeDetailsView.instance());

      case EDIT:
        return makeEditActivity(place);

      case CREATE:
        return makeCreateActivity();
    }

    throw new IllegalArgumentException("Unknown operation "
        + place.getOperation());
  }

It seems to me that we just returned a hundred years if we use the case of constants with constants to make a factory. Now this is the official automatic generation of Spring roo 1.1 with GWT / GAE integration, I do not know what you

I can only assume that some administrators are empty ads because it is definitely not Spring

It seems that VMWare and Google were too fast to release something and didn't quite finish, right?

Am I missing something, or is it half baked, and far from the way Spring + GWT MVP should work?

, Spring, GWT ( 2.1 MVP) GAE ? , . ( ? IOC?)

Spring , , - , , , SpringSource Google roo 1.2 .

+3
1

Roo, . , , GWT MVP Development with Activities and Places (: , ):

public class AppActivityMapper implements ActivityMapper {
...

 /**
  * Map each Place to its corresponding Activity. This would be a great use
  * for GIN.
  */
 @Override
 public Activity getActivity(Place place) {
    // This is begging for GIN
    if (place instanceof HelloPlace)
        return new HelloActivity((HelloPlace) place, clientFactory);
    else if (place instanceof GoodbyePlace)
        return new GoodbyeActivity((GoodbyePlace) place, clientFactory);

    return null;
 }
}

, "switch + getOperation()" "if + instanceof". , Activity new. Injection Dependency.

, , DI, , ActivityMapper, Place:

 public Activity getActivity(Place place) {
    if (place instanceof HelloPlace)
        return helloActivityFactory.build((HelloPlace) place);
    else if (place instanceof GoodbyePlace)
        return goodbyeActivityFactory.build((GoodbyePlace) place);

    return null;
 }

. , - " " ( factory ). :

 Map<String, ActivityFactory> activityMap; /* injected */

 public Activity getActivity(Place place) {
    ActivityFactory factory = activityMap.get(place.getOperation());
    if (factory != null)
        return factory.build(place);

    return null;
 }

... ActivityFactory, (, , build() place ).

( !), - , Roo: " GWT MVP " " MVP" , MVP DI, " , ". , , Injection Dependency. , Roo , .

+2

Source: https://habr.com/ru/post/1782753/


All Articles