Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Dependencie between plugin A and plugin B with OSGi and Spring on Confluence

Richard Bézin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 21, 2018

Hi,

I want to create 2 plugins on Confluence: the first is like a "core" and the second, "macro" uses this core.
I created 2 plugins with atlas-create-confluence-plugin command.
Following the snippset, I only kept api/MyPluginComponent interface:

public interface MyPluginComponent
{
String getName();
}

and impl/MyPluginComponentImpl class file in the "core" plugin:

@Component
public class MyPluginComponentImpl implements MyPluginComponent
{

public String getName()
{
return "myComponent";
}
}


In the "macro" part, I create a Macro wich use MyPluginComponent:

public class PluginMacro implements Macro {

private final MyPluginComponent myPluginComponent;
private final XhtmlContent xhtmlContent;

@Autowired
public PluginMacro(@ComponentImport MyPluginComponent myPluginComponent, @ComponentImport XhtmlContent xhtmlContent) {
this.myPluginComponent = myPluginComponent;
this.xhtmlContent = xhtmlContent;
}

@Override
public String execute(Map<String, String> map, String s, ConversionContext conversionContext) {
try {
return xhtmlContent.convertStorageToView(myPluginComponent.getName(), conversionContext);
} catch (XMLStreamException | XhtmlException e) {
e.printStackTrace();
}
return "Error";
}

@Override
public BodyType getBodyType() {
return BodyType.NONE;
}

@Override
public OutputType getOutputType() {
return OutputType.BLOCK;
}

}

 

The core part compiles, but of course the "macro" part needs the "core" dependencies. I try to add the jar with Maven, but when I upload "core" and "macro" on my Confluence, I take this error :
 

ERROR [Spring DM Context Creation Timer] [internal.dependencies.startup.DependencyWaiterApplicationContextExecutor] fail Unable to create application context for [com.km.plugin_macro], unsatisfied dependencies: Dependency on [(&(objectClass=com.km.core.api.MyPluginComponent)(objectClass=com.km.core.api.MyPluginComponent))]

In /plugins/servlet/upm/osgi, I can see "macro" imports com.km.core.api..

 

I don't know if I use the right annotations, or maybe I need to update pom.xml files ?

Thanks for the help,

Richard

1 answer

0 votes
Santwana Sarangi {Appfire}
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 23, 2018

Hi Richard,

 

You need to include a dependency for core plugin in the pom.xml of the macro plugin and create an obr of the macro plugin. Please refer to the below links

https://community.atlassian.com/t5/Jira-articles/Tutorial-how-to-create-an-obr-with-dependent-jar-inside/ba-p/708656

https://developer.atlassian.com/server/framework/atlassian-sdk/bundling-extra-dependencies-in-an-obr/

Hope this helps.

 

Thanks,

Santwana

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events