All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.sling.api.servlets.ServletResolver Maven / Gradle / Ivy

There is a newer version: 2024.11.18751.20241128T090041Z-241100
Show newest version
/*
 * 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 org.apache.sling.api.servlets;

import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;
import javax.servlet.Servlet;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;

import org.osgi.annotation.versioning.ProviderType;

/**
 * The ServletResolver defines the API for a service capable of
 * resolving javax.servlet.Servlet instances to handle the
 * processing of a request or resource.
 * 

* Applications of the Sling Framework generally do not need the servlet * resolver as resolution of the servlets to process requests and sub-requests * through a RequestDispatcher is handled by the Sling Framework. */ @ProviderType public interface ServletResolver { /** * Resolves a javax.servlet.Servlet whose * service method may be used to handle the given * request. *

* The returned servlet must be assumed to be initialized and ready to run. * That is, the init nor the destroy methods * must NOT be called on the returned servlet. *

* This method must not return a Servlet instance * implementing the {@link OptingServlet} interface and returning * false when the * {@link OptingServlet#accepts(SlingHttpServletRequest)} method is called. * * @param request The {@link SlingHttpServletRequest} object used to drive * selection of the servlet. * @return The servlet whose service method may be called to * handle the request. Might be {@code null}. * @throws org.apache.sling.api.SlingException Is thrown if an error occurs * while trying to find an appropriate servlet to handle the * request. * @throws NullPointerException If {@code request} is null. */ @Nullable Servlet resolveServlet(@NotNull SlingHttpServletRequest request); /** * Resolves a javax.servlet.Servlet whose * service method may be used to handle a request. *

* The returned servlet must be assumed to be initialized and ready to run. * That is, the init nor the destroy methods * must NOT be called on the returned servlet. *

* This method skips all {@link OptingServlet}s as there is no * request object available. * * Basically this method searches a script with the scriptName * for the resource type defined by the resource. * * @param resource The {@link Resource} object used to drive * selection of the servlet. * @param scriptName The name of the script - the script might have an * extension. In this case only a script with the * matching extension is used. * @return The servlet whose service method may be called to * handle the request. Might be {@code null}. * @throws org.apache.sling.api.SlingException Is thrown if an error occurs * while trying to find an appropriate servlet to handle the * request or if no servlet could be resolved to handle the * request. * @throws IllegalArgumentException If {@code resource} is null. * @since 2.1 (Sling API Bundle 2.1.0) */ @Nullable Servlet resolveServlet(@NotNull Resource resource, @NotNull String scriptName); /** * Resolves a javax.servlet.Servlet whose * service method may be used to handle a request. *

* The returned servlet must be assumed to be initialized and ready to run. * That is, the init nor the destroy methods * must NOT be called on the returned servlet. *

* This method skips all {@link OptingServlet}s as there is no * request object available. * * Basically this method searches a script with the scriptName * @param resolver The {@link ResourceResolver} object used to drive * selection of the servlet. * @param scriptName The name of the script - the script might have an * extension. In this case only a script with the * matching extension is used. * @return The servlet whose service method may be called to * handle the request. Might be {@code null}. * @throws org.apache.sling.api.SlingException Is thrown if an error occurs * while trying to find an appropriate servlet to handle the * request. * @throws IllegalArgumentException If {@code resolver} is null. * @since 2.1 (Sling API Bundle 2.1.0) */ @Nullable Servlet resolveServlet(@NotNull ResourceResolver resolver, @NotNull String scriptName); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy