Adding declarations to a CORBA servant class definition (servant.ih)

Why and when to perform this task

Use this task to add declarations for class variables, constructors, and destructors for a CORBA servant class to its skeleton implementation header file, servant.ih. This defines any private data members for the implementation code in the associated servant_I.cpp file.

This task follows the task to compile the servant.idl file, which defines the public interface for the server implementation class. For more information about compiling the IDL file, which creates the servant.ih file, see Compiling the servant IDL (using idlc).

Steps for this task

  1. At a command line change to the directory that contains the servant.ih file, where servant is the name of the servant class.
  2. Edit the implementation header file, servant.ih, to add appropriate declarations for class variables, constructors, and destructors. For more information about the types of declarations that you can add to an implementation header file, see IDL type declarations.
    For example, the idlc command, idlc -ehh:ih:ic:uc:sc -mdllname=WSLogger WSLogger.idl, converts the following interface declaration to the class declaration in the WSLogger.ih file. The WSLogger.ih file was edited to add the extra declarations that are shown in bold in the following example:
    Example: WSLogger interface and declarations added to the skeleton implementation header
    Interface declaration in WSLogger.idl Implementation header in WSLogger.ih
     interface WSLogger {
       void setFileName(in string newFileName);
       string getFileName();
       void setMethodName( in string newMethodName );
       string getMethodName();
       short openLogFile();
       short closeLogFile();
       short writeLogMessage(in string newMessage, in short newSeverity);
       const short DMY_DATE_FORMAT = 1;
       const short MDY_DATE_FORMAT = 2;
       void setDateFormat(in unsigned short newDateFormat);
       unsigned short getDateFormat();
     };
    
     class WSLogger_Impl : public virtual ::WSLogger_Skeleton {
         public:
          ::CORBA::Void setFileName (const char* newFileName);  
          char*  getFileName ();
          ::CORBA::Void setMethodName (const char* newMethodName);
          char*  getMethodName ();
          ::CORBA::Short openLogFile ();
          ::CORBA::Short closeLogFile ();
          ::CORBA::Short writeLogMessage (const char* newMessage, ::CORBA::Short newSeverity);
          ::CORBA::Void setDateFormat (::CORBA::UShort newDateFormat);
          ::CORBA::UShort getDateFormat ();  
    
        private:
          char * fileName;
          char * methodName;
          ::CORBA::UShort dateFormat;
          ofstream logFile;      
          ::CORBA::UShort logFileOpen;
        public:  
          WSLogger_Impl( char * newFileName );
          virtual ~WSLogger_Impl(); 
    
     };
    


Results

What to do next

Add code to the skeleton implementation definition, servant_I.cpp, to implement the business logic as described in Completing the server implementation (server_I.cpp).

Related tasks
Developing a CORBA C++ server
Compiling a CORBA server implementation class IDL (using idlc)
IDL type declarations
Completing the CORBA servant implementation (servant_I.cpp)



Searchable topic ID:   tcor_pgms3
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/corba/tasks/tcor_pgms3.html

Library | Support | Terms of Use | Feedback