Hello,
I have following class in Java code:
public class CHRTreeCreator extends IndexCreator { ... }
Instead CHRTreeCreator
I want to use diffrent implementation which also extends IndexCreator
, but I want to code it in JRuby. The problem is, specific implementation of IndexCreator
is chosen based on xml config file:
<creator>dwe.index.tree.chr.CHRTreeCreator</creator>
the code looks like this:
// className is fetched from XML
Class creatorClass = Class.forName(className);
Constructor constructor = creatorClass.getConstructor(new Class[] { });
creator = (IndexCreator) constructor.newInstance(new Object[] { });
The question is, is it possible to implement it in Ruby, like this:
class MyIndexCreator < IndexCreator
end
and somehow put MyIndexCreator
class name into XML config file. How does module - packages mapping work in that case?
If it's not possible to load Ruby classes by Java's Class.forName, how should I solve that issue?