001: /**
002: *
003: */package clime.messadmin.providers.spi;
004:
005: import java.io.IOException;
006: import java.util.Collection;
007: import java.util.Iterator;
008: import java.util.Set;
009:
010: import javax.servlet.ServletConfig;
011: import javax.servlet.ServletException;
012: import javax.servlet.http.HttpServletRequest;
013: import javax.servlet.http.HttpServletResponse;
014:
015: import clime.messadmin.model.IApplicationInfo;
016: import clime.messadmin.model.IServerInfo;
017: import clime.messadmin.model.ISessionInfo;
018: import clime.messadmin.providers.ProviderUtils;
019:
020: /**
021: * Provider for displaying the administration data.
022: * Sample implementation can be HTML, text, CSV...
023: * @author Cédrik LIME
024: * @since 4.1
025: */
026: public interface DisplayFormatProvider extends BaseProvider {
027: public static class Util {
028: public static String FORMAT_PARAMETER_NAME = "format";//$NON-NLS-1$
029: public static String DEFAULT_FORMAT = "html";//$NON-NLS-1$
030:
031: public static DisplayFormatProvider getInstance(
032: HttpServletRequest request) {
033: String format = request.getParameter(FORMAT_PARAMETER_NAME);
034: if (format == null) {
035: format = DEFAULT_FORMAT;
036: }
037: return getInstance(format);
038: }
039:
040: public static DisplayFormatProvider getInstance(String format) {
041: Iterator iter = ProviderUtils.getProviders(
042: DisplayFormatProvider.class).iterator();
043: while (iter.hasNext()) {
044: DisplayFormatProvider provider = (DisplayFormatProvider) iter
045: .next();
046: if (format.equalsIgnoreCase(provider.getFormatID())) {
047: return provider;
048: }
049: }
050: throw new IllegalArgumentException(format);
051: }
052:
053: public static void initAll(ServletConfig config)
054: throws ServletException {
055: Iterator iter = ProviderUtils.getProviders(
056: DisplayFormatProvider.class).iterator();
057: while (iter.hasNext()) {
058: DisplayFormatProvider provider = (DisplayFormatProvider) iter
059: .next();
060: provider.init(config);
061: }
062: }
063: }
064:
065: public String getFormatID();
066:
067: public String getContentType();
068:
069: public void init(ServletConfig config) throws ServletException;
070:
071: /**
072: * @param req
073: * @param resp
074: * @throws ServletException
075: * @throws IOException
076: */
077: public void preProcess(HttpServletRequest req,
078: HttpServletResponse resp) throws ServletException,
079: IOException;
080:
081: /**
082: * Displays the Web Applications list
083: * @param req
084: * @param resp
085: * @param applicationInfos
086: * @throws ServletException
087: * @throws IOException
088: */
089: public void displayWebAppsList(HttpServletRequest req,
090: HttpServletResponse resp,
091: Set/*<IApplicationInfo>*/applicationInfos)
092: throws ServletException, IOException;
093:
094: /**
095: * Displays the HttpSessions list for a given WebApp (context)
096: * @param req
097: * @param resp
098: * @param sortBy
099: * @param orderBy
100: * @param webAppStats
101: * @param activeSessions
102: * @param passiveSessionsIds
103: * @throws ServletException
104: * @throws IOException
105: */
106: public void displaySessionsListPage(HttpServletRequest req,
107: HttpServletResponse resp, String sortBy, String orderBy,
108: IApplicationInfo webAppStats,
109: Collection/*<ISessionInfo>*/activeSessions,
110: Collection/*<String>*/passiveSessionsIds)
111: throws ServletException, IOException;
112:
113: /**
114: * Displays the details page for a given HttpSession
115: * @param req
116: * @param resp
117: * @param webAppStats
118: * @param currentSession
119: * @throws ServletException
120: * @throws IOException
121: */
122: public void displaySessionDetailPage(HttpServletRequest req,
123: HttpServletResponse resp, IApplicationInfo webAppStats,
124: ISessionInfo currentSession) throws ServletException,
125: IOException;
126:
127: /**
128: * Displays the details page for a Web Application
129: * @param req
130: * @param resp
131: * @param webAppStats
132: * @throws ServletException
133: * @throws IOException
134: */
135: public void displayWebAppStatsPage(HttpServletRequest req,
136: HttpServletResponse resp, IApplicationInfo webAppStats)
137: throws ServletException, IOException;
138:
139: /**
140: * Displays the page for the Server Informations
141: * @param req
142: * @param resp
143: * @param serverInfo
144: * @throws ServletException
145: * @throws IOException
146: */
147: public void displayServerInfosPage(HttpServletRequest req,
148: HttpServletResponse resp, IServerInfo serverInfo)
149: throws ServletException, IOException;
150: }
|