Do I am trying something special? I have a plugin which should access components from other plugins via ComponentManager.
For the OSGi stuff I think a simple call to
ComponentManager.getOSGiComponentInstanceOfType(MultipleGitRepositoryManager.class);
should do the job. But I get a ClassCastException at
public static <T> T getOSGiComponentInstanceOfType(final Class<T> clazz){ .... return clazz.cast(serviceTracker.getService()); .... }
It seems that my MultipleGitRepositoryManager is another than the one Felix have.
In my POM all dependencies have the scope provided.
Is there a way out of this?
After some experiments it seams that Felix hold one reference of a service. If I try to retrieve this service he is running in massive classloader problems.
Community moderators have prevented the ability to post new answers.
If you need to consume a public component, you should do it via the <component-import> tag. Trying to retrieve the service directly via that java code you posted will bypass a lot of protective code that you'll want. You shouldn't have to do anything with package imports, unless there are two instances of that service exposed and you only want a specific instance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
with component-import in plugin.xml and the component in the pom.xml it makes an error. I remove it from pom.xml and it works :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need to declare your component as public in atlassian-plugin.xml
See https://developer.atlassian.com/display/PLUGINFRAMEWORK/Component+Plugin+Module
Specifically the public attribute
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it were nice if it were so simple...the component I want to consume is already public.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You might need to import it in your bundle-imports section in your plugin.xml... Can you try that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you mean this?
<component-import key="gitManager" interface="com.xiplink.jira.git.MultipleGitRepositoryManager"/>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah sorry, read your question in a rush. Thought you were after exposing your component.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No I mean like this:
<bundle-instructions> <Import-Package>com.atlassian.jira.jql.builder,*;resolution:=optional</Import-Package> </bundle-instructions>
in the plugin-info section. Check the atlassian docs...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
seems to working.
But now I get an LinkageError. This I can solve if I restart the RevisionIndexService of the foreign Plugin. Are there known issues if more than one client consume an osgi component?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You shouldn't need to mess with import package statements, as the component-import tag should do the trick. You should only get linkage errors if you are bound to a different classloader that provides that interface than the one used by the service. Therefore, I'd recommend ditch the import package stuff and just use component-import. If that doesn't work, ensure that only one copy of that class is being exposed and once service impl. Also, there are no known issues with multiple plugins consuming a single public component.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes...with the component-import it works now. thanks all for the help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.