Skip to content

Commit

Permalink
importing files
Browse files Browse the repository at this point in the history
importing files
  • Loading branch information
wbuczak committed Nov 5, 2014
1 parent 3e46cb3 commit 73a53c5
Show file tree
Hide file tree
Showing 15 changed files with 1,058 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.project
.classpath
.settings/
.target/
57 changes: 57 additions & 0 deletions 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.ogn</groupId>
<artifactId>ogn-client-java</artifactId>
<version>0.0.1-SNAPSHOT</version>

<url>http://glidernet.org</url>
<name>Open Glider Network (OGN)</name>

<dependencies>

<dependency>
<groupId>org.ogn</groupId>
<artifactId>ogn-commons-java</artifactId>
<version>[,1.0.0)</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.2.4</version>
<optional>true</optional>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
11 changes: 11 additions & 0 deletions src/main/java/org/ogn/client/OgnBeaconListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright (c) 2014 OGN, All Rights Reserved.
*/

package org.ogn.client;

import org.ogn.commons.beacon.OgnBeacon;

public interface OgnBeaconListener<BeaconType extends OgnBeacon> {
void onUpdate(final BeaconType beacon);
}
58 changes: 58 additions & 0 deletions src/main/java/org/ogn/client/OgnClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Copyright (c) 2014 OGN, All Rights Reserved.
*/

package org.ogn.client;

import org.ogn.commons.beacon.AircraftBeacon;
import org.ogn.commons.beacon.ReceiverBeacon;

public interface OgnClient {

/**
* subscribes a listener to the aircraft beacons
*
* @param listener
*/
void subscribeToAircraftBeacons(OgnBeaconListener<AircraftBeacon> listener);

/**
* unsubscribes a listener from receiving aircraft beacons
*
* @param listener
*/
void unsubscribeFromAircraftBeacons(OgnBeaconListener<AircraftBeacon> listener);

/**
* subscribes a listener to the base stations beacons
*
* @param listener
*/
void subscribeToReceiverBeacons(OgnBeaconListener<ReceiverBeacon> listener);

/**
* unsubscribes a listener from receiving base stations beacons
*
* @param listener
*/
void unsubscribeFromReceiverBeacons(OgnBeaconListener<ReceiverBeacon> listener);

/**
* connects the client to the OGN APRS service (no filtering)
*/
void connect();

/**
* connects to the OGN APRS service
*
* @param aprsFilter optional APRS filter, if null no filter will be used, as it is in case of {@link #connect()
* connect()}.
* @see <a href="http://www.aprs-is.net/javAPRSFilter.aspx">Server-side Filter Commands</a>
*/
void connect(String aprsFilter);

/**
* disconnects a client from the OGN APRS service
*/
void disconnect();
}
17 changes: 17 additions & 0 deletions src/main/java/org/ogn/client/OgnClientConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright (c) 2014 OGN, All Rights Reserved.
*/

package org.ogn.client;

public interface OgnClientConstants {
String OGN_DEFAULT_SERVER_NAME = "aprs.glidernet.org";
String OGN_DEFAULT_APP_NAME = "ogn-client-java";
String OGN_DEFAULT_APP_VERSION = "1.0.0";

Integer OGN_DEFAULT_APRS_PORT = 10152;
Integer OGN_DEFAULT_APRS_PORT_FILTERED = 14580;

Integer OGN_DEFAULT_RECONNECTION_TIMEOUT_MS = 5000;
Integer OGN_CLIENT_DEFAULT_KEEP_ALIVE_INTERVAL_MS = 15*60*1000;
}
55 changes: 55 additions & 0 deletions src/main/java/org/ogn/client/OgnClientFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2014 OGN, All Rights Reserved.
*/

package org.ogn.client;

import static org.ogn.client.OgnClientConstants.OGN_CLIENT_DEFAULT_KEEP_ALIVE_INTERVAL_MS;
import static org.ogn.client.OgnClientConstants.OGN_DEFAULT_APP_NAME;
import static org.ogn.client.OgnClientConstants.OGN_DEFAULT_APP_VERSION;
import static org.ogn.client.OgnClientConstants.OGN_DEFAULT_APRS_PORT;
import static org.ogn.client.OgnClientConstants.OGN_DEFAULT_APRS_PORT_FILTERED;
import static org.ogn.client.OgnClientConstants.OGN_DEFAULT_RECONNECTION_TIMEOUT_MS;
import static org.ogn.client.OgnClientConstants.OGN_DEFAULT_SERVER_NAME;
import static org.ogn.client.OgnClientProperties.PROP_OGN_CLIENT_APP_NAME;
import static org.ogn.client.OgnClientProperties.PROP_OGN_CLIENT_APP_VERSION;
import static org.ogn.client.OgnClientProperties.PROP_OGN_CLIENT_IGNORE_AIRCRAFT_BEACONS;
import static org.ogn.client.OgnClientProperties.PROP_OGN_CLIENT_IGNORE_RECEIVER_BEACONS;
import static org.ogn.client.OgnClientProperties.PROP_OGN_CLIENT_KEEP_ALIVE_INTERVAL;
import static org.ogn.client.OgnClientProperties.PROP_OGN_SRV_NAME;
import static org.ogn.client.OgnClientProperties.PROP_OGN_SRV_PORT_FILTERED;
import static org.ogn.client.OgnClientProperties.PROP_OGN_SRV_PORT_UNFILTERED;
import static org.ogn.client.OgnClientProperties.PROP_OGN_SRV_RECONNECTION_TIMEOUT;

import org.ogn.client.aprs.AprsOgnClient;

/**
* This factory creates instances of OGN client. Several parameters can be tuned through the environment variables.
*
* @author wbuczak
*/
public class OgnClientFactory {

private static String serverName = System.getProperty(PROP_OGN_SRV_NAME, OGN_DEFAULT_SERVER_NAME);

private static int port = Integer.getInteger(PROP_OGN_SRV_PORT_UNFILTERED, OGN_DEFAULT_APRS_PORT);
private static int portFiltered = Integer.getInteger(PROP_OGN_SRV_PORT_FILTERED, OGN_DEFAULT_APRS_PORT_FILTERED);
private static int reconnectionTimeout = Integer.getInteger(PROP_OGN_SRV_RECONNECTION_TIMEOUT,
OGN_DEFAULT_RECONNECTION_TIMEOUT_MS);

private static int keepAliveInterval = Integer.getInteger(PROP_OGN_CLIENT_KEEP_ALIVE_INTERVAL,
OGN_CLIENT_DEFAULT_KEEP_ALIVE_INTERVAL_MS);

private static String appName = System.getProperty(PROP_OGN_CLIENT_APP_NAME, OGN_DEFAULT_APP_NAME);
private static String appVersion = System.getProperty(PROP_OGN_CLIENT_APP_VERSION, OGN_DEFAULT_APP_VERSION);

private static boolean ignoreReceiverBeacons = System.getProperty(PROP_OGN_CLIENT_IGNORE_RECEIVER_BEACONS) != null;
private static boolean ignoreAircraftBeacons = System.getProperty(PROP_OGN_CLIENT_IGNORE_AIRCRAFT_BEACONS) != null;

public static OgnClient createClient() {
return new AprsOgnClient.Builder().serverName(serverName).aprsPort(port).aprsPortFiltered(portFiltered)
.reconnectionTimeout(reconnectionTimeout).appName(appName).appVersion(appVersion).keepAlive(keepAliveInterval)
.ignoreReceiverBeacons(ignoreReceiverBeacons).ignoreAicraftrBeacons(ignoreAircraftBeacons).build();
}

}
24 changes: 24 additions & 0 deletions src/main/java/org/ogn/client/OgnClientProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright (c) 2014 OGN, All Rights Reserved.
*/

package org.ogn.client;

/**
* declarations of the environment properties which can be set to overwrite the client's defaults
*
* @author wbuczak
*/
public interface OgnClientProperties {
String PROP_OGN_SRV_NAME = "ogn.server.name";
String PROP_OGN_SRV_PORT_UNFILTERED = "ogn.server.port_unfiltered";
String PROP_OGN_SRV_PORT_FILTERED = "ogn.server.port_filtered";
String PROP_OGN_SRV_RECONNECTION_TIMEOUT = "ogn.reconnection.timeout";

String PROP_OGN_CLIENT_APP_NAME = "ogn.app.name";
String PROP_OGN_CLIENT_APP_VERSION = "ogn.app.version";

String PROP_OGN_CLIENT_KEEP_ALIVE_INTERVAL = "ogn.client.keep_alive";
String PROP_OGN_CLIENT_IGNORE_RECEIVER_BEACONS = "ogn.client.ignore_receiver_beacons";
String PROP_OGN_CLIENT_IGNORE_AIRCRAFT_BEACONS = "ogn.client.ignore_aircraft_beacons";
}
Loading

0 comments on commit 73a53c5

Please sign in to comment.