1 25 26 package org.objectweb.jonas.webapp.jonasadmin.service.resource; 27 28 import java.io.IOException ; 29 import java.util.ArrayList ; 30 import java.util.Collections ; 31 import java.util.Properties ; 32 33 import javax.management.ObjectName ; 34 import javax.servlet.ServletException ; 35 import javax.servlet.http.HttpServletRequest ; 36 import javax.servlet.http.HttpServletResponse ; 37 38 import org.apache.struts.action.ActionForm; 39 import org.apache.struts.action.ActionForward; 40 import org.apache.struts.action.ActionMapping; 41 import org.objectweb.jonas.jmx.JonasManagementRepr; 42 import org.objectweb.jonas.jmx.JonasObjectName; 43 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction; 44 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou; 45 import org.objectweb.jonas.webapp.jonasadmin.service.ejb.EjbItem; 46 import org.objectweb.jonas.webapp.jonasadmin.service.ejb.EjbItemByNameComparator; 47 48 51 52 public class EditResourceAdapterCFAction extends JonasBaseAction { 53 54 56 public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form 57 , HttpServletRequest p_Request, HttpServletResponse p_Response) 58 throws IOException , ServletException { 59 60 String sObjectName = p_Request.getParameter("select"); 62 63 ObjectName oObjectName = null; 64 String domainName = null; 65 String serverName = null; 66 67 ResourceAdapterCFForm oForm = null; 69 if (sObjectName != null) { 71 String sPath = null; 72 try { 73 oObjectName = ObjectName.getInstance(sObjectName); 75 domainName = oObjectName.getDomain(); 76 serverName = oObjectName.getKeyProperty("J2EEServer"); 77 oForm = new ResourceAdapterCFForm(); 79 oForm.reset(p_Mapping, p_Request); 80 if (oObjectName != null) { 81 oForm.setOName(oObjectName); 83 oForm.setName(getStringAttribute(oObjectName, "jndiName")); 84 oForm.setDescription(getStringAttribute(oObjectName, "description")); 85 oForm.setListProperties((Properties ) JonasManagementRepr.getAttribute(oObjectName 86 , "properties")); 87 populate(oForm, oObjectName); 88 } 89 m_Session.setAttribute("resourceAdapterCFForm", oForm); 90 } catch (Throwable t) { 91 addGlobalError(t); 92 saveErrors(p_Request, m_Errors); 93 return (p_Mapping.findForward("Global Error")); 94 } 95 } else { 96 oForm = (ResourceAdapterCFForm) m_Session.getAttribute("resourceAdapterCFForm"); 98 } 99 100 ResourceAdapterForm raForm = (ResourceAdapterForm) m_Session.getAttribute("resourceAdapterForm"); 101 102 m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER) + WhereAreYou.NODE_SEPARATOR 104 + "services" + WhereAreYou.NODE_SEPARATOR + "resourceAdapter" 105 + WhereAreYou.NODE_SEPARATOR + raForm.getFile(), true); 106 107 return (p_Mapping.findForward("Resource AdapterCF")); 109 } 110 111 protected void populate(ResourceAdapterCFForm p_Form, ObjectName oObjectName) 112 throws Exception { 113 114 p_Form.setJdbcConnCheckLevel(toStringIntegerAttribute(oObjectName, "jdbcConnCheckLevel")); 115 p_Form.setConnMaxAge(toStringIntegerAttribute(oObjectName, "connMaxAge")); 116 p_Form.setMaxOpentime(toStringIntegerAttribute(oObjectName, "maxOpentime")); 117 p_Form.setJdbcTestStatement(getStringAttribute(oObjectName, "jdbcTestStatement")); 118 p_Form.setMaxSize(toStringIntegerAttribute(oObjectName, "maxSize")); 119 p_Form.setMinSize(toStringIntegerAttribute(oObjectName, "minSize")); 120 p_Form.setMaxWaitTime(toStringIntegerAttribute(oObjectName, "maxWaitTime")); 121 p_Form.setMaxWaiters(toStringIntegerAttribute(oObjectName, "maxWaiters")); 122 p_Form.setSamplingPeriod(toStringIntegerAttribute(oObjectName, "samplingPeriod")); 123 124 ArrayList al = new ArrayList (); 126 String [] asParam = new String [1]; 127 String [] asSignature = new String [1]; 128 asSignature[0] = "java.lang.String"; 129 asParam[0] = p_Form.getName(); 130 if (JonasManagementRepr.isRegistered(JonasObjectName.ejbService())) { 131 java.util.Iterator it = ((java.util.Set ) JonasManagementRepr.invoke(JonasObjectName. 132 ejbService(), "getDataSourceDependence", asParam, asSignature)).iterator(); 133 while (it.hasNext()) { 134 al.add(new EjbItem((ObjectName ) it.next())); 135 } 136 } 137 Collections.sort(al, new EjbItemByNameComparator()); 139 p_Form.setListUsedByEjb(al); 141 } 142 143 } 144 | Popular Tags |