如何访问 subclipse 在运行时使用的 SVNClientAdapter?

发布于 2024-12-06 04:02:56 字数 174 浏览 0 评论 0原文

我正在使用 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独﹏钓一江月 2024-12-13 04:02:56

抱歉,不幸的是 Subclipse 尚未以这种方式进行编码以提供对内部的访问。 Subclipse 为需要在 Subversion 中进行的每个 API 调用构造一个新的 ISVNClientAdapter 对象,并根据需要动态地将其 ISVNNotifyListener 添加到该对象。所以你没有办法插入你自己的听众。

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

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

    }

}

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.

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

    }

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文