Confluence Serverを使用していると仮定すると、開発マシンではinstall the Atlassian SDKが必要で、Confluence add-onを作成する必要があります。
これをすべて実行したら、スケルトンのConfluenceアドオンが必要です。
次に、あなたがそうのようなあなたのatlassian-plugin.xml
ファイルにイベントリスナーcomponent
とeventPublisher
component-import
を追加する必要があります。
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
</plugin-info>
<component
key="scroll-versions-event-listener"
class="me.davidsimpson.confluence.addons.example.listener.ScrollVersionsPublishEventListener"
name="Scroll Versions Publish Event Listener"
>
</component>
<component-import key="eventPublisher" interface="com.atlassian.event.api.EventPublisher" />
</atlassian-plugin>
次は、イベント・リスナーのクラスファイルを作成する必要があります。ここでは出発点です:この例では
package me.davidsimpson.confluence.addons.example.listener;
import com.atlassian.event.api.EventPublisher;
import org.springframework.beans.factory.DisposableBean;
public class ScrollVersionsPublishEventListener implements DisposableBean
{
protected final EventPublisher eventPublisher;
public ScrollVersionsPublishEventListener(EventPublisher eventPublisher)
{
this.eventPublisher = eventPublisher;
eventPublisher.register(this);
}
/**
* Unregister the listener if the plugin is uninstalled or disabled.
*/
public void destroy() throws Exception
{
eventPublisher.unregister(this);
}
@com.atlassian.event.api.EventListener
public void onVersionPublishEvent(Object event) {
String eventName = event.getClass().getCanonicalName(); // will work for other people's events, not just Atlassian's
// Spit out all events - just to prove the point
System.out.println(" ++ an event happened: " + eventName);
if (eventName.equals("com.k15t.scroll.platform.event.space.VersionPublishEvent")) {
System.out.println(" ++++ Found the right event ");
// Do your stuff here...
}
}
}
通知は、すべてのイベントがコンソールに出力されているが、我々は、この例では、特定の非標準的なイベントのためにチェックしています。
興味のあるイベントにif (eventName.equals(...))
を変更すると、準備が整いました。
こんにちは、特定のイベントが発生した場合、ページを再レンダリングすることは可能ですか? – JayBee
あなたが意味するものの例を挙げてください。あなたは何らかのクライアントサイドのJavaScriptイベントを意味しますか?または、サーバーサイドのConfluenceイベントですか? 通常のConfluenceイベントには、トリガー時にページを開いた人がいるという概念はありません。 – dvdsmpsn