플러그인 개발 가이드.
http://download.igniterealtime.org/openfire/docs/latest/documentation/plugin-dev-guide.html
플러그인 디렉토리에 하위 디렉토리를 추가한다.
- Openfire-3.10.2/src/plugins
- 다음과 같은 디렉토리 구조로 추가.
+ helloWorld ———————> 플러그인 명.
+ src
+ java ———————> 소스 디렉토리로 지정.
+ com.my.openfire.plugin.test ———————> 패키지 명.
+ HelloWorldPlugin.java
+ web
+ index.html
+ plugin.xml
1. plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<class>com.my.openfire.plugin.test.HelloWorldPlugin</class>
<name>HelloWorld</name>
<description>HelloWorld plugin</description>
<author>trvoid</author>
<version>1.0</version>
<date>05/16/2013</date>
<url>http://trvoid.blogspot.com</url>
<minServerVersion>3.0.0</minServerVersion>
<licenseType>internal</licenseType>
<adminconsole>
<tab id="tab-helloworld" name="HelloWorld"
description="Click to manage HelloWorld">
<sidebar id="sidebar-hello-config" name="Configuration">
<item id="hello-intro" name="Introduction" url="index.html" description="Click to view Introduction"/>
</sidebar>
</tab>
</adminconsole>
</plugin>
2. HelloWorldPlugin.java
package com.my.openfire.plugin.test;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.event.SessionEventDispatcher;
import org.jivesoftware.openfire.event.SessionEventListener;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.util.JiveGlobals;
import java.io.File;
public class HelloWorldPlugin implements Plugin {
private static String MYOPTION = "값";
public void setMyOption(String value) {
JiveGlobals.setProperty(MYOPTION, value);
}
public String getMyOption() {
return JiveGlobals.getProperty(MYOPTION, "기본값");
}
@Override
public void initializePlugin(PluginManager manager, File pluginDirectory) {
System.out.println("init HelloWorldPlugin.");
System.out.println("add SessionEventListener.");
SessionEventDispatcher.addListener(new MySessionEventListener());
}
@Override
public void destroyPlugin() {
System.out.println("destroy HelloWorldPlugin.");
}
private class MySessionEventListener implements SessionEventListener {
@Override
public void sessionCreated(Session session) {
System.out.println("MySessionEventListener sessionCreated.");
}
@Override
public void sessionDestroyed(Session session) {
System.out.println("MySessionEventListener sessionDestroyed.");
}
@Override
public void anonymousSessionCreated(Session session) {
System.out.println("MySessionEventListener anonymousSessionCreated.");
}
@Override
public void anonymousSessionDestroyed(Session session) {
System.out.println("MySessionEventListener anonymousSessionDestroyed.");
}
@Override
public void resourceBound(Session session) {
System.out.println("MySessionEventListener resourceBound.");
}
}
}
3. index.html
<html>
<head>
<title>HelloWorld</title>
<meta name="pageID" content="hello-intro"/>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
4. 전체 플러그인 빌드
$ ant plugins
5. 하나의 플러그인 빌드
$ ant -Dplugin=<pluginName> plugin
6. 플러그인 설치
1) Admin Console의 Plugins 탭으로 이동한다.
2) "파일 선택" 버튼을 눌러 아래의 위치에서 설치하고자 하는 플러그인 파일을 선택한다.
openfire_src\target\openfire\plugins
3) "Upload Plugin" 버튼을 누른다.