universe@6: /* universe@6: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. universe@34: * universe@24: * Copyright 2018 Mike Becker. All rights reserved. universe@34: * universe@6: * Redistribution and use in source and binary forms, with or without universe@6: * modification, are permitted provided that the following conditions are met: universe@6: * universe@6: * 1. Redistributions of source code must retain the above copyright universe@6: * notice, this list of conditions and the following disclaimer. universe@6: * universe@6: * 2. Redistributions in binary form must reproduce the above copyright universe@6: * notice, this list of conditions and the following disclaimer in the universe@6: * documentation and/or other materials provided with the distribution. universe@6: * universe@6: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" universe@6: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE universe@6: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE universe@6: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE universe@6: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR universe@6: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF universe@6: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS universe@6: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN universe@6: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) universe@6: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE universe@6: * POSSIBILITY OF SUCH DAMAGE. universe@34: * universe@6: */ universe@6: package de.uapcore.lightpit; universe@6: universe@7: import javax.servlet.annotation.WebServlet; universe@31: import java.lang.annotation.*; universe@6: universe@6: universe@6: /** universe@6: * Contains information about a LightPIT module. universe@34: *

universe@7: * This annotation is typically used to annotate the {@link WebServlet} which universe@7: * implements the module's functionality. universe@6: */ universe@7: @Documented universe@6: @Retention(RetentionPolicy.RUNTIME) universe@6: @Target(ElementType.TYPE) universe@6: public @interface LightPITModule { universe@7: /** universe@7: * Base name of the module specific resource bundle. universe@34: * universe@7: * @return a base name suitable for the JSTL tag 'setBundle'. universe@7: */ universe@7: String bundleBaseName(); universe@34: universe@7: /** universe@7: * An array of required modules, identified by the string representation of universe@7: * their class names. universe@34: * universe@7: * @return an array of class names of required modules universe@7: */ universe@7: String[] requires() default {}; universe@34: universe@10: /** universe@21: * The path for this module, which will also be used for the menu entry. universe@34: *

universe@10: * This path must adhere to the URL pattern of the Servlet but must not universe@10: * contain any starting or trailing slashes. universe@34: * universe@10: * @return the relative module path universe@10: */ universe@10: String modulePath(); universe@34: universe@10: /** universe@21: * Returns the properties key for the module name. universe@34: * universe@21: * @return the properties key universe@21: */ universe@21: String nameKey() default "name"; universe@34: universe@21: /** universe@21: * Returns the properties key for the module description. universe@34: * universe@21: * @return the properties key universe@21: */ universe@21: String descKey() default "description"; universe@34: universe@34: universe@21: /** universe@10: * Returns the properties key for the menu label. universe@34: *

universe@18: * Set this string to empty string, if the module should be hidden from universe@18: * the menu. universe@34: * universe@11: * @return the properties key universe@10: */ universe@10: String menuKey() default "menuLabel"; universe@34: universe@11: /** universe@11: * Returns the properties key for the page title. universe@34: *

universe@11: * By default this is the same as the menu label. universe@34: * universe@11: * @return the properties key universe@11: */ universe@11: String titleKey() default "menuLabel"; universe@31: universe@11: /** universe@20: * If set to true, this module is always loaded, but never universe@20: * visible in the menu or the Web UI module manager. universe@31: * universe@20: * @return true, if this is a system module universe@20: */ universe@20: boolean systemModule() default false; universe@31: universe@31: /** universe@31: * Optionally specifies a default priority for this module. universe@31: * The priority is used to order the menu entries. universe@31: * universe@31: * @return an integer priority universe@31: */ universe@31: int defaultPriority() default 1000; universe@31: universe@20: /** universe@11: * Class representing the annotation. universe@11: * This is necessary, because the EL resolver cannot deal with universe@11: * annotation objects. universe@31: *

universe@11: * Note, that only the properties which are interesting for the JSP pages universe@11: * are proxied by this object. universe@11: */ universe@31: class ELProxy { universe@21: private final String bundleBaseName, modulePath, menuKey, titleKey, nameKey, descKey; universe@31: universe@36: public ELProxy(LightPITModule annotation) { universe@36: bundleBaseName = annotation.bundleBaseName(); universe@36: modulePath = annotation.modulePath(); universe@36: menuKey = annotation.menuKey(); universe@36: titleKey = annotation.titleKey(); universe@36: nameKey = annotation.nameKey(); universe@36: descKey = annotation.descKey(); universe@11: } universe@11: universe@11: public String getBundleBaseName() { universe@11: return bundleBaseName; universe@11: } universe@11: universe@11: public String getMenuKey() { universe@11: return menuKey; universe@11: } universe@11: universe@11: public String getModulePath() { universe@11: return modulePath; universe@11: } universe@11: universe@11: public String getTitleKey() { universe@11: return titleKey; universe@11: } universe@21: universe@21: public String getNameKey() { universe@21: return nameKey; universe@21: } universe@21: universe@21: public String getDescKey() { universe@21: return descKey; universe@21: } universe@34: universe@11: } universe@6: }