blob: ba8f623165a3171e36b2c67b6043896c2c55e500 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<title>Vysper Extending the Server &mdash; Apache MINA</title>
<link href="/assets/css/common.css" rel="stylesheet" type="text/css"/>
<link href="/assets/css/vysper.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<script src="https://www.apachecon.com/event-images/snippet.js"></script>
<div id="container">
<div id="header">
<div id="subProjectsNavBar">
<a href="/">
Apache MINA Project
</a>
&nbsp;|&nbsp;
<a href="/mina-project/">
MINA
</a>
&nbsp;|&nbsp;
<a href="/asyncweb-project/">
AsyncWeb
</a>
&nbsp;|&nbsp;
<a href="/ftpserver-project/">
FtpServer
</a>
&nbsp;|&nbsp;
<a href="/sshd-project/">
SSHD
</a>
&nbsp;|&nbsp;
<a href="/vysper-project/">
<strong>Vysper</strong>
</a>
</div>
</div>
<div id="content">
<div id="leftColumn">
<div id="navigation">
<a class="acevent" data-format="wide" data-width="170"></a>
<h5>Social Networks</h5>
<ul>
<li><a href="https://fosstodon.org/@apachemina">Apache MINA Mastodon</a></li>
</ul>
<h5>Overview</h5>
<ul>
<li><a href="/vysper-project/index.html">Home</a> </li>
<li><a href="/vysper-project/documentation.html">Documentation</a></li>
<li><a href="/vysper-project/downloads.html">Downloads</a></li>
<li><a href="/vysper-project/sources.html">Source</a></li>
</ul>
<h5>Community</h5>
<ul>
<li><a href="/vysper-project/mailing_lists.html">Mailing Lists</a></li>
<li><a href="/vysper-project/getting_involved.html">Getting Involved</a></li>
<li><a href="/vysper-project/issue_tracking.html">Issue Tracking</a></li>
<li><a href="https://www.apache.org/foundation/contributing.html">Contributing</a></li>
<li><a href="https://www.apache.org/licenses/">License</a></li>
<li><a href="https://www.apache.org/security/">Security</a></li>
</ul>
<h5>Sponsorship</h5>
<ul>
<li><a href="https://www.apache.org/foundation/thanks.html">Thanks</a></li>
<li><a href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
<li><a href="https://www.apache.org/">apache.org</a></li>
</ul>
</div>
</div>
<div id="rightColumn">
<h1 id="how-to-extend-the-server-functionality">How to extend the server functionality</h1>
<h2 id="xmpp-support-for-extensions">XMPP support for extensions</h2>
<p><a href="http://www.xmpp.org/">XMPP</a> provides a bunch of already specified extensions. See <a href="http://www.xmpp.org/extensions">http://www.xmpp.org/extensions</a> for a complete list.</p>
<p>XMPP also allows for custom extensions of the core stanza types &lsquo;message&rsquo;, &lsquo;iq&rsquo; and &lsquo;presence&rsquo;. All XMPP clients and servers should be able to savely ignore them unless they are able to deal with them. See the <a href="http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-05.html#stanzas-extended">relevant specification chapter</a>.</p>
<p>Most XMPP extensions rely on Disco (Service Discovery, XEP-0030).
It&rsquo;s easy to integrate modules with Vysper&rsquo;s Disco extension.</p>
<p>Most XMPP extensions rely on Disco (<a href="http://xmpp.org/extensions/xep-0030.html">Service Discovery, XEP-0030</a>).
It&rsquo;s easy to integrate modules with <a href="service_discovery.html">Vysper&rsquo;s Disco extension</a>.</p>
<h2 id="modules">Modules</h2>
<p>Regardless which kind of extension it is (Vysper internal, XMPP standardized or home-brewn) they all can be deployed using the Vysper Modules.</p>
<p>Vysper Modules are implementations of interface org.apache.vysper.xmpp.modules.Module, but it is probably more convenient to extend DefaultModule. Modules supporting disco should extend DefaultDiscoAwareModule.</p>
<p>An example of a Vysper-internal module is org.apache.vysper.xmpp.modules.roster.RosterModule.</p>
<h2 id="handlers-and-dictionaries">Handlers and Dictionaries</h2>
<p>Every incoming stanza is processed by one dedicated StanzaHandler instance. For implementing a new functionality, we&rsquo;d have to code new StanzaHandlers. They are registered with the server. The server introspects the stanza and decides which handler is tailored for it by basically looking at the stanza name (&lsquo;message&rsquo;/&lsquo;iq&rsquo;/&lsquo;presence&rsquo;) and the namespace attributes (&lsquo;xmlns&rsquo;) on the top and first-child XML elements.</p>
<p>Dictionary objects are used to compile handlers for the same namespace.</p>
<h2 id="a-custom-handler">A custom handler</h2>
<p>It is highly recommended that custom handlers do subclass</p>
<ul>
<li>org.apache.vysper.xmpp.modules.core.base.handler.DefaultIQHandler</li>
<li>org.apache.vysper.xmpp.modules.core.base.handler.MessageHandler</li>
<li>org.apache.vysper.xmpp.modules.core.im.handler.PresenceHandler</li>
</ul>
<h2 id="activate-a-module-in-the-server">Activate a module in the server</h2>
<p>Modules are registered with the server calling ServerRuntimeContext.addModule(Module module).</p>
<p>Using spring-config.xml, they are configured in bean &lsquo;server&rsquo;. Simply add a new bean for the module to the config. Then add a bean reference to property &lsquo;modules&rsquo; list in &lsquo;server&rsquo;. On server startup, these modules are loaded and activated.</p>
</div>
<div id="endContent"></div>
</div>
<div id="footer">
&copy; 2003-2024, <a href="https://www.apache.org">The Apache Software Foundation</a> - <a href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy Policy</a><br />
Apache MINA, MINA, Apache Vysper, Vysper, Apache SSHd, SSHd, Apache FtpServer, FtpServer, Apache AsyncWeb, AsyncWeb,
Apache, the Apache feather logo, and the Apache Mina project logos are trademarks of The Apache Software Foundation.
</div>
</div>
</body>
</html>