On May 18, 2009, at 6:52 PM, Vincent Massol wrote:
Great but why do you need the FQN as role hint?
Since you lookup all components implementing the XWikiRestComponent
role you have access to all FQN.
At registration time, I have to tell Restlet/JAXRS what are the
java.lang.Classes that implement JAXRS entities.
So, at startup, I basically do this for registering components once
for all:
List<XWikiRestComponent> components =
componentManager.lookupList(XWikiRestComponent.class);
for (XWikiRestComponent component : components) {
jaxRsClassed.add(component.getClass())
}
During normal operation, Restlet/JAXRS starts calling the object
factory through the method
public <T> T getInstance(Class<T> clazz) throws InstantiateException
whenever it needs an instance of a given class.
So, in order to lookup a component, I just have the class name to be
used as a way for identifying it.
What I do is:
componentManager.lookup(XWikiRestComponent.class, clazz.getName());
That's the reason why the hint if the FQN of the class.
If I don't use the FQN I would have to create a mapping class-
symbolic name (hint) at startup using the lookupMap
method.
Doable but more complicated, so I just delegated the responsibility to
the programmer to declare things in the right way :)
Cheers,
Fabio