public class ServiceSupport extends AbstractPatternWorker
LegacyService
annotations,
for any legacy service defined in 4GL code.
For REST services, this relies on the .paar
archive, which includes:
resourceModel.xml
, a file which defines the resources and the operation(s)
on that resource.mapping.xml
, specifies how to read and write legacy parameters from/to HTTP
request or response..restoe
file, which defines the details about the 4GL source code which is
exposed as a service..paar
archive can be specified via the rest-cfg
configuration value
or that value can be a directory containing one or more .paar
archives.
For SOAP services, a list of .wsm
files must be specified, which will be used to
annotated the converted 4GL code (for each exported SOAP service), and also create WSDL files.
These files are read from the soap-cfg
parameter, which represents a comma-separated
list of .wsm
files or folders. In case of folders, all .wsm
files
will be read from it (non-recursive).
For legacy proxy programs, one or more .xpxg
files is provided. For all these programs, a
new Java class will be generated, which will expose the metadata for the defined datasets and temp-tables,
plus APIs to invoke the internal procedures.
Modifier and Type | Class and Description |
---|---|
class |
ServiceSupport.Library
Exposes APIs to resolve services (REST, etc) for a certain program or OO class.
|
private static class |
ServiceSupport.WorkArea
State which must survive for the duration of the conversion.
|
Modifier and Type | Field and Description |
---|---|
private static ContextLocal<ServiceSupport.WorkArea> |
context
Contains state which must survive for the entire run of the conversion.
|
private java.util.Map<java.lang.String,RestOperation> |
operations
The map of legacy configured REST operations.
|
private java.util.Map<java.lang.String,SoapConfig> |
soapConfigs
A map of SOAP configurations, by their name (the .wsm file name, without extension).
|
private java.util.Map<java.lang.String,java.util.List<WebHandlerConfig>> |
webHandlers
A map of WebHandler classes to their list of paths.
|
Constructor and Description |
---|
ServiceSupport()
Default constructor which defines the symbol libraries to be registered.
|
Modifier and Type | Method and Description |
---|---|
private SoapConfig |
createSoapConfig(java.io.File f)
From the specified .wsm file, with the defining 4GL programs exported as SOAP operations, create a
configuration.
|
private static java.lang.String |
getChildElementText(org.w3c.dom.Element parent,
java.lang.String tag)
Get the TEXT value, from the child with the given tag.
|
static FileList |
getProxyClientPrograms()
Get the list of JAST files which were generated for legay open client proxy programs.
|
private java.util.List<SoapOperation> |
getSoapOperation(java.lang.String program,
java.lang.String internalEntry)
Find all SOAP operations configured in the .wsm document(s), for this external program and internal
entry, or class and method.
|
private java.util.List<SoapOperation> |
getSoapOperation(java.lang.String file,
java.lang.String program,
java.lang.String internalEntry)
Find all SOAP operations configured in the .wsm document(s), for this external program and internal
entry, or class and method.
|
void |
initialize()
Initialize, by interpreting (if specified) any REST, Web or SOAP services.
|
private static java.util.List<RestParameterMapping> |
loadMapping(org.w3c.dom.Document dom)
Load the mappings from a
mapping.xml document. |
private static java.util.List<RestResource> |
loadResources(org.w3c.dom.Document dom,
java.util.List<RestParameterMapping> mappings,
java.lang.String address)
Load the defined REST resources from the given DOM (a
resourceModel.xml source). |
private static java.lang.String |
loadSpring(org.w3c.dom.Document dom)
Load the configuration from a
spring.xml document. |
private static void |
parsePaar(java.io.File file,
java.util.Map<java.lang.String,RestOperation> operations)
Resolve the REST operations from the given
.paar archive. |
private LegacyProxyConfig |
parseProxyProgram(java.io.File file)
Parse the .xpxg file and read the configurations for the external programs exposed as legacy open client
proxy programs.
|
private LegacyProxyClientConfig |
readProxyProgram(org.w3c.dom.Element el)
Read the configuration about an external procedure exposed as legacy open client proxy program.
|
(package private) static void |
readRecursively(java.lang.String parentNode,
org.w3c.dom.Element root,
java.util.Map<java.lang.String,java.lang.String> cfgs)
Given a root XML element, load the entire XML structure in a map, where the keys will be:
the '/' separated path from the parent node
the '/' separated path from the parent node followed by the '#' char and the attribute name,
for element's attributes.
|
private java.util.List<SoapOperation> |
readSoapOperations(SoapConfig cfg,
org.w3c.dom.Element el)
For a
Procedure element in a .wsm file, associate it with one or more SOAP operations. |
private void |
registerSoapOperation(java.lang.String program,
java.lang.String internalEntry)
Register the specified internal entry as a SOAP operation in the given persistent program.
|
private java.util.List<LegacyProxyConfig> |
resolveProxyProgramsConfiguration(java.lang.String proxyCfg)
Parse the .xpxg file(s) and read the configurations for the external programs exposed as legacy open
client proxy programs.
|
private static java.util.Map<java.lang.String,RestOperation> |
resolveRestConfiguration(java.lang.String file)
Resolve the REST operations from one or more
.paar archives. |
private static void |
resolveServices(java.util.List<RestResource> resources,
org.w3c.dom.Document dom)
Resolve the services from the
.restoe file. |
private static java.util.Map<java.lang.String,java.util.List<WebHandlerConfig>> |
resolveWebHandlers(java.lang.String file)
Resolve the web handlers.
|
finish, getCopy, getLibrary, getResolver, getSource, isConditionalRuleSets, isFlagActivated, isRuntimeQueryMode, registerTree, resolveConstant, setLibrary, visitAst
private static final ContextLocal<ServiceSupport.WorkArea> context
private java.util.Map<java.lang.String,RestOperation> operations
private java.util.Map<java.lang.String,java.util.List<WebHandlerConfig>> webHandlers
private java.util.Map<java.lang.String,SoapConfig> soapConfigs
public ServiceSupport()
public static FileList getProxyClientPrograms()
public void initialize()
initialize
in interface PatternWorker
initialize
in class AbstractPatternWorker
private java.util.List<LegacyProxyConfig> resolveProxyProgramsConfiguration(java.lang.String proxyCfg) throws java.lang.Exception
proxyCfg
- The value of the proxy-programs-cfg
configuration.LegacyProxyConfig
instances, one for each .xpxg file.java.lang.Exception
- In case of XML errors.private LegacyProxyConfig parseProxyProgram(java.io.File file) throws java.lang.Exception
file
- The .xpxg file name.LegacyProxyConfig
for this file, with all registered programs for which a
Java class will be generated.java.lang.Exception
- In case of XML errors.private LegacyProxyClientConfig readProxyProgram(org.w3c.dom.Element el)
el
- The 'Procedure' XML element.LegacyProxyClientConfig
instance.private java.util.List<SoapOperation> readSoapOperations(SoapConfig cfg, org.w3c.dom.Element el)
Procedure
element in a .wsm file, associate it with one or more SOAP operations.
If the program is ran persistent, all its internal entries are exposed.cfg
- The parent SOAP configuration instance.el
- The Procedure
XML element.private SoapConfig createSoapConfig(java.io.File f) throws java.lang.Exception
f
- The .wsm file with the exported 4GL programs for SOAP operations.java.lang.Exception
- If there are any problems loading or analyzing the XML document.private static java.util.Map<java.lang.String,java.util.List<WebHandlerConfig>> resolveWebHandlers(java.lang.String file) throws java.lang.Exception
file
- The web handler configuration, a properties file with the format
handler#=[qualifiedClassName] : /web/path/{p1}/{p2}
, where
handler#
is handler1, handler2, etc.java.lang.Exception
private static java.util.Map<java.lang.String,RestOperation> resolveRestConfiguration(java.lang.String file) throws java.lang.Exception
.paar
archives.file
- A .paar
archive or a directory in which to find one or more .paar
files.java.lang.Exception
private static void parsePaar(java.io.File file, java.util.Map<java.lang.String,RestOperation> operations) throws java.lang.Exception
.paar
archive.file
- A .paar
archive.operations
- A map of defined operations.java.lang.Exception
static void readRecursively(java.lang.String parentNode, org.w3c.dom.Element root, java.util.Map<java.lang.String,java.lang.String> cfgs)
parentNode
- The parent node name.root
- The root element.cfgs
- The map where to save the XML texts (from nodes or attributes).private static java.lang.String getChildElementText(org.w3c.dom.Element parent, java.lang.String tag)
parent
- The parent element.tag
- The child's tag.private static void resolveServices(java.util.List<RestResource> resources, org.w3c.dom.Document dom)
.restoe
file.
This associates the resources from resourceModel.xml
with the legacy definitions.
resources
- The defined REST resources.dom
- The DOM document.private static java.util.List<RestResource> loadResources(org.w3c.dom.Document dom, java.util.List<RestParameterMapping> mappings, java.lang.String address)
resourceModel.xml
source).
It will resolve any argument mapping, from the attached list, built from
mapping.xml
.
dom
- The DOM document.mappings
- The argument mappings, from mapping.xml
.address
- The service-level path suffix or null
if none is specified.private static java.util.List<RestParameterMapping> loadMapping(org.w3c.dom.Document dom) throws java.lang.Exception
mapping.xml
document.
The mapping expressions are not resolved here - they will be disambiguated when the resources
are loaded, in loadResources(Document, List, String)
, by evaluating the expression.
dom
- The DOM document.java.lang.Exception
private static java.lang.String loadSpring(org.w3c.dom.Document dom) throws java.lang.Exception
spring.xml
document.
The only value processed is the "address" attribute of element "prgrs:prgRsServer".
dom
- The DOM document.null
if none exists.java.lang.Exception
private java.util.List<SoapOperation> getSoapOperation(java.lang.String program, java.lang.String internalEntry)
program
- The program or class name.internalEntry
- The internal entry or method name. May be null
.private java.util.List<SoapOperation> getSoapOperation(java.lang.String file, java.lang.String program, java.lang.String internalEntry)
file
- The file name.program
- The program or class name.internalEntry
- The internal entry or method name. May be null
.private void registerSoapOperation(java.lang.String program, java.lang.String internalEntry)
program
- The program name.internalEntry
- The internal entry name.