Sodeac StreamPartitioner Parent

Parent pom for Sodeac StreamPartitioner modules

License

License

GroupId

GroupId

org.sodeac
ArtifactId

ArtifactId

sodeac-streampartitioner-parent
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

pom
Description

Description

Sodeac StreamPartitioner Parent
Parent pom for Sodeac StreamPartitioner modules
Project URL

Project URL

https://github.com/spalarus/osgi-sodeac-streampartitioner
Source Code Management

Source Code Management

https://github.com/spalarus/osgi-sodeac-streampartitioner.git

Download sodeac-streampartitioner-parent

How to add to project

<!-- https://jarcasting.com/artifacts/org.sodeac/sodeac-streampartitioner-parent/ -->
<dependency>
    <groupId>org.sodeac</groupId>
    <artifactId>sodeac-streampartitioner-parent</artifactId>
    <version>1.0.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/org.sodeac/sodeac-streampartitioner-parent/
implementation 'org.sodeac:sodeac-streampartitioner-parent:1.0.0'
// https://jarcasting.com/artifacts/org.sodeac/sodeac-streampartitioner-parent/
implementation ("org.sodeac:sodeac-streampartitioner-parent:1.0.0")
'org.sodeac:sodeac-streampartitioner-parent:pom:1.0.0'
<dependency org="org.sodeac" name="sodeac-streampartitioner-parent" rev="1.0.0">
  <artifact name="sodeac-streampartitioner-parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='org.sodeac', module='sodeac-streampartitioner-parent', version='1.0.0')
)
libraryDependencies += "org.sodeac" % "sodeac-streampartitioner-parent" % "1.0.0"
[org.sodeac/sodeac-streampartitioner-parent "1.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
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

  • org.sodeac.streampartitioner.api
  • org.sodeac.streampartitioner.provider
  • org.sodeac.streampartitioner.example
  • org.sodeac.streampartitioner.itest

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.0