1 5 package com.nightlabs.rcp.exceptionhandler; 6 7 import org.eclipse.core.runtime.IConfigurationElement; 8 9 import com.nightlabs.rcp.extensionpoint.AbstractEPProcessor; 10 import com.nightlabs.rcp.extensionpoint.EPProcessorException; 11 12 18 public class ExceptionHandlerEPProcessor extends AbstractEPProcessor{ 19 20 public static final String ExtensionPointID = "com.nightlabs.base.exceptionhandler"; 21 28 public void processElement(IConfigurationElement element) 29 throws EPProcessorException 30 { 31 try{ 32 if (element.getName().toLowerCase().equals("exceptionhandler")){ 33 String targetType = element.getAttribute("targetType"); 34 String handlerClassStr = element.getAttribute("class"); 35 IExceptionHandler handler = (IExceptionHandler) element.createExecutableExtension("class"); 36 if (!IExceptionHandler.class.isAssignableFrom(handler.getClass())) 37 throw new IllegalArgumentException ("Specified class for element exceptionHandler must implement "+IExceptionHandler.class.getName()+". "+handler.getClass().getName()+" does not."); 38 ExceptionHandlerRegistry.getSharedInstance().addExceptionHandler(targetType,handler); 39 } 40 else { 41 throw new IllegalArgumentException ("Element "+element.getName()+" is not supported by extension-point "+ExtensionPointID); 43 } 44 }catch(Throwable e){ 45 throw new EPProcessorException(e); 46 } 47 } 48 49 52 public String getExtensionPointID() { 53 return ExtensionPointID; 54 } 55 } 56 | Popular Tags |