1 11 12 package org.eclipse.core.runtime.internal.adaptor; 13 14 import java.io.IOException ; 15 import java.net.URLConnection ; 16 import java.util.Properties ; 17 import org.eclipse.osgi.baseadaptor.*; 18 import org.eclipse.osgi.baseadaptor.hooks.AdaptorHook; 19 import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor; 20 import org.eclipse.osgi.framework.internal.core.FrameworkProperties; 21 import org.eclipse.osgi.framework.log.FrameworkLog; 22 import org.eclipse.osgi.framework.log.FrameworkLogEntry; 23 import org.osgi.framework.BundleContext; 24 import org.osgi.framework.BundleException; 25 26 public class EclipseErrorHandler implements AdaptorHook, HookConfigurator { 27 private static final String PROP_EXITONERROR = "eclipse.exitOnError"; private BaseAdaptor adaptor; 30 31 public void frameworkStart(BundleContext context) throws BundleException { 32 } 34 35 public void frameworkStop(BundleContext context) throws BundleException { 36 } 38 39 public void frameworkStopping(BundleContext context) { 40 } 42 43 public void addProperties(Properties properties) { 44 } 46 47 public URLConnection mapLocationToURLConnection(String location) throws IOException { 48 return null; 50 } 51 52 private boolean isFatalException(Throwable error) { 53 if (error instanceof VirtualMachineError ) { 54 return true; 55 } 56 if (error instanceof ThreadDeath ) { 57 return true; 58 } 59 return false; 60 } 61 62 public void handleRuntimeError(Throwable error) { 63 boolean exitOnError = false; 65 try { 66 exitOnError = Boolean.valueOf(FrameworkProperties.getProperty(EclipseErrorHandler.PROP_EXITONERROR, "true")).booleanValue(); String message = EclipseAdaptorMsg.ECLIPSE_ADAPTOR_RUNTIME_ERROR; 69 if (exitOnError && isFatalException(error)) 70 message += ' ' + EclipseAdaptorMsg.ECLIPSE_ADAPTOR_EXITING; 71 FrameworkLogEntry logEntry = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.ERROR, 0, message, 0, error, null); 72 adaptor.getFrameworkLog().log(logEntry); 73 } catch (Throwable t) { 74 try { 79 error.printStackTrace(); 80 t.printStackTrace(); 81 } catch (Throwable t1) { 82 } 84 } finally { 85 if (exitOnError && isFatalException(error)) 88 System.exit(13); 89 } 90 } 91 92 public boolean matchDNChain(String pattern, String [] dnChain) { 93 return false; 95 } 96 97 public void addHooks(HookRegistry hookRegistry) { 98 hookRegistry.addAdaptorHook(this); 99 } 100 101 public FrameworkLog createFrameworkLog() { 102 return null; 104 } 105 106 public void initialize(BaseAdaptor adaptor) { 107 this.adaptor = adaptor; 108 } 109 } 110
| Popular Tags
|