KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > monitor > callflow > EndTimeAccessObjectImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * EndTimeAccessObjectImpl.java
26  *
27  * Created on August 3, 2005, 2:15 PM
28  */

29
30 package com.sun.enterprise.admin.monitor.callflow;
31
32 import java.sql.BatchUpdateException JavaDoc;
33 import java.sql.Connection JavaDoc;
34 import com.sun.enterprise.admin.monitor.callflow.TableInfo;
35 import com.sun.enterprise.admin.monitor.callflow.AbstractTableAccessObject;
36 import java.sql.SQLException JavaDoc;
37 import java.util.logging.Level JavaDoc;
38 import java.util.logging.Logger JavaDoc;
39 import com.sun.enterprise.admin.common.constant.AdminConstants;
40 /**
41  * Access Object to access END_TIME_TBL.
42  * Table is created to store the timing information whenever a
43  * container transitions to another container or the application code
44  * Table is used to calculate the Pie Chart information for time
45  * spent in individual containers as well as time spent in an end
46  * user application code.
47  * @author Harpreet Singh
48  */

49 public class EndTimeAccessObjectImpl extends AbstractTableAccessObject{
50     private static final Logger JavaDoc logger =
51             Logger.getLogger(AdminConstants.kLoggerName);
52
53     private static EndTimeAccessObjectImpl _singletonET;
54     
55     /** Creates a new instance of EndTimeAccessObjectImpl */
56     private EndTimeAccessObjectImpl() {
57         String JavaDoc serverName = super.getServerInstanceName();
58         super.tableName = TableInfo.END_TIME_TABLE_NAME +
59                 serverName.toUpperCase();
60     }
61
62     public static TableAccessObject getInstance() {
63         if(_singletonET == null)
64             _singletonET = new EndTimeAccessObjectImpl();
65         return _singletonET;
66     }
67     public boolean insert(java.sql.PreparedStatement JavaDoc pstmt, TransferObject[] transferObject) {
68        // sanity
69
if (pstmt == null)
70             return false;
71         boolean result = false;
72         try{
73             
74             for (int i = 0 ; i<transferObject.length; i++) {
75                 EndTimeTO endTimeTO = (EndTimeTO)transferObject[i];
76                 pstmt.setString(1, endTimeTO.getRequestId());
77                 pstmt.setLong(2, endTimeTO.getTimeStamp());
78                 pstmt.setString(
79                         3, endTimeTO.getContainerTypeOrApplicationType());
80                 pstmt.addBatch();
81             }
82             int[] updated = pstmt.executeBatch();
83             result = (updated.length == transferObject.length)? true : false;
84         } catch(BatchUpdateException JavaDoc bue) {
85             // log it
86
logger.log(Level.FINE, "Error inserting data into CallFlow tables", bue);
87             result = false;
88         }catch (SQLException JavaDoc se) {
89             // log it
90
logger.log(Level.FINE, "Error inserting data into CallFlow tables", se);
91             result = false;
92         }
93         return result;
94     }
95
96     public boolean dropTable(java.sql.Connection JavaDoc connection) {
97         super.con = connection;
98         return super.createStatmentAndExecuteUpdate(
99                 TableInfo.DROP_TABLE_END_TIME_SQL,
100                 TableInfo.END_TIME_TABLE_NAME);
101     }
102
103     public boolean createTable(java.sql.Connection JavaDoc connection) {
104         super.con = connection;
105         return super.createTable(
106                 TableInfo.CREATE_TABLE_END_TIME_SQL,
107                 TableInfo.END_TIME_TABLE_NAME);
108         
109     }
110
111     public String JavaDoc getInsertSQL() {
112         String JavaDoc newsql = super.updateSqlWithTableName(
113                 TableInfo.INSERT_INTO_TABLE_END_TIME_SQL,
114                 TableInfo.END_TIME_TABLE_NAME);
115         return newsql;
116     }
117
118     public String JavaDoc getDeleteSQL () {
119         String JavaDoc newsql = super.updateSqlWithTableName (
120                 TableInfo.DELETE_FROM_TABLE_END_TIME_SQL,
121                 TableInfo.END_TIME_TABLE_NAME);
122         return newsql;
123     }
124     
125 }
126
127
Popular Tags