m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-11-14 20:09:45 +0100
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-11-14 20:09:45 +0100
commit68b2cba1cf2bc96a996a15220e4df95b2e86520e (patch)
tree8175a119c070a17071696d0bcd0fc1b27b95d97e
parent4708ba199166d777d0b60879398a8e000f7aaf56 (diff)
Add basic client
-rw-r--r--build.gradle8
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/client/Client.java42
2 files changed, 50 insertions, 0 deletions
diff --git a/build.gradle b/build.gradle
index 8294b27..732e30d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -18,12 +18,15 @@ repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
+ mavenCentral()
}
dependencies {
// This dependency is used by the application.
implementation 'com.google.guava:guava:28.0-jre'
+ implementation 'org.springframework.boot:spring-boot-starter-web:2.2.1.RELEASE'
+
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
@@ -47,3 +50,8 @@ task runAgent(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'pl.edu.mimuw.cloudatlas.agent.Agent'
}
+
+task runClient(type: JavaExec) {
+ classpath = sourceSets.main.runtimeClasspath
+ main = 'pl.edu.mimuw.cloudatlas.client.Client'
+}
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/client/Client.java b/src/main/java/pl/edu/mimuw/cloudatlas/client/Client.java
new file mode 100644
index 0000000..e573d6c
--- /dev/null
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/client/Client.java
@@ -0,0 +1,42 @@
+package pl.edu.mimuw.cloudatlas.client;
+
+import pl.edu.mimuw.cloudatlas.agent.Api;
+
+import java.rmi.registry.LocateRegistry;
+import java.rmi.RemoteException;
+import java.rmi.registry.Registry;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * Main class for a client.
+ *
+ * Set the following properties on the command line:
+ *
+ * <br>
+ * -Djava.rmi.server.useCodebaseOnly=false
+ * <br>
+ * -Djava.rmi.server.codebase=file:/path/to/compiled/classes/
+ * <br>
+ * -Djava.security.policy=client.policy
+ * <br>
+ *
+ * <b>NOTE: MAKE SURE YOU HAVE THE TRAILING / ON THE CODEBASE PATH</b>
+ */
+
+// https://github.com/rm5248/Java-RMI-Example/
+
+@SpringBootApplication
+public class Client {
+ public static void main(String[] args) {
+ try {
+ Registry registry = LocateRegistry.getRegistry("localhost");
+ Api api = (Api) registry.lookup("Api");
+
+ SpringApplication.run(Client.class, args);
+ } catch (Exception e) {
+ System.err.println("Client exception:");
+ e.printStackTrace();
+ }
+ }
+}