forked from magnuskarlsson/ols
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OSGi I/O-service implementation. Also exports the necessary javax.mic…
…roedition.io classes.
- Loading branch information
Showing
15 changed files
with
1,091 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
service.io/src/main/java/javax/microedition/io/CommConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
13
service.io/src/main/java/javax/microedition/io/Connection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
21 changes: 21 additions & 0 deletions
21
service.io/src/main/java/javax/microedition/io/ConnectionNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
service.io/src/main/java/javax/microedition/io/ContentConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
41
service.io/src/main/java/javax/microedition/io/Datagram.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
54 changes: 54 additions & 0 deletions
54
service.io/src/main/java/javax/microedition/io/DatagramConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
20 changes: 20 additions & 0 deletions
20
service.io/src/main/java/javax/microedition/io/InputConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
20 changes: 20 additions & 0 deletions
20
service.io/src/main/java/javax/microedition/io/OutputConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
7 changes: 7 additions & 0 deletions
7
service.io/src/main/java/javax/microedition/io/StreamConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
} |
13 changes: 13 additions & 0 deletions
13
service.io/src/main/java/javax/microedition/io/StreamConnectionNotifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
18 changes: 18 additions & 0 deletions
18
service.io/src/main/java/javax/microedition/io/UDPDatagramConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
Oops, something went wrong.