Svcconf_Handler.cpp

Go to the documentation of this file.
00001 // $Id: Svcconf_Handler.cpp 79066 2007-07-30 08:39:04Z johnnyw $
00002 
00003 #include "Svcconf_Handler.h"
00004 #include "ace/ACE.h"
00005 #include "ace/Log_Msg.h"
00006 #include "ace/Service_Config.h"
00007 #include "ace/Service_Types.h"
00008 #include "ace/Service_Repository.h"
00009 #include "ace/Service_Gestalt.h"
00010 #include "ace/DLL.h"
00011 #include "ace/ARGV.h"
00012 #include "ace/Module.h"
00013 #include "ace/OS_NS_strings.h"
00014 #include "ace/SString.h"
00015 
00016 #if (ACE_USES_CLASSIC_SVC_CONF == 0)
00017 
00018 #if !defined (__ACEXML_INLINE__)
00019 # include "Svcconf_Handler.inl"
00020 #endif /* __ACEXML_INLINE__ */
00021 
00022 ACEXML_Svcconf_Handler::ACEXML_Svcconf_Handler (void)
00023   : in_stream_def_ (0),
00024     in_module_ (0),
00025     stream_svc_type_ (0),
00026     stream_ (0)
00027 {
00028   // no-op
00029 }
00030 
00031 ACEXML_Svcconf_Handler::~ACEXML_Svcconf_Handler (void)
00032 {
00033   // no-op
00034 }
00035 
00036 void
00037 ACEXML_Svcconf_Handler::characters (const ACEXML_Char *,
00038                                     int,
00039                                     int ACEXML_ENV_ARG_DECL_NOT_USED)
00040 {
00041   // no-op
00042 }
00043 
00044 void
00045 ACEXML_Svcconf_Handler::endDocument ( ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
00046 {
00047   // no-op
00048 }
00049 
00050 void
00051 ACEXML_Svcconf_Handler::endElement (const ACEXML_Char *,
00052                                     const ACEXML_Char *,
00053                                     const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
00054 {
00055   if (ACE_OS::strcmp (qName, ACE_TEXT ("dynamic")) == 0)
00056     {
00057       ACE_Parsed_Info *active_info = (this->in_stream_def_ == 0 ?
00058                                       &this->parsed_info_ :
00059                                       &this->stream_info_);
00060 
00061       // We must allocate a string here to ensure that the
00062       // name is still available by the time the
00063       // ACE_Service_Type_Dynamic_Guard is destructed.
00064       ACE_TString name = active_info->name ();
00065       ACE_Service_Type_Dynamic_Guard dummy (
00066         *ACE_Service_Config::current ()->current_service_repository (),
00067         name.c_str ());
00068       ACE_DLL svc_dll;
00069 
00070       if (svc_dll.open (active_info->path ()) == -1)
00071         {
00072           // build the error message
00073           ACE_CString msg (ACE_TEXT ("Cannot locate DLL: '"));
00074           msg += ACE_CString (ACE_TEXT (active_info->path ()));
00075           msg += ACE_CString (ACE_TEXT ("' for entity '"));
00076           msg += ACE_CString (ACE_TEXT (active_info->name ()));
00077           msg += ACE_CString (ACE_TEXT ("'\n"));
00078 
00079           ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
00080         }
00081 
00082       void *(*func) (ACE_Service_Object_Exterminator *) = 0;
00083       ACE_Service_Object_Exterminator gobbler = 0;
00084       void *symbol = 0;
00085 
00086       long temp_ptr =
00087         reinterpret_cast<long> (svc_dll.symbol (active_info->init_func ()));
00088       func = reinterpret_cast<void *(*)(ACE_Service_Object_Exterminator *)> (temp_ptr);
00089 
00090       if (func == 0)
00091         {
00092           // build the error message
00093           ACE_CString msg (ACE_TEXT ("Cannot locate init function: '"));
00094           msg += ACE_CString (ACE_TEXT (active_info->init_func ()));
00095           msg += ACE_CString (ACE_TEXT ("' for entity '"));
00096           msg += ACE_CString (ACE_TEXT (active_info->name ()));
00097           msg += ACE_CString (ACE_TEXT ("'\n"));
00098 
00099           ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
00100         }
00101       symbol = (*func)(&gobbler); // target object created in the loaded DLL.
00102 
00103       ACE_Service_Type_Impl *stp = ACE_Service_Config::create_service_type_impl
00104         (active_info->name (),
00105          active_info->service_type (),
00106          symbol,
00107          ACE_Service_Type::DELETE_THIS |
00108          ACE_Service_Type::DELETE_OBJ,
00109          gobbler);
00110 
00111       if (this->in_stream_def_)
00112         {
00113 //           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Create dynamic %s for stream\n"),
00114 //                       this->stream_info_.name ()));
00115           if (active_info->service_type () == ACE_Service_Type::STREAM)
00116             {
00117               this->stream_ = (ACE_Stream_Type *) stp;
00118             }
00119           else
00120             {
00121               // We will not retain this stream
00122               delete stp;
00123 
00124               // build the error message
00125               ACE_CString msg (ACE_TEXT ("Expecting Stream type in stream header"));
00126               msg += ACE_CString (ACE_TEXT (" for entity '"));
00127               msg += ACE_CString (ACE_TEXT (active_info->name ()));
00128               msg += ACE_CString (ACE_TEXT ("'\n"));
00129 
00130               ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
00131             }
00132 
00133           this->stream_svc_type_ =
00134             ACE_Service_Config::create_service_type (this->stream_info_.name (),
00135                                                      this->stream_,
00136                                                      svc_dll,
00137                                                      this->stream_info_.active ());
00138 
00139         }
00140       else
00141         {
00142           if (this->in_module_)
00143             {
00144               ACE_ARGV args (active_info->init_params ());
00145 
00146               ACE_Module_Type *mt = (ACE_Module_Type *) stp;
00147 
00148               ACE_Module<ACE_SYNCH> *mp = (ACE_Module<ACE_SYNCH> *) mt->object ();
00149 
00150               if (ACE_OS::strcmp (mp->name (), active_info->name ()) != 0)
00151                 {
00152                   ACE_DEBUG ((LM_DEBUG,
00153                               ACE_TEXT ("warning: assigning Module_Type name %s to Module %s since names differ\n"),
00154                               active_info->name (),
00155                               mp->name ()));
00156                   mp->name (active_info->name ());
00157                 }
00158 
00159               if (mt->init (args.argc (), args.argv ()) == -1
00160                   || this->stream_->push (mt) == -1)
00161                 {
00162                   // build the error message
00163                   ACE_CString msg (ACE_TEXT ("Error initializing module"));
00164                   msg += ACE_CString (ACE_TEXT (" for entity '"));
00165                   msg += ACE_CString (ACE_TEXT (active_info->name ()));
00166                   msg += ACE_CString (ACE_TEXT ("'\n"));
00167 
00168                   ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
00169                 }
00170 
00171 
00172 //               ACE_DEBUG ((LM_INFO, ACE_TEXT ("Push dynamic %s into stream %s\n"),
00173 //                           this->parsed_info_.name (),
00174 //                           this->stream_info_.name ()));
00175             }
00176           else
00177             {
00178               ACE_Service_Type *stype =
00179                 ACE_Service_Config::create_service_type (active_info->name (),
00180                                                          stp,
00181                                                          svc_dll,
00182                                                          active_info->active ());
00183               // @@ Check error here.
00184 
00185               //               ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply dynamic %s\n"),
00186 //                           this->parsed_info_.name ()));
00187               if (ACE_Service_Config::initialize (stype,
00188                                                   active_info->init_params ()) == -1)
00189                 {
00190                   // If it did not initialize correctly, the
00191                   // ACE_Service_Config doesn't own this object
00192                   delete stype;
00193 
00194                   // build the error message
00195                   ACE_CString msg (ACE_TEXT ("Failed to initialize dynamic service"));
00196                   msg += ACE_CString (ACE_TEXT (" for entity '"));
00197                   msg += ACE_CString (ACE_TEXT (active_info->name ()));
00198                   msg += ACE_CString (ACE_TEXT ("'\n"));
00199 
00200                   ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
00201                 }
00202             }
00203           this->parsed_info_.reset ();
00204         }
00205     }
00206   else if (ACE_OS::strcmp (qName, ACE_TEXT ("static")) == 0)
00207     {
00208       if (this->in_stream_def_)
00209         {
00210           // @@ Couldn't make sense out of the original Svc_Conf.y.
00211           ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Create static %s for stream\n"),
00212                       this->stream_info_.name ()));
00213         }
00214       else
00215         {
00216           if (this->in_module_)
00217             {
00218               // @@ Couldn't make sense out of the original Svc_Conf.y.
00219               ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Push static %s into stream %s\n"),
00220                           this->parsed_info_.name (),
00221                           this->stream_info_.name ()));
00222             }
00223           else
00224             {
00225 //               ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply static %s\n"),
00226 //                           this->parsed_info_.name ()));
00227               if (ACE_Service_Config::initialize (this->parsed_info_.name (),
00228                                                   this->parsed_info_.init_params ()) == -1)
00229                 {
00230                   // build the error message
00231                   ACE_CString msg (ACE_TEXT ("Failed to initialize static service"));
00232                   msg += ACE_CString (ACE_TEXT (" for entity '"));
00233                   msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
00234                   msg += ACE_CString (ACE_TEXT ("'\n"));
00235 
00236                   ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
00237                 }
00238             }
00239           this->parsed_info_.reset ();
00240         }
00241     }
00242   else if (ACE_OS::strcmp (qName, ACE_TEXT ("module")) == 0)
00243     {
00244       this->in_module_ = 0;
00245     }
00246   else if (ACE_OS::strcmp (qName, ACE_TEXT ("streamdef")) == 0)
00247     {
00248 //       ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply stream %s of type %s\n"),
00249 //                   this->stream_info_.name (),
00250 //                   this->stream_info_.name ()));
00251       ACE_Service_Config::initialize (this->stream_svc_type_,
00252                                       this->stream_info_.init_params ());
00253 
00254       this->stream_info_.reset ();
00255       this->stream_svc_type_ = 0;
00256       this->stream_ = 0;
00257     }
00258   else if (ACE_OS::strcmp (qName, ACE_TEXT ("stream")) == 0)
00259     {
00260 //       ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply stream %s of type %s\n"),
00261 //                   this->stream_info_.name (),
00262 //                   this->stream_info_.name ()));
00263       this->stream_info_.reset ();
00264     }
00265   else
00266     {
00267     }
00268 }
00269 
00270 void
00271 ACEXML_Svcconf_Handler::endPrefixMapping (const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00272 {
00273   // no-op
00274 }
00275 
00276 void
00277 ACEXML_Svcconf_Handler::ignorableWhitespace (const ACEXML_Char *,
00278                                              int,
00279                                              int ACEXML_ENV_ARG_DECL_NOT_USED)
00280 {
00281   // no-op
00282 }
00283 
00284 void
00285 ACEXML_Svcconf_Handler::processingInstruction (const ACEXML_Char *,
00286                                                const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00287 {
00288   // no-op
00289 }
00290 
00291 void
00292 ACEXML_Svcconf_Handler::setDocumentLocator (ACEXML_Locator* locator)
00293 {
00294   this->locator_ = locator;
00295 }
00296 
00297 void
00298 ACEXML_Svcconf_Handler::skippedEntity (const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00299 {
00300   // no-op
00301 }
00302 
00303 void
00304 ACEXML_Svcconf_Handler::startDocument ( ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
00305 {
00306   // no-op
00307 }
00308 
00309 void
00310 ACEXML_Svcconf_Handler::startElement (const ACEXML_Char *,
00311                                       const ACEXML_Char *,
00312                                       const ACEXML_Char *qName,
00313                                       ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
00314 {
00315   if (ACE_OS::strcmp (qName, ACE_TEXT ("dynamic")) == 0)
00316     {
00317       this->get_dynamic_attrs (alist ACEXML_ENV_ARG_PARAMETER);
00318     }
00319   else if (ACE_OS::strcmp (qName, ACE_TEXT ("initializer")) == 0)
00320     {
00321       this->get_initializer_attrs (alist ACEXML_ENV_ARG_PARAMETER);
00322 
00323     }
00324   else if (ACE_OS::strcmp (qName, ACE_TEXT ("static")) == 0)
00325     {
00326       this->get_static_attrs (alist ACEXML_ENV_ARG_PARAMETER);
00327     }
00328   else if (ACE_OS::strcmp (qName, ACE_TEXT ("stream")) == 0)
00329     {
00330       this->get_stream_id (alist ACEXML_ENV_ARG_PARAMETER);
00331 
00332       if (ACE_Service_Repository::instance()->find
00333           (this->stream_info_.name (),
00334            (const ACE_Service_Type **) &this->stream_svc_type_) == -1)
00335         {
00336           // build the error message
00337           ACE_CString msg (ACE_TEXT ("Cannot find stream '"));
00338           msg += ACE_CString (ACE_TEXT (this->stream_info_.name ()));
00339           msg += ACE_CString (ACE_TEXT ("'\n"));
00340 
00341           ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
00342         }
00343       this->stream_ =   this->stream_svc_type_ == 0
00344         ? 0
00345         : dynamic_cast<ACE_Stream_Type *> (const_cast<ACE_Service_Type_Impl *> (this->stream_svc_type_->type ()));
00346 
00347 //       ACE_DEBUG ((LM_INFO, ACE_TEXT ("Retrieve stream %s from repository\n"),
00348 //                   this->stream_info_.name ()));
00349     }
00350   else if (ACE_OS::strcmp (qName, ACE_TEXT ("streamdef")) == 0)
00351     {
00352       this->in_stream_def_ = 1;
00353       // @@ Set up stream service object
00354     }
00355   else if (ACE_OS::strcmp (qName, ACE_TEXT ("module")) == 0)
00356     {
00357       this->in_stream_def_ = 0;
00358       this->in_module_ = 1;
00359     }
00360   else if (ACE_OS::strcmp (qName, ACE_TEXT ("resume")) == 0)
00361     {
00362       this->get_id (alist ACEXML_ENV_ARG_PARAMETER);
00363       if (this->in_module_)
00364         {
00365 //           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Resume %s in stream %s\n"),
00366 //                       this->parsed_info_.name (),
00367 //                       this->stream_info_.name ()));
00368           ACE_Module_Type *mt = (this->stream_ == 0)
00369             ? 0
00370             : this->stream_->find (this->parsed_info_.name ());
00371 
00372           if (mt == 0)
00373             {
00374               // build the error message
00375               ACE_CString msg (ACE_TEXT ("Can't locate module '"));
00376               msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
00377               msg += ACE_CString (ACE_TEXT ("'\n"));
00378 
00379               ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
00380             }
00381 
00382           mt->resume ();
00383         }
00384       else
00385         {
00386 //           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Resume %s\n"),
00387 //                       this->parsed_info_.name ()));
00388           if (ACE_Service_Config::resume (this->parsed_info_.name ()) == -1)
00389             {
00390               // build the error message
00391               ACE_CString msg (ACE_TEXT ("Resume failed"));
00392               msg += ACE_CString (ACE_TEXT (" for entity '"));
00393               msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
00394               msg += ACE_CString (ACE_TEXT ("'\n"));
00395 
00396               ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
00397             }
00398         }
00399       this->parsed_info_.reset ();
00400     }
00401   else if (ACE_OS::strcmp (qName, ACE_TEXT ("suspend")) == 0)
00402     {
00403       this->get_id (alist ACEXML_ENV_ARG_PARAMETER);
00404       if (this->in_module_)
00405         {
00406 //           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s in stream %s\n"),
00407 //                       this->parsed_info_.name (),
00408 //                       this->stream_info_.name ()));
00409           ACE_Module_Type *mt = (this->stream_ == 0)
00410             ? 0
00411             : this->stream_->find (this->parsed_info_.name ());
00412 
00413           if (mt == 0)
00414             {
00415               // build the error message
00416               ACE_CString msg (ACE_TEXT ("Can't locate module '"));
00417               msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
00418               msg += ACE_CString (ACE_TEXT ("'\n"));
00419 
00420               ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
00421             }
00422 
00423           mt->suspend ();
00424         }
00425       else
00426         {
00427           //          ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s\n"),
00428           //                      this->parsed_info_.name ()));
00429           if (ACE_Service_Config::suspend (this->parsed_info_.name ()) == -1)
00430             {
00431               // build the error message
00432               ACE_CString msg (ACE_TEXT ("Suspend failed"));
00433               msg += ACE_CString (ACE_TEXT (" for entity '"));
00434               msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
00435               msg += ACE_CString (ACE_TEXT ("'\n"));
00436 
00437               ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
00438             }
00439         }
00440       this->parsed_info_.reset ();
00441     }
00442   else if (ACE_OS::strcmp (qName, ACE_TEXT ("remove")) == 0)
00443     {
00444       this->get_id (alist ACEXML_ENV_ARG_PARAMETER);
00445       if (this->in_module_)
00446         {
00447 //           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s in stream %s\n"),
00448 //                       this->parsed_info_.name (),
00449 //                       this->stream_info_.name ()));
00450           ACE_Module_Type *mt = (this->stream_ == 0)
00451             ? 0
00452             : this->stream_->find (this->parsed_info_.name ());
00453 
00454           if (mt == 0)
00455             {
00456               // build the error message
00457               ACE_CString msg (ACE_TEXT ("Can't locate module '"));
00458               msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
00459               msg += ACE_CString (ACE_TEXT ("'\n"));
00460 
00461               ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
00462             }
00463 
00464           this->stream_->remove (mt);
00465         }
00466       else
00467         {
00468 //           ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s\n"),
00469 //                       this->parsed_info_.name ()));
00470           if (ACE_Service_Config::remove (this->parsed_info_.name ()) == -1)
00471             {
00472               // build the error message
00473               ACE_CString msg (ACE_TEXT ("Remove failed"));
00474               msg += ACE_CString (ACE_TEXT (" for entity '"));
00475               msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
00476               msg += ACE_CString (ACE_TEXT ("'\n"));
00477 
00478               ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
00479             }
00480         }
00481       this->parsed_info_.reset ();
00482     }
00483   else if (ACE_OS::strcmp (qName, ACE_TEXT ("ACE_Svc_Conf")) == 0)
00484     {
00485       // Main document tag. no-op.
00486 //       ACE_DEBUG ((LM_INFO, ACE_TEXT ("ACE_Svc_Conf tag\n")));
00487     }
00488   else
00489     {
00490       // @@ Error.  Perhaps we should relay to user event handler here, if available.
00491     }
00492 
00493   return;
00494 }
00495 
00496 void
00497 ACEXML_Svcconf_Handler::startPrefixMapping (const ACEXML_Char *,
00498                                             const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00499 {
00500   // No-op.
00501 }
00502 
00503 // *** Methods inherit from ACEXML_DTDHandler.
00504 
00505 void
00506 ACEXML_Svcconf_Handler::notationDecl (const ACEXML_Char *,
00507                                       const ACEXML_Char *,
00508                                       const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00509 {
00510   // No-op.
00511 }
00512 
00513 void
00514 ACEXML_Svcconf_Handler::unparsedEntityDecl (const ACEXML_Char *,
00515                                             const ACEXML_Char *,
00516                                             const ACEXML_Char *,
00517                                             const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00518 {
00519   // No-op.
00520 }
00521 
00522 // Methods inherit from ACEXML_EnitityResolver.
00523 
00524 ACEXML_InputSource *
00525 ACEXML_Svcconf_Handler::resolveEntity (const ACEXML_Char *,
00526                                        const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
00527 {
00528   // No-op.
00529   return 0;
00530 }
00531 
00532 // Methods inherit from ACEXML_ErrorHandler.
00533 
00534   /*
00535    * Receive notification of a recoverable error.
00536    */
00537 void
00538 ACEXML_Svcconf_Handler::error (ACEXML_SAXParseException& ex ACEXML_ENV_ARG_DECL_NOT_USED)
00539 {
00540   ACE_DEBUG ((LM_DEBUG, "%s: line :%d col: %d ", this->locator_->getSystemId(),
00541               this->locator_->getLineNumber(),
00542               this->locator_->getColumnNumber()));
00543   ex.print();
00544 }
00545 
00546 void
00547 ACEXML_Svcconf_Handler::fatalError (ACEXML_SAXParseException& ex ACEXML_ENV_ARG_DECL_NOT_USED)
00548 {
00549   ACE_DEBUG ((LM_DEBUG, "%s: line :%d col: %d ", this->locator_->getSystemId(),
00550               this->locator_->getLineNumber(),
00551               this->locator_->getColumnNumber()));
00552   ex.print();
00553 }
00554 
00555 void
00556 ACEXML_Svcconf_Handler::warning (ACEXML_SAXParseException& ex ACEXML_ENV_ARG_DECL_NOT_USED)
00557 {
00558   ACE_DEBUG ((LM_DEBUG, "%s: line :%d col: %d ", this->locator_->getSystemId(),
00559               this->locator_->getLineNumber(),
00560               this->locator_->getColumnNumber()));
00561   ex.print();
00562 }
00563 
00564 int
00565 ACEXML_Svcconf_Handler::get_stream_id (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
00566 {
00567   if (alist != 0)
00568     for (size_t i = 0; i < alist->getLength (); ++i)
00569       {
00570         if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
00571           {
00572             this->stream_info_.name (alist->getValue (i));
00573           }
00574         else
00575           {
00576             // build the error message
00577             ACE_CString msg (ACE_TEXT ("Invalid stream attribute '"));
00578             msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
00579             msg += ACE_CString (ACE_TEXT ("' for entity '"));
00580             msg += ACE_CString (ACE_TEXT (this->stream_info_.name ()));
00581             msg += ACE_CString (ACE_TEXT ("'\n"));
00582 
00583             ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()),
00584                                  -1);
00585           }
00586       }
00587   return 0;
00588 }
00589 
00590 int
00591 ACEXML_Svcconf_Handler::get_id (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
00592 {
00593   if (alist != 0)
00594     for (size_t i = 0; i < alist->getLength (); ++i)
00595       {
00596         if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
00597           {
00598             this->parsed_info_.name (alist->getValue (i));
00599           }
00600         else
00601           {
00602             // build the error message
00603             ACE_CString msg (ACE_TEXT ("Invalid attribute '"));
00604             msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
00605             msg += ACE_CString (ACE_TEXT ("', expecting 'id'"));
00606             msg += ACE_CString (ACE_TEXT (" for entity '"));
00607             msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
00608             msg += ACE_CString (ACE_TEXT ("'\n"));
00609 
00610             ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()),
00611                             -1);
00612           }
00613       }
00614   return 0;
00615 }
00616 
00617 int
00618 ACEXML_Svcconf_Handler::get_dynamic_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
00619 {
00620   if (alist != 0)
00621     {
00622       ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
00623                                &this->parsed_info_ :
00624                                &this->stream_info_);
00625       for (size_t i = 0; i < alist->getLength (); ++i)
00626         {
00627           if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
00628             {
00629               info->name (alist->getValue (i));
00630             }
00631           else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("status")) == 0)
00632             {
00633               if (ACE_OS::strcmp (alist->getValue (i), ACE_TEXT ("inactive")) == 0)
00634                 {
00635                   info->active (0);
00636                 }
00637               else if (ACE_OS::strcmp (alist->getValue (i), ACE_TEXT ("active")) == 0)
00638                 {
00639                   info->active (1);
00640                 }
00641               else
00642                 {
00643                   // build the error message
00644                   ACE_CString msg (ACE_TEXT ("Invalid attribute value '"));
00645                   msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
00646                   msg += ACE_CString (ACE_TEXT ("', expecting 'active' or 'inactive'"));
00647                   msg += ACE_CString (ACE_TEXT (" for entity '"));
00648                   msg += ACE_CString (ACE_TEXT (info->name ()));
00649                   msg += ACE_CString (ACE_TEXT ("'\n"));
00650 
00651                   ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()),
00652                                        -1);
00653                 }
00654             }
00655           else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("type")) == 0)
00656             {
00657               if (ACE_OS::strcasecmp (alist->getValue (i), ACE_TEXT ("service_object")) == 0)
00658                 {
00659                   info->service_type (ACE_Service_Type::SERVICE_OBJECT);
00660                 }
00661               else if (ACE_OS::strcasecmp (alist->getValue (i), ACE_TEXT ("stream")) == 0)
00662                 {
00663                   info->service_type (ACE_Service_Type::STREAM);
00664                 }
00665               else if (ACE_OS::strcasecmp (alist->getValue (i), ACE_TEXT ("module")) == 0)
00666                 {
00667                   info->service_type (ACE_Service_Type::MODULE);
00668                 }
00669               else
00670                 {
00671                   // build the error message
00672                   ACE_CString msg (ACE_TEXT ("Invalid Service_Object attribute value'"));
00673                   msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
00674                   msg += ACE_CString (ACE_TEXT ("' for entity '"));
00675                   msg += ACE_CString (ACE_TEXT (info->name ()));
00676                   msg += ACE_CString (ACE_TEXT ("'\n"));
00677 
00678                   ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()),
00679                                   -1);
00680                 }
00681             }
00682           else
00683             {
00684               // build the error message
00685               ACE_CString msg (ACE_TEXT ("Invalid attribute'"));
00686               msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
00687               msg += ACE_CString (ACE_TEXT ("' for entity '"));
00688               msg += ACE_CString (ACE_TEXT (info->name ()));
00689               msg += ACE_CString (ACE_TEXT ("'\n"));
00690 
00691               ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()), -1);
00692             }
00693         }
00694     }
00695   return 0;
00696 }
00697 
00698 int
00699 ACEXML_Svcconf_Handler::get_initializer_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
00700 {
00701   if (alist != 0)
00702     {
00703       ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
00704                                &this->parsed_info_ :
00705                                &this->stream_info_);
00706       for (size_t i = 0; i < alist->getLength (); ++i)
00707         {
00708           if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("init")) == 0)
00709             {
00710               info->init_func (alist->getValue (i));
00711             }
00712           else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("path")) == 0)
00713             {
00714               info->path (alist->getValue (i));
00715             }
00716           else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0)
00717             {
00718               info->init_params (alist->getValue (i));
00719             }
00720           else
00721             {
00722               // build the error message
00723               ACE_CString msg (ACE_TEXT ("Invalid initializer attribute'"));
00724               msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
00725               msg += ACE_CString (ACE_TEXT ("' for entity '"));
00726               msg += ACE_CString (ACE_TEXT (info->name ()));
00727               msg += ACE_CString (ACE_TEXT ("'\n"));
00728 
00729               ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()), -1);
00730             }
00731         }
00732     }
00733   return 0;
00734 }
00735 
00736 int
00737 ACEXML_Svcconf_Handler::get_static_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
00738 {
00739   if (alist != 0)
00740     {
00741       ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
00742                                &this->parsed_info_ :
00743                                &this->stream_info_);
00744       for (size_t i = 0; i < alist->getLength (); ++i)
00745         {
00746           if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
00747             {
00748               info->name (alist->getValue (i));
00749             }
00750           else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0)
00751             {
00752               info->init_params (alist->getValue (i));
00753             }
00754           else
00755             {
00756               // build the error message
00757               ACE_CString msg (ACE_TEXT ("Invalid static attribute '"));
00758               msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
00759               msg += ACE_CString (ACE_TEXT ("' for entity '"));
00760               msg += ACE_CString (ACE_TEXT (info->name ()));
00761               msg += ACE_CString (ACE_TEXT ("'\n"));
00762 
00763               ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()), -1);
00764             }
00765         }
00766     }
00767   return 0;
00768 }
00769 
00770 #endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */

Generated on Sun Jan 27 13:04:15 2008 for ACEXML by doxygen 1.3.6