Package io.grpc.servlet.jakarta
Class GrpcServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
io.grpc.servlet.jakarta.GrpcServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet
,jakarta.servlet.ServletConfig
,Serializable
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/5066")
public class GrpcServlet
extends jakarta.servlet.http.HttpServlet
A simple servlet backed by a gRPC server. Must set
asyncSupported
to true. The
/contextRoot/urlPattern
must match the gRPC services' path, which is
"/full-service-name/short-method-name".
The API is experimental. The authors would like to know more about the real usecases. Users are welcome to provide feedback by commenting on the tracking issue.
- See Also:
-
Field Summary
FieldsFields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD
-
Constructor Summary
ConstructorsConstructorDescriptionGrpcServlet
(ServletAdapter servletAdapter) GrpcServlet
(List<? extends BindableService> bindableServices) Instantiate the servlet serving the given list of gRPC services. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
protected final void
doGet
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) protected final void
doPost
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) private static ServletAdapter
loadServices
(List<? extends BindableService> bindableServices) Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPatch, doPut, doTrace, getLastModified, init, isSensitiveHeader, service, service
Methods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
servletAdapter
-
-
Constructor Details
-
GrpcServlet
GrpcServlet(ServletAdapter servletAdapter) -
GrpcServlet
Instantiate the servlet serving the given list of gRPC services. ServerInterceptors can be added on each gRPC service byServerInterceptors.intercept(BindableService, io.grpc.ServerInterceptor...)
-
-
Method Details
-
loadServices
-
doGet
protected final void doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException - Overrides:
doGet
in classjakarta.servlet.http.HttpServlet
- Throws:
IOException
-
doPost
protected final void doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException - Overrides:
doPost
in classjakarta.servlet.http.HttpServlet
- Throws:
IOException
-
destroy
public void destroy()- Specified by:
destroy
in interfacejakarta.servlet.Servlet
- Overrides:
destroy
in classjakarta.servlet.GenericServlet
-