KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > enhydraManager > business > ApplicationListImpl


1 package enhydraManager.business;
2
3 import java.util.Vector JavaDoc;
4 import java.util.Enumeration JavaDoc;
5 import java.util.Hashtable JavaDoc;
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 JavaDoc[] getServices()
25     {
26      return GlobalImpl.getServices();
27     }
28   
29   
30     public Vector JavaDoc[] getList(String JavaDoc service) throws Exception JavaDoc {
31     Vector JavaDoc hostNames=GlobalImpl.getHostNames(service);
32      
33      Vector JavaDoc[] konacno= new Vector JavaDoc[2];
34               konacno[0] = new Vector JavaDoc();
35               konacno[1] = new Vector JavaDoc();
36        
37    
38    
39    
40     for(int r=0;r<hostNames.size();r++){
41        
42        konacno[0].add(hostNames.elementAt(r));
43        
44        Vector JavaDoc[] result = new Vector JavaDoc[4];
45        result[0] = new Vector JavaDoc();
46        result[1] = new Vector JavaDoc();
47        result[2] = new Vector JavaDoc();
48        result[3] = new Vector JavaDoc();
49        
50     Vector JavaDoc[] temp=GlobalImpl.getServletNames((String JavaDoc)hostNames.elementAt(r),service);
51  
52         SessionManager sessionManager = null;
53        
54      
55        
56        String JavaDoc 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 JavaDoc)temp[0].elementAt(k);
68      
69       
70      boolean jump=true;
71   String JavaDoc started=(String JavaDoc)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 JavaDoc(0));
82     result[3].addElement("Stoped");
83     
84   
85    String JavaDoc deployed=(String JavaDoc)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 JavaDoc)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 JavaDoc o = new Integer JavaDoc(ses.length);
126                 
127                result[1].addElement(o);
128                 
129             }else{
130                 Integer JavaDoc o = new Integer JavaDoc(sessionManager.activeSessionCount());
131               
132                 result[1].addElement(o);
133            
134                 }
135           
136         
137         
138             } catch (Exception JavaDoc 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 JavaDoc num = new Integer JavaDoc(ses.length);
147            
148         result[1].addElement(num);
149           } catch (Exception JavaDoc 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        }//servlets
175
konacno[1].add(result);
176       } //host-names
177
return konacno;
178     }//f-ja
179
}
180
181
Popular Tags