wiki:WritingAService

Creating a Servicia service project in eclipse

Checkout the projects ServiceRuntimeLauncher and Dependencies from the Servicia SVN repository https://servicia.opendfki.de/repos/.


Create a new java project which will host the new Servicia service, let's say ServiciaServiceProject.


Add a project dependency to the project Dependencies. Note: the Core project also contains a jar-file named ServiciaTrayIcon.jar. This jar contains an implementation of the Servicia try icon. You can exchange this implementation and use your own icon and popup-menue. See Branding for details.

Setting project dependency in eclipse


Create the folder structure recommended for Servicia services.

src/
   service/
   test/

service/
   MyServiciaService/
                WEB-INF/
                   lib/
                   classes/
                   default/
                   service.xml 

You can also have multiple services hosted by a single eclipse project

src/
   service_a/
   service_b/
   test/

service/
   ServiceA/
            WEB-INF/
                   lib/
                   classes/
                   default/
                   service.xml 
   ServiceB/
            WEB-INF/
                   lib/
                   classes/
                   default/
                   service.xml 

... or embed a web application

src/
   service/
   test/

service/
   MyServiciaService/
              index.html
              WEB-INF/
                  service.xml 
                  web.xml
                  lib/
                  classes/
                  default/

Set the output folder for the service source folder to be service/<SERVICENAME>/WEB-INF/classes (<SERVICENAME> here is the name of your service)

Setting output folder of the service source directory


Create a service descriptor (service.xml) in the service's WEB-INF folder. For startup it can be empty, that is, it does not define any API. We'll add these later ...

<service type="XML-RPC">
    <description>My first Servicia service!!</description>
   
    <!-- no APIs for now -->
</service>

Create a runtime folder containing a config subfolder. See RuntimeDirectoryManagement for details.


Add a log4j.properties and a logging.properties file in the config folder. This avoid warnings when starting the runtime. They can be empty for now.


Create an eclipse launch configuration for configuring your runtime. Runtime folder is the one created above. You can assign an id to the runtime instance. For more details using the runtime launcher see ServiceRuntimeLauncher.

Eclipse launch configuration - configure runtime ('Main' tab)

Eclipse launch configuration - configure runtime ('Arguments' tab)


Start configure dialog an add all services needed to run in the same runtime instance.

Configure Runtime Dialog


Create an eclipse launch configuration for starting the runtime instance (the runtime directory, as well as the runtime id, has to be the same as the one used in the configuration launch config)


Create a shutdown launch configuration (if you are using Java 6 and tray icons, you may skip this one). We need this one to shutdown a running runtime instance gracefully.


Start runtime instance and watch the message console


Congratulations you wrote your first Servicia service! Move on to learn how to create service APIs and how to access them.

Last modified 9 years ago Last modified on 08/07/08 09:26:10

Attachments (5)

Download all attachments as: .zip