[sip-comm-dev] A few questions about creating a service


#1

hi devs,

I'm working on creating a spell check service. And i got a few questions
about it:

   - First thing, how do we use a .jar library in the service classes
   (interfaces) ? Is it simply an 'import org.dts.spell. ...' in the
   concerned classes ? ( org.dts.spell. is the directories tree of the
   jar library ) after having put the concerned jar library in the
   /lib/installer-exclude/ directory ?
   - Then, the service must be still operational if we change the library
   used. But is it possible, since we do an import of some content of the jar
   in the interfaces of the service ? To be more precise, my
   SpellCheckService.java interface uses different kind of objects such
   as Word and WordFinder objects (which are defined in the library) and not
   only Strings. This makes the service dependent upon the library. Do i have
   to define these Word, WordFinder, ... objects in interfaces in the service
   ?This solution would mean that each time I encounter a new object used in
   the main service interface, i have to create a new interface for this object
   and so on ? In this case the library will soon be completely interfaced in
   the sip.communicator.service.spellcheck directory and therefore there
   is no point in using a library.

Hoping i'm clear enough so that you can help me.

JD


#2

Hello JD,

francky vincent wrote:

hi devs,

I'm working on creating a spell check service. And i got a few questions about it:

    * First thing, how do we use a .jar library in the service classes

A note first: you are not likely to have to use external jars in a service, but rather in its implementation. Services are most often simple interfaces with no external dependencies.

      (interfaces) ? Is it simply an 'import org.dts.spell. ...' in
      the concerned classes ? ( org.dts.spell. is the directories tree
      of the jar library ) after having put the concerned jar library in
      the /lib/installer-exclude/ directory ?

Almost. You should also make sure that it is included in your bundle. Most of the existing bundles in SIP Communicator already do this. Have a look for example at the "bundle-netaddr" target in build.xml (lines 1067-1076). You'll notice the following line in the jar task:

     <zipfileset src="${lib.noinst}/Stun4J.jar" prefix=""/>

That's what you need to do as well for the libs that you are using.

    * Then, the service must be still operational if we change the
      library used. But is it possible, since we do an import of some
      content of the jar in the interfaces of the service ?

No, and that's why you should only use the jar in the implementation.

      To be more
      precise, my SpellCheckService.java interface uses different kind
      of objects such as Word and WordFinder objects (which are defined
      in the library) and not only Strings.

Do you really need to have these classes in the service? If you are convinced that you do, that is, if Word and WordFinder represent a sufficiently generic concept, then you should try to create your own replacement interface that mimics their behaviour. You could then wrap instances of Word and WordFinder in your implementation of the interfaces that you created.

      This makes the service dependent upon the library. Do i have to define these Word,
      WordFinder, ... objects in interfaces in the service ?This
      solution would mean that each time I encounter a new object used
      in the main service interface, i have to create a new interface
      for this object and so on ?

Yes, but only for the classes that you think would be necessary for those using your service.

      In this case the library will soon be
      completely interfaced in the sip.communicator.service.spellcheck
      directory and therefore there is no point in using a library.

More or less, yes. That's the point of the whole thing :).

Cheers
Emil

···

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net