Changes between Version 2 and Version 3 of MapGuideRfc185


Ignore:
Timestamp:
Sep 9, 2022, 5:28:54 AM (20 months ago)
Author:
jng
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MapGuideRfc185

    v2 v3  
    99||RFC Template Version||(1.0)||
    1010||Submission Date||7 Jul 2022||
    11 ||Last Modified||7 Jul 2022||
     11||Last Modified||9 Sep 2022||
    1212||Author||Jackie Ng||
    1313||RFC Status||draft||
     
    2222||no vote|| ||
    2323
     24[[TOC]]
     25
    2426== Overview ==
    2527
     
    4446A new top-level `Bindings` subdirectory and solution will house the various API binding projects and supporting tools/libraries.
    4547
    46 The following projects in `Oem` will be removed:
    47 
    48  * `Oem/SwigEx`
    49  * `Oem/SQLite`
    50 
    51 Vanilla SWIG is now a build requirement. On Windows, pre-compiled binaries of the expected version of SWIG will be provided for convenience.
     48The following projects/directories will be removed as a result of being obsoleted by this new bindings:
     49
     50 * `Oem/SwigEx` (SWIG will now be acquired externally through official channels and is assumed to exist before building)
     51 * `Oem/SQLite` (Proof-of-concept SWIG binding to SQLite and legacy Web API test administration tools)
     52 * `BuildTools/CC.Net` (unused CI configuration)
     53 * `BuildTools/WebTools/IMake` (relocated to new top-level `Bindings` directory)
     54 * `Web/src/JavaApi` (legacy "crufty" Java binding)
     55 * `Web/src/JavaApiEx` (legacy "non-crufty" Java binding)
     56 * `Web/src/PhpApi` (legacy PHP 5.6 binding)
     57 * `Web/src/PhpMapGuideApiEnvConfig` (support library for the legacy PHP 5.6 binding)
     58
     59Vanilla SWIG is now a build requirement. On Windows, pre-compiled binaries of the expected version of SWIG will be provided for convenience. On Linux, the build scripts will acquire and build SWIG source from the github repo if the expected version of SWIG is not present.
    5260
    5361Fusion and all existing web tier applications (eg. AJAX Viewer, Site Administrator) will be migrated across to work against these new API bindings.
     
    5563The existing web tier test suite will also be migrated across to work against these new API bindings.
    5664
     65These changes have been implemented in the [https://trac.osgeo.org/mapguide/browser/sandbox/jng/vanilla_swig vanilla_swig sandbox] for MapGuide.
     66
     67A compatible version of Fusion that works against the PHP 8 binding has been implemented in the [https://trac.osgeo.org/fusion/browser/sandbox/php8 php8 sandbox branch] in the Fusion repo.
     68
     69Upon the adoption of this RFC, these changes will be merged into trunk in their respective repos.
     70
    5771== Impact summary of API changes ==
    5872
    5973To support generating functional API bindings for .net/Java/PHP with vanilla SWIG, we had to make a few changes to our C++ API surface to facilitate/accommodate the code generation needs of vanilla SWIG.
     74
    6075Such changes are detailed below.
    6176
    6277=== General (all languages) ===
    6378
    64  * The exception hierarchy has been flattened to just `MgException`. All existing sub-classes of `MgException` have been removed. A new `GetExceptionCode()` method is available to fetch the appropriate error classification. The available classifications are simply the names of all the removed sub-classes and whose names are now contained in a new `MgExceptionCodes` string constant class.
     79 * The exception hierarchy has been flattened to now be just `MgException`. All existing sub-classes of `MgException` have been removed. A new `GetExceptionCode()` method is available to fetch the appropriate error classification. The available classifications are simply the names of all the removed sub-classes and whose names are now contained in a new `MgExceptionCodes` string constant class.
    6580    * This was done to avoid having to deal with `MgException` polymorphism in a consistent manner across our 3 SWIG language targets.
    66     * Refer to the table below for how to migrate your exception handling code for your target language
    67 
    68 [TODO: Insert before/after table]
     81    * If you used to catch specific `MgException` subclass types, refer to the example below for how to migrate your exception handling code for your target language
     82
     83Before (PHP):
     84{{{#!php
     85try {
     86    ...
     87} catch (MgUnauthorizedAccessException $e) {
     88    ...
     89}
     90}}}
     91
     92After (PHP):
     93{{{#!php
     94try {
     95    ...
     96} catch (MgException $e) {
     97    if ($e->GetExceptionCode() == MgExceptionCodes::MgUnauthorizedAccessException) {
     98        ...
     99    }
     100}
     101}}}
     102
     103Before (Java):
     104{{{#!java
     105try {
     106    ...
     107} catch (MgUnauthorizedAccessException e) {
     108    ...
     109}
     110}}}
     111
     112After (Java):
     113{{{#!java
     114try {
     115    ...
     116} catch (MgException e) {
     117    if (e.getExceptionCode() == MgExceptionCodes.MgUnauthorizedAccessException) {
     118        ...
     119    }
     120}
     121}}}
     122
     123Before (C#/.net):
     124{{{#!csharp
     125try {
     126    ...
     127} catch (MgUnauthorizedAccessException e) {
     128    ...
     129}
     130}}}
     131
     132After (C#/.net):
     133{{{#!csharp
     134try {
     135    ...
     136} catch (MgException e) {
     137    if (e.GetExceptionCode() == MgExceptionCodes.MgUnauthorizedAccessException) {
     138        ...
     139    }
     140}
     141}}}
     142
     143After (C#/.net alternative method):
     144{{{#!csharp
     145try {
     146    ...
     147} catch (MgException e) when (e.GetExceptionCode() == MgExceptionCodes.MgUnauthorizedAccessException) {
     148    ...
     149}
     150}}}
    69151
    70152 * The constant members of the `MgResourcePermission` class are prefixed with `Permission`. For example `MgResourcePermission::ReadOnly` is now `MgResourcePermission::PermissionReadOnly`
    71153    * This was done to prevent reserved name collisions in PHP where `readonly` is now a reserved keyword and cannot be used as a static member name.
    72 
    73 [TODO: Cover various renamed methods in MgCoordinateSystem API]
    74154
    75155=== PHP specific notes ===
     
    78158 * The `MgPlotSpecification` constructor now requires you to specify all 4 margin parameters . If you don't need a margin, or need to set it later on (with the `SetMargins()` method), you can pass `0.0` for all 4 arguments.
    79159 * PHP 8 is more strict about data types and attempting to do things like assigning `int` to `double` and vice-versa and will generally error out in such cases.
    80    * This strictness may arise in calls to APIs like `MgRenderingService`::`RenderMap` where there is a mixture of `int` and `double` parameters in the method signature.
     160   * This strictness will generally arise in calls to APIs like `MgRenderingService`::`RenderMap` where there is a mixture of `int` and `double` parameters in the method signature.
    81161   * To ensure the correct data types are passed in, wrap expected `int` parameters with `intval()` and expected `double` parameters with `doubleval()`
    82162
     163In addition to the above changes, several public APIs are renamed specifically in the PHP binding to avoid incompatible signatures due to how overloaded/inherited methods are handled in PHP 8.
     164
     165`MgCoordinateSystemMeasure`
     166
     167The following method signatures in `MgCoordinateSystemMeasure` are renamed with a `Simple` suffix added.
     168
     169 * `double GetDistance(double x1, double y1, double x2, double y2)` (now called `GetDistanceSimple`)
     170 * `double GetAzimuth(double lon1, double lat1, double lon2, double lat2)` (now called `GetAzimuth`)
     171 * `MgCoordinate GetCoordinate(double lon, double lat, double azimuth, double distance)` (now called `GetCoordinateSimple`)
     172
     173`MgMap`
     174
     175The new overload of `Create` introduced in [wiki:MapGuideRfc157 MapGuide RFC 157] has been renamed to `CreateStateless`
     176
    83177=== Java specific notes ===
    84178
    85 This wrapper is based on and replaces the previous `MapGuideJavaApiEx` variant of the official Java binding (first introduced in [wiki:MapGuideRfc129]) and is once again called `MapGuideApi.jar`
     179The new Java binding carries all the enhancements from the previous `MapGuideJavaApiEx` binding, whose changes will be repeated here:
     180
     181All method names now adopt `camelCase` instead of `PascalCase` to match Java naming conventions.
     182
     183Proxies for various collection classes implement the `java.util.Collection` interface allowing for greater interoperability with existing Java code that works with such interfaces:
     184
     185These classes include:
     186
     187 * `MgClassDefinitionCollection` (as `Collection<MgClassDefinition>`)
     188 * `MgFeatureSchemaCollection` (as `Collection<MgFeatureSchema>`)
     189 * `MgPropertyDefinitionCollection` (as `Collection<MgPropertyDefinition>`)
     190 * `MgPropertyCollection` (as `Collection<MgProperty>`)
     191 * `MgStringCollection` (as `Collection<java.lang.String>`)
     192 * `MgLayerCollection` (as `Collection<MgLayerBase>`)
     193 * `MgLayerGroupCollection` (as `Collection<MgLayerGroup>`)
     194
     195The following collection classes do not implement the `java.util.Collection` interface due to disparity in interface and implementation
     196
     197 * `MgIntCollection` (`int` is not an object in Java)
     198 * `MgBatchPropertyCollection` (can't implement as `Collection<MgPropertyCollection>` due to a different `contains()` API)
     199
     200The following proxy classes implement `java.util.Iterable`
     201
     202 * `MgReadOnlyLayerCollection`
     203
     204Classes that implement `java.util.Collection` or `java.lang.Iterable` can be iterated with java's enhanced for loop like so:
     205
     206{{{#!java
     207MgClassDefinitionCollection classes = ...
     208for (MgClassDefinition clsDef : classes) {
     209    ...
     210}
     211}}}
     212
     213As a result of adopting `camelCase` naming conventions along with some classes implementing special Java interfaces, various methods in the MapGuide API have been renamed specifically for Java:
     214
     215 * The converted `MgException.getStackTrace()` conflicts with `java.lang.Throwable.getStackTrace()`
     216 * The converted `MgPropertyDefinition.delete()` conflicts with the SWIG-generated `delete()` method for finalization
     217 * The converted `MgClassDefinition.delete()` conflicts with the SWIG-generated `delete()` method for finalization
     218 * The converted `MgFeatureSchema.delete()` conflicts with the SWIG-generated `delete()` method for finalization
     219 * The converted `add()` method of any MapGuide collection class conflicts with the `add()` method as specified in the `java.util.Collection` interface (MapGuide's `add()` returns `void`, `java.util.Collection`'s `add()` returns `boolean`)
     220
     221The conflicting methods are renamed in the wrapper as so:
     222
     223 * `MgException::getStackTrace()` will become `MgException.getExceptionStackTrace()`
     224 * `MgPropertyDefinition.delete()` will become `MgPropertyDefinition.markAsDeleted()`
     225 * `MgClassDefinition.delete()` will become `MgClassDefinition.markAsDeleted()`
     226 * `MgFeatureSchema.delete()` will become `MgFeatureSchema.markAsDeleted()`
     227 * The `add()` method of any MapGuide collection class implementing `java.util.Collection` will become `addItem()`
    86228
    87229`MapGuideApiEx.jar` is no longer generated and bundled.
     
    104246 * A greenfield ASP.net application targeting .net Core/.net 5+
    105247
    106 Ability to target [.net Core/.net 5+] on Linux TBD
    107 
    108 == Impact summary for deployments ==
     248Refer to deployment impact summary below for remarks around .net deployment.
     249
     250As part of this RFC, we will offer experimental support to target [.net Core/.net 5+] on Linux. This is achieved by adding support in our Linux build system for building the "common libs subset". This subset consists of:
     251
     252 * Internal Thirdparty Libraries
     253    * ACE
     254    * GEOS
     255    * JsonCpp
     256    * Xerces-C
     257    * CS-Map
     258 * MapGuide Common Libraries
     259    * Foundation
     260    * Geometry
     261    * PlatformBase
     262    * MapGuideCommon
     263 * Web Tier common libraries
     264    * HttpHandler
     265    * WebApp
     266    * WebSupport
     267
     268Along with the .net SWIG interop glue libraries. Once this subset is built, all the `.so` library files will be copied over to a Windows build environment, where such files will be bundled into the resulting NuGet packages we create for the MapGuide API for .net
     269
     270For maximum portability on Linux, the "common libs subset" should be built against internal Thirdparty libraries on a Linux distro with the oldest supported version of glibc. On adoption of this RFC, is is expected that this subset will be built in a CentOS 7 environment.
     271
     272For a full end-to-end build of MapGuide for both Windows/Linux, the recommended build order will be:
     273
     274 1. Common libs subset on a CentOS 7 environment
     275 2. Copy/transfer the compiled `.so` libraries from the CentOS 7 environment to the Windows environment
     276 3. Build MapGuide on Windows
     277 4. Build MapGuide on supported Linux distros
     278
     279Despite now being a `netstandard2.0` library, Mac OSX is not a supported runtime environment
     280
     281== Impact summary for deployments (Windows) ==
     282
     283=== PHP ===
    109284
    110285The PHP binding is built for the Non-Thread-Safe (NTS) profile. This means that we no longer configure PHP support in Apache via `mod_php`. Instead PHP support in Apache is now configured via FastCGI through `mod_fcgid`. This allows us to bundle/ship one set of PHP NTS binaries that can correctly work in both IIS and Apache configurations on Windows. Previously, we did the incorrect thing of bundling the Thread-Safe (TS) PHP binaries and used it for both Apache (supported) and IIS (un-supported).
    111286
     287Barring the required migrations in your PHP codebase, the deployment process/experience should remain the same.
     288
     289=== Java ===
     290
     291The bundled version of Tomcat is 9.0.37. Refer to the Tomcat documentation for any migration/configuration/breaking changes from previous Tomcat versions
     292
     293=== .net ===
     294
     295The MapGuide web tier installation will still assume the default of IIS and .net Framework 4.8 for the .net configuration.
     296
     297If you are intending to deploy an ASP.net core MapGuide application to your MapGuide Web Tier, refer to the [https://docs.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-6.0&tabs=visual-studio Microsoft-recommended deployment process] for deploying to IIS
     298
     299== Impact summary for deployments (Linux) ==
     300
     301=== PHP ===
     302
     303Bundled PHP support does not use FastCGI like Windows. It still uses `mod_php`
     304
     305=== Java ===
     306
     307The bundled version of Tomcat is 9.0.37. Refer to the Tomcat documentation for any migration/configuration/breaking changes from previous Tomcat versions
     308
     309=== .net ===
     310
     311If you are intending to take advantage of the experimental Linux support of the .net binding, you should follow the [https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-6.0 Microsoft-recommended deployment process] for deploying an ASP.net core application to Linux with Apache as the web server, and make the necessary adjustments so that
     312
    112313== Test Plan ==
    113314
     
    116317Ensure AJAX viewer for all 3 languages are functional with these new bindings.
    117318
     319Ensure all code samples work under these new bindings.
     320
    118321Ensure Fusion is functional with these new bindings.
    119322