universe@6: /* universe@6: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. universe@6: * universe@24: * Copyright 2018 Mike Becker. All rights reserved. universe@6: * 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@6: * universe@6: */ universe@6: package de.uapcore.lightpit; universe@6: universe@7: import java.lang.annotation.Documented; universe@6: import java.lang.annotation.ElementType; universe@6: import java.lang.annotation.Retention; universe@6: import java.lang.annotation.RetentionPolicy; universe@6: import java.lang.annotation.Target; universe@7: import javax.servlet.annotation.WebServlet; universe@6: universe@6: universe@6: /** universe@6: * Contains information about a LightPIT module. universe@7: * 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@7: * @return a base name suitable for the JSTL tag 'setBundle'. universe@7: */ universe@7: String bundleBaseName(); universe@6: universe@7: /** universe@7: * An array of required modules, identified by the string representation of universe@7: * their class names. universe@7: * @return an array of class names of required modules universe@7: */ universe@7: String[] requires() default {}; universe@10: universe@10: /** universe@21: * The path for this module, which will also be used for the menu entry. universe@10: * 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@10: * universe@10: * @return the relative module path universe@10: */ universe@10: String modulePath(); universe@10: universe@10: /** universe@21: * Returns the properties key for the module name. universe@21: * universe@21: * @return the properties key universe@21: */ universe@21: String nameKey() default "name"; universe@21: universe@21: /** universe@21: * Returns the properties key for the module description. universe@21: * universe@21: * @return the properties key universe@21: */ universe@21: String descKey() default "description"; universe@21: universe@21: universe@21: /** universe@10: * Returns the properties key for the menu label. universe@18: * universe@18: * Set this string to empty string, if the module should be hidden from universe@18: * the menu. universe@18: * universe@11: * @return the properties key universe@10: */ universe@10: String menuKey() default "menuLabel"; universe@11: universe@11: /** universe@11: * Returns the properties key for the page title. universe@11: * universe@11: * By default this is the same as the menu label. universe@11: * universe@11: * @return the properties key universe@11: */ universe@11: String titleKey() default "menuLabel"; universe@11: 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@20: * universe@20: * @return true, if this is a system module universe@20: */ universe@20: boolean systemModule() default false; universe@20: 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@11: * universe@11: * Note, that only the properties which are interesting for the JSP pages universe@11: * are proxied by this object. universe@11: */ universe@11: public static class ELProxy { universe@21: private final String bundleBaseName, modulePath, menuKey, titleKey, nameKey, descKey; universe@11: universe@11: public static ELProxy convert(LightPITModule annotation) { universe@11: return new ELProxy( universe@11: annotation.bundleBaseName(), universe@11: annotation.modulePath(), universe@11: annotation.menuKey(), universe@21: annotation.titleKey(), universe@21: annotation.nameKey(), universe@21: annotation.descKey() universe@11: ); universe@11: } universe@11: universe@21: private ELProxy(String bundleBaseName, String modulePath, String menuKey, String titleKey, String nameKey, String descKey) { universe@11: this.bundleBaseName = bundleBaseName; universe@11: this.modulePath = modulePath; universe@11: this.menuKey = menuKey; universe@11: this.titleKey = titleKey; universe@21: this.nameKey = nameKey; universe@21: this.descKey = 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@21: universe@11: } universe@6: }