1 package enhydraManager.business; 2 3 import java.util.Vector ; 4 import java.util.Enumeration ; 5 import java.util.Hashtable ; 6 import com.lutris.appserver.server.httpPresentation.servlet.*; 7 8 import com.lutris.appserver.server.*; 9 import com.lutris.appserver.server.session.*; 10 import enhydraManager.spec.*; 11 import com.lutris.appserver.server.sessionContainerAdapter.*; 12 13 import javax.servlet.*; 14 15 import org.apache.catalina.*; 16 import org.apache.catalina.core.*; 17 import org.apache.catalina.core.StandardContext; 18 import org.apache.catalina.session.ManagerBase; 19 20 public class ApplicationListImpl implements ApplicationList{ 21 22 23 24 public String [] getServices() 25 { 26 return GlobalImpl.getServices(); 27 } 28 29 30 public Vector [] getList(String service) throws Exception { 31 Vector hostNames=GlobalImpl.getHostNames(service); 32 33 Vector [] konacno= new Vector [2]; 34 konacno[0] = new Vector (); 35 konacno[1] = new Vector (); 36 37 38 39 40 for(int r=0;r<hostNames.size();r++){ 41 42 konacno[0].add(hostNames.elementAt(r)); 43 44 Vector [] result = new Vector [4]; 45 result[0] = new Vector (); 46 result[1] = new Vector (); 47 result[2] = new Vector (); 48 result[3] = new Vector (); 49 50 Vector [] temp=GlobalImpl.getServletNames((String )hostNames.elementAt(r),service); 51 52 SessionManager sessionManager = null; 53 54 55 56 String tempName=null; 57 58 StandardContext sc=null; 59 Servlet s = null; 60 Application app = null; 61 62 63 64 for(int k=0;k<temp[0].size();k++){ 65 66 67 tempName=(String )temp[0].elementAt(k); 68 69 70 boolean jump=true; 71 String started=(String )temp[2].elementAt(k); 72 73 74 75 76 if( started.equals("Stoped") ) 77 { 78 if(tempName.equals("")) 79 tempName="/"; 80 result[0].addElement(tempName); 81 result[1].addElement(new Integer (0)); 82 result[3].addElement("Stoped"); 83 84 85 String deployed=(String )temp[1].elementAt(k); 86 if( deployed.equals("UnDeployed") ) 87 { 88 result[2].addElement("UnDeployed"); 89 90 } 91 else 92 { 93 result[2].addElement("Deployed"); 94 95 } 96 jump=false; 97 } 98 99 100 if(jump){ 101 102 103 sc=GlobalImpl.getServlet(service,(String )hostNames.elementAt(r),tempName); 104 105 106 try{ 107 108 Container[] wrappers=sc.findChildren(); 109 StandardWrapper sw=(StandardWrapper)wrappers[0]; 110 111 112 s=sw.allocate(); 113 114 if (s instanceof HttpPresentationServlet){ 115 116 app = ((HttpPresentationServlet)s).getApplication(); 117 try { 118 sessionManager = app.getSessionManager(); 119 120 121 if ((sessionManager instanceof ContainerAdapterSessionManager) || (sessionManager instanceof JmxContainerAdapterSessionManager)){ 122 123 Manager manager=sc.getManager(); 124 org.apache.catalina.Session[] ses= manager.findSessions(); 125 Integer o = new Integer (ses.length); 126 127 result[1].addElement(o); 128 129 }else{ 130 Integer o = new Integer (sessionManager.activeSessionCount()); 131 132 result[1].addElement(o); 133 134 } 135 136 137 138 } catch (Exception ex){ 139 System.out.println("Couldn't get number of active sessions for "+tempName+" application!"); 140 141 } 142 } else{ 143 try{ 144 Manager manager=sc.getManager(); 145 org.apache.catalina.Session[] ses= manager.findSessions(); 146 Integer num = new Integer (ses.length); 147 148 result[1].addElement(num); 149 } catch (Exception ex){ 150 System.out.println("Couldn't get number of active sessions for "+tempName+" application!"); 151 152 } 153 154 } 155 156 157 if(tempName.equals("")) 158 tempName="/"; 159 160 161 result[0].addElement(tempName); 162 result[2].addElement("Deployed"); 163 result[3].addElement("Started"); 164 165 166 sw.deallocate(s); 167 168 169 170 }catch(ServletException e){ 171 System.out.println("Couldn't acess to servlet :"+tempName+" !"); 172 } 173 } 174 } konacno[1].add(result); 176 } return konacno; 178 }} 180 181 | Popular Tags |