1 /* Copyright (c) 2008 Sascha Kohlmann 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU Affero General Public License as published by 5 * the Free Software Foundation, either version 3 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU Affero General Public License for more details. 12 * 13 * You should have received a copy of the GNU Affero General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16 package net.sf.eos.config; 17 18 import java.lang.annotation.Documented; 19 import java.lang.annotation.Retention; 20 import java.lang.annotation.Target; 21 22 import net.sf.eos.Experimental; 23 24 import static java.lang.annotation.ElementType.METHOD; 25 import static java.lang.annotation.RetentionPolicy.RUNTIME; 26 27 28 /** 29 * Identifies a method in a class as a factory method. A factory method has 30 * always a {@linkplain Configuration configuration key} in which the name 31 * of the implementing class is stored. 32 * @author Sascha Kohlmann 33 */ 34 @Documented 35 @Retention(value=RUNTIME) 36 @Target(value=METHOD) 37 @Experimental 38 public @interface FactoryMethod { 39 40 /** Default none implementation. */ 41 static class None { 42 private None() { 43 ; 44 } 45 } 46 47 /** Contains the name of the configuration key. 48 * @return the configuration key. */ 49 String key(); 50 51 /** 52 * The class of the default implementation if available. 53 * @return the name of the default implementation. 54 */ 55 Class<?> implementation() default None.class; 56 }