Package org.eclipse.xtext.web.servlet
Class XtextServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.eclipse.xtext.web.servlet.XtextServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
public class XtextServlet
extends jakarta.servlet.http.HttpServlet
An HTTP servlet for publishing the Xtext services. Include this into your web
server by creating a subclass that executes the standalone setups of your
languages in its
GenericServlet.init() method:
@WebServlet(name = "Xtext Services", urlPatterns = "/xtext-service/*")
class MyXtextServlet extends XtextServlet {
override init() {
super.init();
MyDslWebSetup.doSetup();
}
}
Use the WebServlet annotation to register your servlet. The default
URL pattern for Xtext services is "/xtext-service/*".- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) protected voiddoPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) protected voiddoPut(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) protected voiddoService(org.eclipse.xtext.web.server.XtextServiceDispatcher.ServiceDescriptor service, jakarta.servlet.http.HttpServletResponse response) Invoke the service function of the given service descriptor and write its result to the servlet response in Json format.protected StringgetEncoding(org.eclipse.xtext.web.server.XtextServiceDispatcher.ServiceDescriptor service, org.eclipse.xtext.web.server.IServiceResult result) Determine the encoding to apply to servlet responses.protected com.google.inject.InjectorgetInjector(HttpServiceContext serviceContext) Resolve the Guice injector for the language associated with the given context.protected org.eclipse.xtext.web.server.XtextServiceDispatcher.ServiceDescriptorgetService(jakarta.servlet.http.HttpServletRequest request) Retrieve the service metadata for the given request.protected booleanhasTextInput(org.eclipse.xtext.web.server.XtextServiceDispatcher.ServiceDescriptor service) protected voidservice(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doTrace, getLastModified, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
-
Constructor Details
-
XtextServlet
public XtextServlet()
-
-
Method Details
-
service
protected void service(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException - Overrides:
servicein classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
doGet
protected void doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException - Overrides:
doGetin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
doPut
protected void doPut(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException - Overrides:
doPutin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
doPost
protected void doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException - Overrides:
doPostin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
hasTextInput
protected boolean hasTextInput(org.eclipse.xtext.web.server.XtextServiceDispatcher.ServiceDescriptor service) -
getService
protected org.eclipse.xtext.web.server.XtextServiceDispatcher.ServiceDescriptor getService(jakarta.servlet.http.HttpServletRequest request) throws org.eclipse.xtext.web.server.InvalidRequestException Retrieve the service metadata for the given request. This involves resolving the Guice injector for the respective language, querying theXtextServiceDispatcher, and checking the permission to invoke the service.- Throws:
org.eclipse.xtext.web.server.InvalidRequestException
-
doService
protected void doService(org.eclipse.xtext.web.server.XtextServiceDispatcher.ServiceDescriptor service, jakarta.servlet.http.HttpServletResponse response) Invoke the service function of the given service descriptor and write its result to the servlet response in Json format. An exception is made forIUnwrappableServiceResult: here the document itself is written into the response instead of wrapping it into a Json object. -
getEncoding
protected String getEncoding(org.eclipse.xtext.web.server.XtextServiceDispatcher.ServiceDescriptor service, org.eclipse.xtext.web.server.IServiceResult result) Determine the encoding to apply to servlet responses. The default is UTF-8. -
getInjector
protected com.google.inject.Injector getInjector(HttpServiceContext serviceContext) throws org.eclipse.xtext.web.server.InvalidRequestException.UnknownLanguageException Resolve the Guice injector for the language associated with the given context.- Throws:
org.eclipse.xtext.web.server.InvalidRequestException.UnknownLanguageException
-