1 52 53 package freemarker.debug.impl; 54 55 import java.rmi.RemoteException ; 56 import java.util.Collections ; 57 import java.util.List ; 58 59 import freemarker.core.Environment; 60 import freemarker.template.Template; 61 import freemarker.template.utility.SecurityUtilities; 62 63 70 public abstract class DebuggerService 71 { 72 private static final DebuggerService instance = createInstance(); 73 74 private static DebuggerService createInstance() 75 { 76 return 80 SecurityUtilities.getSystemProperty("freemarker.debug.password") == null 81 ? (DebuggerService)new NoOpDebuggerService() 82 : (DebuggerService)new RmiDebuggerService(); 83 } 84 85 public static List getBreakpoints(String templateName) 86 { 87 return instance.getBreakpointsSpi(templateName); 88 } 89 90 abstract List getBreakpointsSpi(String templateName); 91 92 public static void registerTemplate(Template template) 93 { 94 instance.registerTemplateSpi(template); 95 } 96 97 abstract void registerTemplateSpi(Template template); 98 99 public static boolean suspendEnvironment(Environment env, int line) 100 throws 101 RemoteException 102 { 103 return instance.suspendEnvironmentSpi(env, line); 104 } 105 106 abstract boolean suspendEnvironmentSpi(Environment env, int line) 107 throws 108 RemoteException ; 109 110 private static class NoOpDebuggerService extends DebuggerService 111 { 112 List getBreakpointsSpi(String templateName) 113 { 114 return Collections.EMPTY_LIST; 115 } 116 117 boolean suspendEnvironmentSpi(Environment env, int line) 118 { 119 throw new UnsupportedOperationException (); 120 } 121 122 void registerTemplateSpi(Template template) 123 { 124 } 125 } 126 } | Popular Tags |