1 23 24 29 30 package com.sun.enterprise.tools.admingui.handlers; 31 32 import java.util.EventObject ; 33 import javax.servlet.http.HttpSession ; 34 import javax.management.AttributeList ; 35 import javax.management.Attribute ; 36 import java.util.Properties ; 37 import java.util.Enumeration ; 38 39 import com.iplanet.jato.RequestContext; 40 import com.iplanet.jato.RequestManager; 41 import com.iplanet.jato.model.DefaultModel; 42 import com.iplanet.jato.view.View; 43 import com.iplanet.jato.view.ViewBean; 44 import com.iplanet.jato.model.ModelControlException; 45 import com.iplanet.jato.view.ContainerViewBase; 46 import com.iplanet.jato.view.ViewBase; 47 import com.iplanet.jato.view.html.SelectableGroup; 48 import com.iplanet.jato.view.html.OptionList; 49 50 import com.sun.enterprise.tools.guiframework.view.DescriptorContainerView; 51 import com.sun.enterprise.tools.guiframework.view.HandlerContext; 52 import com.sun.enterprise.tools.guiframework.exception.FrameworkException; 53 import com.sun.enterprise.tools.guiframework.model.ModelManager; 54 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor; 55 56 import com.sun.web.ui.model.CCActionTableModelInterface; 57 import com.sun.enterprise.tools.admingui.util.MBeanUtil; 58 59 63 public class ConnectorConnectionPoolHandlers { 64 65 public static final String PROPERTY_NAME = "propertyName"; 66 public static final String PROPERTY_VALUE = "propertyValue"; 67 68 69 public void getValuesFromStep1(RequestContext ctx, HandlerContext handlerCtx) throws ModelControlException { 70 View view = handlerCtx.getView(); 71 DescriptorContainerView descView = (DescriptorContainerView)(((ViewBase)view)); 72 ViewDescriptor vd = descView.getViewDescriptor(); 73 HttpSession session = RequestManager.getSession(); 74 DefaultModel step1Model = (DefaultModel)(session.getValue("connectorPoolStep1.model")); 75 descView.setDisplayFieldValue("Name", step1Model.getValue("Name")); 76 descView.setDisplayFieldValue("ResourceAdapter", step1Model.getValue("ResourceAdapter")); 77 descView.setDisplayFieldValue("ConnectionDefinition", step1Model.getValue("ConnectionDefinition")); 78 } 79 80 81 82 public void populateDefaultProperties(RequestContext ctx, HandlerContext handlerCtx) 83 throws ModelControlException { 84 View view = handlerCtx.getView(); 85 DescriptorContainerView descView = (DescriptorContainerView)(((ViewBase)view)); 86 DescriptorContainerView parent = (DescriptorContainerView)descView.getParent(); 87 String connectionDefinition = (String )parent.getDisplayFieldValue("ConnectionDefinition"); 88 String resourceAdapter = (String )parent.getDisplayFieldValue("ResourceAdapter"); 89 AttributeList attrList = new AttributeList (); 90 attrList.add(new Attribute ("resource-adapter-name", resourceAdapter)); 91 attrList.add(new Attribute ("connection-definition-name", connectionDefinition)); 92 Object [] params = new Object []{attrList}; 93 String [] types = new String []{"javax.management.AttributeList"}; 94 95 Properties properties = 96 (Properties )MBeanUtil.invoke("com.sun.appserv:type=resources,category=config", 97 "getMCFConfigProps", 98 params, types ); 99 CCActionTableModelInterface model = 100 (CCActionTableModelInterface)handlerCtx.getInputValue("propertiesModel"); 101 ((DefaultModel)model).clear(); 102 if (properties == null) 103 return; 104 model.beforeFirst(); 105 Enumeration propertyNames = properties.propertyNames(); 106 while(propertyNames.hasMoreElements()){ 107 model.appendRow(); 108 String name = (String )propertyNames.nextElement(); 109 model.setValue(PROPERTY_NAME, name); 110 model.setValue(PROPERTY_VALUE, properties.getProperty(name)); 111 model.setRowSelected(false); 112 } 113 } 114 115 116 public void populateConnectionDefinitions(RequestContext ctx, HandlerContext handlerCtx) throws ModelControlException { 117 View view = handlerCtx.getView(); 118 SelectableGroup dropDownChild = (SelectableGroup) view; 120 DescriptorContainerView parent = (DescriptorContainerView) dropDownChild.getParent(); 122 String resAdapter = (String )parent.getDisplayFieldValue("ResourceAdapter"); 123 Object [] params = {resAdapter}; 124 String [] types = {"java.lang.String"}; 125 String [] connectionDefinitions = 126 (String [])MBeanUtil.invoke("com.sun.appserv:type=resources,category=config", 127 "getConnectionDefinitionNames", 128 params, types ); 129 if (connectionDefinitions == null) 130 return; 131 OptionList dropDownMenuOptions = new OptionList(connectionDefinitions, connectionDefinitions ); dropDownChild.setOptions(dropDownMenuOptions); 133 } 134 135 137 public void areDefaultPropertiesLoaded(RequestContext ctx, HandlerContext handlerCtx) throws ModelControlException { 138 View view = handlerCtx.getView(); 139 DescriptorContainerView descView = (DescriptorContainerView)(((ViewBase)view)); 140 DescriptorContainerView parent = (DescriptorContainerView)descView.getParent(); 141 String newConnectionDefinition = (String )parent.getDisplayFieldValue("ConnectionDefinition"); 142 HttpSession session = RequestManager.getSession(); 143 String oldConnectionDefinition = (String )session.getAttribute("connectorPoolStep3.ConnectionDefinition"); 144 if (oldConnectionDefinition == null || 145 !oldConnectionDefinition .equals(newConnectionDefinition)) { 146 ctx.getRequest().setAttribute("connectorPoolStep3.areDefaultPropertiesLoaded", "false"); 147 } 148 else { 149 ctx.getRequest().setAttribute("connectorPoolStep3.areDefaultPropertiesLoaded", "true"); 150 } 151 session.setAttribute("connectorPoolStep3.ConnectionDefinition", newConnectionDefinition); 152 } 153 154 } 155 | Popular Tags |