提交 feabad0d 编写于 作者: Y youyong205

init app page

上级 39e23df2
......@@ -51,7 +51,9 @@ com.dianping.cat.report.page.userMonitor.Handler.class,
com.dianping.cat.report.page.system.Handler.class,
com.dianping.cat.report.page.cdn.Handler.class
com.dianping.cat.report.page.cdn.Handler.class,
com.dianping.cat.report.page.app.Handler.class
})
public class ReportModule extends AbstractModule {
......
......@@ -49,7 +49,9 @@ public enum ReportPage implements Page {
SYSTEM("system", "system", "System", "System", true),
CDN("cdn", "cdn", "Cdn", "Cdn", true);
CDN("cdn", "cdn", "Cdn", "Cdn", true),
APP("app", "app", "App", "App", true);
private String m_name;
......
package com.dianping.cat.report.page.app;
public enum Action implements org.unidal.web.mvc.Action {
VIEW("view");
private String m_name;
private Action(String name) {
m_name = name;
}
public static Action getByName(String name, Action defaultAction) {
for (Action action : Action.values()) {
if (action.getName().equals(name)) {
return action;
}
}
return defaultAction;
}
@Override
public String getName() {
return m_name;
}
}
package com.dianping.cat.report.page.app;
import com.dianping.cat.report.ReportContext;
public class Context extends ReportContext<Payload> {
}
package com.dianping.cat.report.page.app;
import java.io.IOException;
import javax.servlet.ServletException;
import com.dianping.cat.report.ReportPage;
import org.unidal.lookup.annotation.Inject;
import org.unidal.web.mvc.PageHandler;
import org.unidal.web.mvc.annotation.InboundActionMeta;
import org.unidal.web.mvc.annotation.OutboundActionMeta;
import org.unidal.web.mvc.annotation.PayloadMeta;
public class Handler implements PageHandler<Context> {
@Inject
private JspViewer m_jspViewer;
@Override
@PayloadMeta(Payload.class)
@InboundActionMeta(name = "app")
public void handleInbound(Context ctx) throws ServletException, IOException {
// display only, no action here
}
@Override
@OutboundActionMeta(name = "app")
public void handleOutbound(Context ctx) throws ServletException, IOException {
Model model = new Model(ctx);
model.setAction(Action.VIEW);
model.setPage(ReportPage.APP);
if (!ctx.isProcessStopped()) {
m_jspViewer.view(ctx, model);
}
}
}
package com.dianping.cat.report.page.app;
public enum JspFile {
VIEW("/jsp/report/app.jsp"),
;
private String m_path;
private JspFile(String path) {
m_path = path;
}
public String getPath() {
return m_path;
}
}
package com.dianping.cat.report.page.app;
import com.dianping.cat.report.ReportPage;
import org.unidal.web.mvc.view.BaseJspViewer;
public class JspViewer extends BaseJspViewer<ReportPage, Action, Context, Model> {
@Override
protected String getJspFilePath(Context ctx, Model model) {
Action action = model.getAction();
switch (action) {
case VIEW:
return JspFile.VIEW.getPath();
}
throw new RuntimeException("Unknown action: " + action);
}
}
package com.dianping.cat.report.page.app;
import com.dianping.cat.report.ReportPage;
import org.unidal.web.mvc.ViewModel;
public class Model extends ViewModel<ReportPage, Action, Context> {
public Model(Context ctx) {
super(ctx);
}
@Override
public Action getDefaultAction() {
return Action.VIEW;
}
}
package com.dianping.cat.report.page.app;
import com.dianping.cat.report.ReportPage;
import org.unidal.web.mvc.ActionContext;
import org.unidal.web.mvc.ActionPayload;
import org.unidal.web.mvc.payload.annotation.FieldMeta;
public class Payload implements ActionPayload<ReportPage, Action> {
private ReportPage m_page;
@FieldMeta("op")
private Action m_action;
public void setAction(String action) {
m_action = Action.getByName(action, Action.VIEW);
}
@Override
public Action getAction() {
return m_action;
}
@Override
public ReportPage getPage() {
return m_page;
}
@Override
public void setPage(String page) {
m_page = ReportPage.getByName(page, ReportPage.APP);
}
@Override
public void validate(ActionContext<?> ctx) {
if (m_action == null) {
m_action = Action.VIEW;
}
}
}
......@@ -26,6 +26,8 @@ public class NavigationBar {
ReportPage.METRIC,
ReportPage.USERMONITOR,
ReportPage.APP,
ReportPage.TRANSACTION,
......
......@@ -3602,6 +3602,24 @@
</requirement>
</requirements>
</component>
<component>
<role>com.dianping.cat.report.page.app.Handler</role>
<implementation>com.dianping.cat.report.page.app.Handler</implementation>
<requirements>
<requirement>
<role>com.dianping.cat.report.page.app.JspViewer</role>
</requirement>
</requirements>
</component>
<component>
<role>com.dianping.cat.report.page.app.JspViewer</role>
<implementation>com.dianping.cat.report.page.app.JspViewer</implementation>
<requirements>
<requirement>
<role>org.unidal.web.mvc.view.model.ModelHandler</role>
</requirement>
</requirements>
</component>
<component>
<role>com.dianping.cat.system.SystemModule</role>
<implementation>com.dianping.cat.system.SystemModule</implementation>
......
......@@ -71,6 +71,9 @@
<page name="cdn" title="Cdn" path="cdn" template="default">
<description>Cdn</description>
</page>
<page name="app" title="App" path="app" template="default">
<description>App</description>
</page>
</module>
<module name="system" path="s" default="false">
<page name="alarm" title="Alarm" default="true" path="alarm" view="/jsp/system/alarm/alarm.jsp">
......
<%@ page contentType="text/html; charset=utf-8" %>
<jsp:useBean id="ctx" type="com.dianping.cat.report.page.app.Context" scope="request"/>
<jsp:useBean id="payload" type="com.dianping.cat.report.page.app.Payload" scope="request"/>
<jsp:useBean id="model" type="com.dianping.cat.report.page.app.Model" scope="request"/>
View of app page under report
\ No newline at end of file
<%@ page contentType="text/html; charset=utf-8" %>
<jsp:useBean id="ctx" type="com.dianping.cat.report.page.network.Context" scope="request"/>
<jsp:useBean id="payload" type="com.dianping.cat.report.page.network.Payload" scope="request"/>
<jsp:useBean id="model" type="com.dianping.cat.report.page.network.Model" scope="request"/>
View of network page under report
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册