001: /**
002: * Copyright 2005 Sun Microsystems, Inc. All
003: * rights reserved. Use of this product is subject
004: * to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users
006: * Subject to Standard License Terms and
007: * Conditions.
008: *
009: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010: * are trademarks or registered trademarks of Sun Microsystems,
011: * Inc. in the United States and other countries.
012: */package com.sun.portal.admin.console.search;
013:
014: import java.util.*;
015: import java.util.logging.Level;
016: import java.lang.*;
017: import java.io.*;
018: import java.text.*;
019:
020: import javax.faces.context.FacesContext;
021: import javax.servlet.http.HttpServletRequest;
022: import javax.management.*;
023:
024: import com.sun.data.provider.*;
025: import com.sun.data.provider.impl.ObjectListDataProvider;
026:
027: import com.sun.cacao.agent.JmxClient;
028:
029: import com.sun.portal.admin.common.util.AdminClientUtil;
030: import com.sun.portal.admin.console.common.PSBaseBean;
031:
032: public class AnalysesBean extends PSBaseBean {
033:
034: private ObjectListDataProvider urls = null;
035: private ObjectListDataProvider protocols = null;
036:
037: public AnalysesBean() {
038: ArrayList al1 = new ArrayList();
039: ArrayList al2 = new ArrayList();
040: try {
041: LinkedList path = new LinkedList();
042: path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
043: path
044: .addFirst((String) getSessionAttribute("search.server.selected"));
045: path.addFirst("database");
046: ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
047: AdminClientUtil.SEARCH_DATABASE_MBEAN_TYPE, path);
048:
049: String database = (String) getSessionAttribute("search.database.selected");
050:
051: Object[] params1 = { database };
052: String[] signatures1 = { "java.lang.String" };
053: Boolean isOld = (Boolean) getMBeanServerConnection()
054: .invoke(on, "isStatisticsOld", params1, signatures1);
055:
056: Object[] params2 = { database, isOld };
057: String[] signatures2 = { "java.lang.String",
058: "java.lang.Boolean" };
059: ArrayList data = (ArrayList) getMBeanServerConnection()
060: .invoke(on, "getStatistics", params2, signatures2);
061:
062: Hashtable ht = (Hashtable) data.get(2);
063: Enumeration e1 = ht.keys();
064: Enumeration e2 = ht.elements();
065: while (e1.hasMoreElements()) {
066: AnalysisBean ab = new AnalysisBean();
067: ab.initialize((String) e2.nextElement(), (String) e1
068: .nextElement());
069: al1.add(ab);
070: }
071:
072: ht = (Hashtable) data.get(1);
073: e1 = ht.keys();
074: e2 = ht.elements();
075: while (e1.hasMoreElements()) {
076: AnalysisBean ab = new AnalysisBean();
077: ab.initialize((String) e2.nextElement(), (String) e1
078: .nextElement());
079: al2.add(ab);
080: }
081: } catch (Exception e) {
082: log(Level.SEVERE,
083: "AnalysesBean.AnalysesBean() : Exception ", e);
084: }
085: urls = new ObjectListDataProvider(al1);
086: urls.setObjectType(AnalysisBean.class);
087: protocols = new ObjectListDataProvider(al2);
088: protocols.setObjectType(AnalysisBean.class);
089: }
090:
091: public String getPageTitle() {
092: MessageFormat mf = new MessageFormat("");
093: mf.applyPattern(getLocalizedString("search",
094: "search.analyses.pagetitle"));
095: return mf
096: .format(new Object[] { (String) getSessionAttribute("search.database.selected") });
097: }
098:
099: public ObjectListDataProvider getUrls() {
100: return urls;
101: }
102:
103: public void setUrls(ObjectListDataProvider urls) {
104: this .urls = urls;
105: }
106:
107: public ObjectListDataProvider getProtocols() {
108: return protocols;
109: }
110:
111: public void setProtocols(ObjectListDataProvider protocols) {
112: this .protocols = protocols;
113: }
114:
115: public String cancel() {
116: return "gotoDatabasesHome";
117: }
118:
119: }
|