summaryrefslogtreecommitdiff
path: root/ACEXML/compass/ComponentServer.cpp
blob: 0909d8be5bab56edcc54bbe52eec0ff5c997f248 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// $Id$

#if defined (__ACE_INLINE__)
#include "ComponentServer.inl"
#endif /* __ACE_INLINE__ */

#include "ACEXML/compass/ComponentServer.h"

using namespace Deployment;

ComponentServer::ComponentServer(ConfigValues* config)
  : containers_ (0),
    config_ (config),
    activator_ (SERVER_ACTIVATOR::instance())
{}

ComponentServer::~ComponentServer()
{
  this->remove();
}

Container*
ComponentServer::create_container (ConfigValues* config)
  ACE_THROW_SPEC ((CreateFailure, InvalidConfiguration))
{
  Container* ctr = 0;
  ACE_NEW_RETURN (ctr, Container (config), 0);
  if (this->containers_->insert (ctr) != 0)
    ACE_THROW (CreateFailure());
  return ctr;
}

void
ComponentServer::remove_container (Container* cref)
  ACE_THROW_SPEC ((RemoveFailure));
{
  if (this->containers_->remove (cref) != 0)
    ACE_THROW (RemoveFailure());
  delete cref;
}

void
ComponentServer::remove()
  ACE_THROW_SPEC ((RemoveFailure))
{
  Container** entry = 0;
  for (Containers::iterator iter (*this->containers_);
       iter.next (entry) != 0;
       iter->advance())
    delete *entry;

  ConfigValues** value = 0;
  for (ConfigValues::iterator iter (*this->config_);
       iter.next (value) != 0;
       iter->advance())
    delete *value;

  this->activator_ = 0;
}