diff options
author | 2021-08-03 18:42:39 +0900 | |
---|---|---|
committer | 2021-08-06 19:32:38 +0900 | |
commit | be4f78978faba3d3ceb88df02a7f93a2e09ff1e0 (patch) | |
tree | 1f3f1a96251ac4f655c8a96fc33d5d4ee779cd06 /rba.tool.editor.endpoint/src/rba/tool/editor/endpoint/RBAModelServlet.xtend | |
parent | 71ca7c6cab863767ef30c8bd05b2bbfda8731cb5 (diff) |
Initial commit
Bug-AGL: SPEC-4033
Signed-off-by: Kenji Hosokawa <khosokawa@jp.adit-jv.com>
Diffstat (limited to 'rba.tool.editor.endpoint/src/rba/tool/editor/endpoint/RBAModelServlet.xtend')
-rw-r--r-- | rba.tool.editor.endpoint/src/rba/tool/editor/endpoint/RBAModelServlet.xtend | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/rba.tool.editor.endpoint/src/rba/tool/editor/endpoint/RBAModelServlet.xtend b/rba.tool.editor.endpoint/src/rba/tool/editor/endpoint/RBAModelServlet.xtend new file mode 100644 index 0000000..b543381 --- /dev/null +++ b/rba.tool.editor.endpoint/src/rba/tool/editor/endpoint/RBAModelServlet.xtend @@ -0,0 +1,68 @@ +/* + * generated by Xtext 2.13.0 + */ +package rba.tool.editor.endpoint + +import com.google.inject.Injector +import javax.servlet.annotation.WebServlet +import org.eclipse.emf.common.util.URI +import org.eclipse.xtext.resource.IResourceServiceProvider +import org.eclipse.xtext.util.DisposableRegistry +import org.eclipse.xtext.web.server.InvalidRequestException.UnknownLanguageException +import org.eclipse.xtext.web.servlet.HttpServiceContext +import org.eclipse.xtext.web.servlet.XtextServlet +import rba.tool.editor.endpoint.server.persistence.RBAModelResourceBaseProviderImpl +import org.eclipse.xtext.web.server.XtextServiceDispatcher.ServiceDescriptor +import org.eclipse.xtext.web.server.IServiceResult + +/** + * Deploy this class into a servlet container to enable DSL-specific services. + */ +@WebServlet(name='XtextServices', urlPatterns='/xtext-service/*') +class RBAModelServlet extends XtextServlet { + + val serviceProviderRegistry = IResourceServiceProvider.Registry.INSTANCE + + DisposableRegistry disposableRegistry + + override init() { + super.init() + val resourceBaseProvider = new RBAModelResourceBaseProviderImpl('') + new RBAModelWebSetup(resourceBaseProvider).createInjectorAndDoEMFRegistration + } + + override protected getInjector(HttpServiceContext serviceContext) throws UnknownLanguageException { + var IResourceServiceProvider resourceServiceProvider + + val emfURI = URI.createURI('./sample.rba') + val contentType = serviceContext.getParameter('contentType') + if (contentType.nullOrEmpty) { + + resourceServiceProvider = serviceProviderRegistry.getResourceServiceProvider(emfURI) + if (resourceServiceProvider === null) { + if (emfURI.toString.empty) + throw new UnknownLanguageException('''Unable to identify the Xtext language: missing parameter 'resource' or 'contentType'.''') + else + throw new UnknownLanguageException('''Unable to identify the Xtext language for resource emfURI.''') + } + } else { + resourceServiceProvider = serviceProviderRegistry.getResourceServiceProvider(emfURI, contentType) + if (resourceServiceProvider === null) + throw new UnknownLanguageException('''Unable to identify the Xtext language for contentType contentType.''') + } + return resourceServiceProvider.get(Injector) + } + + override protected getEncoding(ServiceDescriptor service, IServiceResult result) { + 'Shift_JIS' + } + + override destroy() { + if (disposableRegistry !== null) { + disposableRegistry.dispose() + disposableRegistry = null + } + super.destroy() + } + +} |