diff --git a/build.xml b/build.xml
index e6ed116..ffa5922 100644
--- a/build.xml
+++ b/build.xml
@@ -16,7 +16,7 @@
-
+
@@ -30,12 +30,12 @@
-
-
-
+
diff --git a/scripts/plugin.config b/scripts/plugin.config
index 3ad72ed..e866907 100644
--- a/scripts/plugin.config
+++ b/scripts/plugin.config
@@ -1,7 +1,7 @@
name=I2PControl
signer=dev@robertfoss.se
consoleLinkName=I2PControl
-consoleLinkURL=/I2PControl/
+consoleLinkURL=http://localhost:7656
description=Remote Control Service
author=hottuna
websiteURL=http://XR1kDnLKSUO9lhZGmB9kq8a386yDXkgvqc~nCkfUMESL~XIUIYzXO6xkmbHHS6VANkAtapVPSb1x6iwA7S7BL1E9lnUwgBsK3Wzh9YpLVpYq2thFEWAI-mkUgrhcnSTn5VoetjR~Cv4sI7geDL4MsMEnmno5KKTwVJY6di3dJkzwKx4epjfs3KiCqizTqfLykc8KDitjQ~9-PvBUV9q79~reEsJ32AGSwGflV8a8S8OSv0Jw7V4AvljMLdIYD-FwVUCFHUHzqUcDSyEklmOQoYFxDc2fytx5v04H8YZH4Zp29tJq-O97lCx4TBZxyRaQnWcoE74D0ChTv8Y1~kRYwYloWbcya--XgvLgWbnGbOQZgFUpFc1OGhJFukgVHqTrj~S8DaC4Yv2~P7dcjItYZ12JBoq1wXbQN-ZP~BrOW9FJd7qP~AH4vT1MlstkOTxbIvhDVVY-fPvI7Wf~4IR5uwfeSO65luBpoMqlsNML4mTySv7TGkUVB51aVJkziEtDAAAA/
diff --git a/src/build.xml b/src/build.xml
index 521c3de..0b0c1fc 100644
--- a/src/build.xml
+++ b/src/build.xml
@@ -42,7 +42,8 @@
-
+
-
-
+
+
diff --git a/src/java/net/i2p/i2pcontrol/Example.java b/src/java/net/i2p/i2pcontrol/Example.java
deleted file mode 100644
index a23ff2a..0000000
--- a/src/java/net/i2p/i2pcontrol/Example.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package net.i2p.i2pcontrol;
-
-import com.thetransactioncompany.jsonrpc2.*;
-import com.thetransactioncompany.jsonrpc2.server.*;
-
-import java.text.*;
-import java.util.*;
-
-import javax.servlet.http.*;
-
-
-/**
- * Demonstration of the JSON-RPC 2.0 Server framework usage. The request
- * handlers are implemented as static nested classes for convenience, but in
- * real life applications may be defined as regular classes within their old
- * source files.
- *
- * @author Vladimir Dzhuvinov
- * @version 2011-03-05
- */
-public class Example {
-
-
- // Implements a handler for an "echo" JSON-RPC method
- public static class EchoHandler implements RequestHandler {
-
-
- // Reports the method names of the handled requests
- public String[] handledRequests() {
-
- return new String[]{"echo"};
- }
-
-
- // Processes the requests
- public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx) {
-
- if (req.getMethod().equals("echo")) {
-
- // Echo first parameter
-
- List params = (List)req.getParams();
-
- Object input = params.get(0);
-
- return new JSONRPC2Response(input, req.getID());
- }
- else {
- // Method name not supported
-
- return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID());
- }
- }
- }
-
-
- // Implements a handler for "getDate" and "getTime" JSON-RPC methods
- // that return the current date and time
- public static class DateTimeHandler implements RequestHandler {
-
-
- // Reports the method names of the handled requests
- public String[] handledRequests() {
-
- return new String[]{"getDate", "getTime"};
- }
-
-
- // Processes the requests
- public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx) {
-
- if (req.getMethod().equals("getDate")) {
- DateFormat df = DateFormat.getDateInstance();
-
- String date = df.format(new Date());
-
- return new JSONRPC2Response(date, req.getID());
- }
- else if (req.getMethod().equals("getTime")) {
-
- DateFormat df = DateFormat.getTimeInstance();
-
- String time = df.format(new Date());
-
- return new JSONRPC2Response(time, req.getID());
- }
- else {
-
- // Method name not supported
-
- return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID());
- }
- }
- }
-
-
- public static void main(String[] args) {
-
-
- // Create a new JSON-RPC 2.0 request dispatcher
- Dispatcher dispatcher = new Dispatcher();
-
-
- // Register the "echo", "getDate" and "getTime" handlers with it
- dispatcher.register(new EchoHandler());
- dispatcher.register(new DateTimeHandler());
-
- // Simulate an "echo" JSON-RPC 2.0 request
- List echoParam = new LinkedList();
- echoParam.add("Hello world!");
-
- JSONRPC2Request req = new JSONRPC2Request("echo", echoParam, "req-id-01");
- System.out.println("Request: \n" + req);
-
- JSONRPC2Response resp = dispatcher.dispatch(req, null);
- System.out.println("Response: \n" + resp);
-
-
- // Simulate a "getDate" JSON-RPC 2.0 request
- req = new JSONRPC2Request("getDate", "req-id-02");
- System.out.println("Request: \n" + req);
-
- resp = dispatcher.dispatch(req, null);
- System.out.println("Response: \n" + resp);
-
-
- // Simulate a "getTime" JSON-RPC 2.0 request
- req = new JSONRPC2Request("getTime", "req-id-03");
- System.out.println("Request: \n" + req);
-
- resp = dispatcher.dispatch(req, null);
- System.out.println("Response: \n" + resp);
- }
-}
\ No newline at end of file
diff --git a/src/java/net/i2p/i2pcontrol/HistoryServlet.java b/src/java/net/i2p/i2pcontrol/HistoryServlet.java
new file mode 100644
index 0000000..2c235a4
--- /dev/null
+++ b/src/java/net/i2p/i2pcontrol/HistoryServlet.java
@@ -0,0 +1,40 @@
+package net.i2p.i2pcontrol;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import net.i2p.I2PAppContext;
+import net.i2p.util.Log;
+
+public class HistoryServlet extends HttpServlet {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4018705582081424641L;
+ private static I2PControlManager _manager;
+ private static Log _log;
+
+
+ @Override
+ public void init(){
+ _log = I2PAppContext.getGlobalContext().logManager().getLog(HistoryServlet.class);
+ _manager = I2PControlManager.getInstance();
+ }
+
+ protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException
+ {
+ httpServletResponse.setContentType("text/html");
+ PrintWriter out = httpServletResponse.getWriter();
+ out.println("\n");
+ out.println(_manager.getHistory());
+ out.println("\n");
+ out.close();
+ }
+
+}
diff --git a/src/java/net/i2p/i2pcontrol/I2PControlController.java b/src/java/net/i2p/i2pcontrol/I2PControlController.java
index 42f074a..81402dc 100644
--- a/src/java/net/i2p/i2pcontrol/I2PControlController.java
+++ b/src/java/net/i2p/i2pcontrol/I2PControlController.java
@@ -16,6 +16,7 @@ package net.i2p.i2pcontrol;
*
*/
+import java.io.File;
import java.io.IOException;
import java.util.Calendar;
@@ -68,17 +69,17 @@ public class I2PControlController{
private static void start(String args[]) {
- /*File pluginDir = new File(args[1]);
- if (!pluginDir.exists())
- throw new IllegalArgumentException("Plugin directory " + pluginDir.getAbsolutePath() + " does not exist");
- */
+ //File pluginDir = new File(args[1]);
+ //if (!pluginDir.exists())
+ // throw new IllegalArgumentException("Plugin directory " + pluginDir.getAbsolutePath() + " does not exist");
+
_server = new Server();
try {
_server.addListener(Settings.getListenIP() +":" +Settings.getListenPort());
ServletHttpContext context = (ServletHttpContext) _server.getContext("/");
- context.addServlet("/", "net.i2p.i2pcontrol.JSONRPCServlet");
-
- //context.setClassLoader(Thread.currentThread().getContextClassLoader());
+ context.addServlet("/", "net.i2p.i2pcontrol.SettingsServlet");
+ context.addServlet("/jsonrpc", "net.i2p.i2pcontrol.JSONRPCServlet");
+ context.addServlet("/history", "net.i2p.i2pcontrol.HistoryServlet");
_server.start();
} catch (IOException e) {
_log.error("Unable to add listener " + Settings.getListenIP()+":"+Settings.getListenPort() + " - " + e.getMessage());
diff --git a/src/java/net/i2p/i2pcontrol/I2PControlManager.java b/src/java/net/i2p/i2pcontrol/I2PControlManager.java
index 73b54ab..27d1cee 100644
--- a/src/java/net/i2p/i2pcontrol/I2PControlManager.java
+++ b/src/java/net/i2p/i2pcontrol/I2PControlManager.java
@@ -22,82 +22,23 @@ import java.lang.reflect.*;
* There can be only one - ie. even if the class is loaded in several different classloaders,
* there will be only one instance of the object.
*/
-public class I2PControlManager implements ManagerInterface{
+public class I2PControlManager{
private static StringBuilder _history;
-
- /**
- * This is effectively an instance of this class (although actually it may be instead a
- * java.lang.reflect.Proxy wrapping an instance from the original classloader).
- */
- public static ManagerInterface instance = null;
- /**
- * Retrieve an instance of AbsoluteSingleton from the original classloader. This is a true
- * Singleton, in that there will only be one instance of this object in the virtual machine,
- * even though there may be several copies of its class file loaded in different classloaders.
- */
- public synchronized static ManagerInterface getInstance() {
- ClassLoader myClassLoader = I2PControlManager.class.getClassLoader();
- if (instance==null) {
- // The root classloader is sun.misc.Launcher package. If we are not in a sun package,
- // we need to get hold of the instance of ourself from the class in the root classloader.
- if (! myClassLoader.toString().startsWith("sun.")) {
- try {
- // So we find our parent classloader
- ClassLoader parentClassLoader = I2PControlManager.class.getClassLoader().getParent();
- // And get the other version of our current class
- Class otherClassInstance = parentClassLoader.loadClass(I2PControlManager.class.getName());
- // And call its getInstance method - this gives the correct instance of ourself
- Method getInstanceMethod = otherClassInstance.getDeclaredMethod("getInstance", new Class[] { });
- Object otherAbsoluteSingleton = getInstanceMethod.invoke(null, new Object[] { } );
- // But, we can't cast it to our own interface directly because classes loaded from
- // different classloaders implement different versions of an interface.
- // So instead, we use java.lang.reflect.Proxy to wrap it in an object that *does*
- // support our interface, and the proxy will use reflection to pass through all calls
- // to the object.
- instance = (ManagerInterface) Proxy.newProxyInstance(myClassLoader,
- new Class[] { ManagerInterface.class },
- new PassThroughProxyHandler(otherAbsoluteSingleton));
- // And catch the usual tedious set of reflection exceptions
- // We're cheating here and just catching everything - don't do this in real code
- } catch (Exception e) {
- e.printStackTrace();
- }
- // We're in the root classloader, so the instance we have here is the correct one
- } else {
+ public static I2PControlManager instance = null;
+
+ public synchronized static I2PControlManager getInstance() {
+ if (instance == null) {
instance = new I2PControlManager();
- }
}
return instance;
}
private I2PControlManager() {
_history = new StringBuilder();
-
}
- private String value = "";
- /* (non-Javadoc)
- * @see net.i2p.i2pcontrol.SingleTonInterface#getValue()
- */
- /* (non-Javadoc)
- * @see net.i2p.i2pcontrol.SingletonInterface#getValue()
- */
- public String getValue() { return value; }
- /* (non-Javadoc)
- * @see net.i2p.i2pcontrol.SingleTonInterface#setValue(java.lang.String)
- */
- /* (non-Javadoc)
- * @see net.i2p.i2pcontrol.SingletonInterface#setValue(java.lang.String)
- */
- public void setValue(String value) {
- this.value = value;
- }
-
- /* (non-Javadoc)
- * @see net.i2p.i2pcontrol.SingleTonInterface#prependHistory(java.lang.String)
- */
/* (non-Javadoc)
* @see net.i2p.i2pcontrol.SingletonInterface#prependHistory(java.lang.String)
*/
@@ -105,9 +46,6 @@ public class I2PControlManager implements ManagerInterface{
_history.insert(0,str + "
\n");
}
- /* (non-Javadoc)
- * @see net.i2p.i2pcontrol.SingleTonInterface#appendHistory(java.lang.String)
- */
/* (non-Javadoc)
* @see net.i2p.i2pcontrol.SingletonInterface#appendHistory(java.lang.String)
*/
@@ -116,9 +54,6 @@ public class I2PControlManager implements ManagerInterface{
}
- /* (non-Javadoc)
- * @see net.i2p.i2pcontrol.SingleTonInterface#getHistory()
- */
/* (non-Javadoc)
* @see net.i2p.i2pcontrol.SingletonInterface#getHistory()
*/
diff --git a/src/java/net/i2p/i2pcontrol/JSONRPCServlet.java b/src/java/net/i2p/i2pcontrol/JSONRPCServlet.java
index 927d84d..343c751 100644
--- a/src/java/net/i2p/i2pcontrol/JSONRPCServlet.java
+++ b/src/java/net/i2p/i2pcontrol/JSONRPCServlet.java
@@ -43,14 +43,12 @@ import com.thetransactioncompany.jsonrpc2.server.*;
* Provide an JSON-RPC 2.0 API for remote controlling of I2P
*/
public class JSONRPCServlet extends HttpServlet{
- /**
- *
- */
+
private static final long serialVersionUID = -45075606818515212L;
private static final int BUFFER_LENGTH = 2048;
private static Dispatcher disp;
private static char[] readBuffer;
- private static ManagerInterface _manager;
+ private static I2PControlManager _manager;
private static Log _log;
@@ -58,20 +56,23 @@ public class JSONRPCServlet extends HttpServlet{
public void init(){
_log = I2PAppContext.getGlobalContext().logManager().getLog(JSONRPCServlet.class);
readBuffer = new char[BUFFER_LENGTH];
- _manager = (ManagerInterface) I2PControlManager.getInstance();
+ _manager = I2PControlManager.getInstance();
disp = new Dispatcher();
disp.register(new EchoHandler());
disp.register(new StatHandler());
}
+ @Override
protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException
{
httpServletResponse.setContentType("text/html");
PrintWriter out = httpServletResponse.getWriter();
out.println("Nothing to see here");
+ out.close();
}
+ @Override
protected void doPost(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException
{
String req = getRequest(httpServletRequest.getInputStream());
diff --git a/src/java/net/i2p/i2pcontrol/ManagerInterface.java b/src/java/net/i2p/i2pcontrol/ManagerInterface.java
deleted file mode 100644
index 1d8db95..0000000
--- a/src/java/net/i2p/i2pcontrol/ManagerInterface.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package net.i2p.i2pcontrol;
-
-public interface ManagerInterface {
-
- /* (non-Javadoc)
- * @see net.i2p.i2pcontrol.SingleTonInterface#getValue()
- */
- public abstract String getValue();
-
- /* (non-Javadoc)
- * @see net.i2p.i2pcontrol.SingleTonInterface#setValue(java.lang.String)
- */
- public abstract void setValue(String value);
-
- /* (non-Javadoc)
- * @see net.i2p.i2pcontrol.SingleTonInterface#prependHistory(java.lang.String)
- */
- public abstract void prependHistory(String str);
-
- /* (non-Javadoc)
- * @see net.i2p.i2pcontrol.SingleTonInterface#appendHistory(java.lang.String)
- */
- public abstract void appendHistory(String str);
-
- /* (non-Javadoc)
- * @see net.i2p.i2pcontrol.SingleTonInterface#getHistory()
- */
- public abstract String getHistory();
-
-}
\ No newline at end of file
diff --git a/src/java/net/i2p/i2pcontrol/PassThroughProxyHandler.java b/src/java/net/i2p/i2pcontrol/PassThroughProxyHandler.java
deleted file mode 100644
index c69379f..0000000
--- a/src/java/net/i2p/i2pcontrol/PassThroughProxyHandler.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package net.i2p.i2pcontrol;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-
-/**
- * An invocation handler that passes on any calls made to it directly to its delegate.
- * This is useful to handle identical classes loaded in different classloaders - the
- * VM treats them as different classes, but they have identical signatures.
- *
- * Note this is using class.getMethod, which will only work on public methods.
- */
-class PassThroughProxyHandler implements InvocationHandler {
- private final Object delegate;
- public PassThroughProxyHandler(Object delegate) {
- this.delegate = delegate;
- }
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
- Method delegateMethod = delegate.getClass().getMethod(method.getName(), method.getParameterTypes());
- return delegateMethod.invoke(delegate, args);
- }
-}
diff --git a/src/java/net/i2p/i2pcontrol/Settings.java b/src/java/net/i2p/i2pcontrol/Settings.java
index 54b718a..96e91d5 100644
--- a/src/java/net/i2p/i2pcontrol/Settings.java
+++ b/src/java/net/i2p/i2pcontrol/Settings.java
@@ -23,7 +23,7 @@ public class Settings {
public static int getListenPort() {
// TODO Auto-generated method stub
- return 7658;
+ return 7656;
}
public static String getListenIP() {
diff --git a/src/java/net/i2p/i2pcontrol/SettingsServlet.java b/src/java/net/i2p/i2pcontrol/SettingsServlet.java
new file mode 100644
index 0000000..269bbe2
--- /dev/null
+++ b/src/java/net/i2p/i2pcontrol/SettingsServlet.java
@@ -0,0 +1,42 @@
+package net.i2p.i2pcontrol;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import net.i2p.I2PAppContext;
+import net.i2p.i2pcontrol.JSONRPCServlet.EchoHandler;
+import net.i2p.i2pcontrol.JSONRPCServlet.StatHandler;
+import net.i2p.util.Log;
+
+import com.thetransactioncompany.jsonrpc2.server.Dispatcher;
+
+public class SettingsServlet extends HttpServlet {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4018705582081424641L;
+ private static I2PControlManager _manager;
+ private static Log _log;
+
+
+ @Override
+ public void init(){
+ _log = I2PAppContext.getGlobalContext().logManager().getLog(SettingsServlet.class);
+ _manager = I2PControlManager.getInstance();
+ }
+
+ protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException
+ {
+ httpServletResponse.setContentType("text/html");
+ PrintWriter out = httpServletResponse.getWriter();
+ out.println("Settings be here");
+ out.close();
+ }
+
+}
diff --git a/src/jsp/WEB-INF/web.xml b/src/jsp/WEB-INF/web.xml
index 666d8f6..f376901 100644
--- a/src/jsp/WEB-INF/web.xml
+++ b/src/jsp/WEB-INF/web.xml
@@ -3,8 +3,8 @@
I2PControl
- index.jsp
-
+ index_jsp
+ -->
index
diff --git a/src/jsp/index.html b/src/jsp/index.html
deleted file mode 100644
index 37688b7..0000000
--- a/src/jsp/index.html
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
- Unicode Snowman Plugin for I2P
-
-
-
- ☃
-
-
-Plugin test brought to you by zzz and the snowman
-U+2603
-
-
diff --git a/src/jsp/index.jsp b/src/jsp/index.jsp
index d5e7107..603f256 100644
--- a/src/jsp/index.jsp
+++ b/src/jsp/index.jsp
@@ -10,8 +10,10 @@ I2PControl
History: | <%
-ManagerInterface _manager = I2PControlManager.getInstance();
-out.print( _manager.getHistory() );
+out.print("1ne");
+out.print("2wo");
+out.print("3hree");
+%>
|