devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wk...@apache.org
Subject svn commit: r1742809 - in /devicemap/trunk/examples/1.0/java: servlet/src/main/java/org/apache/devicemap/servlet/Classify.java spring/src/main/java/org/apache/devicemap/spring/Classifier.java
Date Sun, 08 May 2016 12:56:12 GMT
Author: wkeil
Date: Sun May  8 12:56:12 2016
New Revision: 1742809

URL: http://svn.apache.org/viewvc?rev=1742809&view=rev
Log:
DMAP-191: DMAP-Spring on VM broken 

Task-Url: https://issues.apache.org/jira/browse/DMAP-191

Modified:
    devicemap/trunk/examples/1.0/java/servlet/src/main/java/org/apache/devicemap/servlet/Classify.java
    devicemap/trunk/examples/1.0/java/spring/src/main/java/org/apache/devicemap/spring/Classifier.java

Modified: devicemap/trunk/examples/1.0/java/servlet/src/main/java/org/apache/devicemap/servlet/Classify.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/1.0/java/servlet/src/main/java/org/apache/devicemap/servlet/Classify.java?rev=1742809&r1=1742808&r2=1742809&view=diff
==============================================================================
--- devicemap/trunk/examples/1.0/java/servlet/src/main/java/org/apache/devicemap/servlet/Classify.java
(original)
+++ devicemap/trunk/examples/1.0/java/servlet/src/main/java/org/apache/devicemap/servlet/Classify.java
Sun May  8 12:56:12 2016
@@ -20,10 +20,12 @@ package org.apache.devicemap.servlet;
 
 import java.io.IOException;
 import java.io.Writer;
+
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
 import org.apache.devicemap.DeviceMapFactory;
 import org.apache.devicemap.data.Device;
 import org.apache.devicemap.loader.LoaderOption;
@@ -31,37 +33,39 @@ import org.apache.devicemap.loader.Loade
 /**
  *
  * @author Reza Naghibi
+ * @author Werner Keil
  */
 public class Classify extends HttpServlet {
-  
-    /**
+
+	/**
      * 
      */
 	private static final long serialVersionUID = -5231604595735057872L;
 
-@Override
-  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
-    String ua = request.getParameter("ua");
-
-    if (ua == null || ua.isEmpty()) {
-      ua = request.getHeader("User-Agent");
-    }
-    
-    long start = System.nanoTime();
-    
-    final Device device = DeviceMapFactory.getClient(LoaderOption.URL).classifyDevice(ua);
-    
-    long diff = (System.nanoTime() - start) / 1000;
-
-    final StringBuilder sb = new StringBuilder();
-    sb.append("\n{\n\"success\":true,\n\"user-agent\":\"").append(ua).append("\",\"time_microseconds\":");
-    sb.append(diff).append(",\"result\":").append(device.toString()).append("\n}");
-
-    response.setHeader("Content-Type", "application/json");
-
-    Writer writer = response.getWriter();
-    writer.write(sb.toString());
-    writer.flush();
-  }
-
+	@Override
+	protected void doGet(HttpServletRequest request,
+			HttpServletResponse response) throws ServletException, IOException {
+		String ua = request.getParameter("ua");
+
+		if (ua == null || ua.isEmpty()) {
+			ua = request.getHeader("User-Agent");
+		}
+
+		long start = System.nanoTime();
+		final Device device = DeviceMapFactory.getClient(LoaderOption.URL)
+				.classifyDevice(ua);
+		long diff = (System.nanoTime() - start) / 1000;
+
+		final StringBuilder sb = new StringBuilder();
+		sb.append("\n{\n\"success\":true,\n\"user-agent\":\"").append(ua)
+				.append("\",\n\"time_microseconds\":");
+		sb.append(diff).append(",\n\"result\":").append(device.toString())
+				.append("\n}");
+
+		response.setHeader("Content-Type", "application/json");
+
+		Writer writer = response.getWriter();
+		writer.write(sb.toString());
+		writer.flush();
+	}
 }

Modified: devicemap/trunk/examples/1.0/java/spring/src/main/java/org/apache/devicemap/spring/Classifier.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/1.0/java/spring/src/main/java/org/apache/devicemap/spring/Classifier.java?rev=1742809&r1=1742808&r2=1742809&view=diff
==============================================================================
--- devicemap/trunk/examples/1.0/java/spring/src/main/java/org/apache/devicemap/spring/Classifier.java
(original)
+++ devicemap/trunk/examples/1.0/java/spring/src/main/java/org/apache/devicemap/spring/Classifier.java
Sun May  8 12:56:12 2016
@@ -37,8 +37,9 @@ public class Classifier {
     public synchronized void init() throws Exception {
         long start = System.nanoTime();
         client = new DeviceMapClient();
-        client.initDeviceData(LoaderOption.JAR);
-        long diff = (System.nanoTime() - start) / (1000*1000);
+        //client.initDeviceData(LoaderOption.JAR);
+        client.initDeviceData(LoaderOption.URL);
+        long diff = (System.nanoTime() - start) / 1000;
         log.info("DeviceMap Classifier loaded " + client.getDeviceCount() + " devices and
" + client.getPatternCount() + " patterns in " + diff + "ms");
     }
     



Mime
View raw message