|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.beans.factory.xml.SimpleConstructorNamespaceHandler
public class SimpleConstructorNamespaceHandler
Simple NamespaceHandler
implementation that maps custom
attributes directly through to bean properties. An important point to note is
that this NamespaceHandler
does not have a corresponding schema
since there is no way to know in advance all possible attribute names.
An example of the usage of this NamespaceHandler
is shown below:
<bean id="author" class="..TestBean" c:name="Enescu" c:work-ref="compositions"/>Here the '
c:name
' corresponds directly to the 'name
' argument declared on the constructor of class 'TestBean
'. The
'c:work-ref
' attributes corresponds to the 'work
'
argument and, rather than being the concrete value, it contains the name of
the bean that will be considered as a parameter.
Note: This implementation supports only named parameters - there is no
support for indexes or types. Further more, the names are used as hints by
the container which, by default, does type introspection.
SimplePropertyNamespaceHandler
Field Summary | |
---|---|
private static java.lang.String |
DELIMITER_PREFIX
|
private static java.lang.String |
REF_SUFFIX
|
Constructor Summary | |
---|---|
SimpleConstructorNamespaceHandler()
|
Method Summary | |
---|---|
private boolean |
checkName(java.lang.String name,
java.util.Collection<ConstructorArgumentValues.ValueHolder> values)
|
private boolean |
containsArgWithName(java.lang.String name,
ConstructorArgumentValues cvs)
|
BeanDefinitionHolder |
decorate(org.w3c.dom.Node node,
BeanDefinitionHolder definition,
ParserContext parserContext)
Parse the specified Node and decorate the supplied
BeanDefinitionHolder , returning the decorated definition. |
void |
init()
Invoked by the DefaultBeanDefinitionDocumentReader after
construction but before any custom elements are parsed. |
BeanDefinition |
parse(org.w3c.dom.Element element,
ParserContext parserContext)
Parse the specified Element and register any resulting
BeanDefinitions with the
BeanDefinitionRegistry
that is embedded in the supplied ParserContext . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String REF_SUFFIX
private static final java.lang.String DELIMITER_PREFIX
Constructor Detail |
---|
public SimpleConstructorNamespaceHandler()
Method Detail |
---|
public void init()
NamespaceHandler
DefaultBeanDefinitionDocumentReader
after
construction but before any custom elements are parsed.
init
in interface NamespaceHandler
NamespaceHandlerSupport.registerBeanDefinitionParser(String, BeanDefinitionParser)
public BeanDefinition parse(org.w3c.dom.Element element, ParserContext parserContext)
NamespaceHandler
Element
and register any resulting
BeanDefinitions
with the
BeanDefinitionRegistry
that is embedded in the supplied ParserContext
.
Implementations should return the primary BeanDefinition
that results from the parse phase if they wish to be used nested
inside (for example) a <property>
tag.
Implementations may return null
if they will
not be used in a nested scenario.
parse
in interface NamespaceHandler
element
- the element that is to be parsed into one or more BeanDefinitions
parserContext
- the object encapsulating the current state of the parsing process
BeanDefinition
(can be null
as explained above)public BeanDefinitionHolder decorate(org.w3c.dom.Node node, BeanDefinitionHolder definition, ParserContext parserContext)
NamespaceHandler
Node
and decorate the supplied
BeanDefinitionHolder
, returning the decorated definition.
The Node
may be either an Attr
or an
Element
, depending on whether a custom attribute or element
is being parsed.
Implementations may choose to return a completely new definition,
which will replace the original definition in the resulting
BeanFactory
.
The supplied ParserContext
can be used to register any
additional beans needed to support the main definition.
decorate
in interface NamespaceHandler
node
- the source element or attribute that is to be parseddefinition
- the current bean definitionparserContext
- the object encapsulating the current state of the parsing process
null
value is strictly speaking invalid, but will be leniently
treated like the case where the original bean definition gets returned.private boolean containsArgWithName(java.lang.String name, ConstructorArgumentValues cvs)
private boolean checkName(java.lang.String name, java.util.Collection<ConstructorArgumentValues.ValueHolder> values)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |