FileDocCategorySizeDatePackage
RequestStartAccessObjectImpl.javaAPI DocGlassfish v2 API6289Fri May 04 22:24:18 BST 2007com.sun.enterprise.admin.monitor.callflow

RequestStartAccessObjectImpl

public class RequestStartAccessObjectImpl extends AbstractTableAccessObject
author
Harpreet Singh

Fields Summary
private static final Logger
logger
private static RequestStartAccessObjectImpl
_singletonRS
Constructors Summary
private RequestStartAccessObjectImpl()
Creates a new instance of RequestStartAccessObjectImpl


                
      
        String serverName = super.getServerInstanceName();        
        super.tableName = TableInfo.REQUEST_START_TABLE_NAME + 
                serverName.toUpperCase();
        super.setName ("RequestStart");        
    
Methods Summary
public booleancreateTable(java.sql.Connection connection)

        super.con = connection;
        return super.createTable(TableInfo.
                CREATE_TABLE_REQUEST_START_SQL, TableInfo.REQUEST_START_TABLE_NAME);
       
    
public booleandropTable(java.sql.Connection connection)

        super.con = connection;
        return super.createStatmentAndExecuteUpdate(TableInfo.
                DROP_TABLE_REQUEST_START_SQL, TableInfo.REQUEST_START_TABLE_NAME);
                

    
public java.lang.StringgetDeleteSQL()

        String newsql = super.updateSqlWithTableName (
                TableInfo.DELETE_FROM_TABLE_REQUEST_START_SQL,
                TableInfo.REQUEST_START_TABLE_NAME);
        return newsql;
    
public java.lang.StringgetInsertSQL()

        String newsql = super.updateSqlWithTableName(
                TableInfo.INSERT_INTO_TABLE_REQUEST_START_SQL, 
                TableInfo.REQUEST_START_TABLE_NAME);
        return newsql;
    
public static synchronized TableAccessObjectgetInstance()

        if(_singletonRS == null)
            _singletonRS = new RequestStartAccessObjectImpl ();
        
        return _singletonRS;
    
public booleaninsert(java.sql.PreparedStatement pstmt, TransferObject[] requestStart)

        // sanity
        if (pstmt == null)
            return false;
            
        boolean result = false;
        try{
            for (int i = 0 ; i<requestStart.length; i++) {
                RequestStartTO request = (RequestStartTO)requestStart[i];
                pstmt.setString(1, request.getRequestId());
                pstmt.setLong(2, request.getTimeStamp());
                pstmt.setLong (3, request.getTimeStampMillis());
                if(request.getRequestType() != null)
                    pstmt.setString(4, request.getRequestType().toString());
                else
                    pstmt.setString(4, null);
                if (request.getIpAddress() != null)
                    pstmt.setString(5, request.getIpAddress());
                else 
                    pstmt.setString (5, null);
                
                pstmt.addBatch();
            }
            int[] updated = pstmt.executeBatch();
            result =  (updated.length == requestStart.length)? true : false;
            addTotalEntriesProcessed(updated.length);            
            if (isTraceOn()){
                logger.log(Level.INFO, "Callflow: RequestStartAccessObjectImpl " +
                        " Attempting to Insert : " + requestStart.length +
                        " Inserted "+updated.length+ " rows."+
                        " Total Entries written so far:  "+ 
                        getTotalEntriesProcessed());
            }
            
            if (result == false){
                logger.log(Level.WARNING, "callflow.error_insert_row");
            }
        }  catch(BatchUpdateException bue) {
            // log it
            logger.log(Level.FINE, "Error inserting data into CallFlow tables", bue);
            result = false;
        }catch (SQLException se) {
            // log it
            logger.log(Level.FINE, "Error inserting data into CallFlow tables", se);
            result = false;
        }
        return result;