Sodeac StreamPartitioner Provider

Sodeac streampartitioner provider for OSGi μservice.

License

License

Categories

Categories

IDE Development Tools
GroupId

GroupId

org.sodeac
ArtifactId

ArtifactId

org.sodeac.streampartitioner.provider
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

bundle
Description

Description

Sodeac StreamPartitioner Provider
Sodeac streampartitioner provider for OSGi μservice.

Download org.sodeac.streampartitioner.provider

Dependencies

compile (3)

Group / Artifact Type Version
org.sodeac : org.sodeac.streampartitioner.api jar 1.0.0
junit : junit jar 4.12
javax.inject : javax.inject jar 1

provided (3)

Group / Artifact Type Version
org.osgi : osgi.core jar 6.0.0
org.osgi : osgi.cmpn jar 6.0.0
org.osgi : osgi.annotation jar 6.0.1

test (6)

Group / Artifact Type Version
org.ops4j.pax.exam : pax-exam-container-karaf jar 4.11.0
org.ops4j.pax.exam : pax-exam-junit4 jar 4.11.0
org.ops4j.pax.exam : pax-exam-link-mvn jar 4.11.0
org.ops4j.pax.url : pax-url-aether jar 2.5.2
org.apache.karaf : apache-karaf tar.gz 4.1.1
org.easymock : easymock jar 3.4

Project Modules

There are no modules declared in this project.

Build Status

Stream Partitioner

An OSGi-service splits streams (java.io.InputStream and java.io.OutputStream) in substreams.

Maven

<dependency>
  <groupId>org.sodeac</groupId>
  <artifactId>org.sodeac.streampartitioner.api</artifactId>
  <version>1.0.0</version>
</dependency>
<dependency>
  <groupId>org.sodeac</groupId>
  <artifactId>org.sodeac.streampartitioner.provider</artifactId>
  <version>1.0.1</version>
</dependency>

Install to local m2-Repository

mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -Dartifact="org.sodeac:org.sodeac.streampartitioner.provider:1.0.1"

Install to Apache Karaf / Apache ServiceMix

bundle:install -s mvn:org.sodeac/org.sodeac.streampartitioner.api/1.0.0
bundle:install -s mvn:org.sodeac/org.sodeac.streampartitioner.provider/1.0.1

OSGi-Dependencies

Bundle-RequiredExecutionEnvironment: JavaSE-1.8

org.osgi.framework;version="[1.8,2)"
org.osgi.service.component;version="[1.3,2)"
org.osgi.service.log;version="[1.3,2)"

Getting Started

Inject StreamPartitionerFactory into your component.

@Reference
private volatile IStreamPartitionerFactory streamPartitionerFactory = null;

Example: write 3+1 substreams into one file ...

IOutputStreamPartitioner outputStreamPartitioner = streamPartitionerFactory.newOutputStreamPartitioner(filetOutputStream);

OutputStream subtream = outputStreamPartitioner.createNextSubOutputStream();
subtream.write(new String("first very short substream").getBytes());
subtream.close();

subtream = outputStreamPartitioner.createNextSubOutputStream();
subtream.write(new String("second very short substream").getBytes());
subtream.close();

subtream = outputStreamPartitioner.createNextSubOutputStream();
subtream.close();

subtream = outputStreamPartitioner.createNextSubOutputStream();
subtream.write(new String("third very short substream").getBytes());
subtream.close();

filetOutputStream.close();

... read again from file and print out every substream in one line

IInputStreamPartitioner inputStreamPartitioner = streamPartitionerFactory.newInputStreamPartitioner(fileInputStream);

InputStream inputStream;
int len;
byte[] readBuffer = new byte[1024];

while((inputStream = inputStreamPartitioner.getNextSubInputStream()) != null)
{
	System.out.print("substream: ");
	while((len = inputStream.read(readBuffer)) > 0)
	{
		System.out.print(new String(readBuffer,0,len));
	}
	System.out.println();
	inputStream.close();
}
fileInputStream.close();

StdOut:

substream: first very short substream
substream: second very short substream
substream: 
substream: third very short substream

Functional principle

The StreamPartitioner seperates substreams with unique markers. A unique marker is a dynamic delimiter, so it's possible to encapsulate in a substream further substreams.

License

Eclipse Public License 2.0

Versions

Version
1.0.1
1.0.0