blob: b54338149b25f772daae2d34910dc6b225d00550 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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()
}
}
|