Index: subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java =================================================================== --- subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java (revision 1328758) +++ subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java (working copy) @@ -156,7 +156,7 @@ public class SVNClient implements ISVNClient public void setProgressCallback(ProgressCallback listener) { - clientContext.listener = listener; + clientContext.setListener(listener); } public native void remove(Set paths, boolean force, @@ -502,12 +502,11 @@ public class SVNClient implements ISVNClient * A private class to hold the contextual information required to * persist in this object, such as notification handlers. */ - private class ClientContext + private class ClientContext extends CommonContext implements ClientNotifyCallback, ProgressCallback, ConflictResolverCallback { public ClientNotifyCallback notify = null; - public ProgressCallback listener = null; public ConflictResolverCallback resolver = null; public void onNotify(ClientNotifyInformation notifyInfo) @@ -516,12 +515,6 @@ public class SVNClient implements ISVNClient notify.onNotify(notifyInfo); } - public void onProgress(ProgressEvent event) - { - if (listener != null) - listener.onProgress(event); - } - public ConflictResult resolve(ConflictDescriptor conflict) throws SubversionException { Index: subversion/bindings/javahl/src/org/apache/subversion/javahl/CommonContext.java =================================================================== --- subversion/bindings/javahl/src/org/apache/subversion/javahl/CommonContext.java (working copy) +++ subversion/bindings/javahl/src/org/apache/subversion/javahl/CommonContext.java (working copy) @@ -23,513 +23,30 @@ package org.apache.subversion.javahl; -import org.apache.subversion.javahl.callback.*; -import org.apache.subversion.javahl.types.*; +import org.apache.subversion.javahl.callback.ProgressCallback; -import java.io.OutputStream; -import java.io.FileOutputStream; -import java.io.FileNotFoundException; -import java.io.ByteArrayOutputStream; - -import java.util.Collection; -import java.util.Set; -import java.util.List; -import java.util.Map; - /** - * This is the main client class. All Subversion client APIs are - * implemented in this class. This class is not threadsafe; if you - * need threadsafe access, use ClientSynchronized. + * A private class to hold the contextual information required to + * persist in this object, such as notification handlers. */ -public class SVNClient implements ISVNClient +public class CommonContext + implements ProgressCallback { - /** - * Load the required native library. - */ - static - { - NativeResources.loadNativeLibrary(); - } + private ProgressCallback listener = null; - /** - * Standard empty contructor, builds just the native peer. - */ - public SVNClient() + public void onProgress(ProgressEvent event) { - cppAddr = ctNative(); - - // Ensure that Subversion's config file area and templates exist. - try - { - setConfigDirectory(null); - } - catch (ClientException suppressed) - { - // Not an exception-worthy problem, continue on. - } + if (listener != null) + listener.onProgress(event); } - private long getCppAddr() - { - return cppAddr; - } + public ProgressCallback getListener() + { + return listener; + } - /** - * Build the native peer - * @return the adress of the peer - */ - private native long ctNative(); - - /** - * release the native peer (should not depend on finalize) - */ - public native void dispose(); - - /** - * release the native peer (should use dispose instead) - */ - public native void finalize(); - - /** - * slot for the adress of the native peer. The JNI code is the only user - * of this member - */ - protected long cppAddr; - - private ClientContext clientContext = new ClientContext(); - - public Version getVersion() - { - return NativeResources.getVersion(); - } - - public native String getAdminDirectoryName(); - - public native boolean isAdminDirectory(String name); - - /** - * @deprecated - */ - public native String getLastPath(); - - public native void status(String path, Depth depth, boolean onServer, - boolean getAll, boolean noIgnore, - boolean ignoreExternals, - Collection changelists, - StatusCallback callback) - throws ClientException; - - public native void list(String url, Revision revision, - Revision pegRevision, Depth depth, int direntFields, - boolean fetchLocks, ListCallback callback) - throws ClientException; - - public native void username(String username); - - public native void password(String password); - - public native void setPrompt(UserPasswordCallback prompt); - - public native void logMessages(String path, Revision pegRevision, - List revisionRanges, - boolean stopOnCopy, boolean discoverPath, - boolean includeMergedRevisions, - Set revProps, long limit, - LogMessageCallback callback) - throws ClientException; - - public native long checkout(String moduleName, String destPath, - Revision revision, Revision pegRevision, - Depth depth, boolean ignoreExternals, - boolean allowUnverObstructions) - throws ClientException; - - public void notification2(ClientNotifyCallback notify) - { - clientContext.notify = notify; - } - - public void setConflictResolver(ConflictResolverCallback listener) - { - clientContext.resolver = listener; - } - - public void setProgressCallback(ProgressCallback listener) - { - clientContext.listener = listener; - } - - public native void remove(Set paths, boolean force, - boolean keepLocal, - Map revpropTable, - CommitMessageCallback handler, CommitCallback callback) - throws ClientException; - - public native void revert(String path, Depth depth, - Collection changelists) - throws ClientException; - - public native void add(String path, Depth depth, boolean force, - boolean noIgnores, boolean addParents) - throws ClientException; - - public native long[] update(Set paths, Revision revision, - Depth depth, boolean depthIsSticky, - boolean makeParents, - boolean ignoreExternals, - boolean allowUnverObstructions) - throws ClientException; - - public native void commit(Set paths, Depth depth, boolean noUnlock, - boolean keepChangelist, - Collection changelists, - Map revpropTable, - CommitMessageCallback handler, CommitCallback callback) - throws ClientException; - - public native void copy(List sources, String destPath, - boolean copyAsChild, boolean makeParents, - boolean ignoreExternals, - Map revpropTable, - CommitMessageCallback handler, CommitCallback callback) - throws ClientException; - - public native void move(Set srcPaths, String destPath, - boolean force, boolean moveAsChild, - boolean makeParents, - Map revpropTable, - CommitMessageCallback handler, CommitCallback callback) - throws ClientException; - - public native void mkdir(Set paths, boolean makeParents, - Map revpropTable, - CommitMessageCallback handler, CommitCallback callback) - throws ClientException; - - public native void cleanup(String path) - throws ClientException; - - public native void resolve(String path, Depth depth, - ConflictResult.Choice conflictResult) - throws SubversionException; - - public native long doExport(String srcPath, String destPath, - Revision revision, Revision pegRevision, - boolean force, boolean ignoreExternals, - Depth depth, String nativeEOL) - throws ClientException; - - public native long doSwitch(String path, String url, Revision revision, - Revision pegRevision, Depth depth, - boolean depthIsSticky, boolean ignoreExternals, - boolean allowUnverObstructions, - boolean ignoreAncestry) - throws ClientException; - - public native void doImport(String path, String url, Depth depth, - boolean noIgnore, - boolean ignoreUnknownNodeTypes, - Map revpropTable, - CommitMessageCallback handler, CommitCallback callback) - throws ClientException; - - public native Set suggestMergeSources(String path, - Revision pegRevision) - throws SubversionException; - - public native void merge(String path1, Revision revision1, String path2, - Revision revision2, String localPath, - boolean force, Depth depth, - boolean ignoreAncestry, boolean dryRun, - boolean recordOnly) - throws ClientException; - - public native void merge(String path, Revision pegRevision, - List revisions, String localPath, - boolean force, Depth depth, boolean ignoreAncestry, - boolean dryRun, boolean recordOnly) - throws ClientException; - - public native void mergeReintegrate(String path, Revision pegRevision, - String localPath, boolean dryRun) - throws ClientException; - - public native Mergeinfo getMergeinfo(String path, Revision pegRevision) - throws SubversionException; - - public native void getMergeinfoLog(Mergeinfo.LogKind kind, String pathOrUrl, - Revision pegRevision, - String mergeSourceUrl, - Revision srcPegRevision, - boolean discoverChangedPaths, Depth depth, - Set revProps, - LogMessageCallback callback) - throws ClientException; - - public void diff(String target1, Revision revision1, String target2, - Revision revision2, String relativeToDir, - String outFileName, Depth depth, - Collection changelists, - boolean ignoreAncestry, boolean noDiffDeleted, - boolean force, boolean copiesAsAdds) - throws ClientException - { - try { - OutputStream stream = new FileOutputStream(outFileName); - diff(target1, revision1, target2, revision2, relativeToDir, - stream, depth, changelists, ignoreAncestry, noDiffDeleted, - force, copiesAsAdds, false); - } catch (FileNotFoundException ex) { - throw ClientException.fromException(ex); - } - } - - public native void diff(String target1, Revision revision1, String target2, - Revision revision2, String relativeToDir, - OutputStream stream, Depth depth, - Collection changelists, - boolean ignoreAncestry, boolean noDiffDeleted, - boolean force, boolean copiesAsAdds, - boolean ignoreProps) - throws ClientException; - - public void diff(String target, Revision pegRevision, - Revision startRevision, Revision endRevision, - String relativeToDir, String outFileName, - Depth depth, Collection changelists, - boolean ignoreAncestry, boolean noDiffDeleted, - boolean force, boolean copiesAsAdds) - throws ClientException - { - try { - OutputStream stream = new FileOutputStream(outFileName); - diff(target, pegRevision, startRevision, endRevision, - relativeToDir, stream, depth, changelists, ignoreAncestry, - noDiffDeleted, force, copiesAsAdds, false); - } catch (FileNotFoundException ex) { - throw ClientException.fromException(ex); - } - } - - public native void diff(String target, Revision pegRevision, - Revision startRevision, Revision endRevision, - String relativeToDir, OutputStream stream, - Depth depth, Collection changelists, - boolean ignoreAncestry, boolean noDiffDeleted, - boolean force, boolean copiesAsAdds, - boolean ignoreProps) - throws ClientException; - - public native void diffSummarize(String target1, Revision revision1, - String target2, Revision revision2, - Depth depth, Collection changelists, - boolean ignoreAncestry, - DiffSummaryCallback receiver) - throws ClientException; - - public native void diffSummarize(String target, Revision pegRevision, - Revision startRevision, - Revision endRevision, Depth depth, - Collection changelists, - boolean ignoreAncestry, - DiffSummaryCallback receiver) - throws ClientException; - - public native void properties(String path, Revision revision, - Revision pegRevision, Depth depth, - Collection changelists, - ProplistCallback callback) - throws ClientException; - - public native void propertySetLocal(Set paths, String name, - byte[] value, Depth depth, - Collection changelists, - boolean force) - throws ClientException; - - public native void propertySetRemote(String path, long baseRev, - String name, byte[] value, - CommitMessageCallback handler, - boolean force, - Map revpropTable, - CommitCallback callback) - throws ClientException; - - public native byte[] revProperty(String path, String name, Revision rev) - throws ClientException; - - public native Map revProperties(String path, Revision rev) - throws ClientException; - - public native void setRevProperty(String path, String name, Revision rev, - String value, String originalValue, - boolean force) - throws ClientException; - - public native byte[] propertyGet(String path, String name, - Revision revision, Revision pegRevision) - throws ClientException; - - public byte[] fileContent(String path, Revision revision, - Revision pegRevision) - throws ClientException - { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - - streamFileContent(path, revision, pegRevision, stream); - return stream.toByteArray(); - } - - public native void streamFileContent(String path, Revision revision, - Revision pegRevision, - OutputStream stream) - throws ClientException; - - public native void relocate(String from, String to, String path, - boolean ignoreExternals) - throws ClientException; - - public native void blame(String path, Revision pegRevision, - Revision revisionStart, - Revision revisionEnd, boolean ignoreMimeType, - boolean includeMergedRevisions, - BlameCallback callback) - throws ClientException; - - public native void setConfigDirectory(String configDir) - throws ClientException; - - public native String getConfigDirectory() - throws ClientException; - - public native void cancelOperation() - throws ClientException; - - public native void addToChangelist(Set paths, String changelist, - Depth depth, - Collection changelists) - throws ClientException; - - public native void removeFromChangelists(Set paths, Depth depth, - Collection changelists) - throws ClientException; - - public native void getChangelists(String rootPath, - Collection changelists, - Depth depth, ChangelistCallback callback) - throws ClientException; - - public native String getVersionInfo(String path, String trailUrl, - boolean lastChanged) - throws ClientException; - - public native void upgrade(String path) - throws ClientException; - - /** - * Enable logging in the JNI-code - * @param logLevel the level of information to log (See - * ClientLogLevel) - * @param logFilePath path of the log file - */ - public static native void enableLogging(ClientLogLevel logLevel, - String logFilePath); - - /** - * enum for the constants of the logging levels. - */ - public enum ClientLogLevel - { - /** Log nothing */ - NoLog, - - /** Log fatal error */ - ErrorLog, - - /** Log exceptions thrown */ - ExceptionLog, - - /** Log the entry and exits of the JNI code */ - EntryLog; - } - - /** - * Returns version information of subversion and the javahl binding - * @return version information - */ - public static native String version(); - - /** - * Returns the major version of the javahl binding. Same version of the - * javahl support the same interfaces - * @return major version number - */ - public static native int versionMajor(); - - /** - * Returns the minor version of the javahl binding. Same version of the - * javahl support the same interfaces - * @return minor version number - */ - public static native int versionMinor(); - - /** - * Returns the micro (patch) version of the javahl binding. Same version of - * the javahl support the same interfaces - * @return micro version number - */ - public static native int versionMicro(); - - public native void lock(Set paths, String comment, boolean force) - throws ClientException; - - public native void unlock(Set paths, boolean force) - throws ClientException; - - public native void info2(String pathOrUrl, Revision revision, - Revision pegRevision, Depth depth, - Collection changelists, - InfoCallback callback) - throws ClientException; - - public native void patch(String patchPath, String targetPath, - boolean dryRun, int stripCount, boolean reverse, - boolean ignoreWhitespace, boolean removeTempfiles, - PatchCallback callback) - throws ClientException; - - /** - * A private class to hold the contextual information required to - * persist in this object, such as notification handlers. - */ - private class ClientContext - implements ClientNotifyCallback, ProgressCallback, - ConflictResolverCallback - { - public ClientNotifyCallback notify = null; - public ProgressCallback listener = null; - public ConflictResolverCallback resolver = null; - - public void onNotify(ClientNotifyInformation notifyInfo) - { - if (notify != null) - notify.onNotify(notifyInfo); - } - - public void onProgress(ProgressEvent event) - { - if (listener != null) - listener.onProgress(event); - } - - public ConflictResult resolve(ConflictDescriptor conflict) - throws SubversionException - { - if (resolver != null) - return resolver.resolve(conflict); - else - return new ConflictResult(ConflictResult.Choice.postpone, - null); - } - } -} + public void setListener(ProgressCallback listener) + { + this.listener = listener; + } +} \ No newline at end of file