KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > vr > VRWatchAction


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6  
7 package com.raptus.vr;
8
9 import java.io.IOException JavaDoc;
10 import java.sql.*;
11
12 import javax.servlet.*;
13 import javax.servlet.http.*;
14 import javax.sql.DataSource JavaDoc;
15
16 import org.apache.struts.action.*;
17
18 import com.raptus.owxv3.*;
19
20 /**
21  *
22  * <hr>
23  * <table width="100%" border="0">
24  * <tr>
25  * <td width="24%"><b>Filename</b></td><td width="76%">VRWatchAction.java</td>
26  * </tr>
27  * <tr>
28  * <td width="24%"><b>Author</b></td><td width="76%">Guy Zürcher (gzuercher@raptus.com)</td>
29  * </tr>
30  * <tr>
31  * <td width="24%"><b>Date</b></td><td width="76%">2nd of February 2003</td>
32  * </tr>
33  * </table>
34  * <hr>
35  * <table width="100%" border="0">
36  * <tr
37  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
38  * </tr>
39  * </table>
40  * <hr>
41  */

42 public class VRWatchAction extends org.apache.struts.action.Action
43 {
44     /***
45      *
46      */

47     private static String JavaDoc VRWATCH_OWXV3 = "owxv3";
48     
49     /***
50      *
51      */

52     public ActionForward perform(ActionMapping mapping,
53                                  ActionForm form,
54                                  HttpServletRequest request,
55                                  HttpServletResponse response)
56                          throws IOException JavaDoc, ServletException
57     {
58         //
59
// Possible URL combinations:
60
//
61
// .../owxv3/vrmenu/watch.do?cmd=checkowx
62
// .../owxv3/vrmenu/watch.do?cmd=stopowx
63
// .../owxv3/vrmenu/watch.do?cmd=startowx
64
// .../owxv3/vrmenu/watch.do?cmd=restartowx
65
// .../owxv3/vrmenu/watch.do?cmd=sesscount
66
// .../owxv2/vrmenu/watch.do?cmd=checkowx
67
// .../owx/vrmenu/watch.do?cmd=checkowx
68
//
69

70         HttpSession session = request.getSession();
71         ServletContext context = session.getServletContext();
72         VRWatchBean myform = (VRWatchBean) form;
73         String JavaDoc cmd = myform.getCmd();
74         String JavaDoc owxid = context.getServletContextName().toLowerCase();
75         
76 /*
77         LoggingManager.log("SERVLETPATH : " + request.getServletPath(), this);
78         LoggingManager.log("REMOTEHOST : " + request.getRemoteHost(), this);
79         LoggingManager.log("REMOTEADDR : " + request.getRemoteAddr(), this);
80         LoggingManager.log("SERVERNAME : " + request.getServerName(), this);
81         LoggingManager.log("VALIDSESS : " + request.isRequestedSessionIdValid(), this);
82         LoggingManager.log("CONTEXTNAME : " + context.getServletContextName(), this);
83         LoggingManager.log("SERVERINFO : " + context.getServerInfo(), this);
84 */

85         
86         if(cmd.equals("checkowx"))
87         {
88             if(owxid.equals(VRWATCH_OWXV3))
89             {
90                 try
91                 {
92                     VModuleManager vmm = VModuleManager.getInstance();
93                     if(vmm == null)
94                         throw new ServletException("Problems with the VModuleManager");
95                     
96                     XMLConfigManager cm = XMLConfigManager.getInstance();
97                     if(cm != null)
98                     {
99                         String JavaDoc gresDatasrc = cm.getPropertyByTree("virtualhost/global_resource/property?name=datasource", "value");
100                         DataSource JavaDoc ds = servlet.findDataSource(gresDatasrc);
101                         Connection con = ds.getConnection();
102                         Statement stmt = con.createStatement();
103                         ResultSet rs = stmt.executeQuery("select count(*) from owxmsgs ;");
104                         while(rs.next())
105                             LoggingManager.log("Found " + rs.getInt(1) + " rows in owxmsgs table", this);
106                         
107                         LoggingManager.log("OWXV3 FOR " + request.getServerName() +
108                                            " IS FULLY FUNCTIONAL AT " + new java.util.Date JavaDoc(), this);
109                         
110                         myform.setResult("99VIRTUALHOSTOK99");
111                         return mapping.findForward("result");
112                     }
113                 }
114                 catch(Exception JavaDoc e) {
115                     LoggingManager.log("EXCEPTION! " + e.getMessage(), this);
116                 }
117             }
118         }
119             
120         return null;
121     }
122 }
123
124 // eof
125
Popular Tags