How to access the SVNClientAdapter that subclipse is using during runtime?

爷,独闯天下 提交于 2019-12-04 03:42:06

问题


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?


回答1:


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

    }

}


来源:https://stackoverflow.com/questions/7518467/how-to-access-the-svnclientadapter-that-subclipse-is-using-during-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!