Let’s back to ArgoFilter. In ArgoFilter.init(), it creates a ArgoDispatcher instance by calling Argo.init().
In ArgoFilter.doFilter(), It simply hands over the request to ArgoDispatcher.
Request Dispatcher
From the annotation @ImplementedBy(DefaultArgoDispatcher.class), we know that this is inject by guice, and the implementation class is DefaultArgoDispatcher.
The StaticActionAnnotation, MultipartConfigElement in DefaultArgoDispatcher can be injected.
StaticActionAnnotation, MultipartConfigElement are bind with an implementation in ArgoModule.
DefaultArgoDispatcher.service() that ArgoFilter called:
BeatContext
bindBeatContext:
BeatContext is bind to DefaultBeatContext, as in ArgoModule.configure()
Thre are two class implements the interface BeatContext: BeatContextWrapper and DefaultBeatContext. BeatContextWrapper is much simple. DefaultBeatContext can be injected, and ClientContext now is bind to DefaultClientContext.
Route request to Action
DefaultArgoDispatcher.Route():
Router is annotated by @ImplementedBy. The implementation class is DefaultRouter.
DefaultRouter initialized the member actions in constructor.
The buildActions() above instantiated all controller class in getControllerInstances(), extract and saved meta info in ControllerInfo, and called ControllerInfo.analyze() on every Controller and the staticAction injected.
Later, an override buildActions is called.
analyze() finds all matched Methods, (public functions returns ActionResult, and returns a ActionInfo). ActionInfo will finds annotations, especially pre/post interceptors,url patterns,params in url patters,http request type GET/POST in constructor. And the are ordered by the attribute order in @Path(order=1000).
actions is used in DefaultRouter.route(), they applied matchAndInvoke() on beat.
MethodAction.matchAndInvoke checks the Http request type,checks if url matches the Action @Path url pattern by AntPathMatcher. If matches, then execute the interceptor, and invoke on the real actor.
During the executing of interceptor, if any preInterceptor returns NULL, then the following interceptors and action invoke will not be executed.
Action.invoke is java reflection call that calls the method/Action of Controller with the params uriTemplateVariables.
Rend the Page
result.render()
The class implements interface ActionResult contains class implementations to handle 404,405,redirect,redirect301,VelocityViewResult,InnerPrintWriter,DefaultStaticResult.
Take VelocityViewResult for example. It take the Model/map in beatContext.getModel(), and call VelocityWrite to render the velocity template web page.
By now, we have finished the whole journey of Argo.