1 21 package com.db4o.config.annotations.reflect; 22 23 import java.lang.annotation.*; 24 import java.lang.reflect.*; 25 26 27 30 public class NoArgsFieldConfiguratorFactory implements Db4oConfiguratorFactory { 31 private Constructor _constructor; 32 33 public NoArgsFieldConfiguratorFactory(Class configuratorClass) throws NoSuchMethodException { 34 _constructor=configuratorClass.getConstructor(new Class []{String .class,String .class}); 35 } 36 37 public Db4oConfigurator configuratorFor(AnnotatedElement element, Annotation annotation) { 38 try { 39 if(!(element instanceof Field)) { 40 return null; 41 } 42 Field field=(Field)element; 43 String className=field.getDeclaringClass().getName(); 44 String fieldName=field.getName(); 45 return (Db4oConfigurator)_constructor.newInstance(new Object []{className,fieldName}); 46 } catch (Exception exc) { 47 return null; 48 } 49 } 50 } 51 | Popular Tags |