Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8715693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:54:33+00:00 2026-06-13T05:54:33+00:00

I have a custom implementation of an AbstractSingleBeanDefinitionParser to allow me to define 3D

  • 0

I have a custom implementation of an AbstractSingleBeanDefinitionParser to allow me to define 3D Vectors in my spring config with less… ceremony than would otherwise be required.

<rbf:vector3d id="test_vector" delimeter=";" value="45;46;47"/>

That works great, and I have been using it for months without any problems. Yesterday I tried to define the value in a .properties file like this:

In test.properties I have:

vector3d.value=1,2,3

And in the xml file I have:

<context:property-placeholder location="test.properties"/>
<rbf:vector3d id="test_vector_with_properties" delimeter="," value="${vector3d.value}"/>

When I try to run my unit test, it crashes, and I get this exception:

Caused by: java.lang.NumberFormatException: For input string: "${vector3d.value}"
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1222)
    at java.lang.Double.parseDouble(Double.java:510)
    at scala.collection.immutable.StringLike$class.toDouble(StringLike.scala:234)
    at scala.collection.immutable.StringOps.toDouble(StringOps.scala:31)
    at rb.foundation.spring.xml.Vector3DBeanDefinitionParser$$anonfun$1.apply(Vector3DBeanDefinitionParser.scala:25)

When I use the .properties file for normal beans, it works great, which leads me to believe that there is a subtlety that I overlooked in my implemention of my parser. It’s written in scala, but you should be able to follow it:

class Vector3DBeanDefinitionParser extends AbstractSingleBeanDefinitionParser
{
  override def getBeanClass(element : Element) = classOf[Vector3D]

  override def doParse(element: Element, builder: BeanDefinitionBuilder)
  {
    val delim = element.getAttribute("delimeter")
    val value = element.getAttribute("value")

    val values = value.split(delim).map(_.toDouble)

    builder.addConstructorArgValue(values(0))
    builder.addConstructorArgValue(values(1))
    builder.addConstructorArgValue(values(2))
  }
}

I’m happy to add the key substitution if necessary, I just need to know where/how to do it.

Ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:54:33+00:00Added an answer on June 13, 2026 at 5:54 am

    So the reason this doesn’t work is that your BeanDefinitionParser runs much before property placeholders are resolved. Simple overview as I understand it:

    1. BeanDefinitionParsers parse the XML into BeanDefinition objects in memory
    2. BeanDefinitions are then loaded into a BeanFactory
    3. BeanFactoryPostProcessors (including the property placeholder configurers) are executed on the bean definitions
    4. beans are created from the bean definitions

    (Of course other things happen along the way, but those are the relevant steps here.)

    So in order to get the resolved property value into your Vector3D object, I think you’re going to have to delay specifying the arguments to the Vector3D constructor until after BeanFactoryPostProcessors have run. One way that occurs to me is to have your BeanDefinitionParser construct a bean definition for a Spring FactoryBean instead of the Vector3D itself. Then the splitting of the vector value that you currently have in your Vector3DBeanDefinitionParser would need to be in the FactoryBean implementation instead.

    Sorry, I’m not too familiar with Scala so this will be in Java.

    The FactoryBean class would look something like this:

    import org.springframework.beans.factory.FactoryBean;
    
    public class Vector3DFactoryBean implements FactoryBean<Vector3D> {
        private String delimiter;
        private String value;
        private transient Vector3D instance;
    
        public String getDelimiter() { return delimiter; }
        public void setDelimiter(String delimiter) { this.delimiter = delimiter; }
        public String getValue() { return value; }
        public void setValue(String value) { this.value = value; }
    
        @Override
        public Vector3D getObject() {
            if (instance == null) {
                String[] values = value.split(delimiter);
                instance = new Vector3D(
                                        Double.parseDouble(values[0]),
                                        Double.parseDouble(values[1]),
                                        Double.parseDouble(values[2])
                                       );
            }
            return instance;
        }
        @Override
        public Class<?> getObjectType() {
            return Vector3D.class;
        }
        @Override
        public boolean isSingleton() {
            return true;
        }
    }
    

    Then your Vector3DBeanDefinitionParser would just pass the delimiter and value untouched to the Vector3DFactoryBean bean definition:

    class Vector3DBeanDefinitionParser extends AbstractSingleBeanDefinitionParser
    {
      override def getBeanClass(element : Element) = classOf[Vector3DFactoryBean]
    
      override def doParse(element: Element, builder: BeanDefinitionBuilder)
      {
        val delim = element.getAttribute("delimeter")
        val value = element.getAttribute("value")
    
        builder.addPropertyValue("delimiter", delim)
        builder.addPropertyValue("value", value)
      }
    }
    

    Then later when the placeholder property configurer runs, it should resolve the property values in the Vector3DFactoryBean bean definition. When beans are finally created from bean definitions, the Vector3DFactoryBean will parse the vector values and create the Vector3D object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based on the Spring Data Document documentation , I have provided a custom implementation
We are using Spring Security 3. We have a custom implementation of PermissionEvaluator that
I have a custom implementation of a RESTful API for a PHP application that
I have a custom implementation of IDataServiceMetadataProvider / IDataServiceQueryProvider / IDataServiceUpdateProvider, put together from
I have a custom NSTextField sub-class with a custom drawRect: implementation. The text field
I have tab controller created through storyboards with a custom implementation (simple buttons and
I have a custom model binder which pulls an implementation of an interface from
I have a custom implementation of IResourceProvider and ResourceProviderFactory . Now the default way
I have a custom NSTableRowView implementation to display my data cells. The table also
I have a custom windows implementation in a WPF app that hooks WM_GETMINMAXINFO as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.