Cannot get extension report to be found. [message #892828] |
Fri, 29 June 2012 22:52  |
Eclipse User |
|
|
|
Hi there.
I created a plugin extension for MAT following the instructions at wiki.eclipse.org/MemoryAnalyzer/Extending_Memory_Analyzer, targetting a new report (and query) instead. Unfortunately, I've been unable to get MAT to recognize that my report is there. To launch my code, I am doing:
* Run As -> Run Configurations
* Set 'Run An Application' to 'org.eclipse.mat.api.parse'
* Set the Program arguments to '/path/to/my/test/heap org.eclipse.mat.api:my_first_query'
When I hit Run, I just get an error that the report is not found. ("Report not found: org.eclipse.mat.api:my_first_query").
What is the correct way to associate my report & query with MAT? At the moment, I have registered extension points in my plugin.xml file, and added a query.xml file for the query, but this doesnt seem to work.
My code:
MyFirstQuery.java:
package my_mat_extension;
import org.eclipse.mat.query.IQuery;
import org.eclipse.mat.query.IResult;
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.results.TextResult;
import org.eclipse.mat.util.IProgressListener;
import java.io.CharArrayWriter;
import java.io.PrintWriter;
@CommandName("my_first_query")
public class MyFirstQuery implements IQuery {
@Override
public IResult execute(IProgressListener listener) throws Exception {
CharArrayWriter outWriter = new CharArrayWriter(1000);
PrintWriter out = new PrintWriter(outWriter);
out.println("My first query.");
return new TextResult(outWriter.toString(), false);
}
}
plugin.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.mat.report.query">
<query impl="my_mat_extension.MyFirstQuery" />
</extension>
<extension point="org.eclipse.mat.report.report">
<report id="my_first_query" name="My First Query"
description="My First Description"
file="META-INF/reports/my_first_query.xml" />
</extension>
</plugin>
META-INF/reports/my_first_query.xml (link spaces necessary to post this thread):
<query name="My First Query" xmlns:xsi="h t t p : / / w w w .w3.org/2001/XMLSchema-instance"
xmlns="h t t p : / / w w w .eclipse.org/mat/report.xsd"
xsi:schemaLocation="h t t p : / / w w w .eclipse.org/mat/report.xsd ../../../org.eclipse.mat.report/schema/report.xsd">
<param key="filename_suffix" value="My First Query" />
<command>my_first_query</command>
</query>
Thanks for any help, and please ask if there is any more information you need!
Regards,
Stephen
[Updated on: Fri, 29 June 2012 22:53] by Moderator
|
|
|
|
|
|
Re: Cannot get extension report to be found. [message #894623 is a reply to message #893187] |
Mon, 09 July 2012 16:45   |
Eclipse User |
|
|
|
Apologies for the delay! I've now had a chance to look at the added section. It looks good, it's certainly nice to have a little bit on reports. When I have time, I might take a run through those documents and see if I can tidy it up.
Can I ask, is there any plans to expose a fully functional programmatic interface to MAT? That is, at the moment the only way to get at MAT functionality programmatically (and please correct me if I'm wrong!) to generate output for another program is to use the reports framework. However, reports seem to be deeply hardcoded (again as far as I know!) to generate a HTML file inside of a Zipped folder, located in exactly the same place as the heap dump.
Ideally, I'd be able to call one of the queries (or do the same actions as it, as I know that queries are not part of the API) programmatically from some code not relying on OSGI, or at least dump the results of a query out to a file/etc without worrying about this generated HTML & Zip folder.
Thanks,
Stephen
EDIT/UPDATE: So, I realized that using an IApplication might be slightly better, as it avoids the HTML/Zip problem while still allowing access to MAT internals. Is this the best approach then?
[Updated on: Mon, 09 July 2012 21:12] by Moderator
|
|
|
Re: Cannot get extension report to be found. [message #899482 is a reply to message #894623] |
Wed, 01 August 2012 02:45  |
Eclipse User |
|
|
|
Hi Stephen,
sorry for the delayed reply.
Just to make sure what is your use case. Do you want to
a) call MAT from a different Java process, make it do some calclulations for you and use results exported in some form better than HTML
b) have MAT and your code in one process and use the APIs
MAT itself uses the Eclipse extensions mechanism so you won't be able to run it non-OSGi.
Krum
|
|
|
Powered by
FUDForum. Page generated in 0.06412 seconds