1 25 26 package org.objectweb.jonas.webapp.jonasadmin.service.db; 27 28 import java.io.IOException ; 29 30 import javax.management.ObjectName ; 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.J2eeObjectName; 39 import org.objectweb.jonas.jmx.JonasManagementRepr; 40 import org.objectweb.jonas.jmx.JonasObjectName; 41 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction; 42 43 46 47 public class ApplyDatasourceAction extends JonasBaseAction { 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 DatasourceForm oForm = (DatasourceForm) p_Form; 57 try { 58 String domainName = m_WhereAreYou.getCurrentDomainName(); 59 String serverName = m_WhereAreYou.getCurrentJonasServerName(); 60 populate(oForm, domainName, serverName); 61 if (oForm.getAction().equals("save") == true) { 62 save(oForm, domainName, serverName); 63 } 64 } 65 catch (Throwable t) { 66 addGlobalError(t); 67 saveErrors(p_Request, m_Errors); 68 return (p_Mapping.findForward("Global Error")); 69 } 70 return new ActionForward(p_Mapping.findForward("ActionEditDatasource").getPath() + "?name=" 72 + oForm.getDatasourceName()); 73 } 74 75 77 protected void populate(DatasourceForm p_Form, String domainName, String serverName) 78 throws Exception { 79 ObjectName oObjectName = J2eeObjectName.getJDBCDataSource(domainName, serverName, p_Form.getDatasourceName()); 81 setIntegerAttribute(oObjectName, "jdbcConnCheckLevel", p_Form.getJdbcConnCheckLevel()); 83 setIntegerAttribute(oObjectName, "jdbcConnMaxAge", p_Form.getJdbcConnMaxAge()); 84 setIntegerAttribute(oObjectName, "jdbcMaxOpenTime", p_Form.getJdbcMaxOpenTime()); 85 setStringAttribute(oObjectName, "jdbcTestStatement", p_Form.getJdbcTestStatement()); 86 setIntegerAttribute(oObjectName, "jdbcMaxConnPool", p_Form.getJdbcMaxConnPool()); 87 setIntegerAttribute(oObjectName, "jdbcMinConnPool", p_Form.getJdbcMinConnPool()); 88 setIntegerAttribute(oObjectName, "jdbcMaxWaitTime", p_Form.getJdbcMaxWaitTime()); 89 setIntegerAttribute(oObjectName, "jdbcMaxWaiters", p_Form.getJdbcMaxWaiters()); 90 setIntegerAttribute(oObjectName, "jdbcSamplingPeriod", p_Form.getJdbcSamplingPeriod()); 91 } 92 93 protected void save(DatasourceForm p_Form, String domainName, String serverName) 94 throws Exception { 95 JonasManagementRepr.invoke(J2eeObjectName.getJDBCDataSource(domainName, serverName, p_Form.getDatasourceName()) 97 , "saveConfig", null, null); 98 } 99 100 } 101 | Popular Tags |