1 19 package org.netbeans.modules.subversion.client; 20 21 import java.io.File ; 22 import java.lang.reflect.InvocationTargetException ; 23 import java.lang.reflect.Method ; 24 import java.util.*; 25 import org.netbeans.modules.subversion.client.parser.LocalSubversionException; 26 import org.netbeans.modules.subversion.client.parser.SvnWcParser; 27 import org.netbeans.modules.subversion.config.SvnConfigFiles; 28 import org.tigris.subversion.svnclientadapter.ISVNClientAdapter; 29 30 35 public class SvnCmdLineClientInvocationHandler extends SvnClientInvocationHandler { 36 37 private static final String ISVNSTATUS_IMPL = System.getProperty("ISVNStatus.impl", ""); private static final String GET_SINGLE_STATUS = "getSingleStatus"; private static final String GET_STATUS = "getStatus"; private static final String GET_INFO_FROM_WORKING_COPY = "getInfoFromWorkingCopy"; 42 43 private SvnWcParser wcParser = new SvnWcParser(); 44 45 public SvnCmdLineClientInvocationHandler (ISVNClientAdapter adapter, SvnClientDescriptor desc, SvnProgressSupport support, int handledExceptions) { 46 super(adapter, desc, support, handledExceptions); 47 } 48 49 protected Object invokeMethod(Method proxyMethod, Object [] args) 50 throws NoSuchMethodException , IllegalAccessException , InvocationTargetException 51 { 52 Object ret = null; 53 if (isHandledIntern(proxyMethod, args)) { 54 try { 55 ret = handleIntern(proxyMethod, args); 56 } catch (LocalSubversionException ex) { 57 } 59 } else { 60 ret = handle(proxyMethod, args); 61 } 62 return ret; 63 } 64 65 private static boolean isHandledIntern(Method method, Object [] args) { 66 boolean exec = ISVNSTATUS_IMPL.equals("exec"); if(exec) { 68 return false; 69 } 70 71 String methodName = method.getName(); 72 return methodName.equals(GET_SINGLE_STATUS) || 73 methodName.equals(GET_INFO_FROM_WORKING_COPY) || 74 (method.getName().equals(GET_STATUS) && method.getParameterTypes().length == 3); 75 } 76 77 private Object handleIntern(Method method, Object [] args) throws LocalSubversionException { 78 Object returnValue = null; 79 80 if (GET_SINGLE_STATUS.equals(method.getName())) { 81 returnValue = wcParser.getSingleStatus((File ) args[0]); 82 } else if (GET_INFO_FROM_WORKING_COPY.equals(method.getName())) { 83 returnValue= wcParser.getInfoFromWorkingCopy((File ) args[0]); 84 } else if (GET_STATUS.equals(method.getName())) { 85 returnValue= wcParser.getStatus( 86 (File ) args[0], 87 ((Boolean ) args[1]).booleanValue(), 88 ((Boolean ) args[2]).booleanValue() 89 ); 90 } 91 return returnValue; 92 } 93 94 97 protected boolean noRemoteCallinAWT(String methodName, Object [] args) { 98 boolean ret = super.noRemoteCallinAWT(methodName, args); 99 if(!ret) { 100 if ("getStatus".equals(methodName)) { ret = args.length != 4 || (Boolean.TRUE.equals(args[3]) == false); 102 } 103 } 104 return ret; 105 } 106 107 } 108 109 | Popular Tags |