本文介绍了如何访问 subclipse 在运行时使用的 SVNClientAdapter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Subclipse API,并且我想实现 ISVNNotifyListener,以便在运行时了解 subclipse 事件.我相信我需要将通知侦听器的实例添加(订阅)到客户端适配器将通知的一组侦听器,但我不知道如何访问 Subclipse 在运行时使用的客户端适配器.有没有办法访问它,以便我可以将我的侦听器添加到集合中?

I am using the Subclipse API and I would like to implement the ISVNNotifyListener so that I can find out about the subclipse events as they happen during runtime. I believe I need to add (subscribe) my instance of the notify listener to the set of listeners that the Client Adapter will notify, but I am at a loss for how to get access to the Client Adapter that is being used by Subclipse at runtime. Is there a way to access it so that I can add my listener to the set?

推荐答案

很抱歉,很遗憾,Subclipse 没有被编码为提供对内部的访问.Subclipse 为它需要在 Subversion 中进行的每个 API 调用构造一个新的 ISVNClientAdapter 对象,并根据需要动态地将其 ISVNNotifyListener 添加到该对象.因此,您无法插入自己的听众.

Sorry, but unfortunately Subclipse has not been coded in such a way to provide access to the internals. Subclipse constructs a new ISVNClientAdapter object for each API call it needs to make into Subversion and it adds its ISVNNotifyListener to this object on the fly as needed. So there is no way for you to interject your own listener.

也许您可以编写一个实现 IConsoleListener 的类,并让它充当 Subclipse 类的代理.然后,您可以调用 SVNProviderPlugin.getConsoleListener 来获取当前控制台侦听器并将对它的引用存储在您的类中.然后调用 SVNProviderPlugin.setConsoleListener 将 Subclipse 中保存的类替换为您的类.当事件在您的类中触发时,您可以将它们转发到 Subclipse 类,并对代码中的事件做任何您想做的事情.像这样的:

Perhaps you could write a class that implements IConsoleListener and have it act as a proxy for the Subclipse class. You could then call SVNProviderPlugin.getConsoleListener to get the current console listener and store a reference to it in your class. Then call SVNProviderPlugin.setConsoleListener to replace the class held in Subclipse with your class. As the events are fired in your class, you could just forward them on to the Subclipse class and do whatever you want with the events in your code. Something like this:

import java.io.File;

import org.tigris.subversion.subclipse.core.client.IConsoleListener;
import org.tigris.subversion.svnclientadapter.SVNNodeKind;

public class ProxyListener implements IConsoleListener {

    private IConsoleListener subclipseListener;

    public ProxyListener(IConsoleListener subclipseListener) {
        super();
        this.subclipseListener = subclipseListener;
    }


    public void setCommand(int command) {
        subclipseListener.setCommand(command);
        // TODO add your code

    }

    public void logCommandLine(String commandLine) {
        subclipseListener.logCommandLine(commandLine);
        // TODO add your code

    }

    public void logMessage(String message) {
        subclipseListener.logMessage(message);
        // TODO add your code

    }

    public void logError(String message) {
        subclipseListener.logError(message);
        // TODO add your code

    }

    public void logRevision(long revision, String path) {
        subclipseListener.logRevision(revision , path);
        // TODO add your code

    }

    public void logCompleted(String message) {
        subclipseListener.logCompleted(message);
        // TODO add your code

    }

    public void onNotify(File path, SVNNodeKind kind) {
        subclipseListener.onNotify(path, kind);
        // TODO add your code

    }

}

这篇关于如何访问 subclipse 在运行时使用的 SVNClientAdapter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 09:25
查看更多