1 /* 2 * This file is part of Pease Plate Template Engine. 3 * 4 * Pease Plate Template Engine is free software: you can redistribute 5 * it and/or modify it under the terms of the GNU Lesser General 6 * Public License as published by the Free Software Foundation, 7 * either version 3 of the License, or any later version. 8 * 9 * Pease Plate Template Engine is distributed in the hope that it 10 * will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 * See the GNU Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with Pease Plate Template Engine. If not, see 16 * <http://www.gnu.org/licenses/>. 17 * 18 * Copyright (c) 2008 Manfred HANTSCHEL 19 */ 20 package org.peaseplate.service; 21 22 import org.peaseplate.lang.Designator; 23 24 public interface DesignatorService { 25 26 /** 27 * Scans the specified class loaders for designator service definitions. 28 * The definitions are located in a resource with the name 29 * "META-INF/services/org.peaseplate.service.DesignatorService". 30 * The file contains class names of {@link Designator}s, one class name per line. 31 * 32 * @param classLoaders the class loaders 33 * @throws IllegalArgumentException if a class could not be instantiated 34 */ 35 public void add(ClassLoader... classLoaders) throws IllegalArgumentException; 36 37 /** 38 * Adds the specified designator to the service. 39 * Create a new instance of the class immediately. 40 * If there already exists another designator with the same name 41 * it will get replaced by the specified designator. 42 * @param designatorClass the class of the designator 43 * @throws IllegalArgumentException if the instance could not be created 44 */ 45 public void add(Class<? extends Designator> designatorClass) throws IllegalArgumentException; 46 47 /** 48 * Adds the specified designator to the service. 49 * If there already exists another designator with the same name 50 * it will get replaced by the specified designator. 51 * @param designator the designator 52 */ 53 public void add(Designator designator); 54 55 /** 56 * Returns the designator with the specified keyword 57 * @param keyword the keyword 58 * @return the designator or null if not found 59 */ 60 public Designator get(String keyword); 61 62 /** 63 * Returns the keyword of the default designator 64 * (the designator that is used if none is specified; the default is "print") 65 * @return the keyword of the default designator 66 */ 67 public String getDefaultDesignatorKeyword(); 68 69 /** 70 * Sets the keyword of the default designator. 71 * @param defaultDesignatorKeyword the keyword 72 */ 73 public void setDefaultDesignatorKeyword(String defaultDesignatorKeyword); 74 75 /** 76 * Returns the designator specified by the default designator keyword 77 * @return the default designator 78 * @throws IllegalStateException if the default designator does not exist 79 */ 80 public Designator getDefaultDesignator() throws IllegalStateException; 81 82 }