summaryrefslogtreecommitdiff
path: root/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl
diff options
context:
space:
mode:
Diffstat (limited to 'src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl')
-rwxr-xr-xsrc/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/.classpath30
-rwxr-xr-xsrc/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/.project28
-rwxr-xr-xsrc/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/ReadMe.confluence1
-rwxr-xr-xsrc/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/pom.xml60
-rwxr-xr-xsrc/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/src/main/java/org/genivi/trafficincidentsservice/dbus/impl/DBusTrafficIncidentsService.java108
5 files changed, 227 insertions, 0 deletions
diff --git a/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/.classpath b/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/.classpath
new file mode 100755
index 0000000..f6a3397
--- /dev/null
+++ b/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/.classpath
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="src" path="/org.genivi.basetypes-model"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/emf/org.eclipse.emf.common/2.8.0.v20130125-0546/org.eclipse.emf.common-2.8.0.v20130125-0546.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/emf/org.eclipse.emf.ecore/2.8.3.v20130125-0546/org.eclipse.emf.ecore-2.8.3.v20130125-0546.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/emf/org.eclipse.emf.ecore.xmi/2.8.1.v20130125-0546/org.eclipse.emf.ecore.xmi-2.8.1.v20130125-0546.jar"/>
+ <classpathentry kind="src" path="/org.genivi.trafficinfo"/>
+ <classpathentry kind="var" path="M2_REPO/openlr/openlr-cli-sqlite-with-dependencies/1.2.2/openlr-cli-sqlite-with-dependencies-1.2.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/openlr/openlr-map/1.2.2/openlr-map-1.2.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/openlr/openlr-map-sqlite-with-dependencies/1.2.2/openlr-map-sqlite-with-dependencies-1.2.2.jar"/>
+ <classpathentry kind="src" path="/org.genivi.trafficinfo.dbus-java"/>
+ <classpathentry kind="src" path="/org.genivi.trafficinfo.libmatthew"/>
+ <classpathentry kind="src" path="/org.genivi.trafficincidentsservice.trafficincidentsservice-model"/>
+ <classpathentry kind="src" path="/org.genivi.booleanexpr-model"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/4.3.1/junit-4.3.1.jar" sourcepath="M2_REPO/junit/junit/4.3.1/junit-4.3.1-sources.jar">
+ <attributes>
+ <attribute value="jar:file:/D:/maven_repository/repository/junit/junit/4.3.1/junit-4.3.1-javadoc.jar!/" name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="/org.genivi.trafficinfo.demo"/>
+ <classpathentry kind="src" path="/org.genivi.iconset-model"/>
+ <classpathentry kind="src" path="/org.genivi.locref-model"/>
+ <classpathentry kind="src" path="/org.genivi.trafficincidentsservice.trafficincidents.trafficincidents-trafficincident-model"/>
+ <classpathentry kind="src" path="/org.genivi.trafficincidentsservice.trafficincidenttables-model"/>
+ <classpathentry kind="src" path="/org.genivi.trafficincidentsservice.trafficincidentfeed.trafficincidentfeed-trafficincident-model"/>
+ <classpathentry kind="src" path="/org.genivi.trafficincidentsservice.dbuswrapper"/>
+</classpath> \ No newline at end of file
diff --git a/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/.project b/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/.project
new file mode 100755
index 0000000..1af0408
--- /dev/null
+++ b/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.genivi.trafficincidentsservice.dbus.impl</name>
+ <comment>This project contains the Traffic Incidents Service of the GENIVI Traffic Information project. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
+ <projects>
+ <project>org.genivi.basetypes-model</project>
+ <project>org.genivi.trafficinfo</project>
+ <project>org.genivi.trafficinfo.dbus-java</project>
+ <project>org.genivi.trafficinfo.libmatthew</project>
+ <project>org.genivi.trafficincidentsservice.trafficincidentsservice-model</project>
+ <project>org.genivi.booleanexpr-model</project>
+ <project>org.genivi.trafficinfo.demo</project>
+ <project>org.genivi.iconset-model</project>
+ <project>org.genivi.locref-model</project>
+ <project>org.genivi.trafficincidentsservice.trafficincidents.trafficincidents-trafficincident-model</project>
+ <project>org.genivi.trafficincidentsservice.trafficincidenttables-model</project>
+ <project>org.genivi.trafficincidentsservice.trafficincidentfeed.trafficincidentfeed-trafficincident-model</project>
+ <project>org.genivi.trafficincidentsservice.dbuswrapper</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription> \ No newline at end of file
diff --git a/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/ReadMe.confluence b/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/ReadMe.confluence
new file mode 100755
index 0000000..83b2c42
--- /dev/null
+++ b/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/ReadMe.confluence
@@ -0,0 +1 @@
+This project contains a class to wrap the TrafficIncidentsService from org.genivi.trafficincidentsservice.refimpl into a D-Bus service. \ No newline at end of file
diff --git a/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/pom.xml b/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/pom.xml
new file mode 100755
index 0000000..cb6118d
--- /dev/null
+++ b/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns:xsi="http://www.w3.org/2001/XML-Schema-instance" xmlns="http://maven.apache.org/POM/4.0"
+xsi:schemaLocation="http://maven.apache.org/POM/4.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.genivi.trafficincidentsservice</groupId>
+ <artifactId>dbus.impl</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>GENIVI Traffic Incidents Service</name>
+ <description>This project contains the Traffic Incidents Service of the GENIVI Traffic Information project.</description>
+ <parent>
+ <groupId>org.genivi.trafficinfo</groupId>
+ <artifactId>maven-parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../org.genivi.trafficinfo.maven-parent</relativePath>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.genivi</groupId>
+ <artifactId>basetypes-model</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.genivi</groupId>
+ <artifactId>trafficinfo</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.genivi.trafficincidentsservice</groupId>
+ <artifactId>dbuswrapper</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.genivi.trafficincidentsservice</groupId>
+ <artifactId>trafficincidentsservice-model</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.genivi.trafficinfo</groupId>
+ <artifactId>dbus-java</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.genivi.trafficinfo</groupId>
+ <artifactId>libmatthew</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <sourceDirectory>src/main/java</sourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.genivi.trafficincidentsservice.dbus.impl.DBusTrafficIncidentsService</mainClass>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/src/main/java/org/genivi/trafficincidentsservice/dbus/impl/DBusTrafficIncidentsService.java b/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/src/main/java/org/genivi/trafficincidentsservice/dbus/impl/DBusTrafficIncidentsService.java
new file mode 100755
index 0000000..5e86d63
--- /dev/null
+++ b/src/traffic-incidents-service/org.genivi.trafficincidentsservice.dbus.impl/src/main/java/org/genivi/trafficincidentsservice/dbus/impl/DBusTrafficIncidentsService.java
@@ -0,0 +1,108 @@
+/**
+ * Copyright (C) 2013 TomTom International B.V.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+package org.genivi.trafficincidentsservice.dbus.impl;
+
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import openlr.map.MapDatabase;
+import openlr.map.teleatlas.sqlite.impl.MapDatabaseImpl;
+
+import org.freedesktop.dbus.DBusConnection;
+import org.freedesktop.dbus.exceptions.DBusException;
+import org.genivi.locref.LocationReferenceType;
+import org.genivi.locref.decoder.openlr.OpenLRDecoder;
+import org.genivi.locref.refimpl.LocationReferenceDecodingHandlerRefImpl;
+import org.genivi.trafficincidentsservice.TrafficIncidentFeed;
+import org.genivi.trafficincidentsservice.refimpl.TrafficIncidentsService;
+import org.genivi.trafficincidentsservice.textgenerator.basictextgenerator.BasicTextGenerator;
+import org.genivi.trafficincidentsservice.trafficincidentfeed.dbus.impl.TrafficIncidentsUpdatesAdaptor;
+import org.genivi.trafficincidentsservice.trafficincidents.dbus.impl.TrafficIncidentsAdaptor;
+
+public class DBusTrafficIncidentsService {
+ private final static Logger LOGGER = Logger.getLogger(DBusTrafficIncidentsService.class.getName());
+ private final static String TRAFFIC_INCIDENTS_SERVICE_NAME = "org.genivi.trafficinfo.TrafficIncidentsDBus";
+ private final static String TRAFFIC_INCIDENT_FEED_SERVICE_NAME = "org.genivi.trafficinfo.TrafficIncidentsUpdatesDBus";
+ private final static String MAP_PATH = "../resources/tomtom_utrecht_2008_04.db3";
+
+ //settings to control what to run and what not
+ private final static Level logLevel = Level.SEVERE;
+
+ DBusTrafficIncidentsService() throws DBusException {
+
+ logSetup();
+
+ // Create the Traffic Incidents Service
+ TrafficIncidentsService trafficIncidentsService = createTrafficIncidentsService();
+
+ // Create the Traffic Incident Feed Adaptor
+ createTrafficIncidentFeedAdaptor(trafficIncidentsService);
+
+ // Create the Traffic Incidents Adaptor
+ createTrafficIncidentsAdaptor(trafficIncidentsService);
+ }
+
+ private void logSetup() {
+ // Create Logger
+ Logger logger = Logger.getLogger("");
+ logger.setLevel(logLevel);
+
+ Handler consoleHandler = null;
+ for (Handler handler: logger.getHandlers()) {
+ if (handler.getClass().getName().equals("java.util.logging.ConsoleHandler")) {
+ consoleHandler = handler;
+ break;
+ }
+ }
+ consoleHandler.setLevel(Level.INFO);
+ }
+
+ private TrafficIncidentsService createTrafficIncidentsService() {
+ // Create a Location Reference Decoding Handler to be used by the Traffic Incidents Service
+ LocationReferenceDecodingHandlerRefImpl locationReferenceDecodingHandlerRefImpl = new LocationReferenceDecodingHandlerRefImpl();
+
+ // Open a map database to be used by the location decoders
+ MapDatabase mapDataBase = new MapDatabaseImpl(MAP_PATH);
+
+ // Create an OpenLR decoder and register it on the LocationReferenceDecodingHandlerRefImpl
+ OpenLRDecoder openLRDecoder = new OpenLRDecoder(mapDataBase);
+ locationReferenceDecodingHandlerRefImpl.addDecoder((Byte) (byte) LocationReferenceType.OPEN_LR.getValue(), openLRDecoder);
+
+ // Create the Traffic Incidents Service
+ TrafficIncidentsService trafficIncidentsService = new TrafficIncidentsService(locationReferenceDecodingHandlerRefImpl, new BasicTextGenerator());
+
+ return trafficIncidentsService;
+ }
+
+ private void createTrafficIncidentFeedAdaptor(TrafficIncidentFeed trafficIncidentFeed) throws DBusException {
+ DBusConnection conn = DBusConnection.getConnection(DBusConnection.SESSION);
+ LOGGER.info("DBusConnection obtained");
+
+ conn.requestBusName(TRAFFIC_INCIDENT_FEED_SERVICE_NAME);
+ conn.exportObject("/trafficincidentfeed", new TrafficIncidentsUpdatesAdaptor(conn, trafficIncidentFeed));
+ LOGGER.info("D-Bus Service TrafficIncidentsUpdatesDBus running");
+ }
+
+ private void createTrafficIncidentsAdaptor(TrafficIncidentsService trafficIncidentsService) throws DBusException {
+ DBusConnection conn = DBusConnection.getConnection(DBusConnection.SESSION);
+ LOGGER.info("DBusConnection obtained");
+
+ conn.requestBusName(TRAFFIC_INCIDENTS_SERVICE_NAME);
+
+ conn.exportObject("/java", new TrafficIncidentsAdaptor(conn, trafficIncidentsService));
+ LOGGER.info("D-Bus Service TrafficIncidentsDBus running");
+ }
+
+ public static void main(String[] args) throws DBusException {
+ @SuppressWarnings("unused")
+ DBusTrafficIncidentsService dBusTrafficIncidentsService = new DBusTrafficIncidentsService();
+ LOGGER.info("DBusTrafficIncidentsService running");
+ }
+
+}