1 23 24 28 29 package com.sun.enterprise.tools.admingui.handlers; 30 31 import java.util.ArrayList ; 32 import java.util.EventObject ; 33 import java.util.StringTokenizer ; 34 import java.util.Properties ; 35 import java.util.Enumeration ; 36 37 import com.iplanet.jato.RequestContext; 38 import com.iplanet.jato.RequestContextImpl; 39 import com.iplanet.jato.RequestManager; 40 import com.iplanet.jato.model.DefaultModel; 41 import com.iplanet.jato.model.Model; 42 import com.iplanet.jato.util.RootCauseException; 43 import com.iplanet.jato.view.ContainerView; 44 import com.iplanet.jato.view.ContainerViewBase; 45 import com.iplanet.jato.view.View; 46 import com.iplanet.jato.view.DisplayFieldImpl; 47 import com.iplanet.jato.view.ViewBase; 48 import com.iplanet.jato.view.ViewBean; 49 import com.iplanet.jato.view.html.SelectableGroup; 50 import com.iplanet.jato.view.html.OptionList; 51 import com.iplanet.jato.model.ModelControlException; 52 53 import javax.management.MBeanException ; 54 import javax.management.ObjectName ; 55 import javax.management.AttributeList ; 56 import javax.management.Attribute ; 57 import javax.servlet.ServletRequest ; 58 59 import com.sun.enterprise.tools.guiframework.exception.FrameworkException; 60 import com.sun.enterprise.tools.guiframework.model.ModelManager; 61 import com.sun.enterprise.tools.guiframework.view.HandlerContext; 62 import com.sun.enterprise.tools.guiframework.view.DescriptorContainerView; 63 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor; 64 import com.sun.enterprise.tools.guiframework.view.descriptors.CCActionTableDescriptor; 65 import com.sun.enterprise.tools.guiframework.view.event.BeforeCreateEvent; 66 import com.sun.enterprise.tools.guiframework.view.event.ErrorEvent; 67 68 import com.sun.web.ui.model.CCActionTableModelInterface; 69 70 import com.sun.enterprise.tools.admingui.util.MBeanUtil; 71 import com.sun.enterprise.tools.admingui.util.Util; 72 73 74 public class JmsHandlers { 75 76 public static final String PROPERTY_NAME = "propertyName"; 77 public static final String PROPERTY_VALUE = "propertyValue"; 78 79 public void loadJmsPhysicalDestinations(RequestContext ctx, HandlerContext handlerCtx) { 80 View view = handlerCtx.getView(); 81 if (!(handlerCtx.getEvent() instanceof BeforeCreateEvent)) { 82 ViewDescriptor desc = (view instanceof DescriptorContainerView) ? 83 ((DescriptorContainerView)view).getViewDescriptor() : 84 (ViewDescriptor)null; 85 throw new FrameworkException("This handler is for 'beforeCreate'" + 86 " handlers only!", desc, view); 87 } 88 89 ViewDescriptor desc = ((BeforeCreateEvent)handlerCtx.getEvent()).getViewDescriptor(); 90 if (!(desc instanceof CCActionTableDescriptor)) { 91 throw new FrameworkException("Table model expected here", desc, view); 92 } 93 CCActionTableDescriptor ccDesc = (CCActionTableDescriptor)desc; 94 CCActionTableModelInterface model = ccDesc.getModel(); 95 String objectName = (String )handlerCtx.getInputValue("objectName"); 96 String methodName = (String )handlerCtx.getInputValue("methodName"); 97 String configName = (String )handlerCtx.getInputValue("configName"); 98 99 ObjectName [] objectNames = null; 100 String [] params = {configName}; 101 String [] types = {"java.lang.String"}; 102 try{ 103 objectNames = (ObjectName [])MBeanUtil.invoke(objectName, methodName, params, types); 104 }catch (Exception ex){ 105 handlerCtx.setOutputValue("hasError", "true"); 107 Throwable upper = ex.getCause(); handlerCtx.setOutputValue("errorMsg", upper.getCause()); 109 ex.printStackTrace(); 110 return; 111 } 112 113 if (objectNames == null) { 114 return; } 116 for (int i = 0; i < objectNames.length; i++) { 117 model.appendRow(); 119 model.setValue("name", objectNames[i].getKeyProperty("destName")); 120 model.setValue("type", objectNames[i].getKeyProperty("destType")); 121 } 122 } 123 public void physicalDestinationActions(RequestContext ctx, HandlerContext handlerCtx) { 124 View view = handlerCtx.getView(); 125 DescriptorContainerView descView = (DescriptorContainerView)(((ViewBase)view).getParentViewBean()); 126 ViewDescriptor vd = descView.getViewDescriptor(); 127 String childName = (String )vd.getParameter("tableChildName"); 128 if(childName == null) { 129 throw new FrameworkException("deleteHandler: childName not specified", vd, view); 130 } 131 132 ViewDescriptor tableDescriptor = vd.getChildDescriptor(childName); 133 if(tableDescriptor == null) { 134 throw new FrameworkException("deleteHandler: tableDescriptor is null", vd, view); 135 } 136 if(!(tableDescriptor instanceof CCActionTableDescriptor)) { 137 throw new FrameworkException("deleteHandler: tableDescriptor is of wrong type", tableDescriptor, view); 138 } 139 CCActionTableModelInterface model = ((CCActionTableDescriptor)tableDescriptor).getModel(); 140 String methodName = (String )handlerCtx.getInputValue("methodName"); 141 String objectName = (String )handlerCtx.getInputValue("objectName"); 142 String target = (String )handlerCtx.getInputValue("target"); 143 if(objectName == null) { 144 throw new FrameworkException("No ObjectName specified"); 145 } 146 model.setRowSelectionType("multiple"); 147 try { 148 model.beforeFirst(); 149 while(model.next()) { 151 if (model.isRowSelected()) { 152 Object [] params = new Object []{ 153 model.getValue("name"), 154 model.getValue("type"), 155 target}; 156 String [] types = new String []{ 157 "java.lang.String", 158 "java.lang.String", 159 "java.lang.String"}; 160 MBeanUtil.invoke(objectName, methodName, params, types); 161 model.setRowSelected(false); 162 } 163 } 164 } catch (Exception ex) { 165 throw new FrameworkException(ex); 166 } 167 ContainerViewBase containerView = (ContainerViewBase)(tableDescriptor.getView(ctx).getParent()); 168 containerView.removeChild(tableDescriptor.getName()); 169 ((DefaultModel)model).clear(); 170 } 171 172 198 199 } 200 | Popular Tags |