1 25 26 package org.objectweb.jonas.webapp.jonasadmin.resource; 27 28 import java.io.IOException ; 29 import java.util.ArrayList ; 30 import java.util.Collections ; 31 import java.util.Iterator ; 32 33 import javax.servlet.ServletException ; 34 import javax.servlet.http.HttpServletRequest ; 35 import javax.servlet.http.HttpServletResponse ; 36 37 import org.apache.struts.action.ActionForm; 38 import org.apache.struts.action.ActionForward; 39 import org.apache.struts.action.ActionMapping; 40 import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx; 41 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction; 42 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou; 43 import org.objectweb.jonas.webapp.jonasadmin.service.db.DatasourceItem; 44 import org.objectweb.jonas.webapp.jonasadmin.service.db.DatasourceItemByNameComparator; 45 46 49 50 public class ListDatasourcesAction extends JonasBaseAction { 51 52 54 public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form 55 , HttpServletRequest p_Request, HttpServletResponse p_Response) 56 throws IOException , ServletException { 57 58 try { 60 WhereAreYou oWhere = (WhereAreYou) p_Request.getSession().getAttribute(WhereAreYou. 61 SESSION_NAME); 62 ArrayList alDeployable = JonasAdminJmx.getDatasourceFilesDeployable(); 63 ArrayList alDeployed = JonasAdminJmx.getDatasourceFilesDeployed(oWhere.getCurrentDomainName(), oWhere.getCurrentJonasServerName()); 64 65 ArrayList al = new ArrayList (); 66 String sName; 67 boolean bDeployed; 68 Iterator it = alDeployable.iterator(); 69 while (it.hasNext()) { 70 sName = it.next().toString(); 71 bDeployed = alDeployed.contains(sName); 72 al.add(new DatasourceItem(sName, bDeployed)); 73 } 74 Collections.sort(al, new DatasourceItemByNameComparator()); 75 p_Request.setAttribute("listDatasources", al); 77 } 78 catch (Throwable t) { 79 addGlobalError(t); 80 saveErrors(p_Request, m_Errors); 81 return (p_Mapping.findForward("Global Error")); 82 } 83 return (p_Mapping.findForward("Datasources")); 85 } 86 } 87 | Popular Tags |