001 /*
002 * ============================================================================
003 * GNU Lesser General Public License
004 * ============================================================================
005 *
006 * Beanlet - JSE Application Container.
007 * Copyright (C) 2006 Leon van Zantvoort
008 *
009 * This library is free software; you can redistribute it and/or
010 * modify it under the terms of the GNU Lesser General Public
011 * License as published by the Free Software Foundation; either
012 * version 2.1 of the License, or (at your option) any later version.
013 *
014 * This library is distributed in the hope that it will be useful,
015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017 * Lesser General Public License for more details.
018 *
019 * You should have received a copy of the GNU Lesser General Public
020 * License along with this library; if not, write to the Free Software
021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
022 *
023 * Leon van Zantvoort
024 * 243 Acalanes Drive #11
025 * Sunnyvale, CA 94086
026 * USA
027 *
028 * zantvoort@users.sourceforge.net
029 * http://beanlet.org
030 */
031 package org.beanlet.web;
032
033 import org.beanlet.ScopeAnnotation;
034
035 import javax.servlet.annotation.WebInitParam;
036 import java.lang.annotation.ElementType;
037 import java.lang.annotation.Retention;
038 import java.lang.annotation.RetentionPolicy;
039 import java.lang.annotation.Target;
040
041 /**
042 * This annotation is used to declare the configuration of an
043 * {@link javax.servlet.Servlet}. This feature is only supported for Servlet API 3.0
044 * and onwards.<br/>
045 *
046 * If the name attribute is not defined, the fully qualified name of the class
047 * is used.<br/>
048 * <br/>
049 *
050 * At least one URL pattern MUST be declared in either the {@code value} or
051 * {@code urlPattern} attribute of the annotation, but not both.<br/>
052 * <br/>
053 *
054 * The {@code value} attribute is recommended for use when the URL pattern is
055 * the only attribute being set, otherwise the {@code urlPattern} attribute
056 * should be used.<br />
057 * <br />
058 *
059 * The class on which this annotation is declared MUST extend
060 * {@link javax.servlet.http.HttpServlet}. <br />
061 * <br />
062 *
063 * E.g. <code>@WebServlet("/path")}<br />
064 * public class TestServlet extends HttpServlet ... {</code><br />
065 *
066 * E.g.
067 * <code>@WebServlet(name="TestServlet", urlPatterns={"/path", "/alt"}) <br />
068 * public class TestServlet extends HttpServlet ... {</code><br />
069 *
070 * <p><h3>XML Representation</h3>The following xml-fragment shows how to express this annotation in xml.<br><pre><tt><beanlet type="com.google.gwt.user.server.rpc.RemoteServiceServlet">
071 * <b><web:servlet name="TestServlet" create-servlet="false">
072 * <web:url-pattern value="/test/TestServlet"/>
073 * <web:init-param key="test-user" value="john"/>
074 * </web:servlet></b>
075 * <inject constructor="true" index="0">
076 * <beanlet type="com.acme.servlet.TestService"/>
077 * </inject>
078 *</beanlet>
079 *
080 *<beanlet type="com.google.gwt.user.server.rpc.RemoteServiceServlet">
081 * <b><web:servlet name="TestServlet" create-servlet="true">
082 * <web:url-patterns>
083 * <web:url-pattern value="/test/TestServlet"/>
084 * <web:url-pattern value="/test/ProductionServlet"/>
085 * </web:url-patterns>
086 * <web:init-params>
087 * <web:init-param key="test-user" value="john"/>
088 * <web:init-param key="production-user" value="john"/>
089 * </web:init-params>
090 * </web:servlet></b>
091 *</beanlet></tt></pre>
092 *
093 * @author Leon van Zantvoort
094 */
095 @Retention(RetentionPolicy.RUNTIME)
096 @Target(ElementType.TYPE)
097 public @interface WebServlet {
098
099 /**
100 * @return <code>true</code> if instance is created by Servlet container.
101 */
102 boolean createServlet() default false;
103
104 /**
105 * @return name of the Servlet
106 */
107 String name() default "";
108
109 /**
110 * A convenience method, to allow extremely simple annotation of a class.
111 *
112 * @return array of URL patterns
113 * @see #urlPatterns()
114 */
115 String[] value() default {};
116
117 /**
118 * @return array of URL patterns to which this Filter applies
119 */
120 String[] urlPatterns() default {};
121
122 /**
123 * @return load on startup ordering hint
124 */
125 int loadOnStartup() default -1;
126
127 /**
128 * @return array of initialization params for this Servlet
129 */
130 WebInitParam[] initParams() default {};
131
132 /**
133 * @return asynchronous operation supported by this Servlet
134 */
135 boolean asyncSupported() default false;
136
137 /**
138 * @return small icon for this Servlet, if present
139 */
140 String smallIcon() default "";
141
142 /**
143 * @return large icon for this Servlet, if present
144 */
145 String largeIcon() default "";
146
147 /**
148 * @return description of this Servlet, if present
149 */
150 String description() default "";
151
152 /**
153 * @return display name of this Servlet, if present
154 */
155 String displayName() default "";
156 }