📄 svcconf_handler.cpp
字号:
if (mt == 0)
{
ACEXML_THROW (ACEXML_SAXException (ACE_TEXT ("Can't locate module\n")));
}
mt->resume ();
}
else
{
// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Resume %s\n"),
// this->parsed_info_.name ()));
if (ACE_Service_Config::resume (this->parsed_info_.name ()) == -1)
{
ACEXML_THROW (ACEXML_SAXException (ACE_TEXT ("Resume fail\n")));
}
}
this->parsed_info_.reset ();
}
else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("suspend")) == 0)
{
this->get_id (alist ACEXML_ENV_ARG_PARAMETER);
if (this->in_module_)
{
// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s in stream %s\n"),
// this->parsed_info_.name (),
// this->stream_info_.name ()));
ACE_Module_Type *mt = (this->stream_ == 0)
? 0
: this->stream_->find (this->parsed_info_.name ());
if (mt == 0)
{
ACEXML_THROW (ACEXML_SAXException (ACE_TEXT ("Can't locate module\n")));
}
mt->suspend ();
}
else
{
// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s\n"),
// this->parsed_info_.name ()));
if (ACE_Service_Config::suspend (this->parsed_info_.name ()) == -1)
{
ACEXML_THROW (ACEXML_SAXException (ACE_TEXT ("Suspend failed\n")));
}
}
this->parsed_info_.reset ();
}
else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("remove")) == 0)
{
this->get_id (alist ACEXML_ENV_ARG_PARAMETER);
if (this->in_module_)
{
// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s in stream %s\n"),
// this->parsed_info_.name (),
// this->stream_info_.name ()));
ACE_Module_Type *mt = (this->stream_ == 0)
? 0
: this->stream_->find (this->parsed_info_.name ());
if (mt == 0)
{
ACEXML_THROW (ACEXML_SAXException (ACE_TEXT ("Can't locate module\n")));
}
this->stream_->remove (mt);
}
else
{
// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s\n"),
// this->parsed_info_.name ()));
if (ACE_Service_Config::remove (this->parsed_info_.name ()) == -1)
{
ACEXML_THROW (ACEXML_SAXException (ACE_TEXT ("Remove failed\n")));
}
}
this->parsed_info_.reset ();
}
else if (ACE_OS_String::strcmp (qName, ACE_TEXT ("ACE_Svc_Conf")) == 0)
{
// Main document tag. no-op.
// ACE_DEBUG ((LM_INFO, ACE_TEXT ("ACE_Svc_Conf tag\n")));
}
else
{
// @@ Error. Perhaps we should relay to user event handler here, if available.
}
return;
}
void
ACEXML_Svcconf_Handler::startPrefixMapping (const ACEXML_Char *,
const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((ACEXML_SAXException))
{
// No-op.
}
// *** Methods inherit from ACEXML_DTDHandler.
void
ACEXML_Svcconf_Handler::notationDecl (const ACEXML_Char *,
const ACEXML_Char *,
const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((ACEXML_SAXException))
{
// No-op.
}
void
ACEXML_Svcconf_Handler::unparsedEntityDecl (const ACEXML_Char *,
const ACEXML_Char *,
const ACEXML_Char *,
const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((ACEXML_SAXException))
{
// No-op.
}
// Methods inherit from ACEXML_EnitityResolver.
ACEXML_InputSource *
ACEXML_Svcconf_Handler::resolveEntity (const ACEXML_Char *,
const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((ACEXML_SAXException))
{
// No-op.
return 0;
}
// Methods inherit from ACEXML_ErrorHandler.
/*
* Receive notification of a recoverable error.
*/
void
ACEXML_Svcconf_Handler::error (ACEXML_SAXParseException& ex ACEXML_ENV_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((ACEXML_SAXException))
{
ACE_DEBUG ((LM_DEBUG, "%s: line :%d col: %d ", this->locator_->getSystemId(),
this->locator_->getLineNumber(),
this->locator_->getColumnNumber()));
ex.print();
}
void
ACEXML_Svcconf_Handler::fatalError (ACEXML_SAXParseException& ex ACEXML_ENV_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((ACEXML_SAXException))
{
ACE_DEBUG ((LM_DEBUG, "%s: line :%d col: %d ", this->locator_->getSystemId(),
this->locator_->getLineNumber(),
this->locator_->getColumnNumber()));
ex.print();
}
void
ACEXML_Svcconf_Handler::warning (ACEXML_SAXParseException& ex ACEXML_ENV_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((ACEXML_SAXException))
{
ACE_DEBUG ((LM_DEBUG, "%s: line :%d col: %d ", this->locator_->getSystemId(),
this->locator_->getLineNumber(),
this->locator_->getColumnNumber()));
ex.print();
}
int
ACEXML_Svcconf_Handler::get_stream_id (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
{
if (alist != 0)
for (size_t i = 0; i < alist->getLength (); ++i)
{
if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
{
this->stream_info_.name (alist->getValue (i));
}
else
{
ACEXML_THROW_RETURN (ACEXML_SAXException (ACE_TEXT ("Invalid stream attribute\n")),
-1);
}
}
return 0;
}
int
ACEXML_Svcconf_Handler::get_id (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
{
if (alist != 0)
for (size_t i = 0; i < alist->getLength (); ++i)
{
if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
{
this->parsed_info_.name (alist->getValue (i));
}
else
{
ACEXML_THROW_RETURN (ACEXML_SAXException (ACE_TEXT ("Invalid attribute, expecting 'id'\n")), -1);
}
}
return 0;
}
int
ACEXML_Svcconf_Handler::get_dynamic_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
{
if (alist != 0)
{
ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
&this->parsed_info_ :
&this->stream_info_);
for (size_t i = 0; i < alist->getLength (); ++i)
{
if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
{
info->name (alist->getValue (i));
}
else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("status")) == 0)
{
if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("inactive")) == 0)
{
info->active (0);
}
else if (ACE_OS_String::strcmp (alist->getValue (i), ACE_TEXT ("active")) == 0)
{
info->active (1);
}
else
{
ACEXML_THROW_RETURN (ACEXML_SAXException (ACE_TEXT ("Invalid attribute value, expecting 'active' or 'inactive'\n")), -1);
}
}
else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("type")) == 0)
{
if (ACE_OS_String::strcasecmp (alist->getValue (i), ACE_TEXT ("service_object")) == 0)
{
info->service_type (ACE_Service_Type::SERVICE_OBJECT);
}
else if (ACE_OS_String::strcasecmp (alist->getValue (i), ACE_TEXT ("stream")) == 0)
{
info->service_type (ACE_Service_Type::STREAM);
}
else if (ACE_OS_String::strcasecmp (alist->getValue (i), ACE_TEXT ("module")) == 0)
{
info->service_type (ACE_Service_Type::MODULE);
}
else
{
ACEXML_THROW_RETURN (ACEXML_SAXException (ACE_TEXT ("Invalid Service_Object attribute value\n")), -1);
}
}
else
{
ACEXML_THROW_RETURN(ACEXML_SAXException(ACE_TEXT ("Invalid attribute\n")), -1);
}
}
}
return 0;
}
int
ACEXML_Svcconf_Handler::get_initializer_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
{
if (alist != 0)
{
ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
&this->parsed_info_ :
&this->stream_info_);
for (size_t i = 0; i < alist->getLength (); ++i)
{
if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("init")) == 0)
{
info->init_func (alist->getValue (i));
}
else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("path")) == 0)
{
info->path (alist->getValue (i));
}
else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0)
{
info->init_params (alist->getValue (i));
}
else
{
ACEXML_THROW_RETURN (ACEXML_SAXException (ACE_TEXT ("Invalid initializer attribute.\n")), -1);
}
}
}
return 0;
}
int
ACEXML_Svcconf_Handler::get_static_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
{
if (alist != 0)
{
ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
&this->parsed_info_ :
&this->stream_info_);
for (size_t i = 0; i < alist->getLength (); ++i)
{
if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
{
info->name (alist->getValue (i));
}
else if (ACE_OS_String::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0)
{
info->init_params (alist->getValue (i));
}
else
{
ACEXML_THROW_RETURN (ACEXML_SAXException (ACE_TEXT ("Invalid static attribute.\n")), -1);
}
}
}
return 0;
}
#endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -