dataio.jar

Description
This bundle provides a ConnectionFactory demonstration for the ConnectionService. see specification OSGi release 3, chapter 13
For more details on how to use this bundle, refer to the /doc/readme.html file embedded in the bundle jarfile.

Contributors
Didier Donsez (Didier.Donsez@ieee.org)

License
LGPL

Services
org.osgi.service.io.ConnectionFactory

Properties
None

Requirements
org.osgi.service.io; specification-version=1.0
javax.microedition.io


Download

Build

  1. configure the build properties in build.xml
  2. then build with ant

Usage
see chapter 13 in OSGi release 3
Uses this kind of code ServiceReference[] tempRefs = null; tempRefs = bundleContext.getServiceReferences( ConnectorService.class.getName(), null); if (tempRefs == null) { return; } ServiceReference sr = tempRefs[0]; ConnectorService connectorService = (ConnectorService) bundleContext.getService(sr); // test with "data:" System.out.println("=========================================="); System.out.println("read lines from one of the data: input stream"); System.out.println("=========================================="); { Connection connection = connectorService.open( "data:this is a example\nof IO connector", ConnectorService.READ, false); if (connection instanceof InputConnection) { InputStream is = ((InputConnection) connection).openInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line = null; while ((line = br.readLine()) != null) { System.out.println("line:" + line); } } connection.close(); }

Tested gateways

TODO (contributions are welcome)