[Beeframework-svn] SF.net SVN: beeframework:[235] trunk/framework
Brought to you by:
b_hartmann,
m_plomer
|
From: <m_p...@us...> - 2014-09-26 14:56:50
|
Revision: 235
http://sourceforge.net/p/beeframework/code/235
Author: m_plomer
Date: 2014-09-26 14:56:42 +0000 (Fri, 26 Sep 2014)
Log Message:
-----------
Context/Utils: added ValueFactoryBean and namespace def
Modified Paths:
--------------
trunk/framework/Bee/Context/Util/Namespace/ValueFactoryDefinitionParser.php
trunk/framework/Bee/Context/Xml/ParserDelegate.php
trunk/framework/acl-default.xml
Modified: trunk/framework/Bee/Context/Util/Namespace/ValueFactoryDefinitionParser.php
===================================================================
--- trunk/framework/Bee/Context/Util/Namespace/ValueFactoryDefinitionParser.php 2014-09-26 14:14:00 UTC (rev 234)
+++ trunk/framework/Bee/Context/Util/Namespace/ValueFactoryDefinitionParser.php 2014-09-26 14:56:42 UTC (rev 235)
@@ -34,6 +34,6 @@
* @param BeanDefinitionBuilder $builder
*/
protected function doParse(DOMElement $element, ParserContext $parserContext, BeanDefinitionBuilder $builder) {
- $builder->addPropertyValue('sourceValue', $parserContext->getDelegate()->parseValueElement($element, 'string'));
+ $builder->addPropertyValue('sourceValue', $parserContext->getDelegate()->parseTypedAttributeValueElement($element, 'string'));
}
}
Modified: trunk/framework/Bee/Context/Xml/ParserDelegate.php
===================================================================
--- trunk/framework/Bee/Context/Xml/ParserDelegate.php 2014-09-26 14:14:00 UTC (rev 234)
+++ trunk/framework/Bee/Context/Xml/ParserDelegate.php 2014-09-26 14:56:42 UTC (rev 235)
@@ -482,9 +482,11 @@
* @param DOMElement $ele
* @param IBeanDefinition $bd
* @param string $elementName
+ * @param null $defaultType
+ * @throws Bee_Context_BeanCreationException
* @return BeanDefinitionHolder|TypedStringValue|ArrayValue|RuntimeBeanNameReference|RuntimeBeanReference|null
*/
- private function parseComplexPropElement(DOMElement $ele, IBeanDefinition $bd, $elementName) {
+ private function parseComplexPropElement(DOMElement $ele, IBeanDefinition $bd, $elementName, $defaultType = null) {
// Should only have one child element: ref, value, list, etc.
$nl = $ele->childNodes;
@@ -520,8 +522,7 @@
// ref.setSource(extractSource(ele));
return $ref;
} else if ($hasValueAttribute) {
-
- $valueHolder = $this->buildTypedStringValue($ele->getAttribute(self::VALUE_ATTRIBUTE), $ele->getAttribute(self::TYPE_ATTRIBUTE), $ele);
+ $valueHolder = $this->parseTypedAttributeValueElement($ele, $defaultType);
// @todo provide source info via BeanMetadataElement
// valueHolder.setSource(extractSource(ele));
return $valueHolder;
@@ -535,6 +536,15 @@
}
/**
+ * @param DOMElement $ele
+ * @param $defaultType
+ * @return TypedStringValue
+ */
+ public function parseTypedAttributeValueElement(DOMElement $ele, $defaultType) {
+ return $this->buildTypedStringValue($ele->getAttribute(self::VALUE_ATTRIBUTE), $ele, $defaultType);
+ }
+
+ /**
* Parse a value, ref or collection sub-element of a property or
* constructor-arg element
* @param DOMElement $ele subelement of property element; we don't know which yet
@@ -636,13 +646,7 @@
*/
public function parseValueElement(DOMElement $ele, $defaultType) {
// It's a literal value.
- $value = Bee_Utils_Dom::getTextValue($ele);
-
- $typeName = $ele->getAttribute(self::TYPE_ATTRIBUTE);
- if (!Bee_Utils_Strings::hasText($typeName)) {
- $typeName = $defaultType;
- }
- return $this->buildTypedStringValue($value, $typeName, $ele);
+ return $this->buildTypedStringValue(Bee_Utils_Dom::getTextValue($ele), $ele, $defaultType);
}
/**
@@ -650,16 +654,22 @@
* @see org.springframework.beans.factory.config.TypedStringValue
*
* @param String $value
- * @param String $targetTypeName
* @param DOMElement $ele
+ * @param string|null $defaultType
* @return TypedStringValue
*/
- protected function buildTypedStringValue($value, $targetTypeName, DOMElement $ele) {
+ public function buildTypedStringValue($value, DOMElement $ele, $defaultType = null) {
+
+ $typeName = $ele->getAttribute(self::TYPE_ATTRIBUTE);
+ if (!Bee_Utils_Strings::hasText($typeName)) {
+ $typeName = $defaultType;
+ }
+
$typedValue = null;
- if (!Bee_Utils_Strings::hasText($targetTypeName)) {
+ if (!Bee_Utils_Strings::hasText($typeName)) {
$typedValue = new TypedStringValue($value, $this->propertyEditorRegistry);
} else {
- $typedValue = new TypedStringValue($value, $this->propertyEditorRegistry, $targetTypeName);
+ $typedValue = new TypedStringValue($value, $this->propertyEditorRegistry, $typeName);
}
// @todo provide source info via BeanMetadataElement
// $typedValue->setSource(extractSource(ele));
@@ -728,7 +738,7 @@
if (!Bee_Utils_Strings::hasText($key)) {
$this->readerContext->error("Tag 'assoc-item' must have a 'key' attribute", $ele);
}
- $val = $this->parseComplexPropElement($ele, $bd, "<assoc-item> for key $key");
+ $val = $this->parseComplexPropElement($ele, $bd, "<assoc-item> for key $key", $defaultTypeClassName);
return array($key, $val);
}
Modified: trunk/framework/acl-default.xml
===================================================================
--- trunk/framework/acl-default.xml 2014-09-26 14:14:00 UTC (rev 234)
+++ trunk/framework/acl-default.xml 2014-09-26 14:56:42 UTC (rev 235)
@@ -2,7 +2,7 @@
<beans xmlns="http://www.beeframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.beeframework.org/schema/beans http://www.beeframework.org/schema/beans/bee-beans-1.1.xsd">
+ xsi:schemaLocation="http://www.beeframework.org/schema/beans http://www.beeframework.org/schema/beans/bee-beans-1.2.xsd">
<bean id="basicAuditLogger" class="Bee_Security_Acls_Impl_BasicAuditLogger" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|