ICE 3.4.2
[php5-ice-freebsdport.git] / cpp / test / IceGrid / deployer / Service.cpp
blob9d074a8ea852b58eaf81e938dc5762122504656b
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
4 //
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
7 //
8 // **********************************************************************
10 #include <Ice/Ice.h>
11 #include <IceBox/IceBox.h>
12 #include <Freeze/Freeze.h>
13 #include <TestI.h>
15 using namespace std;
16 using namespace Ice;
18 class ServiceI : public ::IceBox::Service
20 public:
22 ServiceI();
23 virtual ~ServiceI();
25 virtual void start(const string&,
26 const CommunicatorPtr&,
27 const StringSeq&);
29 virtual void stop();
32 extern "C"
36 // Factory function
38 ICE_DECLSPEC_EXPORT ::IceBox::Service*
39 create(CommunicatorPtr communicator)
41 return new ServiceI;
46 ServiceI::ServiceI()
50 ServiceI::~ServiceI()
54 void
55 ServiceI::start(const string& name,
56 const CommunicatorPtr& communicator,
57 const StringSeq& args)
59 Ice::PropertiesPtr properties = communicator->getProperties();
60 Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(name);
61 if(properties->getPropertyAsInt(name + ".Freeze") > 0)
64 // We do this to ensure the dbenv directory exists.
66 Freeze::createConnection(communicator, name);
68 Ice::ObjectPtr object = new TestI(properties);
69 adapter->add(object, communicator->stringToIdentity(properties->getProperty(name + ".Identity")));
70 adapter->activate();
73 void
74 ServiceI::stop()