Instantiating spring beans in dynamically created classes.

Posted by Xetius on Stack Overflow See other posts from Stack Overflow or by Xetius
Published on 2010-05-19T17:47:40Z Indexed on 2010/05/19 17:50 UTC
Read the original article Hit count: 228

Filed under:
|

I am dynamically creating classes which contain spring beans, however the beans are not getting instantiated or initialised, leaving them as null.

How do I make sure that a dynamically created class creates all of its spring beans properly?

This is how I am dynamically creating the class:

Class ctransform;
try {
    ctransform = Class.forName(strClassName);
    Method handleRequestMethod = findHandleRequestMethod(ctransform);
    if (handleRequestMethod != null) {
        return (Message<?>) handleRequestMethod.invoke(ctransform.newInstance(), message);
            }
    }

This leaves all spring bean objects within ctransform (of type strClassName) as null.

© Stack Overflow or respective owner

Related posts about java

Related posts about spring