commore  1.0.6-SNAPSHOT
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
commore::Service Class Reference

A commore::Service is an object that mimics an object in an object oriented system : it has a class name (its type) and a name (instance name). It provides callable methods (with call and #send), and has an internal state. A commore::Service is designed for being used via an AutoRef (it inherits from RefObject). However, Service doesn't use RefFactory, but ServiceFactory. This is because RefFactory interface is not suitable for the kind of arguments that is required in create methods. An service has a list of Interfaces (interface_list_ defined in Interface). These interfaces are the one that the object implements. More...

#include <Service.h>

+ Inheritance diagram for commore::Service:

Classes

class  CallMethod
 

Public Member Functions

ListAString & get_addresses (ListAString &addresses) const
 
AString get_address () const
 
PService get_service ()
 
const AString & get_name () const
 
void set_name (const AChar *name)
 
const AString & get_class_name () const
 
virtual long connect (const AChar *user_name, const AChar *password)
 
AString get_session_id () const
 
void set_session_id (const AChar *session_id)
 
Tuple * get_session_context_ptr (bool createIfNeeded=false)
 
virtual bool get_session_context (Tuple &t)
 
virtual void set_session_context (const Tuple &sessionContext)
 
virtual bool get_self_session_context (Tuple &t) const
 
virtual void set_self_session_context ()
 
long publish (PServiceManager &manager)
 
long unpublish (PServiceManager &manager)
 
long unpublish ()
 
long get_managers (List< PServiceManager > &managers) const
 
virtual long call (const Tuple &inArgs, Tuple &outArgs)
 
virtual long call (const AChar *interface_name, const Tuple &inArgs, Tuple &outArgs)
 
virtual long call (const AChar *interface_name, const Tuple &inArgs, Tuple &outArgs, const Tuple *param)
 
long call (Tuple &sessionContext, const AChar *interface_name, const Tuple &inArgs, Tuple &outArgs)
 
long get_interface (const AChar *name, PInterface &inter)
 
bool add_interface (const PInterface &inter)
 
- Public Member Functions inherited from commore::Interface
 Interface (const AChar *name)
 
virtual ~Interface ()
 
virtual bool is_proxy () const
 
virtual long call (const Tuple &in_args, Tuple &out_args, const Tuple *param)
 
const AString & get_name () const
 
virtual PService get_service () const
 
CriticalSection * get_cs () const
 
- Public Member Functions inherited from commore::RefObject
 RefObject ()
 
virtual ~RefObject ()
 
virtual void attach ()
 
virtual void release ()
 
virtual void nested_attach ()
 
virtual void nested_release ()
 
virtual void interface_release ()
 
virtual void Run ()
 
virtual CriticalSection * get_cs ()
 

Static Public Member Functions

static AutoRefBase create (const AChar *)
 
static AutoRefBase create (const AChar *, ServiceFactory &factory)
 
static AutoRefBase bind (const AChar *spec)
 
- Static Public Member Functions inherited from commore::RefObject
static AutoRefBase auto_create ()
 
static AutoRefBase auto_create (const AChar *s)
 
static AutoRefBase create ()
 
static AutoRefBase create (const AChar *s)
 
static AutoRefBase bind ()
 
static AutoRefBase bind (const AChar *s)
 
static const AChar * factory_name ()
 

Protected Member Functions

 Service (const AChar *class_name)
 
 Service (const AChar *class_name, const AChar *name, const AChar *address)
 
 Service (const AChar *class_name, const Tuple &init)
 
 ~Service ()
 
- Protected Member Functions inherited from commore::Interface
bool set_service (const PService &service)
 
 Interface (const Interface &)
 

Friends

class PServiceManager
 
class Interface
 

Additional Inherited Members

- Protected Attributes inherited from commore::Interface
Internals_ * internals_
 

Detailed Description

A commore::Service is an object that mimics an object in an object oriented system : it has a class name (its type) and a name (instance name). It provides callable methods (with call and #send), and has an internal state. A commore::Service is designed for being used via an AutoRef (it inherits from RefObject). However, Service doesn't use RefFactory, but ServiceFactory. This is because RefFactory interface is not suitable for the kind of arguments that is required in create methods. An service has a list of Interfaces (interface_list_ defined in Interface). These interfaces are the one that the object implements.

Constructor & Destructor Documentation

Service::Service ( const AChar *  class_name)
protected
Parameters
class_name
Service::Service ( const AChar *  class_name,
const AChar *  name,
const AChar *  address 
)
protected
Parameters
class_name
name
address
commore::Service::Service ( const AChar *  class_name,
const Tuple &  init 
)
protected
Parameters
class_name
init
Service::~Service ( )
protected

Member Function Documentation

bool Service::add_interface ( const PInterface &  inter)

Add interface implementation to service

Remarks
not implemented
AutoRefBase Service::bind ( const AChar *  spec)
static

Create a proxy service or bind to an existig published service This is the bind method used by AutoRef::bind

Parameters
specdirect service specification or remote service specification
Returns
return a proxy service if spec match <CLASS name>="">:<INSTANCE name>=""><ADDRESS> an existing published service if spec match <CLASS name>="">:<INSTANCE name>="">
long Service::call ( const Tuple &  inArgs,
Tuple &  outArgs 
)
virtual

Basic call method

Default implementation side if no interface name specified

Reimplemented from commore::Interface.

Reimplemented in commore::ProxyService.

long Service::call ( const AChar *  strInterfaceName,
const Tuple &  inArgs,
Tuple &  outArgs 
)
virtual

Call method with interface name

Default implementation with interface name

Reimplemented in commore::ProxyService.

long Service::call ( const AChar *  interface_name,
const Tuple &  inArgs,
Tuple &  outArgs,
const Tuple *  param 
)
virtual

Call method with interface name and param

Reimplemented in commore::ProxyService.

long Service::call ( Tuple &  sessionContext,
const AChar *  interface_name,
const Tuple &  inArgs,
Tuple &  outArgs 
)

Call entry method called by listener callback

Note
not a virtual function !
long Service::connect ( const AChar *  user_name,
const AChar *  password 
)
virtual

Default Authentication Method (to be implemented)

AutoRefBase Service::create ( const AChar *  spec)
static

Create a service using a registered factory This is the create method used by AutoRef::create

AutoRefBase Service::create ( const AChar *  spec,
ServiceFactory &  factory 
)
static

Create a service using an explicit factory

AString Service::get_address ( ) const

Recover addresses on which the services of service manager can be contacted

Returns
a string address list
Remarks
provided for backward compatibility
Deprecated:
ListAString & Service::get_addresses ( ListAString &  addresses) const

Get the addresses on which the services can be contacted

const AString & Service::get_class_name ( ) const
Returns
service class name
long Service::get_interface ( const AChar *  name,
PInterface &  inter 
)

Get interface Using default InterfaceFactory

Parameters
nameinterface name
interreference to retrieved interface
Returns
CMR_OK if succeed
long Service::get_managers ( List< PServiceManager > &  managers) const

Get associated ServiceManager (if service has been published)

Returns
number of ServiceManager where service is published,
const AString & Service::get_name ( ) const
Returns
service name
bool Service::get_self_session_context ( Tuple &  t) const
virtual

Specific for use on the server side, when using direct call inside a call get the session context directly attached to service

Reimplemented from commore::Interface.

PService commore::Service::get_service ( )
inline
Returns
a service reference
bool Service::get_session_context ( Tuple &  t)
virtual

Get a copy of tuple session context

Returns
true if tuple sesion context exist
Remarks
thread safe

Reimplemented from commore::Interface.

Tuple * Service::get_session_context_ptr ( bool  createIfNeeded = false)
Returns
pointer to tuple session context
Warning
pointer not thread safe
AString Service::get_session_id ( ) const
Returns
current session id
Remarks
session id is shared between service proxy and service server
long Service::publish ( PServiceManager &  manager)

Publish service in a service manager

void Service::set_name ( const AChar *  name)

Set service name

void Service::set_self_session_context ( )
virtual

Reimplemented from commore::Interface.

void Service::set_session_context ( const Tuple &  sessionContext)
virtual

Set tuple session context

Reimplemented from commore::Interface.

void Service::set_session_id ( const AChar *  session_id)

Set session id

long Service::unpublish ( PServiceManager &  manager)

Unpublish from a service manager

long Service::unpublish ( )

Unpublish from all service manager

Friends And Related Function Documentation

friend class Interface
friend
friend class PServiceManager
friend

The documentation for this class was generated from the following files: