Example #1
0
 def _convert_component(self, component):
     "This function generates a object definition, then converts scope and property elements."
     self.logger.debug("component: Processing %s" % component)
     c = ObjectDef(component.get("id"), factory=ReflectiveObjectFactory(component.get("class")))
     if "scope" in component.attrib:
         c.scope = scope.convert(component.get("scope"))
     c.props = [self._convert_prop_def(p) for p in component.findall(self.NS+"property")]
     return c
Example #2
0
 def _convert_component(self, component):
     "This function generates a object definition, then converts scope and property elements."
     c = ObjectDef(component.id, factory=ReflectiveObjectFactory(component.class_))
     if hasattr(component, "scope"):
         c.scope = scope.convert(component.scope)
     if hasattr(component, "property"):
         c.props = [self._convert_prop_def(p) for p in component.property]
     return c
Example #3
0
    def _get_basic_object_data(self, object, class_):
        """ A convenience method which creates basic object's data so that
        the code is not repeated.
        """

        if "scope" in object.attrib:
            scope_ = scope.convert(object.get("scope"))
        else:
            scope_ = scope.SINGLETON

        return(object.get("id"),  ReflectiveObjectFactory(class_),
            object.get("lazy-init", False), object.get("abstract", False),
               object.get("parent"), scope_)
Example #4
0
    def _convert_bean(self, bean, prefix=""):
        "This function generates a object definition, then converts scope and property elements."
        if prefix != "":
            if "id" in bean.attrib:
                bean.set("id", prefix + bean.get("id"))
            else:
                bean.set("id", prefix + "<anonymous>")

        c = ObjectDef(bean.get("id"), factory=ReflectiveObjectFactory(bean.get("class")))

        if "scope" in bean.attrib:
            c.scope = scope.convert(bean.get("scope"))
        self.logger.debug("bean: %s" % bean)
        c.pos_constr = [self._convert_prop_def(bean, constr, bean.get("id") + ".constr") for constr in bean.findall(self.NS+"constructor-arg")]
        self.logger.debug("Constructors = %s" % c.pos_constr)
        c.props = [self._convert_prop_def(bean, p, p.get("name")) for p in bean.findall(self.NS+"property")]

        return c
Example #5
0
 def _convert_bean(self, bean, prefix=""):
     "This function generates a object definition, then converts scope and property elements."
     if prefix != "":
         if hasattr(bean, "id"):
             bean.id = prefix + bean.id
         else:
             bean.id = prefix + "<anonymous>"
             
     c = ObjectDef(bean.id, factory=ReflectiveObjectFactory(bean.class_))
     
     if hasattr(bean, "scope"):
         c.scope = scope.convert(bean.scope)
     if hasattr(bean, "constructor_arg"):
         c.pos_constr = [self._convert_prop_def(bean, constr, bean.id + ".constr") for constr in bean.constructor_arg]
         self.logger.debug("Constructors = %s" % c.pos_constr)
     if hasattr(bean, "property"):
         c.props = [self._convert_prop_def(bean, p, p.name) for p in bean.property]
         
     return c
Example #6
0
 def _convert_object(self, object, prefix=""):
     "This function generates a object definition, then converts scope and property elements."
     if prefix != "":
         if hasattr(object, "id"):
             object.id = prefix + "." + object.id
         else:
             object.id = prefix + ".<anonymous>"
             
     c = ObjectDef(object.id, factory=ReflectiveObjectFactory(object.class_))
     
     if hasattr(object, "scope"):
         c.scope = scope.convert(object.scope)
     if hasattr(object, "constructor_arg"):
         c.pos_constr = [self._convert_prop_def(object, constr, object.id + ".constr") for constr in object.constructor_arg
                         if not hasattr(constr, "name")]
         c.named_constr = dict([(str(constr.name), self._convert_prop_def(object, constr, object.id + ".constr")) for constr in object.constructor_arg
                                if hasattr(constr, "name")])
     if hasattr(object, "property"):
         c.props = [self._convert_prop_def(object, p, p.name) for p in object.property]
         
     return c