pass "HardCoded" Constructor Arg Class<T> to bean via Spring Config

Viewed 9669

I have a generic type that I am injecting into a service. Because of the way generics are implemented in Java, I need to have a constructor arg (or property setter) that holds the Class information of the generic type parameter.

My question is -- Can I, via property injection or specifying a constructor arg, pass in an instance of Class with spring?

I DO know the type of T before run time so I know specifically what the Type parameter will be.

I was thinking it would look something like this:

<bean id="dataMartService" class="com.someclass">
    <constructor-arg value="java.lang.class<com.someotherclass>" />
</bean>

Am I completely off in how this should happen?

3 Answers
Related