Can I use simple dependency injection in Jira/Confluence? For example simply annotating a class with @Component and then injecting in another class with @Autowired... or I need to do it using Spring Dynamic Modules as described here - https://developer.atlassian.com/display/DOCS/OSGi,+Spring+and+the+Plugin+Framework
Use dependency injection via constructor or setter -> https://developer.atlassian.com/display/CONFDEV/Spring+IoC+in+Confluence
Thanks, for the reference Steve. As far as I can see I can only use xml declarations of beans? ... no component scanning is in place and therefore cannot use annotations?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's a little bit more complicatet as beside spring each bean is a osgi component.
First, you do not use xml declarations, normally.
You will define a component module which represents a spring bean and an osgi component. This module is defined in the atlassian-plugin.xml. In generall you do not handle with spring directly. And you will not handle osgi directly. That's all wrapped in the atlassian plugin framework.
I'm not sure, but maybe @Reference from Felix-SCR might work. -> http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/scr-annotations.html#reference
But I have never tried that.
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.
Hi,
More Specifically First Add the component in your atlassian-plugin.xml like
<component key="myClass" class="com.componay.confluence.plugin.MyComponentClass"> <description>Provides Body markup service.</description> </component>
Then use setter injection/constructor injection to inject the object like
private MyComponentClass componentClass; public void setMyComponentClass(MyComponentClass componentClass) { this.componentClass= componentClass; }
It will inject the object reference in your target class.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Another way to do it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.
Register nowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.