On 14 Oct 2015 at 06:43:36, Marius Dumitru Florea
(mariusdumitru.florea@xwiki.com(mailto:mariusdumitru.florea@xwiki.com)) wrote:
Hi Debajit,
On Oct 14, 2015 01:17, "Debajit Adhikary" wrote:
I created an XWiki component which is available as a jar file.
I have a ScriptService class for the component too:
----
@Role
public interface SearchClient
{
String search();
}
----
@Component
@Singleton
public class InternalSearchClient implements SearchClient
{
public String search()
{
return "test search results";
}
}
----
@Component
@Named("internalSearch")
@Singleton
public class InternalSearchScriptService implements ScriptService
{
@Inject
private InternalSearchClient searchClient;
You need to "inject" the role (interface), not directly the implementation.
That's why you use the Component Manager. Othewise you could have simply
used the "new" operator to instantiate yourself the component.
Good catch, didn’t see it when I replied yesterday! :)
I guess we could catch this in the AnnotationComponentLoader and report an error.