Library: Remoting
Package: Remoting
Header: Poco/Remoting/ORB.h
The object broker is a singleton which manages listeners, RemoteObjects, Skeletons and proxy creation. A Client will typically use findObject to retrieve an object. It is recommended to use the various helper classes generated by the code generator to retrieve an instance of an object. Example: Assume you have a class MyClass. Create a configuration file containing Remoting/RemoteObject.h, Remoting/Proxy.h, Remoting/Skeleton.h, MyClass.h (see RemoteGen example config file). Start the RemoteGen application which generates the following files:
IMyClass, MyClassHelper, MyClassProxy, MyClassProxyFactory, MyClassSkeleton, MyClassRemoteObject
Use MyClassHelper::find(uri) to retrieve the object behind the given endpoint (if proxy or local object is decided transparently in the ORB). The returned object will be of type AutoPtr<IMyClass> which has the same interface as MyClass.
Member Functions: findObject, getSkeleton, instance, invoke, listeners, registerClass, registerListener, registerObject, registerProxyFactory, registerSkeleton, shutdown, unregisterClass, unregisterListener, unregisterObject, unregisterProxyFactory, unregisterSkeleton
typedef Poco::AutoPtr < Identifiable > IdentifiablePtr;
typedef std::map < std::string, ListenerPtr > ListenerMap;
typedef std::map < std::string, std::set < std::string > > ListenerObjects;
A map that stores for each listener end points the set of object uris registered to it.
typedef Poco::SharedPtr < Listener > ListenerPtr;
typedef std::vector < ListenerPtr > ListenerVec;
typedef Poco::AutoPtr < RemoteObject > RemoteObjectPtr;
typedef std::map < std::string, RemoteObjectPtr > RemoteObjects;
typedef std::pair < SkeletonPtr, TransportRemoteObjects > SkeletonInfo;
typedef Poco::AutoPtr < Skeleton > SkeletonPtr;
typedef std::map < Identifiable::TypeId, SkeletonInfo > Skeletons;
typedef std::map < std::string, RemoteObjects > TransportRemoteObjects;
Maps transports string to a map of oid->RemoteObject
~ORB();
Destroys the ORB.
IdentifiablePtr findObject(
const std::string & uri
);
The uri must have the following format: scheme://serverName/transport/typeId/objectId Don't use directly, use the generated helper class for the given object type which performs the cast from IdentifiablePtr to the object type automatically.
SkeletonPtr getSkeleton(
const Identifiable::TypeId & tid
);
Returns a skeleton for the given type or an exception if not found.
static ORB & instance();
Returns a reference to the global ORB.
bool invoke(
const std::string & uriPath,
std::istream & in,
std::ostream & out,
Transport & transport
);
Mostly used by skeletons. Returns false if the object was not found. It is up to the calling transport to handle this error!
ListenerVec listeners();
Returns a vector containing all registered Listener objects.
void registerClass(
const Identifiable::TypeId & tid,
ProxyFactory * pProxy,
Skeleton * pSkel
);
Registers a proxy factory for the given class and the skeleton. Takes ownership of all pointers. Duplicate registration of a class is ignored!
void registerListener(
Listener * pListener
);
Registers listeners at the ORB, ORB takes ownership of the listener object. The local endpoint of the Listeners must be unique and will result in an exception if not. In this case, the ORB will delete the pointer to the object.
void registerObject(
ORB::RemoteObjectPtr pRO,
const std::string & uri
);
Adds an remote Object to the ORB: a class must have already been registered for the type! Duplicate registration of an object yields an exception! If the registration fails due to the ORB being in shutdown mode, an exception is thrown. A classhandler for the object must exist, a listener also. Takes ownership of the RemoteObject.
void registerProxyFactory(
const Identifiable::TypeId & tid,
ProxyFactory * pProxy
);
Registers a proxy factory for the given class. Takes ownership of all pointers. Duplicate registration of a class is ignored!
void registerSkeleton(
const Identifiable::TypeId & tid,
Skeleton * pSkel
);
Registers a skeleton for the given class. Takes ownership of all pointers. Duplicate registration of a class is ignored!
void shutdown();
Stops all listeners and removes them plus all objects and skeletons from the orb
void unregisterClass(
const Identifiable::TypeId & tid,
bool autoRemoveObjects = false
);
Unregisters a proxy factory for the given type and its skeleton, if found. If objects are still registered and autoRemoveObjects is false, it will fail with a RemotingException.
void unregisterListener(
const std::string & listenerEndPoint,
bool autoRemoveObjects = false
);
Unregisters listeners at the ORB, if found. Will automatically removes all objects associated with that listener if autoRemoveObjects is set to true, otherwise it will check if objects are still registered and will fail with a RemotingException
void unregisterObject(
const std::string & uri
);
void unregisterProxyFactory(
const Identifiable::TypeId & tid
);
Unregisters a proxy factory for the given type, if found.
void unregisterSkeleton(
const Identifiable::TypeId & tid,
bool autoRemoveObjects = false
);
Unregisters a skeleton for the given type, if found. If objects are still registered and autoRemoveObjects is false, it will fail with a RemotingException.