You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devicemap.apache.org by wk...@apache.org on 2014/07/21 00:56:51 UTC
svn commit: r1612172 - in /incubator/devicemap/trunk/examples: ./ console/
console/src/ console/src/main/ console/src/main/java/
console/src/main/java/org/ console/src/main/java/org/apache/
console/src/main/java/org/apache/devicemap/ console/src/main/j...
Author: wkeil
Date: Sun Jul 20 22:56:50 2014
New Revision: 1612172
URL: http://svn.apache.org/r1612172
Log:
DMAP-48: Create example project and web service
Console example
Task-Url: https://issues.apache.org/jira/browse/DMAP-48
Added:
incubator/devicemap/trunk/examples/console/ (with props)
incubator/devicemap/trunk/examples/console/pom.xml
incubator/devicemap/trunk/examples/console/src/
incubator/devicemap/trunk/examples/console/src/main/
incubator/devicemap/trunk/examples/console/src/main/java/
incubator/devicemap/trunk/examples/console/src/main/java/org/
incubator/devicemap/trunk/examples/console/src/main/java/org/apache/
incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/
incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/
incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/
incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java
incubator/devicemap/trunk/examples/console/src/main/resources/
incubator/devicemap/trunk/examples/console/src/test/
incubator/devicemap/trunk/examples/console/src/test/java/
incubator/devicemap/trunk/examples/console/src/test/resources/
Modified:
incubator/devicemap/trunk/examples/pom.xml
Propchange: incubator/devicemap/trunk/examples/console/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Jul 20 22:56:50 2014
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target
Added: incubator/devicemap/trunk/examples/console/pom.xml
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/examples/console/pom.xml?rev=1612172&view=auto
==============================================================================
--- incubator/devicemap/trunk/examples/console/pom.xml (added)
+++ incubator/devicemap/trunk/examples/console/pom.xml Sun Jul 20 22:56:50 2014
@@ -0,0 +1,23 @@
+<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>
+ <parent>
+ <groupId>org.apache.devicemap.examples</groupId>
+ <artifactId>examples-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>console-example</artifactId>
+ <name>DeviceMap Console Example</name>
+ <description>A Console Example using Apache DeviceMap Client</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.devicemap</groupId>
+ <artifactId>devicemap-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.devicemap</groupId>
+ <artifactId>devicemap-data</artifactId>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java?rev=1612172&view=auto
==============================================================================
--- incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java (added)
+++ incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java Sun Jul 20 22:56:50 2014
@@ -0,0 +1,48 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.devicemap.example.console;
+
+import java.util.Map;
+import org.apache.devicemap.DeviceMapClient;
+import org.apache.devicemap.loader.LoaderOption;
+
+/**
+ *
+ * @author Reza Naghibi
+ * @author Werner Keil
+ */
+public class Example {
+
+ public static void main(String[] args) throws Exception {
+ //create a client object, store this somewhere permanent
+ DeviceMapClient client = new DeviceMapClient();
+
+ //load the device data, do this only once!!!
+ client.initDeviceData(LoaderOption.JAR);
+
+ //classify a User-Agent string
+ String test = "Mozilla/5.0 (Linux; U; Android 2.2; en; HTC Aria A6380 Build/ERE27) AppleWebKit/540.13+ (KHTML, like Gecko) Version/3.1 Mobile Safari/524.15.0";
+ Map<String, String> m = client.classify(test);
+
+ //iterate thru the attributes
+ for (String attr : m.keySet()) {
+ System.out.println(attr + ": " + m.get(attr));
+ }
+ }
+}
Modified: incubator/devicemap/trunk/examples/pom.xml
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/examples/pom.xml?rev=1612172&r1=1612171&r2=1612172&view=diff
==============================================================================
--- incubator/devicemap/trunk/examples/pom.xml (original)
+++ incubator/devicemap/trunk/examples/pom.xml Sun Jul 20 22:56:50 2014
@@ -1,15 +1,64 @@
-<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.apache.devicemap.examples</groupId>
- <artifactId>examples-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>Apache DeviceMap Examples</name>
- <modules/>
- <parent>
- <groupId>org.apache</groupId>
- <artifactId>apache</artifactId>
- <version>14</version>
- </parent>
- <url>http://incubator.apache.org/devicemap</url>
+<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.apache.devicemap.examples</groupId>
+ <artifactId>examples-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>Apache DeviceMap Examples</name>
+ <modules>
+ <module>console</module>
+ </modules>
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>14</version>
+ </parent>
+ <url>http://incubator.apache.org/devicemap</url>
+
+ <!-- Test settings that can be overridden from the Maven command line -->
+ <properties>
+ <java.version>1.6</java.version>
+ <jdkVersion>${java.version}</jdkVersion>
+ <maven.compile.targetLevel>${jdkVersion}</maven.compile.targetLevel>
+ <maven.compile.sourceLevel>${jdkVersion}</maven.compile.sourceLevel>
+ <devicemap.version>1.0.0</devicemap.version>
+ <devicemap.data.version>1.0.0</devicemap.data.version>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.devicemap</groupId>
+ <artifactId>devicemap-client</artifactId>
+ <version>${devicemap.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.devicemap</groupId>
+ <artifactId>devicemap-data</artifactId>
+ <version>${devicemap.data.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${maven.compile.sourceLevel}</source>
+ <target>${maven.compile.targetLevel}</target>
+ <debug>true</debug>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file