1 #include "ServiceNode.hxx"
3 #include "ComponentInstance.hxx"
4 #include "ComposedNode.hxx"
10 #include "YacsTrace.hxx"
12 using namespace YACS::ENGINE;
14 const char ServiceNode::KIND[]="";
16 std::string ServiceNode::getKind() const
21 ServiceNode::ServiceNode(const std::string& name):ElementaryNode(name),_component(0)
25 ServiceNode::ServiceNode(const ServiceNode& other, ComposedNode *father)
26 :ElementaryNode(other,father),_method(other._method),_component(0)
30 void ServiceNode::performDuplicationOfPlacement(const Node& other)
32 const ServiceNode &otherC=*(dynamic_cast<const ServiceNode *>(&other));
33 //if other has no component don't clone: this will not have one
35 _component=otherC._component->clone();
38 ServiceNode::~ServiceNode()
41 _component->decrRef();
44 //! Load the component associated to the node
45 void ServiceNode::load()
49 if(!_component->isLoaded())
54 std::string what("ServiceNode::load : a load operation requested on ServiceNode called \"");
55 what+=_name; what+="\" with no component specified.";
56 throw Exception(what);
60 void ServiceNode::accept(Visitor *visitor)
62 visitor->visitServiceNode(this);
65 //! Return the associated component instance
66 ComponentInstance *ServiceNode::getComponent()
71 //! By definition of ServiceNode class.
72 bool ServiceNode::isDeployable() const
77 //! Associate an existing component instance to this service node \b AND check the consistency regarding the deployment from root node point of view.
78 void ServiceNode::setComponent(ComponentInstance* compo) throw(Exception)
81 if(compo->getKind() != this->getKind())
84 std::string what("ServiceNode::setComponent : component instance kind not allowed ");
85 throw Exception(what);
89 //The node is already associated with a component instance
90 _component->decrRef();
91 //Don't forget to unassociate
99 getRootNode()->checkDeploymentTree(false);
106 _component->incrRef();
111 //! Associate a new component instance to this service node
113 * A new component instance with type name ref is created (from runtime
114 * factory createComponentInstance) and associated to the node.
117 void ServiceNode::setRef(const std::string& ref)
122 //The node is already associated with a component instance
123 _component->decrRef();
124 //Don't forget to unassociate
126 _component= getRuntime()->createComponentInstance(ref,getKind());
130 std::string ServiceNode::getRef()