ericluoliu commented on code in PR #153:
URL: 
https://github.com/apache/apisix-java-plugin-runner/pull/153#discussion_r907678632


##########
runner-starter/src/main/java/org/apache/apisix/plugin/runner/MyClassLoader.java:
##########
@@ -0,0 +1,51 @@
+package org.apache.apisix.plugin.runner;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class MyClassLoader extends ClassLoader {
+    public MyClassLoader(ClassLoader parent) {
+        super(parent);
+    }
+
+    @Override
+    public Class<?> loadClass(String name) throws ClassNotFoundException {
+
+        
if(!"org.apache.apisix.plugin.runner.filter.RewriteRequestDemoFilter".equals(name)){
+            return super.loadClass(name);
+        }
+        try {
+            String url = 
"file:/home/parallels/Documents/apisix-java-plugin-runner/runner-plugin/target/classes/org/apache/apisix/plugin/runner/filter/RewriteRequestDemoFilter.class";
+            URL myUrl = new URL(url);
+            URLConnection connection = myUrl.openConnection();
+            InputStream input = connection.getInputStream();
+            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+            int data = input.read();
+
+            while(data != -1){
+                buffer.write(data);
+                data = input.read();
+            }
+
+            input.close();
+
+            byte[] classData = buffer.toByteArray();
+
+            return 
defineClass("org.apache.apisix.plugin.runner.filter.RewriteRequestDemoFilter",
+                    classData, 0, classData.length);
+
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        return null;
+    }
+
+
+}

Review Comment:
   Yes, this is hot loading. I didn't realize I was working in the same git 
branch as before, and I must have accidentally committed all of those changes 
to this PR. Let me fix that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to