Java Services
We will do a quick overview on how to create a Java-based service and get it running under the dbus system.
The service framework of webOS depends largely on dbus, but Palm wrote most of the services in Java (there are maybe two or three native services). They've used a dbus Java library in order to communicate with the dbus and wrote more libraries to make the creation of these services much easier. The library of interest is serviceframework.jar, located under /usr/lib/luna/java.
All Java services extend from either the LunaServiceThread class directly or from a subclass of LunaServiceThread.
Installation / packaging
Files:
<source lang="text"> /etc/event.d/org.webosinternals.hello /usr/share/dbus-1/system-services/org.webosinternals.hello /usr/lib/luna/java/org.webosinternals.services.jar </source>
/usr/share/dbus-1/system-services/org.webosinternals.hello:
<source lang="text"> [D-BUS Service] Name=org.webosinternals.hello Exec=/usr/bin/luna-helper 'luna://com.palm.vm/launch' '{"serviceName":"org.webosinternals.hello","className":"org.webosinternals.services.HelloService"}' </source>
/etc/event.d/org.webosinternals.hello: "I don't believe this is necessary... Where did it come from? PuffTheMagic 03:19, 10 August 2009 (UTC)"
"At the time I've created this Java service, the configuration file for the service under /usr/share/dbus-1/system-services directory did nothing to start the service. I could not find out why, so I've just created the event.d script to start it up. If it isn't needed anymore or there is a correct way of starting the service, please edit it. ShinAli 12:38, 6 October 2009 (UTC)" See the services at git.webos-internals.org for the recommended way to start services. <source lang="text"> start on started java-serviceboot script /usr/bin/luna-helper 'luna://com.palm.vm/launch' '{"serviceName":"org.webosinternals.hello","className":"org.webosinternals.services.HelloService"}' end script </source> /usr/lib/luna/java/org.webosinternals.services.jar: <source lang="text"> META-INF/ META-INF/MANIFEST.MF org/webosinternals/services/HelloService.class </source>