init
This commit is contained in:
106
java/javax/servlet/AsyncContext.java
Normal file
106
java/javax/servlet/AsyncContext.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
/**
|
||||
* TODO SERVLET3 - Add comments
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public interface AsyncContext {
|
||||
public static final String ASYNC_REQUEST_URI =
|
||||
"javax.servlet.async.request_uri";
|
||||
public static final String ASYNC_CONTEXT_PATH =
|
||||
"javax.servlet.async.context_path";
|
||||
public static final String ASYNC_PATH_INFO =
|
||||
"javax.servlet.async.path_info";
|
||||
public static final String ASYNC_SERVLET_PATH =
|
||||
"javax.servlet.async.servlet_path";
|
||||
public static final String ASYNC_QUERY_STRING =
|
||||
"javax.servlet.async.query_string";
|
||||
|
||||
ServletRequest getRequest();
|
||||
|
||||
ServletResponse getResponse();
|
||||
|
||||
boolean hasOriginalRequestAndResponse();
|
||||
|
||||
/**
|
||||
* @throws IllegalStateException if this method is called when the request
|
||||
* is not in asynchronous mode. The request is in asynchronous mode after
|
||||
* {@link javax.servlet.http.HttpServletRequest#startAsync()} or
|
||||
* {@link javax.servlet.http.HttpServletRequest#startAsync(ServletRequest,
|
||||
* ServletResponse)} has been called and before {@link #complete()} or any
|
||||
* other dispatch() method has been called.
|
||||
*/
|
||||
void dispatch();
|
||||
|
||||
/**
|
||||
* @param path The path to which the request/response should be dispatched
|
||||
* relative to the {@link ServletContext} from which this async
|
||||
* request was started.
|
||||
*
|
||||
* @throws IllegalStateException if this method is called when the request
|
||||
* is not in asynchronous mode. The request is in asynchronous mode after
|
||||
* {@link javax.servlet.http.HttpServletRequest#startAsync()} or
|
||||
* {@link javax.servlet.http.HttpServletRequest#startAsync(ServletRequest,
|
||||
* ServletResponse)} has been called and before {@link #complete()} or any
|
||||
* other dispatch() method has been called.
|
||||
*/
|
||||
void dispatch(String path);
|
||||
|
||||
/**
|
||||
* @param path The path to which the request/response should be dispatched
|
||||
* relative to the specified {@link ServletContext}.
|
||||
* @param context The {@link ServletContext} to which the request/response
|
||||
* should be dispatched.
|
||||
*
|
||||
* @throws IllegalStateException if this method is called when the request
|
||||
* is not in asynchronous mode. The request is in asynchronous mode after
|
||||
* {@link javax.servlet.http.HttpServletRequest#startAsync()} or
|
||||
* {@link javax.servlet.http.HttpServletRequest#startAsync(ServletRequest,
|
||||
* ServletResponse)} has been called and before {@link #complete()} or any
|
||||
* other dispatch() method has been called.
|
||||
*/
|
||||
void dispatch(ServletContext context, String path);
|
||||
|
||||
void complete();
|
||||
|
||||
void start(Runnable run);
|
||||
|
||||
void addListener(AsyncListener listener);
|
||||
|
||||
void addListener(AsyncListener listener, ServletRequest request,
|
||||
ServletResponse response);
|
||||
|
||||
<T extends AsyncListener> T createListener(Class<T> clazz)
|
||||
throws ServletException;
|
||||
|
||||
/**
|
||||
* Set the timeout.
|
||||
*
|
||||
* @param timeout The timeout in milliseconds. 0 or less indicates no
|
||||
* timeout.
|
||||
*/
|
||||
void setTimeout(long timeout);
|
||||
|
||||
/**
|
||||
* Get the current timeout.
|
||||
*
|
||||
* @return The timeout in milliseconds. 0 or less indicates no timeout.
|
||||
*/
|
||||
long getTimeout();
|
||||
}
|
||||
74
java/javax/servlet/AsyncEvent.java
Normal file
74
java/javax/servlet/AsyncEvent.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
/**
|
||||
* TODO SERVLET3 - Add comments
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public class AsyncEvent {
|
||||
private final AsyncContext context;
|
||||
private final ServletRequest request;
|
||||
private final ServletResponse response;
|
||||
private final Throwable throwable;
|
||||
|
||||
public AsyncEvent(AsyncContext context) {
|
||||
this.context = context;
|
||||
this.request = null;
|
||||
this.response = null;
|
||||
this.throwable = null;
|
||||
}
|
||||
|
||||
public AsyncEvent(AsyncContext context, ServletRequest request,
|
||||
ServletResponse response) {
|
||||
this.context = context;
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
this.throwable = null;
|
||||
}
|
||||
|
||||
public AsyncEvent(AsyncContext context, Throwable throwable) {
|
||||
this.context = context;
|
||||
this.throwable = throwable;
|
||||
this.request = null;
|
||||
this.response = null;
|
||||
}
|
||||
|
||||
public AsyncEvent(AsyncContext context, ServletRequest request,
|
||||
ServletResponse response, Throwable throwable) {
|
||||
this.context = context;
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
public AsyncContext getAsyncContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public ServletRequest getSuppliedRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public ServletResponse getSuppliedResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
public Throwable getThrowable() {
|
||||
return throwable;
|
||||
}
|
||||
}
|
||||
31
java/javax/servlet/AsyncListener.java
Normal file
31
java/javax/servlet/AsyncListener.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* TODO SERVLET3 - Add comments
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public interface AsyncListener extends EventListener {
|
||||
void onComplete(AsyncEvent event) throws IOException;
|
||||
void onTimeout(AsyncEvent event) throws IOException;
|
||||
void onError(AsyncEvent event) throws IOException;
|
||||
void onStartAsync(AsyncEvent event) throws IOException;
|
||||
}
|
||||
28
java/javax/servlet/DispatcherType.java
Normal file
28
java/javax/servlet/DispatcherType.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
/**
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public enum DispatcherType {
|
||||
FORWARD,
|
||||
INCLUDE,
|
||||
REQUEST,
|
||||
ASYNC,
|
||||
ERROR
|
||||
}
|
||||
117
java/javax/servlet/Filter.java
Normal file
117
java/javax/servlet/Filter.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A filter is an object that performs filtering tasks on either the request to
|
||||
* a resource (a servlet or static content), or on the response from a resource,
|
||||
* or both. <br>
|
||||
* <br>
|
||||
* Filters perform filtering in the <code>doFilter</code> method. Every Filter
|
||||
* has access to a FilterConfig object from which it can obtain its
|
||||
* initialization parameters, a reference to the ServletContext which it can
|
||||
* use, for example, to load resources needed for filtering tasks.
|
||||
* <p>
|
||||
* Filters are configured in the deployment descriptor of a web application
|
||||
* <p>
|
||||
* Examples that have been identified for this design are<br>
|
||||
* 1) Authentication Filters <br>
|
||||
* 2) Logging and Auditing Filters <br>
|
||||
* 3) Image conversion Filters <br>
|
||||
* 4) Data compression Filters <br>
|
||||
* 5) Encryption Filters <br>
|
||||
* 6) Tokenizing Filters <br>
|
||||
* 7) Filters that trigger resource access events <br>
|
||||
* 8) XSL/T filters <br>
|
||||
* 9) Mime-type chain Filter <br>
|
||||
*
|
||||
* @since Servlet 2.3
|
||||
*/
|
||||
public interface Filter {
|
||||
|
||||
/**
|
||||
* Called by the web container to indicate to a filter that it is being
|
||||
* placed into service. The servlet container calls the init method exactly
|
||||
* once after instantiating the filter. The init method must complete
|
||||
* successfully before the filter is asked to do any filtering work.
|
||||
* <p>
|
||||
* The web container cannot place the filter into service if the init method
|
||||
* either:
|
||||
* <ul>
|
||||
* <li>Throws a ServletException</li>
|
||||
* <li>Does not return within a time period defined by the web
|
||||
* container</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param filterConfig The configuration information associated with the
|
||||
* filter instance being initialised
|
||||
*
|
||||
* @throws ServletException if the initialisation fails
|
||||
*/
|
||||
public void init(FilterConfig filterConfig) throws ServletException;
|
||||
|
||||
/**
|
||||
* The <code>doFilter</code> method of the Filter is called by the container
|
||||
* each time a request/response pair is passed through the chain due to a
|
||||
* client request for a resource at the end of the chain. The FilterChain
|
||||
* passed in to this method allows the Filter to pass on the request and
|
||||
* response to the next entity in the chain.
|
||||
* <p>
|
||||
* A typical implementation of this method would follow the following
|
||||
* pattern:- <br>
|
||||
* 1. Examine the request<br>
|
||||
* 2. Optionally wrap the request object with a custom implementation to
|
||||
* filter content or headers for input filtering <br>
|
||||
* 3. Optionally wrap the response object with a custom implementation to
|
||||
* filter content or headers for output filtering <br>
|
||||
* 4. a) <strong>Either</strong> invoke the next entity in the chain using
|
||||
* the FilterChain object (<code>chain.doFilter()</code>), <br>
|
||||
* 4. b) <strong>or</strong> not pass on the request/response pair to the
|
||||
* next entity in the filter chain to block the request processing<br>
|
||||
* 5. Directly set headers on the response after invocation of the next
|
||||
* entity in the filter chain.
|
||||
*
|
||||
* @param request The request to process
|
||||
* @param response The response associated with the request
|
||||
* @param chain Provides access to the next filter in the chain for this
|
||||
* filter to pass the request and response to for further
|
||||
* processing
|
||||
*
|
||||
* @throws IOException if an I/O error occurs during this filter's
|
||||
* processing of the request
|
||||
* @throws ServletException if the processing fails for any other reason
|
||||
*/
|
||||
public void doFilter(ServletRequest request, ServletResponse response,
|
||||
FilterChain chain) throws IOException, ServletException;
|
||||
|
||||
/**
|
||||
* Called by the web container to indicate to a filter that it is being
|
||||
* taken out of service. This method is only called once all threads within
|
||||
* the filter's doFilter method have exited or after a timeout period has
|
||||
* passed. After the web container calls this method, it will not call the
|
||||
* doFilter method again on this instance of the filter. <br>
|
||||
* <br>
|
||||
*
|
||||
* This method gives the filter an opportunity to clean up any resources
|
||||
* that are being held (for example, memory, file handles, threads) and make
|
||||
* sure that any persistent state is synchronized with the filter's current
|
||||
* state in memory.
|
||||
*/
|
||||
public void destroy();
|
||||
}
|
||||
53
java/javax/servlet/FilterChain.java
Normal file
53
java/javax/servlet/FilterChain.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A FilterChain is an object provided by the servlet container to the developer
|
||||
* giving a view into the invocation chain of a filtered request for a resource.
|
||||
* Filters use the FilterChain to invoke the next filter in the chain, or if the
|
||||
* calling filter is the last filter in the chain, to invoke the resource at the
|
||||
* end of the chain.
|
||||
*
|
||||
* @see Filter
|
||||
* @since Servlet 2.3
|
||||
**/
|
||||
|
||||
public interface FilterChain {
|
||||
|
||||
/**
|
||||
* Causes the next filter in the chain to be invoked, or if the calling
|
||||
* filter is the last filter in the chain, causes the resource at the end of
|
||||
* the chain to be invoked.
|
||||
*
|
||||
* @param request
|
||||
* the request to pass along the chain.
|
||||
* @param response
|
||||
* the response to pass along the chain.
|
||||
*
|
||||
* @throws IOException if an I/O error occurs during the processing of the
|
||||
* request
|
||||
* @throws ServletException if the processing fails for any other reason
|
||||
|
||||
* @since 2.3
|
||||
*/
|
||||
public void doFilter(ServletRequest request, ServletResponse response)
|
||||
throws IOException, ServletException;
|
||||
|
||||
}
|
||||
75
java/javax/servlet/FilterConfig.java
Normal file
75
java/javax/servlet/FilterConfig.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package javax.servlet;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
*
|
||||
* A filter configuration object used by a servlet container to pass information
|
||||
* to a filter during initialization.
|
||||
*
|
||||
* @see Filter
|
||||
* @since Servlet 2.3
|
||||
*/
|
||||
public interface FilterConfig {
|
||||
|
||||
/**
|
||||
* Get the name of the filter.
|
||||
*
|
||||
* @return The filter-name of this filter as defined in the deployment
|
||||
* descriptor.
|
||||
*/
|
||||
public String getFilterName();
|
||||
|
||||
/**
|
||||
* Returns a reference to the {@link ServletContext} in which the caller is
|
||||
* executing.
|
||||
*
|
||||
* @return {@link ServletContext} object, used by the caller to interact
|
||||
* with its servlet container
|
||||
*
|
||||
* @see ServletContext
|
||||
*/
|
||||
public ServletContext getServletContext();
|
||||
|
||||
/**
|
||||
* Returns a <code>String</code> containing the value of the named
|
||||
* initialization parameter, or <code>null</code> if the parameter does not
|
||||
* exist.
|
||||
*
|
||||
* @param name
|
||||
* <code>String</code> specifying the name of the initialization
|
||||
* parameter
|
||||
*
|
||||
* @return <code>String</code> containing the value of the initialization
|
||||
* parameter
|
||||
*/
|
||||
public String getInitParameter(String name);
|
||||
|
||||
/**
|
||||
* Returns the names of the filter's initialization parameters as an
|
||||
* <code>Enumeration</code> of <code>String</code> objects, or an empty
|
||||
* <code>Enumeration</code> if the filter has no initialization parameters.
|
||||
*
|
||||
* @return <code>Enumeration</code> of <code>String</code> objects
|
||||
* containing the names of the filter's initialization parameters
|
||||
*/
|
||||
public Enumeration<String> getInitParameterNames();
|
||||
|
||||
}
|
||||
81
java/javax/servlet/FilterRegistration.java
Normal file
81
java/javax/servlet/FilterRegistration.java
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* @since Servlet 3.0
|
||||
* TODO SERVLET3 - Add comments
|
||||
*/
|
||||
public interface FilterRegistration extends Registration {
|
||||
|
||||
/**
|
||||
* Add a mapping for this filter to one or more named Servlets.
|
||||
*
|
||||
* @param dispatcherTypes The dispatch types to which this filter should
|
||||
* apply
|
||||
* @param isMatchAfter Should this filter be applied after any mappings
|
||||
* defined in the deployment descriptor
|
||||
* (<code>true</code>) or before?
|
||||
* @param servletNames Requests mapped to these servlets will be
|
||||
* processed by this filter
|
||||
* @throws IllegalArgumentException if the list of servlet names is empty
|
||||
* or null
|
||||
* @throws IllegalStateException if the associated ServletContext has
|
||||
* already been initialised
|
||||
*/
|
||||
public void addMappingForServletNames(
|
||||
EnumSet<DispatcherType> dispatcherTypes,
|
||||
boolean isMatchAfter, String... servletNames);
|
||||
/**
|
||||
*
|
||||
* @return TODO
|
||||
*/
|
||||
public Collection<String> getServletNameMappings();
|
||||
|
||||
/**
|
||||
* Add a mapping for this filter to one or more URL patterns.
|
||||
*
|
||||
* @param dispatcherTypes The dispatch types to which this filter should
|
||||
* apply
|
||||
* @param isMatchAfter Should this filter be applied after any mappings
|
||||
* defined in the deployment descriptor
|
||||
* (<code>true</code>) or before?
|
||||
* @param urlPatterns The URL patterns to which this filter should be
|
||||
* applied
|
||||
* @throws IllegalArgumentException if the list of URL patterns is empty or
|
||||
* null
|
||||
* @throws IllegalStateException if the associated ServletContext has
|
||||
* already been initialised
|
||||
*/
|
||||
public void addMappingForUrlPatterns(
|
||||
EnumSet<DispatcherType> dispatcherTypes,
|
||||
boolean isMatchAfter, String... urlPatterns);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return TODO
|
||||
*/
|
||||
public Collection<String> getUrlPatternMappings();
|
||||
|
||||
public static interface Dynamic
|
||||
extends FilterRegistration, Registration.Dynamic {
|
||||
// No additional methods
|
||||
}
|
||||
}
|
||||
238
java/javax/servlet/GenericServlet.java
Normal file
238
java/javax/servlet/GenericServlet.java
Normal file
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
* Defines a generic, protocol-independent servlet. To write an HTTP servlet for
|
||||
* use on the Web, extend {@link javax.servlet.http.HttpServlet} instead.
|
||||
* <p>
|
||||
* <code>GenericServlet</code> implements the <code>Servlet</code> and
|
||||
* <code>ServletConfig</code> interfaces. <code>GenericServlet</code> may be
|
||||
* directly extended by a servlet, although it's more common to extend a
|
||||
* protocol-specific subclass such as <code>HttpServlet</code>.
|
||||
* <p>
|
||||
* <code>GenericServlet</code> makes writing servlets easier. It provides simple
|
||||
* versions of the lifecycle methods <code>init</code> and <code>destroy</code>
|
||||
* and of the methods in the <code>ServletConfig</code> interface.
|
||||
* <code>GenericServlet</code> also implements the <code>log</code> method,
|
||||
* declared in the <code>ServletContext</code> interface.
|
||||
* <p>
|
||||
* To write a generic servlet, you need only override the abstract
|
||||
* <code>service</code> method.
|
||||
*/
|
||||
public abstract class GenericServlet implements Servlet, ServletConfig,
|
||||
java.io.Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private transient ServletConfig config;
|
||||
|
||||
/**
|
||||
* Does nothing. All of the servlet initialization is done by one of the
|
||||
* <code>init</code> methods.
|
||||
*/
|
||||
public GenericServlet() {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the servlet container to indicate to a servlet that the servlet
|
||||
* is being taken out of service. See {@link Servlet#destroy}.
|
||||
*/
|
||||
@Override
|
||||
public void destroy() {
|
||||
// NOOP by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a <code>String</code> containing the value of the named
|
||||
* initialization parameter, or <code>null</code> if the parameter does not
|
||||
* exist. See {@link ServletConfig#getInitParameter}.
|
||||
* <p>
|
||||
* This method is supplied for convenience. It gets the value of the named
|
||||
* parameter from the servlet's <code>ServletConfig</code> object.
|
||||
*
|
||||
* @param name
|
||||
* a <code>String</code> specifying the name of the
|
||||
* initialization parameter
|
||||
* @return String a <code>String</code> containing the value of the
|
||||
* initialization parameter
|
||||
*/
|
||||
@Override
|
||||
public String getInitParameter(String name) {
|
||||
return getServletConfig().getInitParameter(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the names of the servlet's initialization parameters as an
|
||||
* <code>Enumeration</code> of <code>String</code> objects, or an empty
|
||||
* <code>Enumeration</code> if the servlet has no initialization parameters.
|
||||
* See {@link ServletConfig#getInitParameterNames}.
|
||||
* <p>
|
||||
* This method is supplied for convenience. It gets the parameter names from
|
||||
* the servlet's <code>ServletConfig</code> object.
|
||||
*
|
||||
* @return Enumeration an enumeration of <code>String</code> objects
|
||||
* containing the names of the servlet's initialization parameters
|
||||
*/
|
||||
@Override
|
||||
public Enumeration<String> getInitParameterNames() {
|
||||
return getServletConfig().getInitParameterNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this servlet's {@link ServletConfig} object.
|
||||
*
|
||||
* @return ServletConfig the <code>ServletConfig</code> object that
|
||||
* initialized this servlet
|
||||
*/
|
||||
@Override
|
||||
public ServletConfig getServletConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the {@link ServletContext} in which this servlet
|
||||
* is running. See {@link ServletConfig#getServletContext}.
|
||||
* <p>
|
||||
* This method is supplied for convenience. It gets the context from the
|
||||
* servlet's <code>ServletConfig</code> object.
|
||||
*
|
||||
* @return ServletContext the <code>ServletContext</code> object passed to
|
||||
* this servlet by the <code>init</code> method
|
||||
*/
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return getServletConfig().getServletContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about the servlet, such as author, version, and
|
||||
* copyright. By default, this method returns an empty string. Override this
|
||||
* method to have it return a meaningful value. See
|
||||
* {@link Servlet#getServletInfo}.
|
||||
*
|
||||
* @return String information about this servlet, by default an empty string
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the servlet container to indicate to a servlet that the servlet
|
||||
* is being placed into service. See {@link Servlet#init}.
|
||||
* <p>
|
||||
* This implementation stores the {@link ServletConfig} object it receives
|
||||
* from the servlet container for later use. When overriding this form of
|
||||
* the method, call <code>super.init(config)</code>.
|
||||
*
|
||||
* @param config
|
||||
* the <code>ServletConfig</code> object that contains
|
||||
* configuration information for this servlet
|
||||
* @exception ServletException
|
||||
* if an exception occurs that interrupts the servlet's
|
||||
* normal operation
|
||||
* @see UnavailableException
|
||||
*/
|
||||
@Override
|
||||
public void init(ServletConfig config) throws ServletException {
|
||||
this.config = config;
|
||||
this.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* A convenience method which can be overridden so that there's no need to
|
||||
* call <code>super.init(config)</code>.
|
||||
* <p>
|
||||
* Instead of overriding {@link #init(ServletConfig)}, simply override this
|
||||
* method and it will be called by
|
||||
* <code>GenericServlet.init(ServletConfig config)</code>. The
|
||||
* <code>ServletConfig</code> object can still be retrieved via
|
||||
* {@link #getServletConfig}.
|
||||
*
|
||||
* @exception ServletException
|
||||
* if an exception occurs that interrupts the servlet's
|
||||
* normal operation
|
||||
*/
|
||||
public void init() throws ServletException {
|
||||
// NOOP by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the specified message to a servlet log file, prepended by the
|
||||
* servlet's name. See {@link ServletContext#log(String)}.
|
||||
*
|
||||
* @param msg
|
||||
* a <code>String</code> specifying the message to be written to
|
||||
* the log file
|
||||
*/
|
||||
public void log(String msg) {
|
||||
getServletContext().log(getServletName() + ": " + msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an explanatory message and a stack trace for a given
|
||||
* <code>Throwable</code> exception to the servlet log file, prepended by
|
||||
* the servlet's name. See {@link ServletContext#log(String, Throwable)}.
|
||||
*
|
||||
* @param message
|
||||
* a <code>String</code> that describes the error or exception
|
||||
* @param t
|
||||
* the <code>java.lang.Throwable</code> error or exception
|
||||
*/
|
||||
public void log(String message, Throwable t) {
|
||||
getServletContext().log(getServletName() + ": " + message, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the servlet container to allow the servlet to respond to a
|
||||
* request. See {@link Servlet#service}.
|
||||
* <p>
|
||||
* This method is declared abstract so subclasses, such as
|
||||
* <code>HttpServlet</code>, must override it.
|
||||
*
|
||||
* @param req
|
||||
* the <code>ServletRequest</code> object that contains the
|
||||
* client's request
|
||||
* @param res
|
||||
* the <code>ServletResponse</code> object that will contain the
|
||||
* servlet's response
|
||||
* @exception ServletException
|
||||
* if an exception occurs that interferes with the servlet's
|
||||
* normal operation occurred
|
||||
* @exception IOException
|
||||
* if an input or output exception occurs
|
||||
*/
|
||||
@Override
|
||||
public abstract void service(ServletRequest req, ServletResponse res)
|
||||
throws ServletException, IOException;
|
||||
|
||||
/**
|
||||
* Returns the name of this servlet instance. See
|
||||
* {@link ServletConfig#getServletName}.
|
||||
*
|
||||
* @return the name of this servlet instance
|
||||
*/
|
||||
@Override
|
||||
public String getServletName() {
|
||||
return config.getServletName();
|
||||
}
|
||||
}
|
||||
125
java/javax/servlet/HttpConstraintElement.java
Normal file
125
java/javax/servlet/HttpConstraintElement.java
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic;
|
||||
import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
|
||||
|
||||
/**
|
||||
* Equivalent of {@link javax.servlet.annotation.HttpConstraint} for
|
||||
* programmatic configuration of security constraints.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public class HttpConstraintElement {
|
||||
|
||||
private static final String LSTRING_FILE = "javax.servlet.LocalStrings";
|
||||
private static final ResourceBundle lStrings =
|
||||
ResourceBundle.getBundle(LSTRING_FILE);
|
||||
|
||||
private final EmptyRoleSemantic emptyRoleSemantic;// = EmptyRoleSemantic.PERMIT;
|
||||
private final TransportGuarantee transportGuarantee;// = TransportGuarantee.NONE;
|
||||
private final String[] rolesAllowed;// = new String[0];
|
||||
|
||||
/**
|
||||
* Default constraint is permit with no transport guarantee.
|
||||
*/
|
||||
public HttpConstraintElement() {
|
||||
// Default constructor
|
||||
this.emptyRoleSemantic = EmptyRoleSemantic.PERMIT;
|
||||
this.transportGuarantee = TransportGuarantee.NONE;
|
||||
this.rolesAllowed = new String[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a constraint with an empty role semantic. Typically used with
|
||||
* {@link EmptyRoleSemantic#DENY}.
|
||||
*
|
||||
* @param emptyRoleSemantic The empty role semantic to apply to the newly
|
||||
* created constraint
|
||||
*/
|
||||
public HttpConstraintElement(EmptyRoleSemantic emptyRoleSemantic) {
|
||||
this.emptyRoleSemantic = emptyRoleSemantic;
|
||||
this.transportGuarantee = TransportGuarantee.NONE;
|
||||
this.rolesAllowed = new String[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a constraint with a transport guarantee and roles.
|
||||
*
|
||||
* @param transportGuarantee The transport guarantee to apply to the newly
|
||||
* created constraint
|
||||
* @param rolesAllowed The roles to associate with the newly created
|
||||
* constraint
|
||||
*/
|
||||
public HttpConstraintElement(TransportGuarantee transportGuarantee,
|
||||
String... rolesAllowed) {
|
||||
this.emptyRoleSemantic = EmptyRoleSemantic.PERMIT;
|
||||
this.transportGuarantee = transportGuarantee;
|
||||
this.rolesAllowed = rolesAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a constraint with an empty role semantic, a transport guarantee
|
||||
* and roles.
|
||||
*
|
||||
* @param emptyRoleSemantic The empty role semantic to apply to the newly
|
||||
* created constraint
|
||||
* @param transportGuarantee The transport guarantee to apply to the newly
|
||||
* created constraint
|
||||
* @param rolesAllowed The roles to associate with the newly created
|
||||
* constraint
|
||||
* @throws IllegalArgumentException if roles are specified when DENY is used
|
||||
*/
|
||||
public HttpConstraintElement(EmptyRoleSemantic emptyRoleSemantic,
|
||||
TransportGuarantee transportGuarantee, String... rolesAllowed) {
|
||||
if (rolesAllowed != null && rolesAllowed.length > 0 &&
|
||||
EmptyRoleSemantic.DENY.equals(emptyRoleSemantic)) {
|
||||
throw new IllegalArgumentException(lStrings.getString(
|
||||
"httpConstraintElement.invalidRolesDeny"));
|
||||
}
|
||||
this.emptyRoleSemantic = emptyRoleSemantic;
|
||||
this.transportGuarantee = transportGuarantee;
|
||||
this.rolesAllowed = rolesAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @return TODO
|
||||
*/
|
||||
public EmptyRoleSemantic getEmptyRoleSemantic() {
|
||||
return emptyRoleSemantic;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @return TODO
|
||||
*/
|
||||
public TransportGuarantee getTransportGuarantee() {
|
||||
return transportGuarantee;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @return TODO
|
||||
*/
|
||||
public String[] getRolesAllowed() {
|
||||
return rolesAllowed;
|
||||
}
|
||||
}
|
||||
57
java/javax/servlet/HttpMethodConstraintElement.java
Normal file
57
java/javax/servlet/HttpMethodConstraintElement.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* @since Servlet 3.0
|
||||
* TODO SERVLET3 - Add comments
|
||||
*/
|
||||
public class HttpMethodConstraintElement extends HttpConstraintElement {
|
||||
|
||||
// Can't inherit from HttpConstraintElement as API does not allow it
|
||||
private static final String LSTRING_FILE = "javax.servlet.LocalStrings";
|
||||
private static final ResourceBundle lStrings =
|
||||
ResourceBundle.getBundle(LSTRING_FILE);
|
||||
|
||||
private final String methodName;
|
||||
|
||||
public HttpMethodConstraintElement(String methodName) {
|
||||
if (methodName == null || methodName.length() == 0) {
|
||||
throw new IllegalArgumentException(lStrings.getString(
|
||||
"httpMethodConstraintElement.invalidMethod"));
|
||||
}
|
||||
this.methodName = methodName;
|
||||
}
|
||||
|
||||
public HttpMethodConstraintElement(String methodName,
|
||||
HttpConstraintElement constraint) {
|
||||
super(constraint.getEmptyRoleSemantic(),
|
||||
constraint.getTransportGuarantee(),
|
||||
constraint.getRolesAllowed());
|
||||
if (methodName == null || methodName.length() == 0) {
|
||||
throw new IllegalArgumentException(lStrings.getString(
|
||||
"httpMethodConstraintElement.invalidMethod"));
|
||||
}
|
||||
this.methodName = methodName;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return methodName;
|
||||
}
|
||||
}
|
||||
23
java/javax/servlet/LocalStrings.properties
Normal file
23
java/javax/servlet/LocalStrings.properties
Normal file
@@ -0,0 +1,23 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
err.not_iso8859_1=Not an ISO 8859-1 character: [{0}]
|
||||
|
||||
httpConstraintElement.invalidRolesDeny=Roles may not be specified when using DENY
|
||||
|
||||
httpMethodConstraintElement.invalidMethod=Invalid HTTP method
|
||||
|
||||
value.false=false
|
||||
value.true=true
|
||||
20
java/javax/servlet/LocalStrings_de.properties
Normal file
20
java/javax/servlet/LocalStrings_de.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
err.not_iso8859_1=Kein ISO 8859-1 Zeichen: [{0}]
|
||||
|
||||
httpMethodConstraintElement.invalidMethod=Ungültige HTTP-Methode
|
||||
|
||||
value.true=wahr
|
||||
23
java/javax/servlet/LocalStrings_es.properties
Normal file
23
java/javax/servlet/LocalStrings_es.properties
Normal file
@@ -0,0 +1,23 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
err.not_iso8859_1=No es un carácter ISO 8859-1: [{0}]
|
||||
|
||||
httpConstraintElement.invalidRolesDeny=No se pueden especificar Roles al utilizar DENY (DENEGAR)
|
||||
|
||||
httpMethodConstraintElement.invalidMethod=Método HTTP inválido
|
||||
|
||||
value.false=false
|
||||
value.true=true
|
||||
23
java/javax/servlet/LocalStrings_fr.properties
Normal file
23
java/javax/servlet/LocalStrings_fr.properties
Normal file
@@ -0,0 +1,23 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
err.not_iso8859_1=[{0}] n''est pas un caractère ISO 8859-1
|
||||
|
||||
httpConstraintElement.invalidRolesDeny=Des rôles ne peuvent pas être spécifiés lorsque DENY est utilisé
|
||||
|
||||
httpMethodConstraintElement.invalidMethod=Méthode HTTP invalide
|
||||
|
||||
value.false=false
|
||||
value.true=true
|
||||
23
java/javax/servlet/LocalStrings_ja.properties
Normal file
23
java/javax/servlet/LocalStrings_ja.properties
Normal file
@@ -0,0 +1,23 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
err.not_iso8859_1=ISO 8859-1 の文字ではありません: [{0}]
|
||||
|
||||
httpConstraintElement.invalidRolesDeny=DENYを使用する場合、Roleを指定することはできません。
|
||||
|
||||
httpMethodConstraintElement.invalidMethod=無効なHTTPメソッド
|
||||
|
||||
value.false=false
|
||||
value.true=true
|
||||
23
java/javax/servlet/LocalStrings_ko.properties
Normal file
23
java/javax/servlet/LocalStrings_ko.properties
Normal file
@@ -0,0 +1,23 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
err.not_iso8859_1=ISO 8859-1 문자가 아닙니다: [{0}]
|
||||
|
||||
httpConstraintElement.invalidRolesDeny=DENY를 사용할 때에는 역할들이 지정될 수 없습니다.
|
||||
|
||||
httpMethodConstraintElement.invalidMethod=유효하지 않은 HTTP 메소드
|
||||
|
||||
value.false=false
|
||||
value.true=true
|
||||
22
java/javax/servlet/LocalStrings_zh_CN.properties
Normal file
22
java/javax/servlet/LocalStrings_zh_CN.properties
Normal file
@@ -0,0 +1,22 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
err.not_iso8859_1=不是ISO 8859-1字符:[{0}]
|
||||
|
||||
httpConstraintElement.invalidRolesDeny=使用 DENY 时可能未指定角色
|
||||
|
||||
httpMethodConstraintElement.invalidMethod=无效的HTTP.方法
|
||||
|
||||
value.true=true
|
||||
85
java/javax/servlet/MultipartConfigElement.java
Normal file
85
java/javax/servlet/MultipartConfigElement.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import javax.servlet.annotation.MultipartConfig;
|
||||
|
||||
/**
|
||||
* @since Servlet 3.0
|
||||
* TODO SERVLET3 - Add comments
|
||||
*/
|
||||
public class MultipartConfigElement {
|
||||
|
||||
private final String location;// = "";
|
||||
private final long maxFileSize;// = -1;
|
||||
private final long maxRequestSize;// = -1;
|
||||
private final int fileSizeThreshold;// = 0;
|
||||
|
||||
public MultipartConfigElement(String location) {
|
||||
// Keep empty string default if location is null
|
||||
if (location != null) {
|
||||
this.location = location;
|
||||
} else {
|
||||
this.location = "";
|
||||
}
|
||||
this.maxFileSize = -1;
|
||||
this.maxRequestSize = -1;
|
||||
this.fileSizeThreshold = 0;
|
||||
}
|
||||
|
||||
public MultipartConfigElement(String location, long maxFileSize,
|
||||
long maxRequestSize, int fileSizeThreshold) {
|
||||
// Keep empty string default if location is null
|
||||
if (location != null) {
|
||||
this.location = location;
|
||||
} else {
|
||||
this.location = "";
|
||||
}
|
||||
this.maxFileSize = maxFileSize;
|
||||
this.maxRequestSize = maxRequestSize;
|
||||
// Avoid threshold values of less than zero as they cause trigger NPEs
|
||||
// in the Commons FileUpload port for fields that have no data.
|
||||
if (fileSizeThreshold > 0) {
|
||||
this.fileSizeThreshold = fileSizeThreshold;
|
||||
} else {
|
||||
this.fileSizeThreshold = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public MultipartConfigElement(MultipartConfig annotation) {
|
||||
location = annotation.location();
|
||||
maxFileSize = annotation.maxFileSize();
|
||||
maxRequestSize = annotation.maxRequestSize();
|
||||
fileSizeThreshold = annotation.fileSizeThreshold();
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public long getMaxFileSize() {
|
||||
return maxFileSize;
|
||||
}
|
||||
|
||||
public long getMaxRequestSize() {
|
||||
return maxRequestSize;
|
||||
}
|
||||
|
||||
public int getFileSizeThreshold() {
|
||||
return fileSizeThreshold;
|
||||
}
|
||||
}
|
||||
52
java/javax/servlet/ReadListener.java
Normal file
52
java/javax/servlet/ReadListener.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Receives notification of read events when using non-blocking IO.
|
||||
*
|
||||
* @since Servlet 3.1
|
||||
*/
|
||||
public interface ReadListener extends java.util.EventListener{
|
||||
|
||||
/**
|
||||
* Invoked when data is available to read. The container will invoke this
|
||||
* method the first time for a request as soon as there is data to read.
|
||||
* Subsequent invocations will only occur if a call to
|
||||
* {@link ServletInputStream#isReady()} has returned false and data has
|
||||
* subsequently become available to read.
|
||||
*
|
||||
* @throws IOException id an I/O error occurs while processing the event
|
||||
*/
|
||||
public abstract void onDataAvailable() throws IOException;
|
||||
|
||||
/**
|
||||
* Invoked when the request body has been fully read.
|
||||
*
|
||||
* @throws IOException id an I/O error occurs while processing the event
|
||||
*/
|
||||
public abstract void onAllDataRead() throws IOException;
|
||||
|
||||
/**
|
||||
* Invoked if an error occurs while reading the request body.
|
||||
*
|
||||
* @param throwable The exception that occurred
|
||||
*/
|
||||
public abstract void onError(java.lang.Throwable throwable);
|
||||
}
|
||||
94
java/javax/servlet/Registration.java
Normal file
94
java/javax/servlet/Registration.java
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Common interface for the registration of Filters and Servlets.
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public interface Registration {
|
||||
|
||||
public String getName();
|
||||
|
||||
public String getClassName();
|
||||
|
||||
/**
|
||||
* Add an initialisation parameter if not already added.
|
||||
*
|
||||
* @param name Name of initialisation parameter
|
||||
* @param value Value of initialisation parameter
|
||||
* @return <code>true</code> if the initialisation parameter was set,
|
||||
* <code>false</code> if the initialisation parameter was not set
|
||||
* because an initialisation parameter of the same name already
|
||||
* existed
|
||||
* @throws IllegalArgumentException if name or value is <code>null</code>
|
||||
* @throws IllegalStateException if the ServletContext associated with this
|
||||
* registration has already been initialised
|
||||
*/
|
||||
public boolean setInitParameter(String name, String value);
|
||||
|
||||
/**
|
||||
* Get the value of an initialisation parameter.
|
||||
*
|
||||
* @param name The initialisation parameter whose value is required
|
||||
*
|
||||
* @return The value of the named initialisation parameter
|
||||
*/
|
||||
public String getInitParameter(String name);
|
||||
|
||||
/**
|
||||
* Add multiple initialisation parameters. If any of the supplied
|
||||
* initialisation parameter conflicts with an existing initialisation
|
||||
* parameter, no updates will be performed.
|
||||
*
|
||||
* @param initParameters The initialisation parameters to add
|
||||
*
|
||||
* @return The set of initialisation parameter names that conflicted with
|
||||
* existing initialisation parameter. If there are no conflicts,
|
||||
* this Set will be empty.
|
||||
* @throws IllegalArgumentException if any of the supplied initialisation
|
||||
* parameters have a null name or value
|
||||
* @throws IllegalStateException if the ServletContext associated with this
|
||||
* registration has already been initialised
|
||||
*/
|
||||
public Set<String> setInitParameters(Map<String,String> initParameters);
|
||||
|
||||
/**
|
||||
* Get the names and values of all the initialisation parameters.
|
||||
*
|
||||
* @return A Map of initialisation parameter names and associated values
|
||||
* keyed by name
|
||||
*/
|
||||
public Map<String, String> getInitParameters();
|
||||
|
||||
public interface Dynamic extends Registration {
|
||||
|
||||
/**
|
||||
* Mark this Servlet/Filter as supported asynchronous processing.
|
||||
*
|
||||
* @param isAsyncSupported Should this Servlet/Filter support
|
||||
* asynchronous processing
|
||||
*
|
||||
* @throws IllegalStateException if the ServletContext associated with
|
||||
* this registration has already been initialised
|
||||
*/
|
||||
public void setAsyncSupported(boolean isAsyncSupported);
|
||||
}
|
||||
}
|
||||
293
java/javax/servlet/RequestDispatcher.java
Normal file
293
java/javax/servlet/RequestDispatcher.java
Normal file
@@ -0,0 +1,293 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Defines an object that receives requests from the client and sends them to
|
||||
* any resource (such as a servlet, HTML file, or JSP file) on the server. The
|
||||
* servlet container creates the <code>RequestDispatcher</code> object, which is
|
||||
* used as a wrapper around a server resource located at a particular path or
|
||||
* given by a particular name.
|
||||
*
|
||||
* <p>
|
||||
* This interface is intended to wrap servlets, but a servlet container can
|
||||
* create <code>RequestDispatcher</code> objects to wrap any type of resource.
|
||||
*
|
||||
* @see ServletContext#getRequestDispatcher(java.lang.String)
|
||||
* @see ServletContext#getNamedDispatcher(java.lang.String)
|
||||
* @see ServletRequest#getRequestDispatcher(java.lang.String)
|
||||
*
|
||||
*/
|
||||
public interface RequestDispatcher {
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when the {@link #forward(ServletRequest, ServletResponse)} method is
|
||||
* called. It provides the original value of a path-related property of the
|
||||
* request. See the chapter "Forwarded Request Parameters" in the Servlet
|
||||
* Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
static final String FORWARD_REQUEST_URI = "javax.servlet.forward.request_uri";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when the {@link #forward(ServletRequest, ServletResponse)} method is
|
||||
* called. It provides the original value of a path-related property of the
|
||||
* request. See the chapter "Forwarded Request Parameters" in the Servlet
|
||||
* Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
static final String FORWARD_CONTEXT_PATH = "javax.servlet.forward.context_path";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when the {@link #forward(ServletRequest, ServletResponse)} method is
|
||||
* called. It provides the original value of a path-related property of the
|
||||
* request. See the chapter "Forwarded Request Parameters" in the Servlet
|
||||
* Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
static final String FORWARD_PATH_INFO = "javax.servlet.forward.path_info";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when the {@link #forward(ServletRequest, ServletResponse)} method is
|
||||
* called. It provides the original value of a path-related property of the
|
||||
* request. See the chapter "Forwarded Request Parameters" in the Servlet
|
||||
* Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
static final String FORWARD_SERVLET_PATH = "javax.servlet.forward.servlet_path";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when the {@link #forward(ServletRequest, ServletResponse)} method is
|
||||
* called. It provides the original value of a path-related property of the
|
||||
* request. See the chapter "Forwarded Request Parameters" in the Servlet
|
||||
* Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
static final String FORWARD_QUERY_STRING = "javax.servlet.forward.query_string";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when the {@link #include(ServletRequest, ServletResponse)} method is
|
||||
* called on the {@code RequestDispatcher} obtained by a path and not by a
|
||||
* name. It provides information on the path that was used to obtain the
|
||||
* {@code RequestDispatcher} instance for this include call. See the chapter
|
||||
* "Included Request Parameters" in the Servlet Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
static final String INCLUDE_REQUEST_URI = "javax.servlet.include.request_uri";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when the {@link #include(ServletRequest, ServletResponse)} method is
|
||||
* called on the {@code RequestDispatcher} obtained by a path and not by a
|
||||
* name. It provides information on the path that was used to obtain the
|
||||
* {@code RequestDispatcher} instance for this include call. See the chapter
|
||||
* "Included Request Parameters" in the Servlet Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
static final String INCLUDE_CONTEXT_PATH = "javax.servlet.include.context_path";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when the {@link #include(ServletRequest, ServletResponse)} method is
|
||||
* called on the {@code RequestDispatcher} obtained by a path and not by a
|
||||
* name. It provides information on the path that was used to obtain the
|
||||
* {@code RequestDispatcher} instance for this include call. See the chapter
|
||||
* "Included Request Parameters" in the Servlet Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
static final String INCLUDE_PATH_INFO = "javax.servlet.include.path_info";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when the {@link #include(ServletRequest, ServletResponse)} method is
|
||||
* called on the {@code RequestDispatcher} obtained by a path and not by a
|
||||
* name. It provides information on the path that was used to obtain the
|
||||
* {@code RequestDispatcher} instance for this include call. See the chapter
|
||||
* "Included Request Parameters" in the Servlet Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
static final String INCLUDE_SERVLET_PATH = "javax.servlet.include.servlet_path";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when the {@link #include(ServletRequest, ServletResponse)} method is
|
||||
* called on the {@code RequestDispatcher} obtained by a path and not by a
|
||||
* name. It provides information on the path that was used to obtain the
|
||||
* {@code RequestDispatcher} instance for this include call. See the chapter
|
||||
* "Included Request Parameters" in the Servlet Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
static final String INCLUDE_QUERY_STRING = "javax.servlet.include.query_string";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when custom error-handling servlet or JSP page is invoked. The value of
|
||||
* the attribute is of type {@code java.lang.Throwable}. See the chapter
|
||||
* "Error Handling" in the Servlet Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public static final String ERROR_EXCEPTION = "javax.servlet.error.exception";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when custom error-handling servlet or JSP page is invoked. The value of
|
||||
* the attribute is of type {@code java.lang.Class}. See the chapter
|
||||
* "Error Handling" in the Servlet Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public static final String ERROR_EXCEPTION_TYPE = "javax.servlet.error.exception_type";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when custom error-handling servlet or JSP page is invoked. The value of
|
||||
* the attribute is of type {@code java.lang.String}. See the chapter
|
||||
* "Error Handling" in the Servlet Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public static final String ERROR_MESSAGE = "javax.servlet.error.message";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when custom error-handling servlet or JSP page is invoked. The value of
|
||||
* the attribute is of type {@code java.lang.String}. See the chapter
|
||||
* "Error Handling" in the Servlet Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public static final String ERROR_REQUEST_URI = "javax.servlet.error.request_uri";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when custom error-handling servlet or JSP page is invoked. The value of
|
||||
* the attribute is of type {@code java.lang.String}. See the chapter
|
||||
* "Error Handling" in the Servlet Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public static final String ERROR_SERVLET_NAME = "javax.servlet.error.servlet_name";
|
||||
|
||||
/**
|
||||
* The name of the request attribute that should be set by the container
|
||||
* when custom error-handling servlet or JSP page is invoked. The value of
|
||||
* the attribute is of type {@code java.lang.Integer}. See the chapter
|
||||
* "Error Handling" in the Servlet Specification for details.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public static final String ERROR_STATUS_CODE = "javax.servlet.error.status_code";
|
||||
|
||||
/**
|
||||
* Forwards a request from a servlet to another resource (servlet, JSP file,
|
||||
* or HTML file) on the server. This method allows one servlet to do
|
||||
* preliminary processing of a request and another resource to generate the
|
||||
* response.
|
||||
*
|
||||
* <p>
|
||||
* For a <code>RequestDispatcher</code> obtained via
|
||||
* <code>getRequestDispatcher()</code>, the <code>ServletRequest</code>
|
||||
* object has its path elements and parameters adjusted to match the path of
|
||||
* the target resource.
|
||||
*
|
||||
* <p>
|
||||
* <code>forward</code> should be called before the response has been
|
||||
* committed to the client (before response body output has been flushed).
|
||||
* If the response already has been committed, this method throws an
|
||||
* <code>IllegalStateException</code>. Uncommitted output in the response
|
||||
* buffer is automatically cleared before the forward.
|
||||
*
|
||||
* <p>
|
||||
* The request and response parameters must be either the same objects as
|
||||
* were passed to the calling servlet's service method or be subclasses of
|
||||
* the {@link ServletRequestWrapper} or {@link ServletResponseWrapper}
|
||||
* classes that wrap them.
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* a {@link ServletRequest} object that represents the request
|
||||
* the client makes of the servlet
|
||||
*
|
||||
* @param response
|
||||
* a {@link ServletResponse} object that represents the response
|
||||
* the servlet returns to the client
|
||||
*
|
||||
* @exception ServletException
|
||||
* if the target resource throws this exception
|
||||
*
|
||||
* @exception IOException
|
||||
* if the target resource throws this exception
|
||||
*
|
||||
* @exception IllegalStateException
|
||||
* if the response was already committed
|
||||
*/
|
||||
public void forward(ServletRequest request, ServletResponse response)
|
||||
throws ServletException, IOException;
|
||||
|
||||
/**
|
||||
* Includes the content of a resource (servlet, JSP page, HTML file) in the
|
||||
* response. In essence, this method enables programmatic server-side
|
||||
* includes.
|
||||
*
|
||||
* <p>
|
||||
* The {@link ServletResponse} object has its path elements and parameters
|
||||
* remain unchanged from the caller's. The included servlet cannot change
|
||||
* the response status code or set headers; any attempt to make a change is
|
||||
* ignored.
|
||||
*
|
||||
* <p>
|
||||
* The request and response parameters must be either the same objects as
|
||||
* were passed to the calling servlet's service method or be subclasses of
|
||||
* the {@link ServletRequestWrapper} or {@link ServletResponseWrapper}
|
||||
* classes that wrap them.
|
||||
*
|
||||
* @param request
|
||||
* a {@link ServletRequest} object that contains the client's
|
||||
* request
|
||||
*
|
||||
* @param response
|
||||
* a {@link ServletResponse} object that contains the servlet's
|
||||
* response
|
||||
*
|
||||
* @exception ServletException
|
||||
* if the included resource throws this exception
|
||||
*
|
||||
* @exception IOException
|
||||
* if the included resource throws this exception
|
||||
*/
|
||||
public void include(ServletRequest request, ServletResponse response)
|
||||
throws ServletException, IOException;
|
||||
}
|
||||
178
java/javax/servlet/Servlet.java
Normal file
178
java/javax/servlet/Servlet.java
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package javax.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Defines methods that all servlets must implement.
|
||||
*
|
||||
* <p>
|
||||
* A servlet is a small Java program that runs within a Web server. Servlets
|
||||
* receive and respond to requests from Web clients, usually across HTTP, the
|
||||
* HyperText Transfer Protocol.
|
||||
*
|
||||
* <p>
|
||||
* To implement this interface, you can write a generic servlet that extends
|
||||
* <code>javax.servlet.GenericServlet</code> or an HTTP servlet that extends
|
||||
* <code>javax.servlet.http.HttpServlet</code>.
|
||||
*
|
||||
* <p>
|
||||
* This interface defines methods to initialize a servlet, to service requests,
|
||||
* and to remove a servlet from the server. These are known as life-cycle
|
||||
* methods and are called in the following sequence:
|
||||
* <ol>
|
||||
* <li>The servlet is constructed, then initialized with the <code>init</code>
|
||||
* method.
|
||||
* <li>Any calls from clients to the <code>service</code> method are handled.
|
||||
* <li>The servlet is taken out of service, then destroyed with the
|
||||
* <code>destroy</code> method, then garbage collected and finalized.
|
||||
* </ol>
|
||||
*
|
||||
* <p>
|
||||
* In addition to the life-cycle methods, this interface provides the
|
||||
* <code>getServletConfig</code> method, which the servlet can use to get any
|
||||
* startup information, and the <code>getServletInfo</code> method, which allows
|
||||
* the servlet to return basic information about itself, such as author,
|
||||
* version, and copyright.
|
||||
*
|
||||
* @see GenericServlet
|
||||
* @see javax.servlet.http.HttpServlet
|
||||
*/
|
||||
public interface Servlet {
|
||||
|
||||
/**
|
||||
* Called by the servlet container to indicate to a servlet that the servlet
|
||||
* is being placed into service.
|
||||
*
|
||||
* <p>
|
||||
* The servlet container calls the <code>init</code> method exactly once
|
||||
* after instantiating the servlet. The <code>init</code> method must
|
||||
* complete successfully before the servlet can receive any requests.
|
||||
*
|
||||
* <p>
|
||||
* The servlet container cannot place the servlet into service if the
|
||||
* <code>init</code> method
|
||||
* <ol>
|
||||
* <li>Throws a <code>ServletException</code>
|
||||
* <li>Does not return within a time period defined by the Web server
|
||||
* </ol>
|
||||
*
|
||||
*
|
||||
* @param config
|
||||
* a <code>ServletConfig</code> object containing the servlet's
|
||||
* configuration and initialization parameters
|
||||
*
|
||||
* @exception ServletException
|
||||
* if an exception has occurred that interferes with the
|
||||
* servlet's normal operation
|
||||
*
|
||||
* @see UnavailableException
|
||||
* @see #getServletConfig
|
||||
*/
|
||||
public void init(ServletConfig config) throws ServletException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns a {@link ServletConfig} object, which contains initialization and
|
||||
* startup parameters for this servlet. The <code>ServletConfig</code>
|
||||
* object returned is the one passed to the <code>init</code> method.
|
||||
*
|
||||
* <p>
|
||||
* Implementations of this interface are responsible for storing the
|
||||
* <code>ServletConfig</code> object so that this method can return it. The
|
||||
* {@link GenericServlet} class, which implements this interface, already
|
||||
* does this.
|
||||
*
|
||||
* @return the <code>ServletConfig</code> object that initializes this
|
||||
* servlet
|
||||
*
|
||||
* @see #init
|
||||
*/
|
||||
public ServletConfig getServletConfig();
|
||||
|
||||
/**
|
||||
* Called by the servlet container to allow the servlet to respond to a
|
||||
* request.
|
||||
*
|
||||
* <p>
|
||||
* This method is only called after the servlet's <code>init()</code> method
|
||||
* has completed successfully.
|
||||
*
|
||||
* <p>
|
||||
* The status code of the response always should be set for a servlet that
|
||||
* throws or sends an error.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Servlets typically run inside multithreaded servlet containers that can
|
||||
* handle multiple requests concurrently. Developers must be aware to
|
||||
* synchronize access to any shared resources such as files, network
|
||||
* connections, and as well as the servlet's class and instance variables.
|
||||
* More information on multithreaded programming in Java is available in <a
|
||||
* href
|
||||
* ="http://java.sun.com/Series/Tutorial/java/threads/multithreaded.html">
|
||||
* the Java tutorial on multi-threaded programming</a>.
|
||||
*
|
||||
*
|
||||
* @param req
|
||||
* the <code>ServletRequest</code> object that contains the
|
||||
* client's request
|
||||
*
|
||||
* @param res
|
||||
* the <code>ServletResponse</code> object that contains the
|
||||
* servlet's response
|
||||
*
|
||||
* @exception ServletException
|
||||
* if an exception occurs that interferes with the servlet's
|
||||
* normal operation
|
||||
*
|
||||
* @exception IOException
|
||||
* if an input or output exception occurs
|
||||
*/
|
||||
public void service(ServletRequest req, ServletResponse res)
|
||||
throws ServletException, IOException;
|
||||
|
||||
/**
|
||||
* Returns information about the servlet, such as author, version, and
|
||||
* copyright.
|
||||
*
|
||||
* <p>
|
||||
* The string that this method returns should be plain text and not markup
|
||||
* of any kind (such as HTML, XML, etc.).
|
||||
*
|
||||
* @return a <code>String</code> containing servlet information
|
||||
*/
|
||||
public String getServletInfo();
|
||||
|
||||
/**
|
||||
* Called by the servlet container to indicate to a servlet that the servlet
|
||||
* is being taken out of service. This method is only called once all
|
||||
* threads within the servlet's <code>service</code> method have exited or
|
||||
* after a timeout period has passed. After the servlet container calls this
|
||||
* method, it will not call the <code>service</code> method again on this
|
||||
* servlet.
|
||||
*
|
||||
* <p>
|
||||
* This method gives the servlet an opportunity to clean up any resources
|
||||
* that are being held (for example, memory, file handles, threads) and make
|
||||
* sure that any persistent state is synchronized with the servlet's current
|
||||
* state in memory.
|
||||
*/
|
||||
public void destroy();
|
||||
}
|
||||
69
java/javax/servlet/ServletConfig.java
Normal file
69
java/javax/servlet/ServletConfig.java
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
* A servlet configuration object used by a servlet container to pass
|
||||
* information to a servlet during initialization.
|
||||
*/
|
||||
public interface ServletConfig {
|
||||
|
||||
/**
|
||||
* Returns the name of this servlet instance. The name may be provided via
|
||||
* server administration, assigned in the web application deployment
|
||||
* descriptor, or for an unregistered (and thus unnamed) servlet instance it
|
||||
* will be the servlet's class name.
|
||||
*
|
||||
* @return the name of the servlet instance
|
||||
*/
|
||||
public String getServletName();
|
||||
|
||||
/**
|
||||
* Returns a reference to the {@link ServletContext} in which the caller is
|
||||
* executing.
|
||||
*
|
||||
* @return a {@link ServletContext} object, used by the caller to interact
|
||||
* with its servlet container
|
||||
* @see ServletContext
|
||||
*/
|
||||
public ServletContext getServletContext();
|
||||
|
||||
/**
|
||||
* Returns a <code>String</code> containing the value of the named
|
||||
* initialization parameter, or <code>null</code> if the parameter does not
|
||||
* exist.
|
||||
*
|
||||
* @param name
|
||||
* a <code>String</code> specifying the name of the
|
||||
* initialization parameter
|
||||
* @return a <code>String</code> containing the value of the initialization
|
||||
* parameter
|
||||
*/
|
||||
public String getInitParameter(String name);
|
||||
|
||||
/**
|
||||
* Returns the names of the servlet's initialization parameters as an
|
||||
* <code>Enumeration</code> of <code>String</code> objects, or an empty
|
||||
* <code>Enumeration</code> if the servlet has no initialization parameters.
|
||||
*
|
||||
* @return an <code>Enumeration</code> of <code>String</code> objects
|
||||
* containing the names of the servlet's initialization parameters
|
||||
*/
|
||||
public Enumeration<String> getInitParameterNames();
|
||||
}
|
||||
53
java/javax/servlet/ServletContainerInitializer.java
Normal file
53
java/javax/servlet/ServletContainerInitializer.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* ServletContainerInitializers (SCIs) are registered via an entry in the
|
||||
* file META-INF/services/javax.servlet.ServletContainerInitializer that must be
|
||||
* included in the JAR file that contains the SCI implementation.
|
||||
* <p>
|
||||
* SCI processing is performed regardless of the setting of metadata-complete.
|
||||
* SCI processing can be controlled per JAR file via fragment ordering. If
|
||||
* absolute ordering is defined, then only the JARs included in the ordering
|
||||
* will be processed for SCIs. To disable SCI processing completely, an empty
|
||||
* absolute ordering may be defined.
|
||||
* <p>
|
||||
* SCIs register an interest in annotations (class, method or field) and/or
|
||||
* types via the {@link javax.servlet.annotation.HandlesTypes} annotation which
|
||||
* is added to the class.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public interface ServletContainerInitializer {
|
||||
|
||||
/**
|
||||
* Receives notification during startup of a web application of the classes
|
||||
* within the web application that matched the criteria defined via the
|
||||
* {@link javax.servlet.annotation.HandlesTypes} annotation.
|
||||
*
|
||||
* @param c The (possibly null) set of classes that met the specified
|
||||
* criteria
|
||||
* @param ctx The ServletContext of the web application in which the
|
||||
* classes were discovered
|
||||
*
|
||||
* @throws ServletException If an error occurs
|
||||
*/
|
||||
void onStartup(Set<Class<?>> c, ServletContext ctx) throws ServletException;
|
||||
}
|
||||
969
java/javax/servlet/ServletContext.java
Normal file
969
java/javax/servlet/ServletContext.java
Normal file
File diff suppressed because it is too large
Load Diff
68
java/javax/servlet/ServletContextAttributeEvent.java
Normal file
68
java/javax/servlet/ServletContextAttributeEvent.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
/**
|
||||
* This is the event class for notifications about changes to the attributes of
|
||||
* the servlet context of a web application.
|
||||
*
|
||||
* @see ServletContextAttributeListener
|
||||
* @since v 2.3
|
||||
*/
|
||||
public class ServletContextAttributeEvent extends ServletContextEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String name;
|
||||
private final Object value;
|
||||
|
||||
/**
|
||||
* Construct a ServletContextAttributeEvent from the given context for the
|
||||
* given attribute name and attribute value.
|
||||
*
|
||||
* @param source The ServletContext associated with this attribute event
|
||||
* @param name The name of the servlet context attribute
|
||||
* @param value The value of the servlet context attribute
|
||||
*/
|
||||
public ServletContextAttributeEvent(ServletContext source, String name,
|
||||
Object value) {
|
||||
super(source);
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the attribute that changed on the ServletContext.
|
||||
*
|
||||
* @return The name of the attribute that changed
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the attribute that has been added, removed, or
|
||||
* replaced.
|
||||
*
|
||||
* @return If the attribute was added, this is the value of the attribute.
|
||||
* If the attribute was removed, this is the value of the removed
|
||||
* attribute. If the attribute was replaced, this is the old value
|
||||
* of the attribute.
|
||||
*/
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
52
java/javax/servlet/ServletContextAttributeListener.java
Normal file
52
java/javax/servlet/ServletContextAttributeListener.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* Implementations of this interface receive notifications of changes to the
|
||||
* attribute list on the servlet context of a web application. To receive
|
||||
* notification events, the implementation class must be configured in the
|
||||
* deployment descriptor for the web application.
|
||||
*
|
||||
* @see ServletContextAttributeEvent
|
||||
* @since v 2.3
|
||||
*/
|
||||
|
||||
public interface ServletContextAttributeListener extends EventListener {
|
||||
/**
|
||||
* Notification that a new attribute was added to the servlet context.
|
||||
* Called after the attribute is added.
|
||||
* @param scae Information about the new attribute
|
||||
*/
|
||||
public void attributeAdded(ServletContextAttributeEvent scae);
|
||||
|
||||
/**
|
||||
* Notification that an existing attribute has been removed from the servlet
|
||||
* context. Called after the attribute is removed.
|
||||
* @param scae Information about the removed attribute
|
||||
*/
|
||||
public void attributeRemoved(ServletContextAttributeEvent scae);
|
||||
|
||||
/**
|
||||
* Notification that an attribute on the servlet context has been replaced.
|
||||
* Called after the attribute is replaced.
|
||||
* @param scae Information about the replaced attribute
|
||||
*/
|
||||
public void attributeReplaced(ServletContextAttributeEvent scae);
|
||||
}
|
||||
48
java/javax/servlet/ServletContextEvent.java
Normal file
48
java/javax/servlet/ServletContextEvent.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
/**
|
||||
* This is the event class for notifications about changes to the servlet
|
||||
* context of a web application.
|
||||
*
|
||||
* @see ServletContextListener
|
||||
* @since v 2.3
|
||||
*/
|
||||
public class ServletContextEvent extends java.util.EventObject {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Construct a ServletContextEvent from the given context.
|
||||
*
|
||||
* @param source
|
||||
* - the ServletContext that is sending the event.
|
||||
*/
|
||||
public ServletContextEvent(ServletContext source) {
|
||||
super(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ServletContext that changed.
|
||||
*
|
||||
* @return the ServletContext that sent the event.
|
||||
*/
|
||||
public ServletContext getServletContext() {
|
||||
return (ServletContext) super.getSource();
|
||||
}
|
||||
}
|
||||
48
java/javax/servlet/ServletContextListener.java
Normal file
48
java/javax/servlet/ServletContextListener.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* Implementations of this interface receive notifications about changes to the
|
||||
* servlet context of the web application they are part of. To receive
|
||||
* notification events, the implementation class must be configured in the
|
||||
* deployment descriptor for the web application.
|
||||
*
|
||||
* @see ServletContextEvent
|
||||
* @since v 2.3
|
||||
*/
|
||||
|
||||
public interface ServletContextListener extends EventListener {
|
||||
|
||||
/**
|
||||
** Notification that the web application initialization process is starting.
|
||||
* All ServletContextListeners are notified of context initialization before
|
||||
* any filter or servlet in the web application is initialized.
|
||||
* @param sce Information about the ServletContext that was initialized
|
||||
*/
|
||||
public void contextInitialized(ServletContextEvent sce);
|
||||
|
||||
/**
|
||||
** Notification that the servlet context is about to be shut down. All
|
||||
* servlets and filters have been destroy()ed before any
|
||||
* ServletContextListeners are notified of context destruction.
|
||||
* @param sce Information about the ServletContext that was destroyed
|
||||
*/
|
||||
public void contextDestroyed(ServletContextEvent sce);
|
||||
}
|
||||
91
java/javax/servlet/ServletException.java
Normal file
91
java/javax/servlet/ServletException.java
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
/**
|
||||
* Defines a general exception a servlet can throw when it encounters
|
||||
* difficulty.
|
||||
*/
|
||||
public class ServletException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructs a new servlet exception.
|
||||
*/
|
||||
public ServletException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new servlet exception with the specified message. The
|
||||
* message can be written to the server log and/or displayed for the user.
|
||||
*
|
||||
* @param message
|
||||
* a <code>String</code> specifying the text of the exception
|
||||
* message
|
||||
*/
|
||||
public ServletException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new servlet exception when the servlet needs to throw an
|
||||
* exception and include a message about the "root cause" exception that
|
||||
* interfered with its normal operation, including a description message.
|
||||
*
|
||||
* @param message
|
||||
* a <code>String</code> containing the text of the exception
|
||||
* message
|
||||
* @param rootCause
|
||||
* the <code>Throwable</code> exception that interfered with the
|
||||
* servlet's normal operation, making this servlet exception
|
||||
* necessary
|
||||
*/
|
||||
public ServletException(String message, Throwable rootCause) {
|
||||
super(message, rootCause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new servlet exception when the servlet needs to throw an
|
||||
* exception and include a message about the "root cause" exception that
|
||||
* interfered with its normal operation. The exception's message is based on
|
||||
* the localized message of the underlying exception.
|
||||
* <p>
|
||||
* This method calls the <code>getLocalizedMessage</code> method on the
|
||||
* <code>Throwable</code> exception to get a localized exception message.
|
||||
* When subclassing <code>ServletException</code>, this method can be
|
||||
* overridden to create an exception message designed for a specific locale.
|
||||
*
|
||||
* @param rootCause
|
||||
* the <code>Throwable</code> exception that interfered with the
|
||||
* servlet's normal operation, making the servlet exception
|
||||
* necessary
|
||||
*/
|
||||
public ServletException(Throwable rootCause) {
|
||||
super(rootCause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exception that caused this servlet exception.
|
||||
*
|
||||
* @return the <code>Throwable</code> that caused this servlet exception
|
||||
*/
|
||||
public Throwable getRootCause() {
|
||||
return getCause();
|
||||
}
|
||||
}
|
||||
121
java/javax/servlet/ServletInputStream.java
Normal file
121
java/javax/servlet/ServletInputStream.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Provides an input stream for reading binary data from a client request,
|
||||
* including an efficient <code>readLine</code> method for reading data one line
|
||||
* at a time. With some protocols, such as HTTP POST and PUT, a
|
||||
* <code>ServletInputStream</code> object can be used to read data sent from the
|
||||
* client.
|
||||
* <p>
|
||||
* A <code>ServletInputStream</code> object is normally retrieved via the
|
||||
* {@link ServletRequest#getInputStream} method.
|
||||
* <p>
|
||||
* This is an abstract class that a servlet container implements. Subclasses of
|
||||
* this class must implement the <code>java.io.InputStream.read()</code> method.
|
||||
*
|
||||
* @see ServletRequest
|
||||
*/
|
||||
public abstract class ServletInputStream extends InputStream {
|
||||
|
||||
/**
|
||||
* Does nothing, because this is an abstract class.
|
||||
*/
|
||||
protected ServletInputStream() {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the input stream, one line at a time. Starting at an offset, reads
|
||||
* bytes into an array, until it reads a certain number of bytes or reaches
|
||||
* a newline character, which it reads into the array as well.
|
||||
* <p>
|
||||
* This method returns -1 if it reaches the end of the input stream before
|
||||
* reading the maximum number of bytes.
|
||||
*
|
||||
* @param b
|
||||
* an array of bytes into which data is read
|
||||
* @param off
|
||||
* an integer specifying the character at which this method
|
||||
* begins reading
|
||||
* @param len
|
||||
* an integer specifying the maximum number of bytes to read
|
||||
* @return an integer specifying the actual number of bytes read, or -1 if
|
||||
* the end of the stream is reached
|
||||
* @exception IOException
|
||||
* if an input or output exception has occurred
|
||||
*/
|
||||
public int readLine(byte[] b, int off, int len) throws IOException {
|
||||
|
||||
if (len <= 0) {
|
||||
return 0;
|
||||
}
|
||||
int count = 0, c;
|
||||
|
||||
while ((c = read()) != -1) {
|
||||
b[off++] = (byte) c;
|
||||
count++;
|
||||
if (c == '\n' || count == len) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return count > 0 ? count : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the end of this InputStream been reached?
|
||||
*
|
||||
* @return <code>true</code> if all the data has been read from the stream,
|
||||
* else <code>false</code>
|
||||
*
|
||||
* @since Servlet 3.1
|
||||
*/
|
||||
public abstract boolean isFinished();
|
||||
|
||||
/**
|
||||
* Can data be read from this InputStream without blocking?
|
||||
* Returns If this method is called and returns false, the container will
|
||||
* invoke {@link ReadListener#onDataAvailable()} when data is available.
|
||||
*
|
||||
* @return <code>true</code> if data can be read without blocking, else
|
||||
* <code>false</code>
|
||||
*
|
||||
* @since Servlet 3.1
|
||||
*/
|
||||
public abstract boolean isReady();
|
||||
|
||||
/**
|
||||
* Sets the {@link ReadListener} for this {@link ServletInputStream} and
|
||||
* thereby switches to non-blocking IO. It is only valid to switch to
|
||||
* non-blocking IO within async processing or HTTP upgrade processing.
|
||||
*
|
||||
* @param listener The non-blocking IO read listener
|
||||
*
|
||||
* @throws IllegalStateException If this method is called if neither
|
||||
* async nor HTTP upgrade is in progress or
|
||||
* if the {@link ReadListener} has already
|
||||
* been set
|
||||
* @throws NullPointerException If listener is null
|
||||
*
|
||||
* @since Servlet 3.1
|
||||
*/
|
||||
public abstract void setReadListener(ReadListener listener);
|
||||
}
|
||||
309
java/javax/servlet/ServletOutputStream.java
Normal file
309
java/javax/servlet/ServletOutputStream.java
Normal file
@@ -0,0 +1,309 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.io.CharConversionException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Provides an output stream for sending binary data to the client. A
|
||||
* <code>ServletOutputStream</code> object is normally retrieved via the
|
||||
* {@link ServletResponse#getOutputStream} method.
|
||||
* <p>
|
||||
* This is an abstract class that the servlet container implements. Subclasses
|
||||
* of this class must implement the <code>java.io.OutputStream.write(int)</code>
|
||||
* method.
|
||||
*
|
||||
* @see ServletResponse
|
||||
*/
|
||||
public abstract class ServletOutputStream extends OutputStream {
|
||||
|
||||
private static final String LSTRING_FILE = "javax.servlet.LocalStrings";
|
||||
private static final ResourceBundle lStrings = ResourceBundle.getBundle(LSTRING_FILE);
|
||||
|
||||
/**
|
||||
* Does nothing, because this is an abstract class.
|
||||
*/
|
||||
protected ServletOutputStream() {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>String</code> to the client, without a carriage
|
||||
* return-line feed (CRLF) character at the end.
|
||||
*
|
||||
* @param s
|
||||
* the <code>String</code> to send to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void print(String s) throws IOException {
|
||||
if (s == null) {
|
||||
s = "null";
|
||||
}
|
||||
int len = s.length();
|
||||
byte[] buffer = new byte[len];
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
char c = s.charAt(i);
|
||||
|
||||
//
|
||||
// XXX NOTE: This is clearly incorrect for many strings,
|
||||
// but is the only consistent approach within the current
|
||||
// servlet framework. It must suffice until servlet output
|
||||
// streams properly encode their output.
|
||||
//
|
||||
if ((c & 0xff00) != 0) { // high order byte must be zero
|
||||
String errMsg = lStrings.getString("err.not_iso8859_1");
|
||||
Object[] errArgs = new Object[1];
|
||||
errArgs[0] = Character.valueOf(c);
|
||||
errMsg = MessageFormat.format(errMsg, errArgs);
|
||||
throw new CharConversionException(errMsg);
|
||||
}
|
||||
buffer[i] = (byte) (c & 0xFF);
|
||||
}
|
||||
write(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>boolean</code> value to the client, with no carriage
|
||||
* return-line feed (CRLF) character at the end.
|
||||
*
|
||||
* @param b
|
||||
* the <code>boolean</code> value to send to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void print(boolean b) throws IOException {
|
||||
String msg;
|
||||
if (b) {
|
||||
msg = lStrings.getString("value.true");
|
||||
} else {
|
||||
msg = lStrings.getString("value.false");
|
||||
}
|
||||
print(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a character to the client, with no carriage return-line feed
|
||||
* (CRLF) at the end.
|
||||
*
|
||||
* @param c
|
||||
* the character to send to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void print(char c) throws IOException {
|
||||
print(String.valueOf(c));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an int to the client, with no carriage return-line feed (CRLF) at
|
||||
* the end.
|
||||
*
|
||||
* @param i
|
||||
* the int to send to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void print(int i) throws IOException {
|
||||
print(String.valueOf(i));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>long</code> value to the client, with no carriage
|
||||
* return-line feed (CRLF) at the end.
|
||||
*
|
||||
* @param l
|
||||
* the <code>long</code> value to send to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void print(long l) throws IOException {
|
||||
print(String.valueOf(l));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>float</code> value to the client, with no carriage
|
||||
* return-line feed (CRLF) at the end.
|
||||
*
|
||||
* @param f
|
||||
* the <code>float</code> value to send to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void print(float f) throws IOException {
|
||||
print(String.valueOf(f));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>double</code> value to the client, with no carriage
|
||||
* return-line feed (CRLF) at the end.
|
||||
*
|
||||
* @param d
|
||||
* the <code>double</code> value to send to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void print(double d) throws IOException {
|
||||
print(String.valueOf(d));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a carriage return-line feed (CRLF) to the client.
|
||||
*
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void println() throws IOException {
|
||||
print("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>String</code> to the client, followed by a carriage
|
||||
* return-line feed (CRLF).
|
||||
*
|
||||
* @param s
|
||||
* the <code>String</code> to write to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void println(String s) throws IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(s);
|
||||
sb.append("\r\n");
|
||||
print(sb.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>boolean</code> value to the client, followed by a carriage
|
||||
* return-line feed (CRLF).
|
||||
*
|
||||
* @param b
|
||||
* the <code>boolean</code> value to write to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void println(boolean b) throws IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (b) {
|
||||
sb.append(lStrings.getString("value.true"));
|
||||
} else {
|
||||
sb.append(lStrings.getString("value.false"));
|
||||
}
|
||||
sb.append("\r\n");
|
||||
print(sb.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a character to the client, followed by a carriage return-line feed
|
||||
* (CRLF).
|
||||
*
|
||||
* @param c
|
||||
* the character to write to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void println(char c) throws IOException {
|
||||
println(String.valueOf(c));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an int to the client, followed by a carriage return-line feed
|
||||
* (CRLF) character.
|
||||
*
|
||||
* @param i
|
||||
* the int to write to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void println(int i) throws IOException {
|
||||
println(String.valueOf(i));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>long</code> value to the client, followed by a carriage
|
||||
* return-line feed (CRLF).
|
||||
*
|
||||
* @param l
|
||||
* the <code>long</code> value to write to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void println(long l) throws IOException {
|
||||
println(String.valueOf(l));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>float</code> value to the client, followed by a carriage
|
||||
* return-line feed (CRLF).
|
||||
*
|
||||
* @param f
|
||||
* the <code>float</code> value to write to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void println(float f) throws IOException {
|
||||
println(String.valueOf(f));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>double</code> value to the client, followed by a carriage
|
||||
* return-line feed (CRLF).
|
||||
*
|
||||
* @param d
|
||||
* the <code>double</code> value to write to the client
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
*/
|
||||
public void println(double d) throws IOException {
|
||||
println(String.valueOf(d));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a non-blocking write will succeed. If this returns
|
||||
* <code>false</code>, it will cause a callback to
|
||||
* {@link WriteListener#onWritePossible()} when the buffer has emptied. If
|
||||
* this method returns <code>false</code> no further data must be written
|
||||
* until the contain calls {@link WriteListener#onWritePossible()}.
|
||||
*
|
||||
* @return <code>true</code> if data can be written, else <code>false</code>
|
||||
*
|
||||
* @since Servlet 3.1
|
||||
*/
|
||||
public abstract boolean isReady();
|
||||
|
||||
/**
|
||||
* Sets the {@link WriteListener} for this {@link ServletOutputStream} and
|
||||
* thereby switches to non-blocking IO. It is only valid to switch to
|
||||
* non-blocking IO within async processing or HTTP upgrade processing.
|
||||
*
|
||||
* @param listener The non-blocking IO write listener
|
||||
*
|
||||
* @throws IllegalStateException If this method is called if neither
|
||||
* async nor HTTP upgrade is in progress or
|
||||
* if the {@link WriteListener} has already
|
||||
* been set
|
||||
* @throws NullPointerException If listener is null
|
||||
*
|
||||
* @since Servlet 3.1
|
||||
*/
|
||||
public abstract void setWriteListener(javax.servlet.WriteListener listener);
|
||||
}
|
||||
49
java/javax/servlet/ServletRegistration.java
Normal file
49
java/javax/servlet/ServletRegistration.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* TODO SERVLET3 - Add comments
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public interface ServletRegistration extends Registration {
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @param urlPatterns The URL patterns that this Servlet should be mapped to
|
||||
* @return TODO
|
||||
* @throws IllegalArgumentException if urlPattern is null or empty
|
||||
* @throws IllegalStateException if the associated ServletContext has
|
||||
* already been initialised
|
||||
*/
|
||||
public Set<String> addMapping(String... urlPatterns);
|
||||
|
||||
public Collection<String> getMappings();
|
||||
|
||||
public String getRunAsRole();
|
||||
|
||||
public static interface Dynamic
|
||||
extends ServletRegistration, Registration.Dynamic {
|
||||
public void setLoadOnStartup(int loadOnStartup);
|
||||
public void setMultipartConfig(MultipartConfigElement multipartConfig);
|
||||
public void setRunAsRole(String roleName);
|
||||
public Set<String> setServletSecurity(ServletSecurityElement constraint);
|
||||
}
|
||||
}
|
||||
501
java/javax/servlet/ServletRequest.java
Normal file
501
java/javax/servlet/ServletRequest.java
Normal file
File diff suppressed because it is too large
Load Diff
73
java/javax/servlet/ServletRequestAttributeEvent.java
Normal file
73
java/javax/servlet/ServletRequestAttributeEvent.java
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
/**
|
||||
* This is the event class for notifications of changes to the attributes of the
|
||||
* servlet request in an application.
|
||||
*
|
||||
* @see ServletRequestAttributeListener
|
||||
* @since Servlet 2.4
|
||||
*/
|
||||
public class ServletRequestAttributeEvent extends ServletRequestEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String name;
|
||||
private final Object value;
|
||||
|
||||
/**
|
||||
* Construct a ServletRequestAttributeEvent giving the servlet context of
|
||||
* this web application, the ServletRequest whose attributes are changing
|
||||
* and the name and value of the attribute.
|
||||
*
|
||||
* @param sc
|
||||
* the ServletContext that is sending the event.
|
||||
* @param request
|
||||
* the ServletRequest that is sending the event.
|
||||
* @param name
|
||||
* the name of the request attribute.
|
||||
* @param value
|
||||
* the value of the request attribute.
|
||||
*/
|
||||
public ServletRequestAttributeEvent(ServletContext sc,
|
||||
ServletRequest request, String name, Object value) {
|
||||
super(sc, request);
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the attribute that changed on the ServletRequest.
|
||||
*
|
||||
* @return the name of the changed request attribute
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the attribute that has been added, removed or
|
||||
* replaced. If the attribute was added, this is the value of the attribute.
|
||||
* If the attribute was removed, this is the value of the removed attribute.
|
||||
* If the attribute was replaced, this is the old value of the attribute.
|
||||
*
|
||||
* @return the value of the changed request attribute
|
||||
*/
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
55
java/javax/servlet/ServletRequestAttributeListener.java
Normal file
55
java/javax/servlet/ServletRequestAttributeListener.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* A ServletRequestAttributeListener can be implemented by the
|
||||
* developer interested in being notified of request attribute
|
||||
* changes. Notifications will be generated while the request
|
||||
* is within the scope of the web application in which the listener
|
||||
* is registered. A request is defined as coming into scope when
|
||||
* it is about to enter the first servlet or filter in each web
|
||||
* application, as going out of scope when it exits the last servlet
|
||||
* or the first filter in the chain.
|
||||
*
|
||||
* @since Servlet 2.4
|
||||
*/
|
||||
public interface ServletRequestAttributeListener extends EventListener {
|
||||
/**
|
||||
* Notification that a new attribute was added to the
|
||||
* servlet request. Called after the attribute is added.
|
||||
* @param srae Information about the new request attribute
|
||||
*/
|
||||
public void attributeAdded(ServletRequestAttributeEvent srae);
|
||||
|
||||
/**
|
||||
* Notification that an existing attribute has been removed from the
|
||||
* servlet request. Called after the attribute is removed.
|
||||
* @param srae Information about the removed request attribute
|
||||
*/
|
||||
public void attributeRemoved(ServletRequestAttributeEvent srae);
|
||||
|
||||
/**
|
||||
* Notification that an attribute was replaced on the
|
||||
* servlet request. Called after the attribute is replaced.
|
||||
* @param srae Information about the replaced request attribute
|
||||
*/
|
||||
public void attributeReplaced(ServletRequestAttributeEvent srae);
|
||||
}
|
||||
|
||||
60
java/javax/servlet/ServletRequestEvent.java
Normal file
60
java/javax/servlet/ServletRequestEvent.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
/**
|
||||
* Events of this kind indicate lifecycle events for a ServletRequest. The
|
||||
* source of the event is the ServletContext of this web application.
|
||||
*
|
||||
* @see ServletRequestListener
|
||||
* @since Servlet 2.4
|
||||
*/
|
||||
public class ServletRequestEvent extends java.util.EventObject {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final transient ServletRequest request;
|
||||
|
||||
/**
|
||||
* Construct a ServletRequestEvent for the given ServletContext and
|
||||
* ServletRequest.
|
||||
*
|
||||
* @param sc
|
||||
* the ServletContext of the web application.
|
||||
* @param request
|
||||
* the ServletRequest that is sending the event.
|
||||
*/
|
||||
public ServletRequestEvent(ServletContext sc, ServletRequest request) {
|
||||
super(sc);
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated ServletRequest.
|
||||
* @return the ServletRequest that is changing.
|
||||
*/
|
||||
public ServletRequest getServletRequest() {
|
||||
return this.request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated ServletContext.
|
||||
* @return the ServletContext that is changing.
|
||||
*/
|
||||
public ServletContext getServletContext() {
|
||||
return (ServletContext) super.getSource();
|
||||
}
|
||||
}
|
||||
44
java/javax/servlet/ServletRequestListener.java
Normal file
44
java/javax/servlet/ServletRequestListener.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* A ServletRequestListener can be implemented by the developer
|
||||
* interested in being notified of requests coming in and out of
|
||||
* scope in a web component. A request is defined as coming into
|
||||
* scope when it is about to enter the first servlet or filter
|
||||
* in each web application, as going out of scope when it exits
|
||||
* the last servlet or the first filter in the chain.
|
||||
*
|
||||
* @since Servlet 2.4
|
||||
*/
|
||||
public interface ServletRequestListener extends EventListener {
|
||||
|
||||
/**
|
||||
* The request is about to go out of scope of the web application.
|
||||
* @param sre Information about the request
|
||||
*/
|
||||
public void requestDestroyed (ServletRequestEvent sre);
|
||||
|
||||
/**
|
||||
* The request is about to come into scope of the web application.
|
||||
* @param sre Information about the request
|
||||
*/
|
||||
public void requestInitialized (ServletRequestEvent sre);
|
||||
}
|
||||
481
java/javax/servlet/ServletRequestWrapper.java
Normal file
481
java/javax/servlet/ServletRequestWrapper.java
Normal file
@@ -0,0 +1,481 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Provides a convenient implementation of the ServletRequest interface that can
|
||||
* be subclassed by developers wishing to adapt the request to a Servlet. This
|
||||
* class implements the Wrapper or Decorator pattern. Methods default to calling
|
||||
* through to the wrapped request object.
|
||||
*
|
||||
* @since Servlet 2.3
|
||||
* @see javax.servlet.ServletRequest
|
||||
*/
|
||||
public class ServletRequestWrapper implements ServletRequest {
|
||||
private ServletRequest request;
|
||||
|
||||
/**
|
||||
* Creates a ServletRequest adaptor wrapping the given request object.
|
||||
*
|
||||
* @param request The request to wrap
|
||||
*
|
||||
* @throws IllegalArgumentException if the request is null
|
||||
*/
|
||||
public ServletRequestWrapper(ServletRequest request) {
|
||||
if (request == null) {
|
||||
throw new IllegalArgumentException("Request cannot be null");
|
||||
}
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the wrapped request.
|
||||
* @return the wrapped request object
|
||||
*/
|
||||
public ServletRequest getRequest() {
|
||||
return this.request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the request object being wrapped.
|
||||
* @param request The new wrapped request.
|
||||
*
|
||||
* @throws IllegalArgumentException if the request is null.
|
||||
*/
|
||||
public void setRequest(ServletRequest request) {
|
||||
if (request == null) {
|
||||
throw new IllegalArgumentException("Request cannot be null");
|
||||
}
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to call getAttribute(String name)
|
||||
* on the wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
return this.request.getAttribute(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getAttributeNames() on
|
||||
* the wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
return this.request.getAttributeNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getCharacterEncoding()
|
||||
* on the wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return this.request.getCharacterEncoding();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to set the character encoding on
|
||||
* the wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public void setCharacterEncoding(String enc)
|
||||
throws java.io.UnsupportedEncodingException {
|
||||
this.request.setCharacterEncoding(enc);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getContentLength() on
|
||||
* the wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public int getContentLength() {
|
||||
return this.request.getContentLength();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getContentLengthLong()
|
||||
* on the wrapped request object.
|
||||
*
|
||||
* @since Servlet 3.1
|
||||
*/
|
||||
@Override
|
||||
public long getContentLengthLong() {
|
||||
return this.request.getContentLengthLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getContentType() on the
|
||||
* wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return this.request.getContentType();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getInputStream() on the
|
||||
* wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
return this.request.getInputStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getParameter(String
|
||||
* name) on the wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public String getParameter(String name) {
|
||||
return this.request.getParameter(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getParameterMap() on the
|
||||
* wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String[]> getParameterMap() {
|
||||
return this.request.getParameterMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getParameterNames() on
|
||||
* the wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public Enumeration<String> getParameterNames() {
|
||||
return this.request.getParameterNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return
|
||||
* getParameterValues(String name) on the wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
return this.request.getParameterValues(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getProtocol() on the
|
||||
* wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public String getProtocol() {
|
||||
return this.request.getProtocol();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getScheme() on the
|
||||
* wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public String getScheme() {
|
||||
return this.request.getScheme();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getServerName() on the
|
||||
* wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return this.request.getServerName();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getServerPort() on the
|
||||
* wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public int getServerPort() {
|
||||
return this.request.getServerPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getReader() on the
|
||||
* wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public BufferedReader getReader() throws IOException {
|
||||
return this.request.getReader();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getRemoteAddr() on the
|
||||
* wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public String getRemoteAddr() {
|
||||
return this.request.getRemoteAddr();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getRemoteHost() on the
|
||||
* wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public String getRemoteHost() {
|
||||
return this.request.getRemoteHost();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return setAttribute(String
|
||||
* name, Object o) on the wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public void setAttribute(String name, Object o) {
|
||||
this.request.setAttribute(name, o);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to call removeAttribute(String
|
||||
* name) on the wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
this.request.removeAttribute(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getLocale() on the
|
||||
* wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return this.request.getLocale();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getLocales() on the
|
||||
* wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public Enumeration<Locale> getLocales() {
|
||||
return this.request.getLocales();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return isSecure() on the
|
||||
* wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return this.request.isSecure();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return
|
||||
* getRequestDispatcher(String path) on the wrapped request object.
|
||||
*/
|
||||
@Override
|
||||
public RequestDispatcher getRequestDispatcher(String path) {
|
||||
return this.request.getRequestDispatcher(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getRealPath(String path)
|
||||
* on the wrapped request object.
|
||||
*
|
||||
* @deprecated As of Version 3.0 of the Java Servlet API
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("dep-ann")
|
||||
// Spec API does not use @Deprecated
|
||||
public String getRealPath(String path) {
|
||||
return this.request.getRealPath(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getRemotePort() on the
|
||||
* wrapped request object.
|
||||
*
|
||||
* @since Servlet 2.4
|
||||
*/
|
||||
@Override
|
||||
public int getRemotePort() {
|
||||
return this.request.getRemotePort();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getLocalName() on the
|
||||
* wrapped request object.
|
||||
*
|
||||
* @since Servlet 2.4
|
||||
*/
|
||||
@Override
|
||||
public String getLocalName() {
|
||||
return this.request.getLocalName();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getLocalAddr() on the
|
||||
* wrapped request object.
|
||||
*
|
||||
* @since Servlet 2.4
|
||||
*/
|
||||
@Override
|
||||
public String getLocalAddr() {
|
||||
return this.request.getLocalAddr();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getLocalPort() on the
|
||||
* wrapped request object.
|
||||
*
|
||||
* @since Servlet 2.4
|
||||
*/
|
||||
@Override
|
||||
public int getLocalPort() {
|
||||
return this.request.getLocalPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getServletContext() on
|
||||
* the wrapped request object.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return request.getServletContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return startAsync() on the
|
||||
* wrapped request object.
|
||||
*
|
||||
* @throws IllegalStateException If asynchronous processing is not supported
|
||||
* for this request or if the request is already in asynchronous
|
||||
* mode
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
@Override
|
||||
public AsyncContext startAsync() throws IllegalStateException {
|
||||
return request.startAsync();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return startAsync(Runnable) on
|
||||
* the wrapped request object.
|
||||
*
|
||||
* @param servletRequest The ServletRequest with which to initialise the
|
||||
* asynchronous context
|
||||
* @param servletResponse The ServletResponse with which to initialise the
|
||||
* asynchronous context
|
||||
* @throws IllegalStateException If asynchronous processing is not supported
|
||||
* for this request or if the request is already in asynchronous
|
||||
* mode
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
@Override
|
||||
public AsyncContext startAsync(ServletRequest servletRequest,
|
||||
ServletResponse servletResponse) throws IllegalStateException {
|
||||
return request.startAsync(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return isAsyncStarted() on the
|
||||
* wrapped request object.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
@Override
|
||||
public boolean isAsyncStarted() {
|
||||
return request.isAsyncStarted();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return isAsyncSupported() on
|
||||
* the wrapped request object.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
@Override
|
||||
public boolean isAsyncSupported() {
|
||||
return request.isAsyncSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getAsyncContext() on the
|
||||
* wrapped request object.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
@Override
|
||||
public AsyncContext getAsyncContext() {
|
||||
return request.getAsyncContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO SERVLET3 - Add comments
|
||||
* @param wrapped The request to compare to the wrapped request
|
||||
* @return <code>true</code> if the request wrapped by this wrapper (or
|
||||
* series of wrappers) is the same as the supplied request,
|
||||
* otherwise <code>false</code>
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public boolean isWrapperFor(ServletRequest wrapped) {
|
||||
if (request == wrapped) {
|
||||
return true;
|
||||
}
|
||||
if (request instanceof ServletRequestWrapper) {
|
||||
return ((ServletRequestWrapper) request).isWrapperFor(wrapped);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO SERVLET3 - Add comments
|
||||
* @param wrappedType The class to compare to the class of the wrapped
|
||||
* request
|
||||
* @return <code>true</code> if the request wrapped by this wrapper (or
|
||||
* series of wrappers) is the same type as the supplied type,
|
||||
* otherwise <code>false</code>
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public boolean isWrapperFor(Class<?> wrappedType) {
|
||||
if (wrappedType.isAssignableFrom(request.getClass())) {
|
||||
return true;
|
||||
}
|
||||
if (request instanceof ServletRequestWrapper) {
|
||||
return ((ServletRequestWrapper) request).isWrapperFor(wrappedType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to call getDispatcherType() on the
|
||||
* wrapped request object.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
@Override
|
||||
public DispatcherType getDispatcherType() {
|
||||
return this.request.getDispatcherType();
|
||||
}
|
||||
}
|
||||
354
java/javax/servlet/ServletResponse.java
Normal file
354
java/javax/servlet/ServletResponse.java
Normal file
@@ -0,0 +1,354 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Defines an object to assist a servlet in sending a response to the client.
|
||||
* The servlet container creates a <code>ServletResponse</code> object and
|
||||
* passes it as an argument to the servlet's <code>service</code> method.
|
||||
* <p>
|
||||
* To send binary data in a MIME body response, use the
|
||||
* {@link ServletOutputStream} returned by {@link #getOutputStream}. To send
|
||||
* character data, use the <code>PrintWriter</code> object returned by
|
||||
* {@link #getWriter}. To mix binary and text data, for example, to create a
|
||||
* multipart response, use a <code>ServletOutputStream</code> and manage the
|
||||
* character sections manually.
|
||||
* <p>
|
||||
* The charset for the MIME body response can be specified explicitly using the
|
||||
* {@link #setCharacterEncoding} and {@link #setContentType} methods, or
|
||||
* implicitly using the {@link #setLocale} method. Explicit specifications take
|
||||
* precedence over implicit specifications. If no charset is specified,
|
||||
* ISO-8859-1 will be used. The <code>setCharacterEncoding</code>,
|
||||
* <code>setContentType</code>, or <code>setLocale</code> method must be called
|
||||
* before <code>getWriter</code> and before committing the response for the
|
||||
* character encoding to be used.
|
||||
* <p>
|
||||
* See the Internet RFCs such as <a href="http://www.ietf.org/rfc/rfc2045.txt">
|
||||
* RFC 2045</a> for more information on MIME. Protocols such as SMTP and HTTP
|
||||
* define profiles of MIME, and those standards are still evolving.
|
||||
*
|
||||
* @see ServletOutputStream
|
||||
*/
|
||||
public interface ServletResponse {
|
||||
|
||||
/**
|
||||
* Returns the name of the character encoding (MIME charset) used for the
|
||||
* body sent in this response. The character encoding may have been
|
||||
* specified explicitly using the {@link #setCharacterEncoding} or
|
||||
* {@link #setContentType} methods, or implicitly using the
|
||||
* {@link #setLocale} method. Explicit specifications take precedence over
|
||||
* implicit specifications. Calls made to these methods after
|
||||
* <code>getWriter</code> has been called or after the response has been
|
||||
* committed have no effect on the character encoding. If no character
|
||||
* encoding has been specified, <code>ISO-8859-1</code> is returned.
|
||||
* <p>
|
||||
* See RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt) for more information
|
||||
* about character encoding and MIME.
|
||||
*
|
||||
* @return a <code>String</code> specifying the name of the character
|
||||
* encoding, for example, <code>UTF-8</code>
|
||||
*/
|
||||
public String getCharacterEncoding();
|
||||
|
||||
/**
|
||||
* Returns the content type used for the MIME body sent in this response.
|
||||
* The content type proper must have been specified using
|
||||
* {@link #setContentType} before the response is committed. If no content
|
||||
* type has been specified, this method returns null. If a content type has
|
||||
* been specified and a character encoding has been explicitly or implicitly
|
||||
* specified as described in {@link #getCharacterEncoding}, the charset
|
||||
* parameter is included in the string returned. If no character encoding
|
||||
* has been specified, the charset parameter is omitted.
|
||||
*
|
||||
* @return a <code>String</code> specifying the content type, for example,
|
||||
* <code>text/html; charset=UTF-8</code>, or null
|
||||
* @since 2.4
|
||||
*/
|
||||
public String getContentType();
|
||||
|
||||
/**
|
||||
* Returns a {@link ServletOutputStream} suitable for writing binary data in
|
||||
* the response. The servlet container does not encode the binary data.
|
||||
* <p>
|
||||
* Calling flush() on the ServletOutputStream commits the response. Either
|
||||
* this method or {@link #getWriter} may be called to write the body, not
|
||||
* both.
|
||||
*
|
||||
* @return a {@link ServletOutputStream} for writing binary data
|
||||
* @exception IllegalStateException
|
||||
* if the <code>getWriter</code> method has been called on
|
||||
* this response
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
* @see #getWriter
|
||||
*/
|
||||
public ServletOutputStream getOutputStream() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns a <code>PrintWriter</code> object that can send character text to
|
||||
* the client. The <code>PrintWriter</code> uses the character encoding
|
||||
* returned by {@link #getCharacterEncoding}. If the response's character
|
||||
* encoding has not been specified as described in
|
||||
* <code>getCharacterEncoding</code> (i.e., the method just returns the
|
||||
* default value <code>ISO-8859-1</code>), <code>getWriter</code> updates it
|
||||
* to <code>ISO-8859-1</code>.
|
||||
* <p>
|
||||
* Calling flush() on the <code>PrintWriter</code> commits the response.
|
||||
* <p>
|
||||
* Either this method or {@link #getOutputStream} may be called to write the
|
||||
* body, not both.
|
||||
*
|
||||
* @return a <code>PrintWriter</code> object that can return character data
|
||||
* to the client
|
||||
* @exception java.io.UnsupportedEncodingException
|
||||
* if the character encoding returned by
|
||||
* <code>getCharacterEncoding</code> cannot be used
|
||||
* @exception IllegalStateException
|
||||
* if the <code>getOutputStream</code> method has already
|
||||
* been called for this response object
|
||||
* @exception IOException
|
||||
* if an input or output exception occurred
|
||||
* @see #getOutputStream
|
||||
* @see #setCharacterEncoding
|
||||
*/
|
||||
public PrintWriter getWriter() throws IOException;
|
||||
|
||||
/**
|
||||
* Sets the character encoding (MIME charset) of the response being sent to
|
||||
* the client, for example, to UTF-8. If the character encoding has already
|
||||
* been set by {@link #setContentType} or {@link #setLocale}, this method
|
||||
* overrides it. Calling {@link #setContentType} with the
|
||||
* <code>String</code> of <code>text/html</code> and calling this method
|
||||
* with the <code>String</code> of <code>UTF-8</code> is equivalent with
|
||||
* calling <code>setContentType</code> with the <code>String</code> of
|
||||
* <code>text/html; charset=UTF-8</code>.
|
||||
* <p>
|
||||
* This method can be called repeatedly to change the character encoding.
|
||||
* This method has no effect if it is called after <code>getWriter</code>
|
||||
* has been called or after the response has been committed.
|
||||
* <p>
|
||||
* Containers must communicate the character encoding used for the servlet
|
||||
* response's writer to the client if the protocol provides a way for doing
|
||||
* so. In the case of HTTP, the character encoding is communicated as part
|
||||
* of the <code>Content-Type</code> header for text media types. Note that
|
||||
* the character encoding cannot be communicated via HTTP headers if the
|
||||
* servlet does not specify a content type; however, it is still used to
|
||||
* encode text written via the servlet response's writer.
|
||||
*
|
||||
* @param charset
|
||||
* a String specifying only the character set defined by IANA
|
||||
* Character Sets
|
||||
* (http://www.iana.org/assignments/character-sets)
|
||||
* @see #setContentType #setLocale
|
||||
* @since 2.4
|
||||
*/
|
||||
public void setCharacterEncoding(String charset);
|
||||
|
||||
/**
|
||||
* Sets the length of the content body in the response In HTTP servlets,
|
||||
* this method sets the HTTP Content-Length header.
|
||||
*
|
||||
* @param len
|
||||
* an integer specifying the length of the content being returned
|
||||
* to the client; sets the Content-Length header
|
||||
*/
|
||||
public void setContentLength(int len);
|
||||
|
||||
/**
|
||||
* Sets the length of the content body in the response In HTTP servlets,
|
||||
* this method sets the HTTP Content-Length header.
|
||||
*
|
||||
* @param length
|
||||
* an integer specifying the length of the content being returned
|
||||
* to the client; sets the Content-Length header
|
||||
*
|
||||
* @since Servlet 3.1
|
||||
*/
|
||||
public void setContentLengthLong(long length);
|
||||
|
||||
/**
|
||||
* Sets the content type of the response being sent to the client, if the
|
||||
* response has not been committed yet. The given content type may include a
|
||||
* character encoding specification, for example,
|
||||
* <code>text/html;charset=UTF-8</code>. The response's character encoding
|
||||
* is only set from the given content type if this method is called before
|
||||
* <code>getWriter</code> is called.
|
||||
* <p>
|
||||
* This method may be called repeatedly to change content type and character
|
||||
* encoding. This method has no effect if called after the response has been
|
||||
* committed. It does not set the response's character encoding if it is
|
||||
* called after <code>getWriter</code> has been called or after the response
|
||||
* has been committed.
|
||||
* <p>
|
||||
* Containers must communicate the content type and the character encoding
|
||||
* used for the servlet response's writer to the client if the protocol
|
||||
* provides a way for doing so. In the case of HTTP, the
|
||||
* <code>Content-Type</code> header is used.
|
||||
*
|
||||
* @param type
|
||||
* a <code>String</code> specifying the MIME type of the content
|
||||
* @see #setLocale
|
||||
* @see #setCharacterEncoding
|
||||
* @see #getOutputStream
|
||||
* @see #getWriter
|
||||
*/
|
||||
public void setContentType(String type);
|
||||
|
||||
/**
|
||||
* Sets the preferred buffer size for the body of the response. The servlet
|
||||
* container will use a buffer at least as large as the size requested. The
|
||||
* actual buffer size used can be found using <code>getBufferSize</code>.
|
||||
* <p>
|
||||
* A larger buffer allows more content to be written before anything is
|
||||
* actually sent, thus providing the servlet with more time to set
|
||||
* appropriate status codes and headers. A smaller buffer decreases server
|
||||
* memory load and allows the client to start receiving data more quickly.
|
||||
* <p>
|
||||
* This method must be called before any response body content is written;
|
||||
* if content has been written or the response object has been committed,
|
||||
* this method throws an <code>IllegalStateException</code>.
|
||||
*
|
||||
* @param size
|
||||
* the preferred buffer size
|
||||
* @exception IllegalStateException
|
||||
* if this method is called after content has been written
|
||||
* @see #getBufferSize
|
||||
* @see #flushBuffer
|
||||
* @see #isCommitted
|
||||
* @see #reset
|
||||
*/
|
||||
public void setBufferSize(int size);
|
||||
|
||||
/**
|
||||
* Returns the actual buffer size used for the response. If no buffering is
|
||||
* used, this method returns 0.
|
||||
*
|
||||
* @return the actual buffer size used
|
||||
* @see #setBufferSize
|
||||
* @see #flushBuffer
|
||||
* @see #isCommitted
|
||||
* @see #reset
|
||||
*/
|
||||
public int getBufferSize();
|
||||
|
||||
/**
|
||||
* Forces any content in the buffer to be written to the client. A call to
|
||||
* this method automatically commits the response, meaning the status code
|
||||
* and headers will be written.
|
||||
*
|
||||
* @throws IOException if an I/O occurs during the flushing of the response
|
||||
*
|
||||
* @see #setBufferSize
|
||||
* @see #getBufferSize
|
||||
* @see #isCommitted
|
||||
* @see #reset
|
||||
*/
|
||||
public void flushBuffer() throws IOException;
|
||||
|
||||
/**
|
||||
* Clears the content of the underlying buffer in the response without
|
||||
* clearing headers or status code. If the response has been committed, this
|
||||
* method throws an <code>IllegalStateException</code>.
|
||||
*
|
||||
* @see #setBufferSize
|
||||
* @see #getBufferSize
|
||||
* @see #isCommitted
|
||||
* @see #reset
|
||||
* @since 2.3
|
||||
*/
|
||||
public void resetBuffer();
|
||||
|
||||
/**
|
||||
* Returns a boolean indicating if the response has been committed. A
|
||||
* committed response has already had its status code and headers written.
|
||||
*
|
||||
* @return a boolean indicating if the response has been committed
|
||||
* @see #setBufferSize
|
||||
* @see #getBufferSize
|
||||
* @see #flushBuffer
|
||||
* @see #reset
|
||||
*/
|
||||
public boolean isCommitted();
|
||||
|
||||
/**
|
||||
* Clears any data that exists in the buffer as well as the status code and
|
||||
* headers. If the response has been committed, this method throws an
|
||||
* <code>IllegalStateException</code>.
|
||||
*
|
||||
* @exception IllegalStateException
|
||||
* if the response has already been committed
|
||||
* @see #setBufferSize
|
||||
* @see #getBufferSize
|
||||
* @see #flushBuffer
|
||||
* @see #isCommitted
|
||||
*/
|
||||
public void reset();
|
||||
|
||||
/**
|
||||
* Sets the locale of the response, if the response has not been committed
|
||||
* yet. It also sets the response's character encoding appropriately for the
|
||||
* locale, if the character encoding has not been explicitly set using
|
||||
* {@link #setContentType} or {@link #setCharacterEncoding},
|
||||
* <code>getWriter</code> hasn't been called yet, and the response hasn't
|
||||
* been committed yet. If the deployment descriptor contains a
|
||||
* <code>locale-encoding-mapping-list</code> element, and that element
|
||||
* provides a mapping for the given locale, that mapping is used. Otherwise,
|
||||
* the mapping from locale to character encoding is container dependent.
|
||||
* <p>
|
||||
* This method may be called repeatedly to change locale and character
|
||||
* encoding. The method has no effect if called after the response has been
|
||||
* committed. It does not set the response's character encoding if it is
|
||||
* called after {@link #setContentType} has been called with a charset
|
||||
* specification, after {@link #setCharacterEncoding} has been called, after
|
||||
* <code>getWriter</code> has been called, or after the response has been
|
||||
* committed.
|
||||
* <p>
|
||||
* Containers must communicate the locale and the character encoding used
|
||||
* for the servlet response's writer to the client if the protocol provides
|
||||
* a way for doing so. In the case of HTTP, the locale is communicated via
|
||||
* the <code>Content-Language</code> header, the character encoding as part
|
||||
* of the <code>Content-Type</code> header for text media types. Note that
|
||||
* the character encoding cannot be communicated via HTTP headers if the
|
||||
* servlet does not specify a content type; however, it is still used to
|
||||
* encode text written via the servlet response's writer.
|
||||
*
|
||||
* @param loc
|
||||
* the locale of the response
|
||||
* @see #getLocale
|
||||
* @see #setContentType
|
||||
* @see #setCharacterEncoding
|
||||
*/
|
||||
public void setLocale(Locale loc);
|
||||
|
||||
/**
|
||||
* Returns the locale specified for this response using the
|
||||
* {@link #setLocale} method. Calls made to <code>setLocale</code> after the
|
||||
* response is committed have no effect.
|
||||
*
|
||||
* @return The locale specified for this response using the
|
||||
* {@link #setLocale} method. If no locale has been specified, the
|
||||
* container's default locale is returned.
|
||||
*
|
||||
* @see #setLocale
|
||||
*/
|
||||
public Locale getLocale();
|
||||
|
||||
}
|
||||
261
java/javax/servlet/ServletResponseWrapper.java
Normal file
261
java/javax/servlet/ServletResponseWrapper.java
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Provides a convenient implementation of the ServletResponse interface that
|
||||
* can be subclassed by developers wishing to adapt the response from a Servlet.
|
||||
* This class implements the Wrapper or Decorator pattern. Methods default to
|
||||
* calling through to the wrapped response object.
|
||||
*
|
||||
* @since v 2.3
|
||||
* @see javax.servlet.ServletResponse
|
||||
*/
|
||||
public class ServletResponseWrapper implements ServletResponse {
|
||||
private ServletResponse response;
|
||||
|
||||
/**
|
||||
* Creates a ServletResponse adaptor wrapping the given response object.
|
||||
*
|
||||
* @param response The response to wrap
|
||||
*
|
||||
* @throws java.lang.IllegalArgumentException
|
||||
* if the response is null.
|
||||
*/
|
||||
public ServletResponseWrapper(ServletResponse response) {
|
||||
if (response == null) {
|
||||
throw new IllegalArgumentException("Response cannot be null");
|
||||
}
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the wrapped ServletResponse object.
|
||||
*
|
||||
* @return The wrapped ServletResponse object.
|
||||
*/
|
||||
public ServletResponse getResponse() {
|
||||
return this.response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the response being wrapped.
|
||||
*
|
||||
* @param response The new response to wrap
|
||||
*
|
||||
* @throws java.lang.IllegalArgumentException
|
||||
* if the response is null.
|
||||
*/
|
||||
public void setResponse(ServletResponse response) {
|
||||
if (response == null) {
|
||||
throw new IllegalArgumentException("Response cannot be null");
|
||||
}
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to call
|
||||
* setCharacterEncoding(String charset) on the wrapped response object.
|
||||
*
|
||||
* @since 2.4
|
||||
*/
|
||||
@Override
|
||||
public void setCharacterEncoding(String charset) {
|
||||
this.response.setCharacterEncoding(charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getCharacterEncoding()
|
||||
* on the wrapped response object.
|
||||
*/
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return this.response.getCharacterEncoding();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getOutputStream() on the
|
||||
* wrapped response object.
|
||||
*/
|
||||
@Override
|
||||
public ServletOutputStream getOutputStream() throws IOException {
|
||||
return this.response.getOutputStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getWriter() on the
|
||||
* wrapped response object.
|
||||
*/
|
||||
@Override
|
||||
public PrintWriter getWriter() throws IOException {
|
||||
return this.response.getWriter();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to call setContentLength(int len)
|
||||
* on the wrapped response object.
|
||||
*/
|
||||
@Override
|
||||
public void setContentLength(int len) {
|
||||
this.response.setContentLength(len);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to call setContentLengthLong(long len)
|
||||
* on the wrapped response object.
|
||||
*
|
||||
* @since Servlet 3.1
|
||||
*/
|
||||
@Override
|
||||
public void setContentLengthLong(long length) {
|
||||
this.response.setContentLengthLong(length);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to call setContentType(String
|
||||
* type) on the wrapped response object.
|
||||
*/
|
||||
@Override
|
||||
public void setContentType(String type) {
|
||||
this.response.setContentType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getContentType() on the
|
||||
* wrapped response object.
|
||||
*
|
||||
* @since 2.4
|
||||
*/
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return this.response.getContentType();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to call setBufferSize(int size) on
|
||||
* the wrapped response object.
|
||||
*/
|
||||
@Override
|
||||
public void setBufferSize(int size) {
|
||||
this.response.setBufferSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getBufferSize() on the
|
||||
* wrapped response object.
|
||||
*/
|
||||
@Override
|
||||
public int getBufferSize() {
|
||||
return this.response.getBufferSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to call flushBuffer() on the
|
||||
* wrapped response object.
|
||||
*/
|
||||
@Override
|
||||
public void flushBuffer() throws IOException {
|
||||
this.response.flushBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return isCommitted() on the
|
||||
* wrapped response object.
|
||||
*/
|
||||
@Override
|
||||
public boolean isCommitted() {
|
||||
return this.response.isCommitted();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to call reset() on the wrapped
|
||||
* response object.
|
||||
*/
|
||||
@Override
|
||||
public void reset() {
|
||||
this.response.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to call resetBuffer() on the
|
||||
* wrapped response object.
|
||||
*/
|
||||
@Override
|
||||
public void resetBuffer() {
|
||||
this.response.resetBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to call setLocale(Locale loc) on
|
||||
* the wrapped response object.
|
||||
*/
|
||||
@Override
|
||||
public void setLocale(Locale loc) {
|
||||
this.response.setLocale(loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default behavior of this method is to return getLocale() on the
|
||||
* wrapped response object.
|
||||
*/
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return this.response.getLocale();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO SERVLET3 - Add comments
|
||||
* @param wrapped The response to compare to the wrapped response
|
||||
* @return <code>true</code> if the response wrapped by this wrapper (or
|
||||
* series of wrappers) is the same as the supplied response,
|
||||
* otherwise <code>false</code>
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public boolean isWrapperFor(ServletResponse wrapped) {
|
||||
if (response == wrapped) {
|
||||
return true;
|
||||
}
|
||||
if (response instanceof ServletResponseWrapper) {
|
||||
return ((ServletResponseWrapper) response).isWrapperFor(wrapped);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO SERVLET3 - Add comments
|
||||
* @param wrappedType The class to compare to the class of the wrapped
|
||||
* response
|
||||
* @return <code>true</code> if the response wrapped by this wrapper (or
|
||||
* series of wrappers) is the same type as the supplied type,
|
||||
* otherwise <code>false</code>
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public boolean isWrapperFor(Class<?> wrappedType) {
|
||||
if (wrappedType.isAssignableFrom(response.getClass())) {
|
||||
return true;
|
||||
}
|
||||
if (response instanceof ServletResponseWrapper) {
|
||||
return ((ServletResponseWrapper) response).isWrapperFor(wrappedType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
135
java/javax/servlet/ServletSecurityElement.java
Normal file
135
java/javax/servlet/ServletSecurityElement.java
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.annotation.HttpMethodConstraint;
|
||||
import javax.servlet.annotation.ServletSecurity;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
* TODO SERVLET3 - Add comments
|
||||
*/
|
||||
public class ServletSecurityElement extends HttpConstraintElement {
|
||||
|
||||
private final Map<String,HttpMethodConstraintElement> methodConstraints =
|
||||
new HashMap<>();
|
||||
|
||||
/**
|
||||
* Use default HttpConstraint.
|
||||
*/
|
||||
public ServletSecurityElement() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use specified HttpConstraintElement.
|
||||
* @param httpConstraintElement The constraint
|
||||
*/
|
||||
public ServletSecurityElement(HttpConstraintElement httpConstraintElement) {
|
||||
this (httpConstraintElement, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use specific constraints for specified methods and default
|
||||
* HttpConstraintElement for all other methods.
|
||||
* @param httpMethodConstraints Method constraints
|
||||
* @throws IllegalArgumentException if a method name is specified more than
|
||||
* once
|
||||
*/
|
||||
public ServletSecurityElement(
|
||||
Collection<HttpMethodConstraintElement> httpMethodConstraints) {
|
||||
super();
|
||||
addHttpMethodConstraints(httpMethodConstraints);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Use specified HttpConstraintElement as default and specific constraints
|
||||
* for specified methods.
|
||||
* @param httpConstraintElement Default constraint
|
||||
* @param httpMethodConstraints Method constraints
|
||||
* @throws IllegalArgumentException if a method name is specified more than
|
||||
*/
|
||||
public ServletSecurityElement(HttpConstraintElement httpConstraintElement,
|
||||
Collection<HttpMethodConstraintElement> httpMethodConstraints) {
|
||||
super(httpConstraintElement.getEmptyRoleSemantic(),
|
||||
httpConstraintElement.getTransportGuarantee(),
|
||||
httpConstraintElement.getRolesAllowed());
|
||||
addHttpMethodConstraints(httpMethodConstraints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create from an annotation.
|
||||
* @param annotation Annotation to use as the basis for the new instance
|
||||
* @throws IllegalArgumentException if a method name is specified more than
|
||||
*/
|
||||
public ServletSecurityElement(ServletSecurity annotation) {
|
||||
this(new HttpConstraintElement(annotation.value().value(),
|
||||
annotation.value().transportGuarantee(),
|
||||
annotation.value().rolesAllowed()));
|
||||
|
||||
List<HttpMethodConstraintElement> l = new ArrayList<>();
|
||||
HttpMethodConstraint[] constraints = annotation.httpMethodConstraints();
|
||||
if (constraints != null) {
|
||||
for (int i = 0; i < constraints.length; i++) {
|
||||
HttpMethodConstraintElement e =
|
||||
new HttpMethodConstraintElement(constraints[i].value(),
|
||||
new HttpConstraintElement(
|
||||
constraints[i].emptyRoleSemantic(),
|
||||
constraints[i].transportGuarantee(),
|
||||
constraints[i].rolesAllowed()));
|
||||
l.add(e);
|
||||
}
|
||||
}
|
||||
addHttpMethodConstraints(l);
|
||||
}
|
||||
|
||||
public Collection<HttpMethodConstraintElement> getHttpMethodConstraints() {
|
||||
Collection<HttpMethodConstraintElement> result = new HashSet<>();
|
||||
result.addAll(methodConstraints.values());
|
||||
return result;
|
||||
}
|
||||
|
||||
public Collection<String> getMethodNames() {
|
||||
Collection<String> result = new HashSet<>();
|
||||
result.addAll(methodConstraints.keySet());
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addHttpMethodConstraints(
|
||||
Collection<HttpMethodConstraintElement> httpMethodConstraints) {
|
||||
if (httpMethodConstraints == null) {
|
||||
return;
|
||||
}
|
||||
for (HttpMethodConstraintElement constraint : httpMethodConstraints) {
|
||||
String method = constraint.getMethodName();
|
||||
if (methodConstraints.containsKey(method)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Duplicate method name: " + method);
|
||||
}
|
||||
methodConstraints.put(method, constraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
110
java/javax/servlet/SessionCookieConfig.java
Normal file
110
java/javax/servlet/SessionCookieConfig.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
/**
|
||||
* Configures the session cookies used by the web application associated with
|
||||
* the ServletContext from which this SessionCookieConfig was obtained.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public interface SessionCookieConfig {
|
||||
|
||||
/**
|
||||
* Sets the session cookie name.
|
||||
*
|
||||
* @param name The name of the session cookie
|
||||
*
|
||||
* @throws IllegalStateException if the associated ServletContext has
|
||||
* already been initialised
|
||||
*/
|
||||
public void setName(String name);
|
||||
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Sets the domain for the session cookie
|
||||
*
|
||||
* @param domain The session cookie domain
|
||||
*
|
||||
* @throws IllegalStateException if the associated ServletContext has
|
||||
* already been initialised
|
||||
*/
|
||||
public void setDomain(String domain);
|
||||
|
||||
public String getDomain();
|
||||
|
||||
/**
|
||||
* Sets the path of the session cookie.
|
||||
*
|
||||
* @param path The session cookie path
|
||||
*
|
||||
* @throws IllegalStateException if the associated ServletContext has
|
||||
* already been initialised
|
||||
*/
|
||||
public void setPath(String path);
|
||||
|
||||
public String getPath();
|
||||
|
||||
/**
|
||||
* Sets the comment for the session cookie
|
||||
*
|
||||
* @param comment The session cookie comment
|
||||
*
|
||||
* @throws IllegalStateException if the associated ServletContext has
|
||||
* already been initialised
|
||||
*/
|
||||
public void setComment(String comment);
|
||||
|
||||
public String getComment();
|
||||
|
||||
/**
|
||||
* Sets the httpOnly flag for the session cookie.
|
||||
*
|
||||
* @param httpOnly The httpOnly setting to use for session cookies
|
||||
*
|
||||
* @throws IllegalStateException if the associated ServletContext has
|
||||
* already been initialised
|
||||
*/
|
||||
public void setHttpOnly(boolean httpOnly);
|
||||
|
||||
public boolean isHttpOnly();
|
||||
|
||||
/**
|
||||
* Sets the secure flag for the session cookie.
|
||||
*
|
||||
* @param secure The secure setting to use for session cookies
|
||||
*
|
||||
* @throws IllegalStateException if the associated ServletContext has
|
||||
* already been initialised
|
||||
*/
|
||||
public void setSecure(boolean secure);
|
||||
|
||||
public boolean isSecure();
|
||||
|
||||
/**
|
||||
* Sets the maximum age.
|
||||
*
|
||||
* @param MaxAge the maximum age to set
|
||||
* @throws IllegalStateException if the associated ServletContext has
|
||||
* already been initialised
|
||||
*/
|
||||
public void setMaxAge(int MaxAge);
|
||||
|
||||
public int getMaxAge();
|
||||
|
||||
}
|
||||
26
java/javax/servlet/SessionTrackingMode.java
Normal file
26
java/javax/servlet/SessionTrackingMode.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
/**
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
public enum SessionTrackingMode {
|
||||
COOKIE,
|
||||
URL,
|
||||
SSL
|
||||
}
|
||||
44
java/javax/servlet/SingleThreadModel.java
Normal file
44
java/javax/servlet/SingleThreadModel.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
/**
|
||||
* Ensures that servlets handle only one request at a time. This interface has
|
||||
* no methods.
|
||||
* <p>
|
||||
* If a servlet implements this interface, you are <i>guaranteed</i> that no two
|
||||
* threads will execute concurrently in the servlet's <code>service</code>
|
||||
* method. The servlet container can make this guarantee by synchronizing access
|
||||
* to a single instance of the servlet, or by maintaining a pool of servlet
|
||||
* instances and dispatching each new request to a free servlet.
|
||||
* <p>
|
||||
* Note that SingleThreadModel does not solve all thread safety issues. For
|
||||
* example, session attributes and static variables can still be accessed by
|
||||
* multiple requests on multiple threads at the same time, even when
|
||||
* SingleThreadModel servlets are used. It is recommended that a developer take
|
||||
* other means to resolve those issues instead of implementing this interface,
|
||||
* such as avoiding the usage of an instance variable or synchronizing the block
|
||||
* of the code accessing those resources. This interface is deprecated in
|
||||
* Servlet API version 2.4.
|
||||
*
|
||||
* @deprecated As of Java Servlet API 2.4, with no direct replacement.
|
||||
*/
|
||||
@SuppressWarnings("dep-ann")
|
||||
// Spec API does not use @Deprecated
|
||||
public interface SingleThreadModel {
|
||||
// No methods
|
||||
}
|
||||
178
java/javax/servlet/UnavailableException.java
Normal file
178
java/javax/servlet/UnavailableException.java
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package javax.servlet;
|
||||
|
||||
/**
|
||||
* Defines an exception that a servlet or filter throws to indicate that it is
|
||||
* permanently or temporarily unavailable.
|
||||
* <p>
|
||||
* When a servlet or filter is permanently unavailable, something is wrong with
|
||||
* it, and it cannot handle requests until some action is taken. For example, a
|
||||
* servlet might be configured incorrectly, or a filter's state may be
|
||||
* corrupted. The component should log both the error and the corrective action
|
||||
* that is needed.
|
||||
* <p>
|
||||
* A servlet or filter is temporarily unavailable if it cannot handle requests
|
||||
* momentarily due to some system-wide problem. For example, a third-tier server
|
||||
* might not be accessible, or there may be insufficient memory or disk storage
|
||||
* to handle requests. A system administrator may need to take corrective
|
||||
* action.
|
||||
* <p>
|
||||
* Servlet containers can safely treat both types of unavailable exceptions in
|
||||
* the same way. However, treating temporary unavailability effectively makes
|
||||
* the servlet container more robust. Specifically, the servlet container might
|
||||
* block requests to the servlet or filter for a period of time suggested by the
|
||||
* exception, rather than rejecting them until the servlet container restarts.
|
||||
*/
|
||||
public class UnavailableException extends ServletException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Servlet servlet; // what's unavailable
|
||||
private final boolean permanent; // needs admin action?
|
||||
private final int seconds; // unavailability estimate
|
||||
|
||||
/**
|
||||
* @param servlet
|
||||
* the <code>Servlet</code> instance that is unavailable
|
||||
* @param msg
|
||||
* a <code>String</code> specifying the descriptive message
|
||||
* @deprecated As of Java Servlet API 2.2, use
|
||||
* {@link #UnavailableException(String)} instead.
|
||||
*/
|
||||
@SuppressWarnings("dep-ann")
|
||||
// Spec API does not use @Deprecated
|
||||
public UnavailableException(Servlet servlet, String msg) {
|
||||
super(msg);
|
||||
this.servlet = servlet;
|
||||
permanent = true;
|
||||
this.seconds = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param seconds
|
||||
* an integer specifying the number of seconds the servlet
|
||||
* expects to be unavailable; if zero or negative, indicates that
|
||||
* the servlet can't make an estimate
|
||||
* @param servlet
|
||||
* the <code>Servlet</code> that is unavailable
|
||||
* @param msg
|
||||
* a <code>String</code> specifying the descriptive message,
|
||||
* which can be written to a log file or displayed for the user.
|
||||
* @deprecated As of Java Servlet API 2.2, use
|
||||
* {@link #UnavailableException(String, int)} instead.
|
||||
*/
|
||||
@SuppressWarnings("dep-ann")
|
||||
// Spec API does not use @Deprecated
|
||||
public UnavailableException(int seconds, Servlet servlet, String msg) {
|
||||
super(msg);
|
||||
this.servlet = servlet;
|
||||
if (seconds <= 0)
|
||||
this.seconds = -1;
|
||||
else
|
||||
this.seconds = seconds;
|
||||
permanent = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with a descriptive message indicating that the
|
||||
* servlet is permanently unavailable.
|
||||
*
|
||||
* @param msg
|
||||
* a <code>String</code> specifying the descriptive message
|
||||
*/
|
||||
public UnavailableException(String msg) {
|
||||
super(msg);
|
||||
seconds = 0;
|
||||
servlet = null;
|
||||
permanent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new exception with a descriptive message indicating that the
|
||||
* servlet is temporarily unavailable and giving an estimate of how long it
|
||||
* will be unavailable.
|
||||
* <p>
|
||||
* In some cases, the servlet cannot make an estimate. For example, the
|
||||
* servlet might know that a server it needs is not running, but not be able
|
||||
* to report how long it will take to be restored to functionality. This can
|
||||
* be indicated with a negative or zero value for the <code>seconds</code>
|
||||
* argument.
|
||||
*
|
||||
* @param msg
|
||||
* a <code>String</code> specifying the descriptive message,
|
||||
* which can be written to a log file or displayed for the user.
|
||||
* @param seconds
|
||||
* an integer specifying the number of seconds the servlet
|
||||
* expects to be unavailable; if zero or negative, indicates that
|
||||
* the servlet can't make an estimate
|
||||
*/
|
||||
public UnavailableException(String msg, int seconds) {
|
||||
super(msg);
|
||||
|
||||
if (seconds <= 0)
|
||||
this.seconds = -1;
|
||||
else
|
||||
this.seconds = seconds;
|
||||
servlet = null;
|
||||
permanent = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a <code>boolean</code> indicating whether the servlet is
|
||||
* permanently unavailable. If so, something is wrong with the servlet, and
|
||||
* the system administrator must take some corrective action.
|
||||
*
|
||||
* @return <code>true</code> if the servlet is permanently unavailable;
|
||||
* <code>false</code> if the servlet is available or temporarily
|
||||
* unavailable
|
||||
*/
|
||||
public boolean isPermanent() {
|
||||
return permanent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the servlet that is reporting its unavailability.
|
||||
*
|
||||
* @return the <code>Servlet</code> object that is throwing the
|
||||
* <code>UnavailableException</code>
|
||||
* @deprecated As of Java Servlet API 2.2, with no replacement.
|
||||
*/
|
||||
@SuppressWarnings("dep-ann")
|
||||
// Spec API does not use @Deprecated
|
||||
public Servlet getServlet() {
|
||||
return servlet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of seconds the servlet expects to be temporarily
|
||||
* unavailable.
|
||||
* <p>
|
||||
* If this method returns a negative number, the servlet is permanently
|
||||
* unavailable or cannot provide an estimate of how long it will be
|
||||
* unavailable. No effort is made to correct for the time elapsed since the
|
||||
* exception was first reported.
|
||||
*
|
||||
* @return an integer specifying the number of seconds the servlet will be
|
||||
* temporarily unavailable, or a negative number if the servlet is
|
||||
* permanently unavailable or cannot make an estimate
|
||||
*/
|
||||
public int getUnavailableSeconds() {
|
||||
return permanent ? -1 : seconds;
|
||||
}
|
||||
}
|
||||
45
java/javax/servlet/WriteListener.java
Normal file
45
java/javax/servlet/WriteListener.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Receives notification of write events when using non-blocking IO.
|
||||
*
|
||||
* @since Servlet 3.1
|
||||
*/
|
||||
public interface WriteListener extends java.util.EventListener{
|
||||
|
||||
/**
|
||||
* Invoked when it it possible to write data without blocking. The container
|
||||
* will invoke this method the first time for a request as soon as data can
|
||||
* be written. Subsequent invocations will only occur if a call to
|
||||
* {@link ServletOutputStream#isReady()} has returned false and it has since
|
||||
* become possible to write data.
|
||||
*
|
||||
* @throws IOException if an I/O error occurs while processing this event
|
||||
*/
|
||||
public void onWritePossible() throws IOException;
|
||||
|
||||
/**
|
||||
* Invoked if an error occurs while writing the response.
|
||||
*
|
||||
* @param throwable The throwable that represents the error that occurred
|
||||
*/
|
||||
public void onError(java.lang.Throwable throwable);
|
||||
}
|
||||
39
java/javax/servlet/annotation/HandlesTypes.java
Normal file
39
java/javax/servlet/annotation/HandlesTypes.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* This annotation is used to declare an array of application classes which are
|
||||
* passed to a {@link javax.servlet.ServletContainerInitializer}.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface HandlesTypes {
|
||||
|
||||
/**
|
||||
* @return array of classes
|
||||
*/
|
||||
Class<?>[] value();
|
||||
|
||||
}
|
||||
69
java/javax/servlet/annotation/HttpConstraint.java
Normal file
69
java/javax/servlet/annotation/HttpConstraint.java
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package javax.servlet.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic;
|
||||
import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
|
||||
|
||||
/**
|
||||
* This annotation represents the security constraints that are applied to all
|
||||
* requests with HTTP protocol method types that are not otherwise represented
|
||||
* by a corresponding {@link javax.servlet.annotation.HttpMethodConstraint} in a
|
||||
* {@link javax.servlet.annotation.ServletSecurity} annotation.
|
||||
*
|
||||
* @since Servlet 3.0
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface HttpConstraint {
|
||||
|
||||
/**
|
||||
* The EmptyRoleSemantic determines the behaviour when the rolesAllowed list
|
||||
* is empty.
|
||||
*
|
||||
* @return empty role semantic
|
||||
*/
|
||||
EmptyRoleSemantic value() default EmptyRoleSemantic.PERMIT;
|
||||
|
||||
/**
|
||||
* Determines whether SSL/TLS is required to process the current request.
|
||||
*
|
||||
* @return transport guarantee
|
||||
*/
|
||||
TransportGuarantee transportGuarantee() default TransportGuarantee.NONE;
|
||||
|
||||
/**
|
||||
* The authorized roles' names. The container may discard duplicate role
|
||||
* names during processing of the annotation. N.B. The String "*" does not
|
||||
* have a special meaning if it occurs as a role name.
|
||||
*
|
||||
* @return array of names. The array may be of zero length, in which case
|
||||
* the EmptyRoleSemantic applies; the returned value determines
|
||||
* whether access is to be permitted or denied regardless of the
|
||||
* identity and authentication state in either case, PERMIT or DENY.<br>
|
||||
* Otherwise, when the array contains one or more role names access
|
||||
* is permitted if the user a member of at least one of the named
|
||||
* roles. The EmptyRoleSemantic is not applied in this case.
|
||||
*
|
||||
*/
|
||||
String[] rolesAllowed() default {};
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user