| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/Oracle/OCI/include/occiAQ.h
Go to the documentation of this file.

    00001 /* Copyright (c) 2002, 2003, Oracle Corporation.  All rights reserved.  */
    00002
    00003 /*
    00004    NAME
    00005      occiAQ.h - Header file for occi AQ classes
    00006
    00007    DESCRIPTION
    00008      Class declarations for Producer, Consumer, Message, Agent
    00009      Listener, Subscription
    00010
    00011    RELATED DOCUMENTS
    00012      <note any documents related to this facility>
    00013
    00014    EXPORT FUNCTION(S)
    00015      <external functions declared for use outside package - one-line
    00016      descriptions>
    00017
    00018    INTERNAL FUNCTION(S)
    00019      <other external functions declared - one-line descriptions>
    00020
    00021    EXAMPLES
    00022
    00023    NOTES
    00024      <other useful comments, qualifications, etc.>
    00025
    00026    MODIFIED   (MM/DD/YY)
    00027    cparampa    10/12/02 - creation
    00028
    00029 */
    00030
    00031 #ifndef _olint   /* disable olint check */
    00032
    00033 #ifndef OCCIAQ_ORACLE
    00034 # define OCCIAQ_ORACLE
    00035
    00036 #ifndef OCCICOMMON_ORACLE
    00037 #include <occiCommon.h>
    00038 #endif
    00039
    00040 namespace oracle {
    00041 namespace occi {
    00042 namespace aq{
    00043
    00044 /*---------------------------------------------------------------------------
    00045                      PUBLIC TYPES AND CONSTANTS
    00046   ---------------------------------------------------------------------------*/
    00047
    00048 class Message
    00049 {
    00050   public:
    00051
    00052      enum MessageState
    00053      {
    00054         MSG_READY = OCI_MSG_READY,
    00055         MSG_WAITING = OCI_MSG_WAITING,
    00056         MSG_PROCESSED = OCI_MSG_PROCESSED,
    00057         MSG_EXPIRED = OCI_MSG_EXPIRED
    00058      };
    00059      enum PayloadType
    00060      {
    00061         RAW,
    00062         ANYDATA,
    00063         OBJECT
    00064      };
    00065
    00066      Message( const Environment *env );
    00067      Message( const Message& rhs);
    00068      ~Message();
    00069
    00070      void operator=(const Message& rhs);
    00071      int getAttemptsToDequeue() const ;
    00072      void setCorrelationId( const OCCI_STD_NAMESPACE::string& corr_id ) ;
    00073      OCCI_STD_NAMESPACE::string getCorrelationId() const ;
    00074      void setDelay( int delay ) ;
    00075      int getDelay() const ;
    00076      Date getMessageEnqueuedTime() const ;
    00077      void setExceptionQueueName( const OCCI_STD_NAMESPACE::string& queue ) ;
    00078      OCCI_STD_NAMESPACE::string getExceptionQueueName() const ;
    00079      void setExpiration( int exp ) ;
    00080      int getExpiration() const ;
    00081      MessageState getMessageState() const ;
    00082      void setPriority( int priority ) ;
    00083      int getPriority() const ;
    00084      void setRecipientList( OCCI_STD_NAMESPACE::vector<Agent>& ag_list ) ;
    00085      void setSenderId( const Agent& sender ) ;
    00086      Agent getSenderId() const ;
    00087      void setOriginalMessageId( const Bytes& queue ) ;
    00088      Bytes getOriginalMessageId() const ;
    00089      void setNull();
    00090      bool isNull() const;
    00091
    00092      void setBytes( const Bytes& bytes);
    00093      void setObject( PObject* pobj);
    00094      void setAnyData( const AnyData& any);
    00095
    00096      Bytes getBytes() const ;
    00097      PObject *getObject() ;
    00098      AnyData getAnyData() const ;
    00099
    00100      PayloadType getPayloadType( ) const;
    00101
    00102    private:
    00103      Ptr<MessageImpl> ptr;
    00104      OCIAQMsgProperties* getOCIMsgProperties() const;
    00105      Message( const Environment *env, const Connection *con,
    00106           OCIAQMsgProperties *msgprop, void *data, unsigned int dataLen,
    00107           PayloadType pType);
    00108      friend class ConsumerImpl;
    00109      friend class ProducerImpl;
    00110      friend class NotifyResult;
    00111 };
    00112
    00113 class Producer
    00114 {
    00115    public:
    00116
    00117      enum EnqueueSequence
    00118      {
    00119        ENQ_BEFORE = OCI_ENQ_BEFORE,
    00120        ENQ_TOP    = OCI_ENQ_TOP
    00121      };
    00122      enum Visibility
    00123      {
    00124        ENQ_IMMEDIATE = OCI_ENQ_IMMEDIATE,
    00125        ENQ_ON_COMMIT = OCI_ENQ_ON_COMMIT
    00126      };
    00127
    00128      Producer( const Connection *conn );
    00129      Producer( const Connection *conn,
    00130                const OCCI_STD_NAMESPACE::string& queue );
    00131      Producer( const Producer& rhs);
    00132      ~Producer();
    00133
    00134      void operator=(const Producer& prod);
    00135      void setRelativeMessageId( const Bytes& msgid );
    00136      Bytes getRelativeMessageId() const;
    00137      void setSequenceDeviation( EnqueueSequence option );
    00138      EnqueueSequence getSequenceDeviation() const;
    00139      void setVisibility( Visibility option );
    00140      Visibility getVisibility() const;
    00141      void setQueueName( const OCCI_STD_NAMESPACE::string& queue );
    00142      OCCI_STD_NAMESPACE::string getQueueName() const;
    00143      void setTransformation( const OCCI_STD_NAMESPACE::string& fName);
    00144      OCCI_STD_NAMESPACE::string getTransformation() const;
    00145      Bytes send( Message& msg, const OCCI_STD_NAMESPACE::string& queue );
    00146      Bytes send( Message& msg );
    00147      void setNull();
    00148      bool isNull() const;
    00149
    00150   private:
    00151      Ptr<ProducerImpl> ptr;
    00152 };
    00153
    00154 class Consumer
    00155 {
    00156    public:
    00157
    00158      enum DequeueMode
    00159      {
    00160        DEQ_BROWSE  = OCI_DEQ_BROWSE,
    00161        DEQ_LOCKED  = OCI_DEQ_LOCKED,
    00162        DEQ_REMOVE  = OCI_DEQ_REMOVE,
    00163        DEQ_REMOVE_NODATA = OCI_DEQ_REMOVE_NODATA
    00164      };
    00165      enum Navigation
    00166      {
    00167        DEQ_FIRST_MSG        = OCI_DEQ_FIRST_MSG,
    00168        DEQ_NEXT_TRANSACTION = OCI_DEQ_NEXT_TRANSACTION,
    00169        DEQ_NEXT_MSG         = OCI_DEQ_NEXT_MSG
    00170      };
    00171      enum Visibility
    00172      {
    00173        DEQ_IMMEDIATE = OCI_DEQ_IMMEDIATE,
    00174        DEQ_ON_COMMIT = OCI_DEQ_ON_COMMIT
    00175      };
    00176      enum
    00177      {
    00178        DEQ_WAIT_FOREVER = OCI_DEQ_WAIT_FOREVER,
    00179        DEQ_NO_WAIT      = OCI_DEQ_NO_WAIT
    00180      };
    00181
    00182      Consumer( const Connection *conn );
    00183      Consumer( const Connection * conn, const Agent& agent);
    00184      Consumer( const Connection *conn,
    00185                const OCCI_STD_NAMESPACE::string& queue );
    00186      Consumer(const Consumer& con);
    00187      ~Consumer();
    00188
    00189      void operator=(const Consumer& con);
    00190      void setAgent(const Agent& agent);
    00191      void setConsumerName( const OCCI_STD_NAMESPACE::string& name );
    00192      OCCI_STD_NAMESPACE::string getConsumerName() const;
    00193      void setCorrelationId( const OCCI_STD_NAMESPACE::string& cor_id );
    00194      OCCI_STD_NAMESPACE::string getCorrelationId() const;
    00195      void setDequeueMode( DequeueMode mode );
    00196      DequeueMode getDequeueMode() const;
    00197      void setMessageIdToDequeue( const Bytes& msgid );
    00198      Bytes getMessageIdToDequeue() const;
    00199      void setPositionOfMessage( Navigation pos );
    00200      Navigation getPositionOfMessage() const;
    00201      void setVisibility( Visibility option );
    00202      Visibility getVisibility() const;
    00203      void setWaitTime( unsigned int wait );
    00204      unsigned int getWaitTime() const;
    00205      void setQueueName( const OCCI_STD_NAMESPACE::string& queue );
    00206      OCCI_STD_NAMESPACE::string getQueueName() const;
    00207      void setTransformation( const OCCI_STD_NAMESPACE::string& fName);
    00208      OCCI_STD_NAMESPACE::string getTransformation() const;
    00209      Message receive( Message::PayloadType pType,
    00210                       const OCCI_STD_NAMESPACE::string& type="",
    00211                       const OCCI_STD_NAMESPACE::string& schema="");
    00212      void setNull();
    00213      bool isNull() const;
    00214
    00215    private:
    00216      Ptr<ConsumerImpl> ptr;
    00217 };
    00218
    00219 class Agent
    00220 {
    00221    public:
    00222      Agent( const Environment *env );
    00223      Agent( const Environment *env,
    00224             const OCCI_STD_NAMESPACE::string& name,
    00225             const OCCI_STD_NAMESPACE::string& address,
    00226             unsigned int protocol=0 ) ;
    00227      Agent(const Agent& a);
    00228      ~Agent() ;
    00229
    00230      void operator=(const Agent& a);
    00231      void setName( const OCCI_STD_NAMESPACE::string& name );
    00232      OCCI_STD_NAMESPACE::string getName() const;
    00233      void setAddress( const OCCI_STD_NAMESPACE::string& addr );
    00234      OCCI_STD_NAMESPACE::string getAddress() const;
    00235      void setProtocol(unsigned int protocol = 0);
    00236      unsigned int getProtocol() const;
    00237      void setNull();
    00238      bool isNull() const;
    00239      OCIAQAgent* getOCIAQAgent() const;
    00240
    00241    private:
    00242      Ptr<AgentImpl> ptr;
    00243      Agent( const Environment *env, OCIAQAgent *rhs, bool toFree = false );
    00244      friend class Listener;
    00245      friend class MessageImpl;
    00246 };
    00247
    00248 class Listener
    00249 {
    00250    public:
    00251      Listener( const Connection *conn );
    00252      Listener( const Connection *conn,
    00253                OCCI_STD_NAMESPACE::vector<Agent> &agList,
    00254                int waitTime=0 );
    00255      ~Listener();
    00256
    00257      Agent listen();
    00258      void setAgentList(OCCI_STD_NAMESPACE::vector<Agent> &agList);
    00259      void setTimeOutForListen(int waitTime);
    00260      OCCI_STD_NAMESPACE::vector<Agent> getAgentList() const;
    00261      int getTimeOutForListen() const;
    00262
    00263    private:
    00264      const ConnectionImpl *conn;
    00265      OCIAQAgent** agentList;
    00266      unsigned int numAgents;
    00267      int timeOut;
    00268      void *listenerExt;
    00269 };
    00270
    00271
    00272 class Subscription
    00273 {
    00274   public:
    00275     enum Presentation
    00276     {
    00277        PRES_DEFAULT = OCI_SUBSCR_PRES_DEFAULT,
    00278        PRES_XML = OCI_SUBSCR_PRES_XML
    00279     };
    00280     enum Protocol
    00281     {
    00282        PROTO_CBK = OCI_SUBSCR_PROTO_OCI,
    00283        PROTO_MAIL = OCI_SUBSCR_PROTO_MAIL,
    00284        PROTO_SERVER = OCI_SUBSCR_PROTO_SERVER,
    00285        PROTO_HTTP = OCI_SUBSCR_PROTO_HTTP
    00286     };
    00287     enum Namespace
    00288     {
    00289        NS_ANONYMOUS = OCI_SUBSCR_NAMESPACE_ANONYMOUS,
    00290        NS_AQ = OCI_SUBSCR_NAMESPACE_AQ
    00291     };
    00292
    00293     Subscription(const Environment* env);
    00294     Subscription(const Environment* env, OCISubscription* sub);
    00295     Subscription(const Subscription& sub);
    00296     ~Subscription();
    00297
    00298     void operator=(const Subscription& sub);
    00299     unsigned int getDatabaseServersCount() const;
    00300     void setDatabaseServerNames(
    00301         const OCCI_STD_NAMESPACE::vector<OCCI_STD_NAMESPACE::string>& dbsrv);
    00302     OCCI_STD_NAMESPACE::vector<OCCI_STD_NAMESPACE::string>
    00303                       getDatabaseServerNames() const ;
    00304     void setNotifyCallback(unsigned int (*callback)(Subscription& sub,
    00305                                                     NotifyResult *nr));
    00306     unsigned int  (*getNotifyCallback() const)(Subscription& sub,
    00307                                                NotifyResult *nr);
    00308     void setCallbackContext(void* ctx);
    00309     void* getCallbackContext() const;
    00310     void setSubscriptionName(const OCCI_STD_NAMESPACE::string& name);
    00311     OCCI_STD_NAMESPACE::string getSubscriptionName() const ;
    00312     void setSubscriptionNamespace(Namespace nameSpace);
    00313     Namespace getSubscriptionNamespace() const ;
    00314     void setPayload(const Bytes& payload);
    00315     Bytes getPayload() const ;
    00316     void setRecipientName( const OCCI_STD_NAMESPACE::string& name);
    00317     OCCI_STD_NAMESPACE::string getRecipientName() const;
    00318     void setPresentation( Presentation pres) ;
    00319     Presentation getPresentation() const ;
    00320     void setProtocol( Protocol prot) ;
    00321     Protocol getProtocol() const ;
    00322     OCISubscription* getOCISubscription() const;
    00323     void setNull();
    00324     bool isNull() const;
    00325     Environment* getEnvironment() const;
    00326
    00327   private:
    00328     Ptr<SubscriptionImpl> ptr;
    00329 };
    00330
    00331 class NotifyResult
    00332 {
    00333    public:
    00334      Bytes getPayload() const;
    00335      Message getMessage() const;
    00336      Bytes getMessageId() const;
    00337      OCCI_STD_NAMESPACE::string getConsumerName() const;
    00338      OCCI_STD_NAMESPACE::string getQueueName() const;
    00339
    00340   private:
    00341      const EnvironmentImpl *env;
    00342      void *payload;
    00343      unsigned int payloadLen;
    00344      dvoid *desc;
    00345      ub4 mode;
    00346      void *notifyResultExt;
    00347
    00348      //private constructor
    00349      NotifyResult(const Environment *env, void *payload, ub4 payloadLen,
    00350                   void *pdescriptor, ub4 mode);
    00351
    00352      friend class SubscriptionImpl;
    00353 };
    00354
    00355 /*---------------------------------------------------------------------------
    00356                      PRIVATE TYPES AND CONSTANTS
    00357   ---------------------------------------------------------------------------*/
    00358
    00359
    00360 /*---------------------------------------------------------------------------
    00361                            EXPORT FUNCTIONS
    00362   ---------------------------------------------------------------------------*/
    00363
    00364
    00365 /*---------------------------------------------------------------------------
    00366                           INTERNAL FUNCTIONS
    00367   ---------------------------------------------------------------------------*/
    00368 } /* end of namespace aq */
    00369 } /* end of namespace occi */
    00370 } /* end of namespace oracle */
    00371
    00372 #endif                                              /* OCCIAQ_ORACLE */
    00373
    00374 #endif                                              /* _olint */

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines