简体   繁体   English

如何在不访问源代码的情况下从现有 Java 应用程序中检索实时数据?

[英]How to retrieve real-time data from an existing Java application without access to source code?

Update: Jun 10, 2022更新:2022 年 6 月 10 日

I have successfully been able to create a demo application with AspectJ integration that could extract variables from the demo application.我已经成功地创建了一个带有 AspectJ 集成的演示应用程序,它可以从演示应用程序中提取变量。 It was quite a hassle since there's a bit of trouble going on with Eclipse AJDT integration.这很麻烦,因为 Eclipse AJDT 集成存在一些问题。

I was able to use CLI Java and ajc (AspectJ compiler) to achieve binary weaving into my demo application.我能够使用 CLI Java 和 ajc(AspectJ 编译器)在我的演示应用程序中实现二进制编织。

Original Question:原始问题:

I am trying to retrieve real-time data from a running Java application and push it into an API I have on a server.|我正在尝试从正在运行的 Java 应用程序中检索实时数据并将其推送到我在服务器上拥有的 API 中。|

I have no access to the source code of the running application;我无权访问正在运行的应用程序的源代码; I only have the Jar file.我只有 Jar 文件。 I have tried decompilation into .java files;我试过反编译成 .java 文件; however, due to the scale of the app, I was not able to fix all of the missing access$000 function calls.但是,由于应用程序的规模,我无法修复所有丢失的 access$000 函数调用。

Is there a certain approach I should use when retrieving real-time data from an existing Java application?从现有 Java 应用程序检索实时数据时,我应该使用某种方法吗? Has that been done before?以前这样做过吗? Am I missing something that I am not aware of?我错过了一些我不知道的东西吗?

Any help is appreciated.任何帮助表示赞赏。

This is big challenge obviously.这显然是一个很大的挑战。 If you can glean enough understanding of how the program works from decompiling and reading log files to target some methods where you suspect there's data of interest to your API, then I would read up about Aspect Oriented Programming [AOP] and use those tools.如果您能够充分了解程序的工作原理,从反编译和读取日志文件到针对您怀疑 API 感兴趣的数据的某些方法,那么我会阅读面向方面编程 [AOP] 并使用这些工具。

With AOP you can modify the classes in the jar file at runtime as its loaded by the JVM and access the classes.使用 AOP,您可以在运行时修改 jar 文件中的类,因为它由 JVM 加载并访问这些类。

For example: You can gather data from:例如:您可以从以下位置收集数据:

  1. fields within the class that owns a method拥有方法的类中的字段
  2. parameters passed to a method传递给方法的参数
  3. value returned from a method从方法返回的值

Once you gather the data, you can also insert calls to your API.收集数据后,您还可以插入对 API 的调用。

Here's a place to start - https://www.baeldung.com/aspectj .这是一个开始的地方 - https://www.baeldung.com/aspectj

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM