1 25 26 package org.objectweb.jonas.webapp.jonasadmin.resource; 27 28 import java.io.IOException ; 29 import java.util.Properties ; 30 31 import javax.servlet.ServletException ; 32 import javax.servlet.http.HttpServletRequest ; 33 import javax.servlet.http.HttpServletResponse ; 34 35 import org.apache.struts.action.ActionForm; 36 import org.apache.struts.action.ActionForward; 37 import org.apache.struts.action.ActionMapping; 38 import org.objectweb.jonas.jmx.JonasManagementRepr; 39 import org.objectweb.jonas.jmx.JonasObjectName; 40 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou; 41 import org.objectweb.jonas.webapp.jonasadmin.deploy.BaseDeployAction; 42 43 46 47 public class ApplyDatasourcePropertiesAction extends BaseDeployAction { 48 49 51 public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form 52 , HttpServletRequest p_Request, HttpServletResponse p_Response) 53 throws IOException , ServletException { 54 55 DatasourcePropertiesForm oForm = (DatasourcePropertiesForm) p_Form; 57 try { 58 populate(oForm); 60 m_WhereAreYou.setCurrentJonasDeploymentType(WhereAreYou.DEPLOYMENT_DATASOURCE); 62 refreshTree(p_Request); 63 } 64 catch (Throwable t) { 65 addGlobalError(t); 66 saveErrors(p_Request, m_Errors); 67 return (p_Mapping.findForward("Global Error")); 68 } 69 m_Session.removeAttribute("datasourcePropertiesForm"); 71 return (p_Mapping.findForward("ActionListDatasources")); 73 } 74 75 77 private static final String DEF_CLASSNAME = "no class name"; 78 private static final String DEF_URL = "no url"; 79 private static final String DEF_DESCRIPTION = "no desc"; 80 private static final String DEF_USERNAME = ""; 81 private static final String DEF_PASSWORD = ""; 82 private static final String DEF_FACTORY = "none"; 83 private static final String DEF_MAPPERNAME = "rdb"; 84 85 protected void populate(DatasourcePropertiesForm p_Form) 86 throws Exception { 87 Properties oProps = new Properties (); 88 setStringAttribute(oProps, "datasource.name", p_Form.getDatasourceName()); 89 setStringAttribute(oProps, "datasource.description", p_Form.getDatasourceDescription() 90 , DEF_DESCRIPTION); 91 setStringAttribute(oProps, "datasource.url", p_Form.getDatasourceUrl(), DEF_URL); 92 setStringAttribute(oProps, "datasource.classname", p_Form.getDatasourceClassname() 93 , DEF_CLASSNAME); 94 setStringAttribute(oProps, "datasource.username", p_Form.getDatasourceUsername() 95 , DEF_USERNAME); 96 setStringAttribute(oProps, "datasource.password", p_Form.getDatasourcePassword() 97 , DEF_PASSWORD); 98 setStringAttribute(oProps, "datasource.mapper", p_Form.getDatasourceMapper() 99 , DEF_MAPPERNAME); 100 setStringAttribute(oProps, "jdbc.connmaxage", p_Form.getJdbcConnmaxage()); 101 setStringAttribute(oProps, "jdbc.maxopentime", p_Form.getJdbcMaxopentime()); 102 setStringAttribute(oProps, "jdbc.connchecklevel", p_Form.getJdbcConnchecklevel()); 103 setStringAttribute(oProps, "jdbc.connteststmt", p_Form.getJdbcConnteststmt()); 104 setStringAttribute(oProps, "jdbc.minconpool", p_Form.getJdbcMinconpool()); 105 setStringAttribute(oProps, "jdbc.maxconpool", p_Form.getJdbcMaxconpool()); 106 setStringAttribute(oProps, "jdbc.maxwaittime", p_Form.getJdbcMaxwaittime()); 107 setStringAttribute(oProps, "jdbc.maxwaiters", p_Form.getJdbcMaxwaiters()); 108 setStringAttribute(oProps, "jdbc.samplingperiod", p_Form.getJdbcSamplingperiod()); 109 110 Object [] aoParam = { 112 p_Form.getName(), oProps, new Boolean (false)}; 113 String [] asSign_3 = { 114 "java.lang.String", "java.util.Properties", "java.lang.Boolean"}; 115 JonasManagementRepr.invoke(JonasObjectName.databaseService(), "loadDataSource", aoParam 116 , asSign_3); 117 118 } 119 } 120 | Popular Tags |