Skip to content

Commit

Permalink
OSGi I/O-service implementation. Also exports the necessary javax.mic…
Browse files Browse the repository at this point in the history
…roedition.io classes.
  • Loading branch information
jawi committed Jan 3, 2011
1 parent e05234e commit 1361c70
Show file tree
Hide file tree
Showing 15 changed files with 1,091 additions and 0 deletions.
57 changes: 57 additions & 0 deletions service.io/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>nl.lxtreme.ols</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
</parent>
<groupId>nl.lxtreme.ols.service</groupId>
<artifactId>io</artifactId>
<packaging>bundle</packaging>
<version>1.0.0</version>
<name>OSGi I/O-connection service</name>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<type>jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Activator>nl.lxtreme.ols.io.Activator</Bundle-Activator>
<Import-Package>
org.osgi.framework; version="1.3.0",
org.osgi.service.io; version="[1.0,2.0)"
</Import-Package>
<Export-Package>javax.microedition.io</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
10 changes: 10 additions & 0 deletions service.io/src/main/java/javax/microedition/io/CommConnection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package javax.microedition.io;

/**
* @since MIDP 2.0
*/
public interface CommConnection extends StreamConnection {
int getBaudRate();

int setBaudRate(int baudrate);
}
13 changes: 13 additions & 0 deletions service.io/src/main/java/javax/microedition/io/Connection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package javax.microedition.io;

import java.io.IOException;

/**
* @since CLDC 1.0
*/
public interface Connection {
/**
* @throws IOException
*/
void close() throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package javax.microedition.io;

import java.io.IOException;

/**
* @since CLDC 1.0
*/
public class ConnectionNotFoundException extends IOException
{
private static final long serialVersionUID = 8617995896221113348L;

public ConnectionNotFoundException()
{
super();
}

public ConnectionNotFoundException(final String s)
{
super(s);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package javax.microedition.io;

/**
* @since CLDC 1.0
*/
public interface ContentConnection extends StreamConnection {
String getEncoding();

long getLength();

String getType();
}
41 changes: 41 additions & 0 deletions service.io/src/main/java/javax/microedition/io/Datagram.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package javax.microedition.io;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
* @since CLDC 1.0
*/
public interface Datagram extends DataInput, DataOutput {
String getAddress();

byte[] getData();

int getLength();

int getOffset();

void reset();

/**
* @throws IllegalArgumentException
* @throws IOException
*/
void setAddress(String addr) throws IOException;

/**
* @throws IllegalArgumentException
*/
void setAddress(Datagram reference);

/**
* @throws IllegalArgumentException
*/
void setData(byte[] buffer, int offset, int len);

/**
* @throws IllegalArgumentException
*/
void setLength(int len);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package javax.microedition.io;

import java.io.IOException;

/**
* @since CLDC 1.0
*/
public interface DatagramConnection extends Connection {
/**
* @throws IOException
*/
int getMaximumLength() throws IOException;

/**
* @throws IOException
*/
int getNominalLength() throws IOException;

/**
* @throws IOException
* @throws IllegalArgumentException
*/
Datagram newDatagram(int size) throws IOException;

/**
* @throws IOException
* @throws IllegalArgumentException
*/
Datagram newDatagram(int size, String addr) throws IOException;

/**
* @throws IOException
* @throws IllegalArgumentException
*/
Datagram newDatagram(byte[] buf, int size) throws IOException;

/**
* @throws IOException
* @throws IllegalArgumentException
*/
Datagram newDatagram(byte[] buf, int size, String addr) throws IOException;

/**
* @throws IOException
* @throws InterruptedIOException
*/
void receive(Datagram dgram) throws IOException;

/**
* @throws IOException
* @throws InterruptedIOException
*/
void send(Datagram arg0) throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package javax.microedition.io;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
* @since CLDC 1.0
*/
public interface InputConnection extends Connection {
/**
* @throws IOException
*/
DataInputStream openDataInputStream() throws IOException;

/**
* @throws IOException
*/
InputStream openInputStream() throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package javax.microedition.io;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
* @since CLDC 1.0
*/
public interface OutputConnection extends Connection {
/**
* @throws IOException
*/
DataOutputStream openDataOutputStream() throws IOException;

/**
* @throws IOException
*/
OutputStream openOutputStream() throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package javax.microedition.io;

/**
* @since CLDC 1.0
*/
public interface StreamConnection extends InputConnection, OutputConnection {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package javax.microedition.io;

import java.io.IOException;

/**
* @since CLDC 1.0
*/
public interface StreamConnectionNotifier extends Connection {
/**
* @throws IOException
*/
StreamConnection acceptAndOpen() throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package javax.microedition.io;

import java.io.IOException;

/**
* @since MIDP 2.0
*/
public interface UDPDatagramConnection extends DatagramConnection {
/**
* @throws IOException
*/
String getLocalAddress() throws IOException;

/**
* @throws IOException
*/
int getLocalPort() throws IOException;
}
63 changes: 63 additions & 0 deletions service.io/src/main/java/nl/lxtreme/ols/io/Activator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* OpenBench LogicSniffer / SUMP project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*
* Copyright (C) 2006-2010 Michael Poppitz, www.sump.org
* Copyright (C) 2010 J.W. Janssen, www.lxtreme.nl
*/
package nl.lxtreme.ols.io;


import org.osgi.framework.*;
import org.osgi.service.io.ConnectorService;


/**
* Provides a bundle activator, that registers the ConnectorService
* implementation as service.
*/
public class Activator implements BundleActivator
{
// VARIABLES

private ConnectorServiceImpl connectorService;

// METHODS

/**
* {@inheritDoc}
*/
@Override
public void start( final BundleContext aContext ) throws Exception
{
this.connectorService = new ConnectorServiceImpl( aContext );

aContext.registerService( ConnectorService.class.getName(), this.connectorService, null );
}

/**
* {@inheritDoc}
*/
@Override
public void stop( final BundleContext aContext ) throws Exception
{
if ( this.connectorService != null )
{
this.connectorService.shutdown();
this.connectorService = null;
}
}
}
Loading

0 comments on commit 1361c70

Please sign in to comment.