Results 1 to 2 of 2

Thread: How to set a bean property of type safe-type enum class?

  1. #1
    Join Date
    Dec 2004
    Posts
    1

    Default How to set a bean property of type safe-type enum class?

    Hi.. I'm a newbie Spring user.

    I've this class :

    public class MyClass {

    private ConfigKey theKey;

    // setter

    }

    ConfigKey is a type-safe enum class :

    public class ConfigKey {

    private ConfigKey(int key){
    this.key = key;
    }

    private int key;

    public static final ConfigKey KEY_1 = new ConfigKey(1);
    public static final ConfigKey KEY_2 = new ConfigKey(2);

    }


    How should I fill the ??? below?

    <bean class="MyClass " id="myClass">
    <property name="minProcessKey">
    <value>???</value>>
    </property>
    <property name="maxProcessKey">
    <value>???</value>>
    </property>
    </bean>

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    If you want to assign instances of your enum class to a property you can use org.springframework.beans.factory.config.FieldRetr ievingFactoryBean. Have a look at the API documentation for an example.

    Alternatively, maybe this thread could be helpful (though it's about java5 enums):
    http://forum.springframework.org/sho...highlight=enum

    Hope that helps,
    Andreas
    Last edited by robyn; May 14th, 2006 at 05:42 PM.

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •