3

In the application context XML file, how do you set a constructor argument to a static class member?

For example, I am using Restlet and one of Restlet's classes called ChallengeAuthenticator receives a challenge scheme member variable.

// Normal Initialization
ChallengeAuthenticator challengeAuthenticator = new ChallengeAuthenticator(
                null, ChallengeScheme.HTTP_BASIC, "WSRealm");

I want to have this in the application context if possible. To something like this:

<bean id="challengeAuthenticator" class="org.restlet.security.ChallengeAuthenticator">
  <!-- Not meant to be String for value just trying to make it easier to reader to interpret my question -->  
  <constructor-arg value="ChallengeScheme.HTTP_BASIC" />
</bean>
ColinMc
  • 1,238
  • 3
  • 16
  • 33

1 Answers1

3

The easiest way is to use Spring Expression Language:

<constructor-arg value="#{ T(ChallengeScheme).HTTP_BASIC }" />

Note that you need a full class name in T(...).

axtavt
  • 239,438
  • 41
  • 511
  • 482