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 static ConversionStatus |
LOG
Logger
|
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(java.util.Set<java.lang.String> doneAppObjects)
Get the list of JAST files which were generated for legay open client proxy programs.
|
private LegacyProxyConfig |
getProxyConfig(java.lang.String file)
Resolve the proxy configuration for the given file.
|
static java.util.List<LegacyProxyConfig> |
getProxyConfigs()
Get the list of proxy configs for legacy OpenClient.
|
private LegacyProxyClientConfig |
getProxyProgramConfig(java.lang.String file)
Resolve the proxy program configuration for the given file.
|
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.
|
static void |
initializeProxyConfigurations()
Read and initialize the proxy program configurations, from
p2j.cfg.xml. |
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. |
static void |
main(java.lang.String[] args)
Given a file or folder with .xpxg proxy program configurations, get the list of target programs.
|
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 static java.util.List<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 static LegacyProxyClientConfig |
readProxyProgram(java.io.File file,
org.w3c.dom.Element el,
java.lang.String appObject,
java.lang.String pkg,
boolean allowUnknown)
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 static 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.
|
static void |
setBrewProxy(boolean state)
Set the
ServiceSupport.WorkArea.brewProxy flag. |
static void |
setCurrentProxyConfigs(java.util.List<LegacyProxyConfig> cfgs)
Set the current proxy configuration for legacy OpenClient proxy generation.
|
getCopy, getLibrary, getResolver, getSource, isConditionalRuleSets, isFlagActivated, isRuntimeQueryMode, registerTree, resolveConstant, setLibraryclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfinish, leaveAst, visitAstprivate static final ContextLocal<ServiceSupport.WorkArea> context
private static final ConversionStatus LOG
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 void setCurrentProxyConfigs(java.util.List<LegacyProxyConfig> cfgs)
cfgs - The proxy client configs.public static java.util.List<LegacyProxyConfig> getProxyConfigs()
public static FileList getProxyClientPrograms(java.util.Set<java.lang.String> doneAppObjects)
doneAppObjects - The set of (Sub)AppObject class names (qualified with their packages), which can have their
JASTs discarded, as there are no more programs for them to generate.public static void initializeProxyConfigurations()
p2j.cfg.xml.public static void setBrewProxy(boolean state)
ServiceSupport.WorkArea.brewProxy flag. This allows generation of the proxy Java programs in the
folder specified in the proxy-output-root parameter from p2j.cfg.xml.state - The state of the flag.public void initialize()
private static 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 static java.util.List<LegacyProxyConfig> parseProxyProgram(java.io.File file) throws java.lang.Exception
file - The .xpxg file name.configs for this file's AppObject and SubAppObject, with all
registered programs for which a Java class will be generated.java.lang.Exception - In case of XML errors.private static LegacyProxyClientConfig readProxyProgram(java.io.File file, org.w3c.dom.Element el, java.lang.String appObject, java.lang.String pkg, boolean allowUnknown)
file - The .xpxg file name.el - The 'Procedure' XML element.appObject - The name of the (Sub)AppObject where this program is configured.pkg - The Java package for the proxy program.allowUnknown - Flag indicating if unknown arguments are allowed.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.Exceptionprivate 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.Exceptionprivate 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.Exceptionstatic 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.Exceptionprivate 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.Exceptionprivate 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.private LegacyProxyClientConfig getProxyProgramConfig(java.lang.String file)
file - The proxy program file.private LegacyProxyConfig getProxyConfig(java.lang.String file)
file - The proxy program file.public static void main(java.lang.String[] args)
throws java.lang.Exception
args - A single argument with the folder's or file's location.java.lang.Exception