Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [wtp-incubator-dev] [XQDT] Proposition to resolve problem with Marklogic launch Run-As (Terminate is never done)

Hi Gabriel,

Thank a lot for your answer. For the moment I'm using my RuntimeProcess (that I have improved to launch the run method into a Thread). I will see your idea about RemoteExecEnvironment. In my case DebugPlugin.newProcess(ILaunch launch, Process process, String label) cannot be used because this method wait java.lang.Process.

Anyway thank a lot for your feedback.

Regards Angelo

2010/5/21 Gabriel Petrovay <gabipetrovay@xxxxxxxxx>
Hi Angelo,

Thanks your your e-mail.

I have looked over the proposed solution and the solution works but I
think there is a cleaner solution (although a little more complex) to
integrate your RunnableProcess into the IInterpreterRunner. This
solution I try to explain below:

1. DLTK has the notion of "execution environments"
(org.eclipse.dltk.core.environment.IExecutionEnvironment). Both
MarkLogic and your use case are not suitable for a
LocalExecEnvironment for a series of reasons raging from UI to
Lunching and Debug functionality. Therefore this brings again the need
of a "RemoteExecEnvironment" which is unfortunately not available in
DLTK (at least DLTK 1.0, but it's worth to search for it in DLTK 2.0).
This will solve the java.lang.Process problem in an elegant manner.
But you have to come up with the RemoteExecEnvironment code. This
implies that that an IEnvironment also needs to be coded, probably
RemoteEnvironment, just like
org.eclipse.dltk.core.internal.environment.LocalEnvironment. To define
a new environment, you must use the
"org.eclipse.dltk.core.environment" extension point.

2. DebugPlugin.newProcess can be extended with the help of the
"org.eclipse.debug.core.processFactories" extension point. In this way
you can define your own IProcess. Look how we did it in the Sausalito
plugins (org.eclipse.wst.xquery.set.launching/plugin.xml)


These two points seem to integrate well with the DLTK infrastructure,
at least from what I see in theory. Thus you can have your own
RunnableProcess passed to your own RuntimeProcess.

IMHO I think that the AbstractInterpreterRunner is generic enough and
need no more extensions for this problem.


Regards,
Gabriel

PS: I was usually against DLTK (because I use it). But it's not that
bad afterall


On Fri, May 21, 2010 at 10:49 AM, Angelo zerr <angelo.zerr@xxxxxxxxx> wrote:
> Hi XQDT Team,
>
> At first, I would like thank you for your work.
>
> I have started to implements XHive XQDT plugin by studying Marklogic code
> and now I can Run my XQuery by using XHive server. That's very cool:)
> But I have noticed into Debug View that when I launch an XQuery, the process
> is never terminated and it's impossible to terminate it. Problem comes from
> into class
> org.eclipse.wst.xquery.internal.launching.marklogic.MarkLogicRunner into
> private class MarkLogicProcess. MarkLogicProcess implements IProcess and
> some methods (like isTerminated, terminate...) are not implemented.
>
> I have seen that you have implemented a lot of Eclipse Debug interface like
> MockStreamMonitor, MockStreamsProxy...and I have studied a solution to
> resolve that. My goal was :
>
> 1) fix terminate problem.
> 2) don't implements MockStreamMonitor, MockStreamsProxy but use Eclipse
> Debug implementation (org.eclipse.debug.internal.core.StreamsProxy instead
> of MockStreamsProxy, org.eclipse.debug.internal.core.OutputStreamMonitor
> instead of MockStreamMonitor )
> 3) use DLTK AbstractInterpreterRunner instead of implementing
> IInterpreterRunner (as you have done with MarkLogicRunner).
>
> And I have resolved this 3 points. The basic idea is that
> AbstractInterpreterRunner works only with Java process and in your case (my
> case too) we wish launch not a Java Process but a Java class in our plugin.
> I have studied the code of AbstractInterpreterRunner and DLTK use this code
>
> --------------------
> IProcess process = DebugPlugin.newProcess(launch, p, label, attributes);
> --------------------
>
> where p is java.lang.Process implementation.
>
> DebugPlugin.newProcess use internally the code
>
> --------------------
> return new org.eclipse.debug.core.model.RuntimeProcess(launch, process,
> label, attributes);
> --------------------
>
> IHMO I think we shoud use RuntimeProcess too in our case to use
> AbstractInterpreterRunner, and RuntimeProcess  manage muti threading for the
> monitor (thread for message, for error..). The only problem is  process
> (which implement java.lang.Process and which is Java lang Process). So to
> resolve that I have created a class RunnableProcess  wich extends
> java.lang.Process by implementing the methods. This abstract class
> implements Runnable too. So the only thing to do is to extends this class
> and implement run method :
>
> --------------------
> public abstract class RunnableProcess extends java.lang.Process implements
> Runnable {
>
>    public int waitFor() throws InterruptedException {
>       ....
>       run()
>       ...
>    }
> }
> --------------------
>
> I have done that into Freemarker Plugin which is based on DLTK too into
> class FreemarkerRunnableProcess:  This class implements DLTKRunnableProcess
> (which implements RunnableProcess) because I need launch, install
> information to get the file content (like you) :
>
> --------------------
>
> public class FreemarkerRunnableProcess extends DLTKRunnableProcess {
>
>     public FreemarkerRunnableProcess(IInterpreterInstall install,
>             ILaunch launch, InterpreterConfig config) {
>         super(install, launch, config);
>     }
>
>     public void run() {
>       File templateFile = super.getFile();
>       // do something...
>
>       super.out("Write message into console");
>       super.err("Write error into console");
>    }
> }
> --------------------
>
> After you must extends my AbstractRunnableInterpreterRunner which extends
> DLTK AbstractInterpreterRunner and return instance of RunnableProcess (wich
> is java.lang.Process). I have done that into class
> FreemarkerInterpreterRunner
>
>
> --------------------
> public class FreemarkerInterpreterRunner extends
>         AbstractRunnableInterpreterRunner {
>
>     public FreemarkerInterpreterRunner(IInterpreterInstall install) {
>         super(install);
>     }
>
>     @Override
>     protected RunnableProcess createRunnableProcess(ILaunch launch,
>             InterpreterConfig config) {
>         return new FreemarkerRunnableProcess(super.getInstall(), launch,
> config);
>     }
>
> }
> --------------------
>
> And that's all! You need not create another classes like Mock* you have
> done. Terminate (so the launch is terminated when run is done, you can
> terminate the process if you wish...) is managed with Eclipse Debug class
> RuntimeProcess.
>
> I have tried to clean my code and if you are interested you must get classes
> from the 2 packages :
>
> * /org/eclipse/dltk/launching/
> * /org/eclipse/dltk/internal/launching/
>
> from the folder
> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/org.eclipse.dltk.freemarker.launching/src/org/eclipse/dltk/
>
> If you wish use this code, in your case you must  :
>
> 1) add org.eclipse.dltk.debug require bundle into the Marklogic launching
> plugin
> 2) add source of Freemarker SVN (as I have explained below)
> 3) create class MarklogicRunnableProcess like this :
>
> --------------------
>
> package org.eclipse.wst.xquery.internal.launching.marklogic;
>
> import java.io.File;
>
> import org.eclipse.debug.core.ILaunch;
> import org.eclipse.dltk.launching.DLTKRunnableProcess;
> import org.eclipse.dltk.launching.IInterpreterInstall;
> import org.eclipse.dltk.launching.InterpreterConfig;
>
> public class MarklogicRunnableProcess extends DLTKRunnableProcess {
>
>     public MarklogicRunnableProcess(IInterpreterInstall install,
>             ILaunch launch, InterpreterConfig config) {
>         super(install, launch, config);
>     }
>
>     public void run() {
>         File file = super.getFile();
>         // copty paste your MarkLogicProcess#run code
>
>     }
>
> }
> --------------------
>
> 4) Update your class MarkLogicRunner like this :
>
> --------------------
> package org.eclipse.wst.xquery.internal.launching.marklogic;
>
> import org.eclipse.debug.core.ILaunch;
> import org.eclipse.dltk.launching.AbstractRunnableInterpreterRunner;
> import org.eclipse.dltk.launching.IInterpreterInstall;
> import org.eclipse.dltk.launching.InterpreterConfig;
> import org.eclipse.dltk.launching.RunnableProcess;
>
> public class MarkLogicRunner extends AbstractRunnableInterpreterRunner {
>
>     public MarkLogicRunner(IInterpreterInstall install) {
>         super(install);
>     }
>
>     @Override
>     protected RunnableProcess createRunnableProcess(ILaunch launch,
>             InterpreterConfig config) {
>         return new MarklogicRunnableProcess(super.getInstall(), launch,
> config);
>     }
>
> }
> --------------------
>
> And that's all!
>
> I think it shoule be better to put AbstractRunnableInterpreterRunner.. into
> org.eclipse.wst.xquery.launching plugin (not sure if it exists) because
> Marklogic need this class but in my case XHive too.
>
> If you like this idea (and if it works for your case), I think it should be
> cool if DLTK could integrate this code.
>
> Don't hesitate to contact me, for more informations.
>
> Regards Angelo
>
>
> _______________________________________________
> wtp-incubator-dev mailing list
> https://dev.eclipse.org/mailman/listinfo/wtp-incubator-dev
>
>



--
MSc Gabriel Petrovay
Mobile: +41(0)787978034
www.28msec.com
_______________________________________________
wtp-incubator-dev mailing list
https://dev.eclipse.org/mailman/listinfo/wtp-incubator-dev


Back to the top