Difference between revisions of "Java Services"

From WebOS Internals
Jump to navigation Jump to search
 
Line 24: Line 24:
  
 
/etc/event.d/org.webosinternals.hello:  "I don't believe this is necessary... Where did it come from? [[User:PuffTheMagic|PuffTheMagic]] 03:19, 10 August 2009 (UTC)"
 
/etc/event.d/org.webosinternals.hello:  "I don't believe this is necessary... Where did it come from? [[User:PuffTheMagic|PuffTheMagic]] 03:19, 10 August 2009 (UTC)"
<p>"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. [[User:ShinAli|ShinAli]] 12:38, 6 October 2009 (UTC)"
+
<p>"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. [[User:ShinAli|ShinAli]] 12:38, 6 October 2009 (UTC)"</p>
 +
<p>I have just tried this on my own Palm Pre device with WebOS 1.2.1 installed.  Services still do not start automatically by virtue of being included in /usr/share/dbus-1/system-services.  As far as I can tell, the /etc/event.d/org.webosinternals.hello or equivalent startup script is still necessary.  In addition, the services at git.webos-internals.org do startup in completely different ways, and a couple of them use scripts as noted above.  --[[User:Coderkevin|Coderkevin]] 18:13, 5 November 2009 (UTC)
 +
</p>
  
See the services at git.webos-internals.org for the recommended way to start services.
+
<p>See the services at git.webos-internals.org for the recommended way to start services.</p>
  
 
<source lang="text">
 
<source lang="text">

Latest revision as of 18:13, 5 November 2009

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)"

I have just tried this on my own Palm Pre device with WebOS 1.2.1 installed. Services still do not start automatically by virtue of being included in /usr/share/dbus-1/system-services. As far as I can tell, the /etc/event.d/org.webosinternals.hello or equivalent startup script is still necessary. In addition, the services at git.webos-internals.org do startup in completely different ways, and a couple of them use scripts as noted above. --Coderkevin 18:13, 5 November 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>