1 12 13 package org.eclipse.jdt.apt.core.internal; 14 15 import org.eclipse.core.runtime.CoreException; 16 17 class ClassServiceFactory implements IServiceFactory { 18 private final Class <?> _clazz; 19 20 public ClassServiceFactory(Class <?> clazz) { 21 _clazz = clazz; 22 } 23 24 public Object newInstance() throws CoreException { 25 try { 26 return _clazz.newInstance(); 27 } catch (InstantiationException e) { 28 throw new CoreException(AptPlugin.createWarningStatus(e, 29 "Unable to create instance of annotation processor " + _clazz.getName())); } catch (IllegalAccessException e) { 31 throw new CoreException(AptPlugin.createWarningStatus(e, 32 "Unable to create instance of annotation processor " + _clazz.getName())); } 34 } 35 36 public String toString() { 37 if (_clazz == null) { 38 return "unknown (null)"; } 40 else { 41 return _clazz.getName(); 42 } 43 } 44 } | Popular Tags |