Keywords: doc

Next: POA Up: BOA Previous: Making Objects Persistent

## Migrating Objects

Up until now we described how objects are moved between different instances of the same server. Here we explain how to move objects between two completely different servers. This is for example useful if a server has to be replaced by a new version without interrupting usual business.

Recall that we augmented the account object by a management interface in section 4.3.4. The management interface offered a method `exit()` that terminates the server when invoked. Now let us add a method `migrate()` that migrates an account object to a new server. The new server is specified through an implementation repository entry.

      // account.idl
      interface Account {
        ...
        void migrate (in CORBA::ImplementationDef destination);
      };

Here is the implementation of the `migrate()` method:

     1:  #include "account.h"
     2:
     3:  class Account_impl : virtual public Account_skel {
     4:    ...
     5:  public:
     6:    ...
     7:    virtual void migrate (CORBA::ImplementationDef_ptr dest)
     8:    {
     9:       CORBA::BOA_var boa = _boa();
    10:       boa->change_implementation (this, dest);
    11:    }
    12:  };

The `change_implementation()` in line 10 does the whole job. It will save the object's state as described in section 4.3.4 and tell the BOA daemon to use the new implementation from now on. See `demo/account4` for an example.

The current version of MICO can only perform the migration when the destination implementation is not currently active, which means that:

- you cannot migrate an object to a persistent server
- you cannot migrate an object to a shared server that is already running

This limitation will be removed in a future version of MICO.