1 23 24 package com.sun.enterprise.web.stats; 25 26 import java.util.logging.Level ; 27 import java.util.logging.Logger ; 28 import javax.management.j2ee.statistics.Stats ; 29 import javax.management.j2ee.statistics.Statistic ; 30 import com.sun.logging.LogDomains; 31 import com.sun.enterprise.web.VirtualServer; 32 import com.sun.enterprise.admin.monitor.stats.StringStatistic; 33 import com.sun.enterprise.admin.monitor.stats.StringStatisticImpl; 34 import com.sun.enterprise.admin.monitor.stats.PWCVirtualServerStats; 35 import com.sun.enterprise.admin.monitor.stats.GenericStatsImpl; 36 37 40 public class PWCVirtualServerStatsImpl implements PWCVirtualServerStats { 41 42 private static Logger _logger = LogDomains.getLogger( 43 LogDomains.WEB_LOGGER); 44 45 private long startTime; 46 private GenericStatsImpl baseStatsImpl; 47 private StringStatistic idStats; 48 private StringStatistic modeStats; 49 private StringStatistic hostsStats; 50 private StringStatistic interfacesStats; 51 52 55 public PWCVirtualServerStatsImpl(VirtualServer vs) { 56 57 initializeStatistics(vs); 58 59 baseStatsImpl = new GenericStatsImpl( 60 com.sun.enterprise.admin.monitor.stats.PWCVirtualServerStats.class, 61 this); 62 } 63 64 69 public StringStatistic getId() { 70 return idStats; 71 } 72 73 78 public StringStatistic getMode() { 79 return modeStats; 80 } 81 82 87 public StringStatistic getHosts() { 88 return hostsStats; 89 } 90 91 96 public StringStatistic getInterfaces() { 97 return interfacesStats; 98 } 99 100 public Statistic [] getStatistics() { 101 return baseStatsImpl.getStatistics(); 102 } 103 104 public String [] getStatisticNames() { 105 return baseStatsImpl.getStatisticNames(); 106 } 107 108 public Statistic getStatistic(String str) { 109 return baseStatsImpl.getStatistic(str); 110 } 111 112 117 private void initializeStatistics(VirtualServer vs) { 118 119 startTime = System.currentTimeMillis(); 120 121 idStats = new StringStatisticImpl( 123 vs.getID(), 124 "Id", 125 "String", 126 "Virtual Server ID", 127 startTime, 128 startTime); 129 130 modeStats = new StringStatisticImpl( 132 vs.isActive() ? "active" : "unknown", 133 "Mode", 134 "unknown/active", 135 "Virtual Server mode", 136 startTime, 137 startTime); 138 139 String hosts = null; 141 String [] aliases = vs.findAliases(); 142 if (aliases != null) { 143 for (int i=0; i<aliases.length; i++) { 144 if (hosts == null) { 145 hosts = aliases[i]; 146 } else { 147 hosts += ", " + aliases[i]; 148 } 149 } 150 } 151 hostsStats = new StringStatisticImpl( 152 hosts, 153 "Hosts", 154 "String", 155 "The software virtual hostnames serviced by " 156 + "this Virtual Server", 157 startTime, 158 startTime); 159 160 interfacesStats = new StringStatisticImpl( 162 "0.0.0.0", "Interfaces", 164 "String", 165 "The interfaces for which this Virtual Server " 166 + "has been configured", 167 startTime, 168 startTime); 169 } 170 171 172 } 173 | Popular Tags |