Nick (gagravarr) wrote,

Spring in a QName

This post was originally written in September 2010, and was available at - I have reposted it here as that blog is no longer online.

Within Alfresco, we make a lot of use of Qualified Names (QNames) for addressing and naming things. Generally, when configuring Alfresco through Spring or properties files, we can use the short form, eg

<bean id="coreBean" class="org.alfresco.some.thing.core">
  <property name="typeQName">

Within the bean, the NamespaceResolver is used to turn the friendly, short form (eg cm:description) into the full form (eg {}description).

However, every so often you may find yourself trying to configure something with Spring that no-one ever expected you to be trying to do… In this situation, the string form isn’t accepted by the class, and only a real QName object may be sprung in.

As it turns out, creating a real QName object from within Spring isn’t actually too hard to do. So, in case you ever find yourself needing to do it, the definition will look something like this:

<bean id="coreBean" class="org.alfresco.some.thing.core">
  <property name="typeQName">
      <bean class="org.alfresco.service.namespace.QName"
        <constructor-arg value="" />
        <constructor-arg value="description"/>

Tags: alfresco, spring

  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.