javacommons/javastorage/src.linux/client/javadataaccessimpl.h
branchRCL_3
changeset 18 9ac0a0a7da70
parent 17 0fd27995241b
child 19 71c436fe3ce0
equal deleted inserted replaced
17:0fd27995241b 18:9ac0a0a7da70
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  JavaDataAccessImpl
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef JAVADATAACCESSIMPL_H
       
    20 #define JAVADATAACCESSIMPL_H
       
    21 
       
    22 #include <memory>
       
    23 
       
    24 #include "javadataaccess.h"
       
    25 #include "javaosheaders.h"
       
    26 
       
    27 namespace java
       
    28 {
       
    29 namespace comms
       
    30 {
       
    31 class CommsClientEndpoint;
       
    32 class CommsMessage;
       
    33 }    // end namespace comms
       
    34 namespace storage
       
    35 {
       
    36 
       
    37 /**
       
    38  * JavaDataAccessImpl implements JavaDataAccess interface.
       
    39  */
       
    40 class JavaDataAccessImpl : public JavaDataAccess
       
    41 {
       
    42 
       
    43     friend class JavaDataAccess;
       
    44 
       
    45 public:
       
    46     /**
       
    47      * Destructor. If destructor is called while having active connection
       
    48      * Connection is rollbacked and closed before closing comms connection
       
    49      * to storage server.
       
    50      */
       
    51     OS_IMPORT virtual ~JavaDataAccessImpl();
       
    52 
       
    53     /**
       
    54      * Open connection to given storage. Send connection open comms mesasge to
       
    55      * storage server and caches received session ID to disconnect connection
       
    56      * gracefully at error situation.
       
    57      *
       
    58      * @param aHeaders connection headers.
       
    59      * @param aStorageName storage name.
       
    60      * @param aReceiveMessage received comms message.
       
    61      * @throws JavaStorageException if communication fails.
       
    62      */
       
    63     OS_IMPORT virtual void open(const std::string& aHeaders,
       
    64                                 const std::string& aStorageName,
       
    65                                 comms::CommsMessage& aReceivedMessage)
       
    66     throw(JavaStorageException);
       
    67 
       
    68     /**
       
    69      * Send close message to storage server.
       
    70      *
       
    71      * @param aHeaders connection headers.
       
    72      * @param aReceiveMessage received comms message.
       
    73      * @throws JavaStorageException if communication fails.
       
    74      */
       
    75     OS_IMPORT virtual void close(const std::string& aHeaders,
       
    76                                  comms::CommsMessage& aReceivedMessage)
       
    77     throw(JavaStorageException);
       
    78 
       
    79     /**
       
    80      * Send SQL statement to storage server for execution.
       
    81      *
       
    82      * @param aHeaders connection headers.
       
    83      * @param aSqlStatement SQL statement.
       
    84      * @param aReceiveMessage received comms message.
       
    85      * @throws JavaStorageException if communication fails.
       
    86      */
       
    87     OS_IMPORT virtual void execute(const std::string& aHeaders,
       
    88                                    const std::wstring& aSqlStatement,
       
    89                                    comms::CommsMessage& aReceivedMessage)
       
    90     throw(JavaStorageException);
       
    91 
       
    92 private:
       
    93     /**
       
    94      * Constructor. Initiate comms connection to storage server
       
    95      *
       
    96      * @throws JavaStorageException if cannot connect to storage server using
       
    97      * comms.
       
    98      */
       
    99     JavaDataAccessImpl() throw(JavaStorageException);
       
   100 
       
   101     /**
       
   102      * Send and receive comms messages.
       
   103      *
       
   104      * @param aSendMessage message to be sent.
       
   105      * @param aReceivedMessage received message.
       
   106      * @throws JavaStorageException if communication fails. Exception is thrown
       
   107      * if comms returns error code. Comms error code is set as exception error
       
   108      * code.
       
   109      */
       
   110     void sendReceiveMessage(comms::CommsMessage& aSendMessage,
       
   111                             comms::CommsMessage& aReceivedMessage)
       
   112     throw(JavaStorageException);
       
   113 
       
   114 private:
       
   115     std::auto_ptr<comms::CommsClientEndpoint> mCliConn;
       
   116     bool mConnOpen;
       
   117     std::string mCachedSessionID;
       
   118 };
       
   119 
       
   120 } // end namespace storage
       
   121 } // end namespace java
       
   122 
       
   123 #endif // JAVADATAACCESSIMPL_H
       
   124