...
Defining new service
Example: Openfire Service
Step 1. Create project directory
Under sipXconfig/plugins
directory: create a new project called . For example: openfire
Step 2. Create package
Create a new package. For example: org.sipfoundry.sipxconfig.openfire
(must start with: org.sipfoundry.sipxconfig)
Step 3. Create implementation.
Inside the package:
2.1 Create the service java class (. It must extend SipxService) org.sipfoundry.sipxconfig.service.SipxService
otherwise system will not recognize your class as a possible service.
Code Block |
---|
public class SipxOpenfireService extends SipxService { public static final String BEAN_ID = "sipxOpenfireService"; } |
2.2 Step 4. Create plugin manifest
Create the xml spring configuration file: sipxOpenfire-service-modelssipxplugins.beans.xml (must end with: -models.beans.xml) located in the root of your source tree
Code Block |
---|
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd"> <bean id="imBundle" parent="abstractBundle"> <constructor-arg value="im" /> </bean> <bean id="sipxOpenfireService" class="org.sipfoundry.sipxconfig.openfire.SipxOpenfireService" scope="prototype" parent="sipxService"> <property name="processName" value="SipXopenfire" /> <property name="bundles"> <set> <ref bean="imBundle" /> </set> </property> </bean> </beans> |
Any other Spring beans that perform any kind of functionality should be added here.
3Step 5. Create service start/stop script
Create a corresponding process.xml file that should be added on the sipX installation directory in process.d directory (near the other process.xml files): sipxopenfire-process.xml
Code Block |
---|
<?xml version='1.0' encoding='iso-8859-1' standalone='yes'?> <sipXecs-process xmlns='http://www.sipfoundry.org/sipX/schema/xml/sipXecs-process-01-00'> <name>SipXopenfire</name> <version><at:var at:name="VERSION" /></version> <commands> <configtest> <execute><at:var at:name="SIPX_BINDIR" />/sipxopenfire.sh</execute> <parameter>--configtest</parameter> </configtest> <start> <execute><at:var at:name="SIPX_BINDIR" />/sipxopenfire.sh</execute> <parameter>--start</parameter> </start> <stop> <execute><at:var at:name="SIPX_BINDIR" />/sipxopenfire.sh</execute> <parameter>--stop</parameter> </stop> </commands> <status> <pid><at:var at:name="SIPX_RUNDIR" />/sipxopenfire.pid</pid> <log><at:var at:name="SIPX_LOGDIR" />/sipxopenfire.log</log> </status> <resources> </resources> </sipXecs-process> |
Please make Be sure that SipXopenfire is the same as the name defined in -models.beans.xml file: <property name="processName" value="SipXopenfire" />
Please check sipXconfig's services.beans.xml/bundle in sipxplugins.beans.xml
for more information
Packaging
It is a paired down version of sipxconfig.spec that might be a template for packaging sipXconfig plugins.
sipxconfig-plugin-acme.spec
Code Block |
---|
Name: sipxconfig-acme
Version: 1.0
Release: 1
# java, no debug rpm nec.
%define debug_package %{nil}
# disable JAR repacking
%define __jar_repack %{nil}
Summary: Acme phone support for sipXconfig
License: LGPL??
Group: Telcommunications
Vendor: Example Corp.
Packager: First Last <first.last@example.com>
%define sipxpbxconf %{_sysconfdir}/sipxpbx
%define sipxconfiglib %{_datadir}/java/sipXecs/sipXconfig
Requires: sipxconfig
Source: %name-%version.tar.gz
BuildRoot: %{_tmppath}/%name-%version-root
%description
This package adds support for the Acme phones.
%prep
%setup -q
%build
%configure
make
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
%clean
rm -rf $RPM_BUILD_ROOT
# build should install one or more jars in sipxconfiglib directory...
%files
%defattr(644,root,root,755)
%{sipxconfiglib}/sipxconfig-acme.jar
%config(noreplace) %{sipxpbxconf}/acme/*
%post
%preun |
Service template
The attached template could be considered for developing a new managed service (by replacing all occurrences of "myservice" one could easily set up the needed sipXconfig project structure)
service-template.zip matches
<name>SipXopenfire</name>
in your service start/stop script.
Step 6. Packaging
Update appropriate Makefile, and rpm spec file to build and install your plugin.