Creating a simple Funambol connector


Tue 27 June 2006 By nuxeo

This article will be about the problems I encountered as a beginner in
writing a Funambol connector. It aims at avoiding simple stupind things that
makes you loosing time. The article will be based on the 3.0 Beta 1 version
of Funambol: there are some API changes between Beta 1 and Beta 2, so the
following lines might be wrong for the last version.


Vocabulary




  • Connector: a set of classes creating a connection between the
    Funambol DS Server and a data source. This data source could be of any
    type: email account, Relational databases,  PIM data, JCR and so
    on.




  • Module: a module is a functionnal archive to install on the
    Funambol DS Server. It will contain all the necessary files for the
    contained connector(s) to work. A module can contain several connectors:
    this will be defines in a specific database table.




  • Synchronization Source: a class which provides the data items of
    the external source to the Funambol DS Server.




The basic example: dummy


First of all, to develop a connector, you will have at least to have a
serious look at the dummy connector code (see the link for the CVS, tag
funambol30b1). You can see there that this connector doesn't do many
things and contains only 2 classes:



  • the SyncSource providing the items to Funambol

  • the Admin Panel to let you create new sources using the
    funamboladmin program


All the classes are packaged in a jar with the name of your connector (in
my case: jcr-sync-0.0.1). The file to install on the Funambol DS server has
an s4j extension and contains:



  • the classes jar

  • all the dependencies jars

  • SQL scripts to register the module into the database


There are two solutions to implement your own connector afterwards: a
copy-paste of the dummy connector and using this as a base for your
connector, or understanding the dummy connector to create your connector. I
choose the second solution and had to fight with this problem: I got a
server error when I tried to create a SyncSource using my connector source
type.


Solving the problem


To solve this problem I had some tools:



  • a network sniffer

  • the funambol server and admin source code


First thing I tried was to locate the error: for this you can change the
server logging preferences to print all the messages. This way you will be
able to see quite exactly where it fails. However you won't be able to debug
at this point in the code: then the idea is to sniff the messages between
the admin program and the serveur. If you are using the bundle as I am, you
just have to listen on the local interface for TCP messages on 8080
port.


This way I could see one important point:The server was trying to guess
if there wa already SyncSources with the same URI or name than the one I
wanted to add. The problem was that these value were not set. Thus here are
the conclusions:



  1. The URI and Name value are mandatory for a SyncSource

  2. You have to call the setter for each property before to send the
    ActionEvent to the admin panel: otherwise, the values aren't set in the
    SyncSource and the server will return a NullPointerException



(Post originally written by Cedric Bosdonnat on the old Nuxeo blogs.)


Category: Product & Development