/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/
public void event(UserRequest ureq, Component source, Event event) {
if (source == tabbedPane) { // those must be links
TabbedPaneChangedEvent tbcEvent = (TabbedPaneChangedEvent)event;
Component newComponent = tbcEvent.getNewComponent();
if (newComponent == cachePanel) {
if (cacheController != null) {
cacheController.dispose();
}
cacheController = new AllCachesController(ureq, getWindowControl());
cachePanel.setContent(cacheController.getInitialComponent());
}
else if (newComponent == infoMsgCtrl.getInitialComponent()) {
}
else if (newComponent == mySysinfo) {
Runtime r = Runtime.getRuntime();
StringBuilder sb = new StringBuilder();
appendFormattedKeyValue(sb, "Processors", new Integer(r.availableProcessors()));
appendFormattedKeyValue(sb, "Total Memory", StringHelper.formatMemory(r.totalMemory()));
appendFormattedKeyValue(sb, "Free Memory", StringHelper.formatMemory(r.freeMemory()));
appendFormattedKeyValue(sb, "Max Memory", StringHelper.formatMemory(r.maxMemory()));
int controllerCnt = DefaultController.getControllerCount();
sb.append("<br />Controller Count (active and not disposed):"+controllerCnt);
sb.append("<br />Concurrent Dispatching Threads: "+DispatcherAction.getConcurrentCounter());
mySysinfo.contextPut("memory", sb.toString());
mySysinfo.contextPut("threads",getThreadsInfo());
mySysinfo.contextPut("javaenv", getJavaenv());
}
else if (newComponent == usessC.getInitialComponent()) {
usessC.reset();
}
else if (newComponent == myMultiUserEvents) {
StringBuilder sb = new StringBuilder();
Map infocenter = CoordinatorManager.getCoordinator().getEventBus().getUnmodifiableInfoCenter();
int cntRes = infocenter.size();
// cluster::: sort the entries (table?): sort by count and name
// REVIEW:2008-12-11:pb access ea.getListenerCount -> possible dead lock
// -> look for a different way to show info
// see also OLAT-3681
//
/*
sb.append("Total (possible weak-referenced) Resources: "+cntRes+" (showing only those with listeners, 'null' for a listener value meaning the OLAT system), count is cluster-wide, identities only vm-wide<br /><br />");
for (Iterator it_ores = infocenter.entrySet().iterator(); it_ores.hasNext();) {
Map.Entry entry = (Map.Entry) it_ores.next();
String oresDerivedString = (String) entry.getKey();
EventAgency ea = (EventAgency) entry.getValue();
Set listenIdentNames = ea.getListeningIdentityNames();
if (listenIdentNames.size() > 0) {
sb.append("<b>Resource:</b> [").append(ea.getListenerCount()).append("] on ").append(oresDerivedString).append("<br />Listeners: ");
for (Iterator it_id = listenIdentNames.iterator(); it_id.hasNext();) {
String login = (String) it_id.next();
sb.append(login).append("; ");
}
sb.append("<br /><br />");
}
}
*/
sb.append(" <a href=\"http://bugs.olat.org/jira/browse/OLAT-3681\">OLAT-3681</a> ");
myMultiUserEvents.contextPut("info", sb.toString());
}
else if (newComponent == sessionAdministrationController.getInitialComponent()) {
}
else if (newComponent == myHibernateInfo) {
myHibernateInfo.contextPut("isStatisticsEnabled", DBFactory.getInstance(false).getStatistics().isStatisticsEnabled());
myHibernateInfo.contextPut("hibernateStatistics", DBFactory.getInstance(false).getStatistics());
}
else if (newComponent == myLocks) {
StringBuilder sb = new StringBuilder();
List<LockEntry> locks = CoordinatorManager.getCoordinator().getLocker().adminOnlyGetLockEntries();
for (LockEntry entry : locks) {
sb.append("user "+entry.getOwner().getName()+" owns lock on "+entry.getKey()+"<br /><br />");
}
myLocks.contextPut("locks", sb.toString());
}
else if (newComponent == myLoglevels) {
List loggers = Tracing.getLoggersSortedByName(); // put it in a list in case of a reload (enum can only be used once)
myLoglevels.contextPut("loggers", loggers);
}
else if (newComponent == mySnoop) {
mySnoop.contextPut("snoop", getSnoop(ureq));
}
}
else if (source == myLoglevels) {
if (event.getCommand().equals(ACTION_SETLEVEL)) {
String level = ureq.getHttpReq().getParameter("level");
String logger = ureq.getHttpReq().getParameter("logger");
if (logger.equals(org.olat.core.logging.Tracing.class.getName())) {
getWindowControl().setError("log level of "+org.olat.core.logging.Tracing.class.getName()+" must not be changed!");
return;
}
Level l;
if (level.equals("debug")) l = Level.DEBUG;
else if (level.equals("info")) l = Level.INFO;
else if (level.equals("warn")) l = Level.WARN;
else l = Level.ERROR;
Tracing.setLevelForLogger(l, logger);
getWindowControl().setInfo("Set logger " + logger + " to level " + level);
} else if (event.getCommand().equals(ACTION_VIEWLOG)) {
String toBeViewed = ureq.getParameter(ACTION_VIEWLOG_PACKAGE);
if (toBeViewed == null) return; // should not happen
if (logViewerCtr != null) logViewerCtr.dispose();
logViewerCtr = new LogRealTimeViewerController(ureq, getWindowControl(), toBeViewed, Level.ALL, true);
if (cmc != null) cmc.dispose();
cmc = new CloseableModalController(getWindowControl(), getTranslator().translate("close"), logViewerCtr.getInitialComponent());
cmc.addControllerListener(this);
cmc.activate();
}
// push loglevel list again
event(ureq, tabbedPane, new TabbedPaneChangedEvent(null, myLoglevels));
}
else if (source == resetloglevelsButton){
Tracing.setLevelForAllLoggers(Level.INFO);
getWindowControl().setInfo("All loglevels set to INFO");
}
else if (source == gcButton){
Runtime.getRuntime().gc();
getWindowControl().setInfo("Garbage collection done.");
event(ureq, tabbedPane, new TabbedPaneChangedEvent(null, mySysinfo));
}
else if (source == myErrors) {
HttpServletRequest hreq = ureq.getHttpReq();
err_nr = hreq.getParameter("mynr");
if (hreq.getParameter("mydd") != null)
err_dd = hreq.getParameter("mydd");
if (hreq.getParameter("mymm") != null)
err_mm = hreq.getParameter("mymm");
if (hreq.getParameter("myyyyy") != null)
err_yyyy = hreq.getParameter("myyyyy");
if (err_nr != null) {
myErrors.contextPut("mynr", err_nr);
LogFile lf = new LogFile();
myErrors.contextPut("errormsgs", lf.getError(err_nr, err_dd, err_mm, err_yyyy, true));
}
myErrors.contextPut("highestError", Tracing.getErrorCount());
myErrors.contextPut("mydd", err_dd);
myErrors.contextPut("mymm", err_mm);
myErrors.contextPut("myyyyy", err_yyyy);
myErrors.contextPut("olat_formatter", Formatter.getInstance(ureq.getLocale()));
}
else if (source == enableHibernateStatisticsButton){
DBFactory.getInstance(false).getStatistics().setStatisticsEnabled(true);
myHibernateInfo.contextPut("isStatisticsEnabled", DBFactory.getInstance(false).getStatistics().isStatisticsEnabled());
getWindowControl().setInfo("Hibernate statistics enabled.");
event(ureq, tabbedPane, new TabbedPaneChangedEvent(null, myHibernateInfo));
}
else if (source == disableHibernateStatisticsButton){
DBFactory.getInstance(false).getStatistics().setStatisticsEnabled(false);
myHibernateInfo.contextPut("isStatisticsEnabled", DBFactory.getInstance(false).getStatistics().isStatisticsEnabled());
getWindowControl().setInfo("Hibernate statistics disabled.");
event(ureq, tabbedPane, new TabbedPaneChangedEvent(null, myHibernateInfo));
}
else if (source == clearHibernateStatisticsButton){
DBFactory.getInstance(false).getStatistics().clear();
getWindowControl().setInfo("Hibernate statistics clear done.");
event(ureq, tabbedPane, new TabbedPaneChangedEvent(null, myHibernateInfo));
}
}