How to inject a Jakarta enums in a Spring application context?

I have a class which constructor takes a Jakarta enums. I'm trying to find how I can easily inject it via an Spring XML aplicationContext.

For example :

The enum :

public class MyEnum extends org.apache.commons.lang.enums.Enum {
    public static final MyEnum MY_FIRST_VALUE = new MyEnum("MyFirstValue");
    public static final MyEnum MY_SECOND_VALUE = new MyEnum("MySecondValue");

    public static MyEnum getEnum(String name) {
        return (MyEnum) getEnum(MyEnum.class, name);
    [...other standard enum methods]

The class in which to inject :

public class MyService {
    private final MyEnum status;
    public MyService(MyEnum status) {
        this.status = status;

The application context :

<bean id="myService" class="MyService">
    <constructor-arg index="0" value="MyFirstValue" />

Of course, with this I have a no matching editors or conversion strategy found error. Is there an easy integration between Spring and the Jakarta enums ? Or should I write my own PropertyEditor ?


Check out the <util:constant> tag in Spring. It will require you to add the schema to your xml definition. So you would wind up with the following:

<bean id="myService" class="MyService">
  <constructor-arg index="0">
    <util:constant static-field="MyEnum.MY_FIRST_VALUE"/>

The definition and usage of the tag (including the XSD def) is found here.

Need Your Help

str_replace between first and second occurence


I want to make a function PHP to replace the Text Like this example

no route.h on the iPhone SDK

iphone c networking network-programming

I am trying to build some code that is originally target at OSX/BSD/Linux for the iPhone. It uses struct rt_msghdr from route.h but as it turns out this header is not available in the iPhone SDK.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.