KickJava   Java API By Example, From Geeks To Geeks.

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


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  * RequestEndAccessObjectImpl.java
26  *
27  * Created on July 13, 2005, 6:36 PM
28  */

29
30 package com.sun.enterprise.admin.monitor.callflow;
31 import java.sql.BatchUpdateException JavaDoc;
32 import java.sql.Connection JavaDoc;
33 import com.sun.enterprise.admin.monitor.callflow.TableInfo;
34 import java.sql.SQLException JavaDoc;
35 import java.util.logging.Level JavaDoc;
36 import java.util.logging.Logger JavaDoc;
37 import com.sun.enterprise.admin.common.constant.AdminConstants;
38 /**
39  *
40  * @author Harpreet Singh
41  */

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