|
| 1 | += jdp-2026-06: Service manager request customization |
| 2 | + |
| 3 | +// SPDX-FileCopyrightText: Copyright 2026 Mark Rotteveel |
| 4 | +// SPDX-License-Identifier: LicenseRef-PDL-1.0 |
| 5 | + |
| 6 | +== Status |
| 7 | + |
| 8 | +* Draft |
| 9 | +* Proposed for: Jaybird 5.0.13, Jaybird 6.0.6, Jaybird 7 |
| 10 | + |
| 11 | +== Type |
| 12 | + |
| 13 | +* Feature-Specification |
| 14 | + |
| 15 | +== Context |
| 16 | + |
| 17 | +When new options are added to Services API operations, users of Jaybird cannot use them without: |
| 18 | + |
| 19 | +. A new Jaybird release providing support |
| 20 | +. Subclassing or duplicating the service manager implementation to add support |
| 21 | + |
| 22 | +Sometimes we only add new features after users explicitly ask for them, or if we notice their absence -- possibly long after the initial introduction in Firebird. |
| 23 | + |
| 24 | +Having some way for Jaybird users to customize the request buffer of an operation before it's executed will allow them to configure options not (yet) supported by Jaybird (or, possibly, correct or work around bugs). |
| 25 | + |
| 26 | +Most operations to be customized go through `FBServiceManager#executeServicesOperation(FbService, ServiceRequestBuffer)`. |
| 27 | + |
| 28 | +Exceptions to this are: |
| 29 | + |
| 30 | +* `FBStreamingBackupManager#backupDatabase` |
| 31 | +* `FBStreamingBackupManager#backupMetadata` |
| 32 | +* `FBStreamingBackupManager#restoreDatabase` |
| 33 | +* Various operations in `FBTraceManager` |
| 34 | + |
| 35 | +(Some might be rewritten to call `executeServicesOperation` instead.) |
| 36 | + |
| 37 | +== Decision |
| 38 | + |
| 39 | +We add a functional interface `org.firebirdsql.management.ServiceRequestCustomizer` with a single method, `customize(ServiceRequestBuffer, ServiceRequestContext)`. |
| 40 | + |
| 41 | +.Parameters of `customize` |
| 42 | +`org.firebirdsql.gds.ServiceRequestBuffer`:: |
| 43 | +The parameter buffer to be passed to the start service action method. |
| 44 | ++ |
| 45 | +This parameter buffer has been populated by the implementation before it is passed to the customizer. |
| 46 | +The customizer may add or remove arguments as needed. |
| 47 | + |
| 48 | +`org.firebirdsql.management.ServiceRequestContext`:: |
| 49 | +A class (or interface or record) providing context information. |
| 50 | ++ |
| 51 | +Initially, we'll only add one accessor: |
| 52 | + |
| 53 | +`String operation()`::: |
| 54 | +The operation name. |
| 55 | + |
| 56 | +`ServiceManager` receives a property for the `ServiceRequestCustomizer`, and implementations call the customizer before starting the service action. |
| 57 | +Implementations that previously did not call `executeServicesOperation` are either rewritten to call it, or are changed to call the customizer themselves. |
| 58 | + |
| 59 | +The operation name is generally the name of the API method initiating the operation. |
| 60 | +For example, it reports the method name of the caller of `executeServicesOperation`. |
| 61 | +Bar bugs, like deeper callstacks than assumed, the operation names are stable as these are the methods defined in the API of the various service manager interfaces. |
| 62 | + |
| 63 | +Alternatively, a customizer can look at the first argument in the service request buffer (the action), or use solutions like `java.lang.StackWalker` to look at the callstack. |
| 64 | + |
| 65 | +The use of the `ServiceRequestContext` object instead of passing the operation name directly allows for future extension without changing the method signature. |
| 66 | + |
| 67 | +For example, the gbak `-INCLUDE_DATA` support added to Jaybird 7 by https://github.com/FirebirdSQL/jaybird/issues/944[#944] can also be realized with: |
| 68 | + |
| 69 | +[source,java] |
| 70 | +---- |
| 71 | +var backupManager = new FBBackupManager(); |
| 72 | +// Perform other config... |
| 73 | +// Set customizer |
| 74 | +backupManager.setServiceRequestCustomizer((request, context) -> { |
| 75 | + // Only apply for backup |
| 76 | + if (!"backupDatabase".equals(context.operation())) return; |
| 77 | + request.addArgument(ISCConstants.isc_spb_bkp_include_data, "ORDER%") |
| 78 | +}); |
| 79 | +---- |
| 80 | + |
| 81 | +(Above example is tentative, and might differ from actual implementation.) |
| 82 | + |
| 83 | +== Consequences |
| 84 | + |
| 85 | +The addition of `ServiceRequestCustomizer` will provide users with an escape hatch for missing features. |
| 86 | +As we consider this a feature of last resort, it is only documented in the API docs, and receives minimal coverage in the release notes. |
| 87 | +It will not be documented in the Jaybird manual. |
| 88 | +This decision may be revisited in the future. |
| 89 | + |
| 90 | +The customizer gives full control over the service request buffer. |
| 91 | +This means that users can change the action performed or make other additions or changes that can can result in errors from the server if wrong information is put in the request buffer. |
| 92 | +Jaybird may also produce errors if the changes result in different service output than expected by the implementation in Jaybird. |
| 93 | + |
| 94 | +Providing this customization feature may result in users implementing their own workarounds, and never reporting an improvement request. |
| 95 | +This could result in Jaybird never or much later receiving such new features. |
| 96 | +We accept that risk. |
| 97 | + |
| 98 | +[appendix] |
| 99 | +== License Notice |
| 100 | + |
| 101 | +The contents of this Documentation are subject to the Public Documentation License Version 1.0 (the “License”); |
| 102 | +you may only use this Documentation if you comply with the terms of this License. |
| 103 | +A copy of the License is available at https://firebirdsql.org/en/public-documentation-license/. |
| 104 | + |
| 105 | +The Original Documentation is "`jdp-2026-06: Service manager request customization`". |
| 106 | +The Initial Writer of the Original Documentation is Mark Rotteveel, Copyright © 2026. |
| 107 | +All Rights Reserved. |
| 108 | +(Initial Writer contact(s): mark (at) lawinegevaar (dot) nl). |
| 109 | + |
| 110 | +//// |
| 111 | +Contributor(s): ______________________________________. |
| 112 | +Portions created by ______ are Copyright © _________ [Insert year(s)]. |
| 113 | +All Rights Reserved. |
| 114 | +(Contributor contact(s): ________________ [Insert hyperlink/alias]). |
| 115 | +//// |
| 116 | + |
| 117 | +The exact file history is recorded in our Git repository; |
| 118 | +see https://github.com/FirebirdSQL/jaybird |
0 commit comments