BLOG

Modifying and rebuilding openfire plugins from source

We just finished modifying an openfire plugin for a  real time ecommerce requirement in our project.  It gave us a chance to peek into the internals of technology we use (openfire) and we were really glad .  The purpose of this post is to share what we learnt so that it can help anyone else seeking knowledge of the subject

javameetsof

Openfire is an XMPP (Jabber) server written in java. If you are reading this article, chances are that you already know about XMPP or are at least
interested in developing with xmpp . If not then its a technology worth knowing as it makes instant messaging and
real time collaboration possible. Its also one of the many things that powers all the fancy real-time stuff that we see happening all the
time on google and facebook. In our project, which is an online social shopping mall, openfire powers the real-time features such as
one-to-one chat between sellers and shoppers, store shoutbox, group buying, real-time notification and
activity feeds.

Coming back to openfire, the functionality of the server can be extended by means of plugins which makes it really powerful.
A lot of plugins are available that meet general requirements but if you are using xmpp extensively in your application, there may
be a case that you need to modify the plugin to add a specific functionality. This post will throw some light on how to do this.

Getting the source -
The first thing to do is to get the openfire source code which also includes the source of all officially available plugins.

check-out the code from their svn in eclipse

http://svn.igniterealtime.org/svn/repos/openfire/trunk

Renaming the plugin -
Plugins can be found under the plugins namespace.
For eg. in our case the plugin was Monitoring service plugin that archives messages sent over the server. It can be found in
plugins.monitoring namespace. All the plugin info is specified in the plugin.xml file along with rules to add changes to the user interface in the admin

console.

(To know more about complete structure of a plugin directory refer to this guide

http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/plugin-dev-guide.html)

Plugins can be renamed by changing the name property in this file.
But when we did it, we made a copy of the plugin and kept the original plugin which meant that the directory name was changed and thus the references in code

had to be changed as well. If you choose to do it this way, then its necessary to make sure that while renaming the package, leave the “update references”

checkbox blank when eclipse prompts you with an option. otherwise it will try to change the package declaration which will cause compilation errors later.
Although I am not too sure about this but I think we could have avoided changing the class name and references by simply modifying the plugin and just

changing the name inside the xml file instead of renaming the package.

After renaming the plugin, you are free to do whatever modifications you wish to do. In case you wish to add some user defined variables, then its very easy
to make changes to the admin console user interface as well. This can be done by modifying the jsp files inside the src.web interface.
Remember that Openfire has multi language support, so it would be a wise to add text to i18n files instead of hard coding it in jsp files.

Rebuilding
Openfire uses Apache Ant (http://ant.apache.org/) for build processes such as compilation and deployment. So you will also need this tool.
Now, in simple words, Ant does what we want it to do by reading an xml file called BuildFile.
The buildfile for Openfire and its plugins comes with the source code which we give to Ant and it takes care of the rest.
But before we build Openfire plugin using Ant, I would recommend you try out building a simple Hello-World-type. This will require you to
create your own buildfile which will help in understanding Ant better. I found this (http://www.roseindia.net/jboss/10_minutes_guide_to_ant.shtml)
tutorial quite useful when I want doing it.

Once you have finished this tutorial, you are all set to build the Openfire plugin. Locate the buildfile in Openfire/build directory.
Open the terminal and go inside this directory. Now you may run different Ant commands depending upon what you are trying to do -

For building openfire -
$ ant openfire

For building all plugins -
$ ant plugins

This will create two new directories inside your main Openfire directory named “target” and “work”

Find the .jar file for your plugin inside the target/openfire/plugins directory

If ant finds any compilation errors in the code, it will throw them in the terminal itself and stop the compilation. It will also
show the line numbers etc for debugging. In such a case you would want to delete the files created due to incomplete compilation
So just execute this command

$ ant clean

It will delete the target and work directories. Fix the bugs and run ant command again.

Uploading and Activating the plugin
To upload your modified plugin, go to the Plugins section inside the Openfire admin console. At the bottom of the page, there is a form
to upload plugins in .jar format. When plugins are uploaded this way, openfire copies it to plugins directory inside the Openfire “Home” directory
and also extracts it there. The location of the Home directory will differ depending upon the OS. Here, on Ubuntu desktop, its /var/lib/openfire


Ecommerce Quickstart

ecom3

At Kodeplay ,  our esteemed clients come up with queries,ideas during the initial stages of an ecommerce project . As they venture into the world of online
retail , we are happy to help them  make the right decisions after studying their requirements and business model . We have compiled a list of FAQ’s for
Businesses wanting to chalk out a strategy to hit the Bulls Eye with their first attempt at starting a web store .

1)Which ecommerce software  solution will be the best for me?

In order to get a web store up and running quickly , It is important to start with the most appropriate out of the box solution .

As per the Business rules  and user feedback  customizations can be added .
Open source solutions have the advantage of a wide community , less turn around time for customizations,available plugins,modules for plug and play.
Closed source solutions can be looked at for high scalability ,security and use cases involving integrations with legacy systems, integrations with existing architecture

The most widely used open source ecommerce solutions currently are :
OSCommerce , Zen Cart , magento , VirtueMart ,Uber cart ,WP commerce, prestashop , opencart ,CS cart .

The following points must be considered to choose an open source solution :

1)Level of customization required to implement Business Rules
2)Choice of web server , infrastructure
3)Skills required for possible customizations
4)Expected traffic , end user preferences,ease of use

It is very important to use the right opensource codebase for the right job.
To avoid changes , rework it is best to evaluate the open source solutions in detail or hire an expert .

2)Can we have the same web store for multiple languages across countries

Yes . Most open source solutions as well as propreitory systems offer language packs which can be easily integrated.
In case a specific language pack is unavailable , Translation services will have to be subscribed to .

Cusomized modules should also use text from the language packs . The end users can choose a language of their choice from the frontend.

3)Will I be able to change the look and feel of my web shop instantly from time to time ?

This is an excellent idea  during seasonal offers , festivals . It is best to create custom themes for specific events .

Themes can be switched from the administrator panel. The customized themes should be web standards compliant for better performance .

4)Can I bulk upload products from excel directly into my web store

Yes . This can be done with the help of available or custom plugins .
The excel file can be imported from the administrator panel and products will appear on the store frontend .

5)Can I change the marketing content or create emarketing spots  on my web shop ?

It is possible to hook content management systems like wordpress with a web shop . Plugins also exist for open source solutions.
Marketing spots , Best selling products can be updated through the administration panel.

6)How do i set up Taxation rules  for my web shop ?

Tax rates can be associated with targeted jurisdictions . Tax rules can be associated with the products .Selected products can be made tax free . Support for
multiple currencies is also present in the administration panel .

The end user can choose a preferred currency from the store frontend.

6)Which payment gateways should we integrate with ?

First we should identify the geographic locations we are targeting . We will then evaluate the payment gateways which support currencies of these geographic locations and are trusted by the users of specific locations . Payment gateway extensions to integrate open source soutions with popular payment gateways are often avaliable .

7)For paypal integrations should our buyers have a paypal account?

The shoppers will not require a paypal account . They will be redirected to paypal on checkout . After completing credit card payments on the paypal website  the shoppers will be redirected back to your webshop .

8)Will i need an ssl certificate?

An SSL certificate will be required only when we accept payments on our website itself .
PCI compliance will also be required for this case . This can be obtained from reliable ssl , PCI vendors

9)Will we be able to create staff accounts or roles for product managers , sales managers , customer care ?

Yes. Users with specific roles and permissions can be created from the administration panel . This is an important requirement as you move onto scaling up and appoint staff to manage parts of the store . Ease of use should be verified for this feature .

10)How will we handle backups of our database ?

Periodic Backups for database can be implemented by exporting the database file from the administration panel . It is important to backup regularly . As Order transaction volumes increase ,automated  daily backups should be set up .

11)Can we source products from multiple suppliers ?

Yes . User roles can be created for suppliers . The suppliers can then import a csv file to mass upload the products

12)Are there any security concerns while starting a web shop ?

Web Application security best practices should be factored in by the web developers . Penetration testing needs to be implemented before migrating the store assets to the server . Open Source solutions also implement best practices to avoid exploits . Payments are normally handled by the gateways so most of the exploits can be avoided .

13)How will I promote my web shop to increase sales .

It is important to integrate your web store with social media like facebook , twitter to create a community around your products . Allow your users to login through their twitter and facebook accounts . Update your social media pages with news about product launch , discount offers . A Customer database can be created . Newsletters with helpful content can be sent out .
Search engine optimization can be implemented to provide more visibility for your store content .

It is important to identify useful content for your shoppers and serve quality content through the right channels on the web.

14)Will we be able to add multiple shops on the same sites ?

Multi store mode or online shopping malls are not available out of the box . We have customized open source solutions to work as online shopping malls .
Please feel free to contact us for a demo .




Technology

Contact Us