Reputation: 2749
I am new to camel and While reading some code , I found these linesof codes,
String className = "ConvertMapToBeanType";
Class clazz = exchange.getContext().getClassResolver().resolveMandatoryClass(className);
getContext()
returns CamelContext.
getClassResolver()
Returns the class resolver to be used for loading/lookup of classes.
And what resolveMandatoryClass(className)
do? Is this returns Object of the 'className' Class. Is this true, then what is the advantage of creating class like this?
Upvotes: 0
Views: 64
Reputation: 6853
Depending on your runtime environment or configuration you might want to apply different strategies how to load a class by name. The calling code does not care about the strategy as long as it is the right one for the environment. So you provide an interface (e.g., ClassResolver
) to the calling code to execute one of several different strategy implementations (e.g., DefaultClassResolver
and OsgiClassResolver
) to achieve the goal.
Upvotes: 2