Home · Modules · Classes · Namespaces · Functions

QxtWebServiceDirectory Class Reference
[QxtWeb module]

The QxtWebServiceDirectory class provides Path-based web service dispatcher More...

    #include <QxtWebServiceDirectory>

Inherits QxtAbstractWebService.

Public Functions

Protected Functions

Additional Inherited Members


Detailed Description

The QxtWebServiceDirectory class provides Path-based web service dispatcher

QxtWebServiceDirectory allows multiple services to be associated with a single session. Selection between services is determined by the first path component in the URL. For example, the URL "/site/request?param=true" would relay the URL "/request?param=true" to the service named "site".

This class can be used recursively to declare a hierarchy of services. For example:

    QxtWebServiceDirectory* top = new QxtWebServiceDirectory(sm, sm);
    QxtWebServiceDirectory* service1 = new QxtWebServiceDirectory(sm, top);
    QxtWebServiceDirectory* service2 = new QxtWebServiceDirectory(sm, top);
    QxtWebServiceDirectory* service1a = new QxtWebServiceDirectory(sm, service1);
    QxtWebServiceDirectory* service1b = new QxtWebServiceDirectory(sm, service1);
    top->addService("1", service1);
    top->addService("2", service2);
    service1->addService("a", service1a);
    service1->addService("b", service1b);

This accepts the URLs "/1/a/", "/1/b/", and "/2/".


Member Function Documentation

QxtWebServiceDirectory::QxtWebServiceDirectory ( QxtAbstractWebSessionManager * sm, QObject * parent = 0 )

Constructs a QxtWebServiceDirectory object with the specified session manager sm and parent.

Often, the session manager will also be the parent, but this is not a requirement.

void QxtWebServiceDirectory::addService ( const QString & path, QxtAbstractWebService * service )

Adds a service to the directory at the given path.

See also removeService() and service().

QString QxtWebServiceDirectory::defaultRedirect () const

Returns the path that will be used by default by the indexRequested event.

See also indexRequested() and setDefaultRedirect().

void QxtWebServiceDirectory::indexRequested ( QxtWebRequestEvent * event )   [virtual protected]

This event handler is called whenever the URL does not contain a path, that is, the URL is "/" or empty.

The default implementation redirects to the service specified by setDefaultRedirect(), or invokes unknownServiceRequested() if no default redirect has been set.

void QxtWebServiceDirectory::removeService ( const QString & path )

Removes the service at the given path.

Note that the service object is not destroyed.

QxtAbstractWebService * QxtWebServiceDirectory::service ( const QString & path ) const

Returns the service at the given path.

void QxtWebServiceDirectory::setDefaultRedirect ( const QString & path )

Sets the path that will be used by default by the indexRequested event.

See also indexRequested() and defaultRedirect().

void QxtWebServiceDirectory::unknownServiceRequested ( QxtWebRequestEvent * event, const QString & name )   [virtual protected]

This event handler is called whenever the URL requests a service with name that has not been added to the directory.

The default implementation returns a 404 "Service not known" error. Subclasses may reimplement this event handler to customize this behavior.


Copyright © 2007-2010 Qxt Foundation
Qxt 0.6.1