|
@@ -0,0 +1,24 @@
|
|
1
|
+package com.uqac.rthoni.java_rmi.server.executors;
|
|
2
|
+
|
|
3
|
+import com.uqac.rthoni.java_rmi.common.Command;
|
|
4
|
+import com.uqac.rthoni.java_rmi.server.ServerApplication;
|
|
5
|
+
|
|
6
|
+/**
|
|
7
|
+ * Created by robin on 9/16/16.
|
|
8
|
+ */
|
|
9
|
+public class NewInstanceExecutor extends AbstractCommandExecutor {
|
|
10
|
+ @Override
|
|
11
|
+ public String getCommandName() {
|
|
12
|
+ return "creation";
|
|
13
|
+ }
|
|
14
|
+
|
|
15
|
+ @Override
|
|
16
|
+ public String run(Command command, ServerApplication server) throws Exception {
|
|
17
|
+ String className = command.getArgument(0);
|
|
18
|
+ String id = command.getArgument(1);
|
|
19
|
+ Class c = Class.forName(className);
|
|
20
|
+ Object obj = c.newInstance();
|
|
21
|
+ server.addObject(id, obj);
|
|
22
|
+ return null;
|
|
23
|
+ }
|
|
24
|
+}
|