Browse Source

add java for kuaishou

liuyuqi-dellpc 5 years ago
parent
commit
42ce97fc36

+ 1 - 0
.gitignore

@@ -1 +1,2 @@
 /.idea
 /.idea
+/java/.settings

+ 23 - 0
java/.classpath

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="src" path="src/main/cpp"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

+ 1 - 0
java/.gitignore

@@ -0,0 +1 @@
+/target/

+ 23 - 0
java/.project

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>kuaishou</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+	</natures>
+</projectDescription>

+ 3 - 0
java/README.md

@@ -0,0 +1,3 @@
+## kuaishou
+
+java代码调用libcore.so实现快手api签名

+ 25 - 0
java/pom.xml

@@ -0,0 +1,25 @@
+<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>me.yoqi</groupId>
+  <artifactId>kuaishou</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <name>kuaishou</name>
+  <url>http://maven.apache.org</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

+ 1 - 0
java/src/main/cpp/me_yoqi_kuaishou_jni_cpu.cpp

@@ -0,0 +1 @@
+include<jni.h>

+ 40 - 0
java/src/main/java/me/yoqi/kuaishou/App.java

@@ -0,0 +1,40 @@
+package me.yoqi.kuaishou;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * 快手API签名算法,jni
+ *
+ */
+public class App {
+	private static List<String> arrayList;
+
+	public static void main(String[] args) {
+		System.out.println("Hello World!");
+	}
+
+	public static List<String> b(Map<String, String> map, Map<String, String> map2) {
+		List<String> arraylist = new ArrayList<String>(map.size() + map2.size());
+		for (Entry<String, String> entry : map.entrySet()) {
+			arraylist
+					.add(((String) entry.getKey()) + "=" + (entry.getValue() == null ? "" : (String) entry.getValue()));
+		}
+		for (Entry<String, String> entry2 : map2.entrySet()) {
+			arraylist.add(
+					((String) entry2.getKey()) + "=" + (entry2.getValue() == null ? "" : (String) entry2.getValue()));
+		}
+		try {
+			Collections.sort(arraylist);
+
+		} catch (Throwable e) {
+			System.out.println(e.getMessage());
+			// com.google.a.a.a.a.a.a.a(e);
+		}
+		return arrayList;
+	}
+
+}

+ 9 - 0
java/src/main/java/me/yoqi/kuaishou/jni/CPU.java

@@ -0,0 +1,9 @@
+package me.yoqi.kuaishou.jni;
+
+public class CPU {
+	static {
+		System.loadLibrary("libcore.so");
+	}
+
+	public native void getClock();
+}

+ 16 - 0
java/src/main/java/me/yoqi/kuaishou/jni/JNILibCore.java

@@ -0,0 +1,16 @@
+package me.yoqi.kuaishou.jni;
+
+public class JNILibCore {
+	//	java -Djava.library.path=. me.yoqi.kuaishou.jni.JNILibCore
+	//	-Djava.library.path= C:/Users/liuyuqi/Desktop/crawl-kuaishou/java/kuaishou/src/main/resources me.yoqi.kuaishou.jni.JNILibCore
+	
+	static {
+		System.loadLibrary("libcore.so");
+	}
+
+	public static void main(String[] args) {
+		new JNILibCore().say("hello world");
+	}
+
+	public native void say(String str);
+}

BIN
java/src/main/java/me/yoqi/kuaishou/jni/libcore.so


+ 0 - 0
java/src/main/resources/sum.txt


+ 38 - 0
java/src/test/java/me/yoqi/kuaishou/AppTest.java

@@ -0,0 +1,38 @@
+package me.yoqi.kuaishou;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}