Shant Dashjian
Shant Dashjian

Reputation: 1010

How do I pass a class type to a method call using Spring Expression Language in an XML bean configuration?

I want to inject a bean using XML configuration. The constructor takes an object of type OrderService which I get from calling the factory method serviceBroker.getService(). That method takes a class type as argument. How do I specify that class type in the method call using Spring Expression Language? Here is what I have right now and it is giving an error when deploying:

  <bean id="extendItemRequestProcessor" class="com.site.ExtendItemRequestProcessor">
    <constructor-arg type="com.site.service.order.OrderService" value="#{serviceBroker.getService(com.site.service.order.OrderService.class)}"/>
  </bean>

Upvotes: 0

Views: 1833

Answers (1)

Gary Russell
Gary Russell

Reputation: 174494

Use the T operator.

 T(com.foo.MyClass)

Upvotes: 1

Related Questions