1 23 24 28 29 package com.sun.enterprise.tools.admingui.handlers; 30 31 import java.util.ArrayList ; 32 import java.util.List ; 33 34 import com.iplanet.jato.RequestContext; 35 import com.iplanet.jato.view.DisplayField; 36 import com.iplanet.jato.view.ContainerView; 37 import com.iplanet.jato.view.View; 38 import com.iplanet.jato.view.ViewBase; 39 import com.iplanet.jato.view.html.SelectableGroup; 40 import javax.management.Attribute ; 41 42 43 44 import com.sun.enterprise.tools.guiframework.exception.FrameworkException; 45 import com.sun.enterprise.tools.guiframework.view.HandlerContext; 46 import com.sun.enterprise.tools.guiframework.view.DescriptorContainerView; 47 48 import com.sun.enterprise.tools.admingui.util.MBeanUtil; 49 import com.sun.enterprise.tools.admingui.util.Util; 50 51 54 public class LogModuleHandler { 55 56 public void showPersistenceLogLevel(RequestContext ctx, HandlerContext handlerCtx) { 57 SelectableGroup dropDownChild = (SelectableGroup)handlerCtx.getInputValue(DISPLAY_FIELD); 59 String objectName = (String ) handlerCtx.getInputValue("objectName"); 60 String [] types = new String []{"java.lang.String"}; 62 Object [] params = new Object []{PERSISTENCE_MODULE_PROPERTY}; 63 String value = "INFO"; 64 try { 65 value = (String ) MBeanUtil.invoke(objectName, "getPropertyValue", params, types); 66 }catch (Exception ex){ 67 } 69 dropDownChild.setValue(value); 70 } 71 72 public void setPersistenceLogLevel(RequestContext ctx, HandlerContext handlerCtx) { 73 String objectName = (String ) handlerCtx.getInputValue("objectName"); 75 String value = (String ) handlerCtx.getInputValue("value"); 76 Attribute attr = new Attribute (PERSISTENCE_MODULE_PROPERTY, value); 78 String [] types = new String []{"javax.management.Attribute"}; 79 Object [] params = new Object []{attr}; 80 MBeanUtil.invoke(objectName, "setProperty", params, types); 81 82 attr = new Attribute ("jdo", value); 83 MBeanUtil.setAttribute(objectName, attr); 84 85 attr = new Attribute ("cmp", value); 86 MBeanUtil.setAttribute(objectName, attr); 87 88 attr = new Attribute ("cmp-container", value); 89 MBeanUtil.setAttribute(objectName, attr); 90 } 91 92 93 public void showPersistenceLogModule(RequestContext ctx, HandlerContext handlerCtx) { 94 DisplayField field = (DisplayField)handlerCtx.getInputValue(DISPLAY_FIELD); 96 String jdo = getLoggerList("jdo", field.getName()); 97 String cmp = getLoggerList("cmp", field.getName()); 98 field.setValue( "( " + PERSISTENCE_MODULE_PROPERTY + "; " + jdo + cmp + ")" ); 99 } 100 101 public void showModuleLogger(RequestContext reqCtx, HandlerContext handlerCtx) { 102 ArrayList attributeNames = (ArrayList )handlerCtx.getInputValue("attributeNames"); 104 if (attributeNames == null) { 105 throw new IllegalArgumentException ( 106 "The parameter map did not contain " + "attributeNames"); 107 } 108 109 ArrayList displayNames = (ArrayList )handlerCtx.getInputValue("displayNames"); 111 if (displayNames == null) { 112 throw new IllegalArgumentException ( 113 "The parameter map did not contain " + "displayNames"); 114 } 115 116 ContainerView view = MBeanHandlers.getView(reqCtx, handlerCtx); 118 119 for (int i=0; i < displayNames.size(); i++) { 120 String module = (String ) attributeNames.get(i); 121 String label = displayNames.get(i)+"Label"; 122 String logList = getLoggerList(module, label); 123 view.setDisplayFieldValue(label, "( " + logList + ")"); 125 } 126 } 127 128 private String getLoggerList(String module, String label ){ 129 String [] params = {module}; 130 String [] types = {"java.lang.String"}; 131 132 String logList = ""; 133 List loggers = (List ) MBeanUtil.invoke( 134 "com.sun.appserv:name=logmanager,category=runtime,server=server", 135 "getLognames4LogModule", params, types); 136 137 if (loggers != null){ 138 for(int cnt = 0; cnt < loggers.size(); cnt++){ 139 logList += loggers.get(cnt); 140 logList +="; "; 141 } 142 } 143 144 return logList; 145 } 146 147 148 private static final String PERSISTENCE_MODULE_PROPERTY = "oracle.toplink.essentials"; 149 private static final String DISPLAY_FIELD = "displayField"; 150 } 151 | Popular Tags |