I am using the GWT Activities and Places framework to structure my application and it is turning out nicely. One thing that annoys me though is that the ActivityMapper
Actually I am using custom boilerplate code for this task:
public class PuksaActivityMapper implements ActivityMapper {
private HashMap mappings;
@Inject
private SearchResultActivityContainer searchResultContainer;
@Inject
private HelloActivityContainer helloContainer;
@Override
public Activity getActivity(Place place) {
ActivityContainer container = getMappings().get(place.getClass().getName());
return container.getActivity(place);
}
public HashMap getMappings() {
if (mappings == null) {
mappings = new HashMap();
mappings.put(ShowResultsPlace.class.getName(), searchResultContainer);
mappings.put(HelloPlace.class.getName(), helloContainer);
}
return mappings;
}
}
Where ActivityContainer is a simple factory type (from this point classic ioc methods can be used).
Of course now it is only changing 'if block' with a map lookup/population, but combined with Gin multibinding (witch currently does not exist) could do it's job.
Also Gin enhancement - generic GinModule for GWT Activity/Places looks promising.