| Name | Plugin Message Client |
|---|---|
| Version | 1.0 |
| Product Versions | tested on 2.7.0 & 2.7.3 but should work on conf 2.3+ and even jira |
| Author(s) | Alain Moran |
| Homepage | http://confluence.atlassian.com/display/CODEGEIST/Plugin+Message+Client |
| Price | FREE |
| License | BSD |
| Issue Tracking | https://jira.adaptavist.com/browse/PMC |
| Download jar | https://maven.atlassian.com/contrib/com/adaptavist/confluence/plugin-message-client/1.0.0/plugin-message-client-1.0.0.jar |
| Download Source | http://svn.atlassian.com/svn/public/contrib/confluence/plugin-message-client/ |
Description/Features
A library which when included as an extracted dependancy will allow java communication between the classloaders of the installed plugins.
The library uses the separation of the classloaders to allow multiple copies of itself to be loaded, each copy provides a local 'node' that manages the local message handlers, and executes them when a message is recieved.
The message manager also deals with locating the copy of itself in the target plugin and sending the message to it.
No attempt is made to copy classes between classloaders, so java native or maps of java native objects should be used for the messages themselves I tend to send hashmaps of strings however depending on your application you may find passing a Boolean more convenient. Theoretically it should be possible to pass any shared class, so Page objects should be just as valid as Boolean.
Sending your own classes may result in unexpected behaviour and should be avoided ![]()
Usage
Add the dependancy to your pom
<!-- plugin messaging -->
<dependency>
<groupId>com.adaptavist.confluence</groupId>
<artifactId>plugin-message-client</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
Also add the repository for the library
<repository>
<id>atlassian-m2-contrib</id>
<name>Atlassian Maven 2 Contributor Repository</name>
<url>http://maven.atlassian.com/contrib</url>
</repository>
Next, implement a message handler
public class MyMessageHandler extends PluginMessageHandler { private Logger log = Logger.getLogger(this.getClass()); private static final String[] HANDLED_MESSAGES = { "mymessageid"}; public Object execute(String messageId, Object message) { log.info("recieved message: "+messageId); return null; } public String[] getHandledMessageIds { return HANDLED_MESSAGES; } }
And register it with the message manager
PluginMessageManager.getInstance().addMessageHandler(new MyMessageHandler());
Messages are also sent using the manager
PluginMessageManager.getInstance().sendMessage("mymessageid","value");
Version History
| Version | Date | State | License | Price |
|---|---|---|---|---|
| 1.0 | 9 May 2008 | beta | BSD | FREE |
Other Adaptavist Entries
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
