1 16 17 package org.apache.jetspeed.portal.portlets.admin; 18 19 import org.apache.ecs.html.B; 21 import org.apache.ecs.html.BR; 22 import org.apache.ecs.html.HR; 23 import org.apache.ecs.ConcreteElement; 24 import org.apache.ecs.ElementContainer; 25 26 import org.apache.jetspeed.portal.PortletException; 28 import org.apache.jetspeed.portal.portlets.AbstractPortlet; 29 import org.apache.jetspeed.services.portletcache.GlobalCache; 30 import org.apache.jetspeed.services.Registry; 31 import org.apache.jetspeed.services.threadpool.ThreadPoolService; 32 import org.apache.jetspeed.services.threadpool.JetspeedThreadPoolService; 33 import org.apache.jetspeed.services.urlmanager.URLManager; 34 import org.apache.jetspeed.services.urlmanager.URLManagerService; 35 import org.apache.jetspeed.services.urlmanager.URLFetcher; 36 37 38 import org.apache.turbine.util.RunData; 40 import org.apache.turbine.services.TurbineServices; 41 42 48 public class GlobalAdminPortlet extends AbstractPortlet { 49 50 51 58 public ConcreteElement getContent( RunData rundata ) { 59 60 61 ElementContainer ec = new ElementContainer(); 62 63 this.createCategory( ec, "Memory" ); 64 65 ec.addElement( this.getEntry( "Free Memory (K)", 66 Long.toString( Runtime.getRuntime().freeMemory()/1024 ) ) ); 67 ec.addElement( this.getEntry( "Total Memory (K)", 68 Long.toString( Runtime.getRuntime().totalMemory()/1024 ) ) ); 69 70 JetspeedThreadPoolService service = 71 ( JetspeedThreadPoolService ) TurbineServices 72 .getInstance() 73 .getService( ThreadPoolService.SERVICE_NAME ); 74 75 this.createCategory( ec, "Thread Pool" ); 76 77 ec.addElement( this.getEntry( "Available threads: ", 78 service.getAvailableThreadCount() ) ); 79 80 ec.addElement( this.getEntry( "Total threads: ", 81 service.getThreadCount() ) ); 82 83 ec.addElement( this.getEntry( "Runnable queue length: ", 84 service.getQueueLength() ) ); 85 86 ec.addElement( this.getEntry( "Processed thread count: ", 87 service.getThreadProcessedCount() ) ); 88 89 this.createCategory( ec, "PortletRegistry" ); 90 91 ec.addElement( this.getEntry( "Number of entries: ", 92 Registry.get(Registry.PORTLET).getEntryCount() ) ); 93 94 this.createCategory( ec, "Resource Manager" ); 95 96 ec.addElement( this.getEntry( "Entries in Manager", 97 URLManager.list( URLManagerService.STATUS_ANY ).size() ) ); 98 ec.addElement( this.getEntry( "Bad Entries", 99 URLManager.list( URLManagerService.STATUS_BAD ).size() ) ); 100 ec.addElement( this.getEntry( "URLs Loading/Refreshing", 101 URLFetcher.getRealtimeURLs().size() ) ); 102 103 this.createCategory( ec, "Global Memory Cache" ); 104 ec.addElement( this.getEntry( "Objects in Cache", 105 GlobalCache.getNumberOfObjects())); 106 107 return ec; 108 109 } 110 111 114 private void createCategory( ElementContainer ec, 115 String title ) { 116 117 118 ec.addElement( new HR() ); 119 ec.addElement( new B().addElement( title + ":" ) ); 120 ec.addElement( new BR() ); 121 122 } 123 124 private ConcreteElement getEntry( String title, 125 int value ) { 126 return getEntry( title, Integer.toString( value ) ); 127 } 128 129 private ConcreteElement getEntry( String title, 130 String value ) { 131 132 ElementContainer ec = new ElementContainer(); 133 134 ec.addElement( title ); 135 ec.addElement( " -> " ); 136 ec.addElement( value ); 137 ec.addElement( new BR() ); 138 139 return ec; 140 } 141 142 146 147 public void init() throws PortletException { 148 149 this.setTitle( "Global" ); 150 this.setDescription( "Global information..." ); 151 152 } 153 154 157 public boolean getAllowEdit(RunData rundata) { 158 return false; 159 } 160 161 164 public boolean getAllowMaximize(RunData rundata) { 165 return false; 166 } 167 168 } 169 | Popular Tags |