You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changes receive dependencies through method parameters, automatically injected by Flamingock from the target system's context, global context, or underlying framework context.
179
+
Changes receive dependencies through method parameters, automatically injected by Flamingock using a **flexible, multi-source approach** with fallback hierarchy.
// database and session injected from target system or global context
186
-
}
181
+
### Change Execution Dependency Resolution
187
182
188
-
// SQL target system
189
-
@Apply
190
-
publicvoid apply(DataSource dataSource) {
191
-
// dataSource and connection injected from target system or global context
192
-
}
193
-
```
183
+
Change execution uses a flexible dependency resolution flow(in this priority order):
184
+
185
+
1.**Target system context** - dependencies from **constructor** + `.withXXX()` methods
186
+
2.**Target system additional dependencies** - added via `.addDependency()` or `.setProperty()`
187
+
3.**Global context** (fallback) - shared dependencies available to all target systems
188
+
189
+
190
+
### Key Benefits of This Architecture
191
+
192
+
-**Target system isolation**: Each target system has its own dependency context
193
+
-**Flexible fallback**: Changes can access both system-specific and shared dependencies
194
+
-**Clear precedence**: Target system dependencies always override global ones
195
+
-**Type safety**: Strongly typed dependency injection with compile-time checking
194
196
195
-
For more details on how dependency resolution works, see [Context and dependencies](../flamingock-library-config/context-and-dependencies.md).
197
+
For complete details on target system configuration vs change execution dependencies, see [Target Systems Introduction](../target-systems/introduction.md#dependency-injection).
Copy file name to clipboardExpand all lines: docs/target-systems/couchbase-target-system.md
+40-32Lines changed: 40 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,57 +7,65 @@ sidebar_position: 5
7
7
8
8
The Couchbase target system (`CouchbaseTargetSystem`) enables Flamingock to apply changes to Couchbase databases using the official Couchbase Java SDK. As a transactional target system, it supports automatic rollback through Couchbase's transaction capabilities.
While dependencies can be provided through the global context, we highly recommend injecting them directly at the target system level. This provides clearer scoping, better isolation between systems, and makes dependencies explicit and easier to track.
16
+
The constructor requires the target system name, Couchbase cluster, and bucket. Optional configurations can be added via `.withXXX()` methods.
19
17
20
-
## Dependencies
18
+
## Target System Configuration
21
19
22
-
Following Flamingock's [dependency resolution hierarchy](../flamingock-library-config/context-and-dependencies.md), you can provide dependencies via direct injection or global context.
20
+
The Couchbase target system uses Flamingock's [split dependency resolution architecture](introduction.md#dependency-injection) with separate flows for target system configuration and change execution dependencies.
23
21
24
-
### Required dependencies
22
+
### Constructor Dependencies (Mandatory)
25
23
26
-
| Dependency | Method | Description |
27
-
|------------|--------|-------------|
28
-
|`Cluster`|`.withCluster(cluster)`| Couchbase cluster connection - **required** for both Change execution and transaction management |
29
-
|`Bucket`|`.withBucket(bucket)`| Target bucket instance - **required** for both Change execution and transaction management |
24
+
These dependencies must be provided at target system creation time with **no global context fallback**:
30
25
31
-
Remember: If not provided directly via `.withXXX()`, Flamingock searches the global context. If still not found:
32
-
-**Required dependencies** will throw an exception
|`Cluster`|`cluster`| Couchbase cluster connection - **required** for both target system configuration and change execution |
29
+
|`Bucket`|`bucket`| Target bucket instance - **required** for both target system configuration and change execution |
30
+
31
+
### Dependencies Available to Changes
32
+
33
+
Changes can access dependencies through [dependency injection with fallback](../changes/anatomy-and-structure.md#method-parameters-and-dependency-injection):
34
+
35
+
1.**Target system context** (highest priority) - `Cluster`, `Bucket`, `AttemptContext`, plus any added via `.addDependency()`
36
+
2.**Target system additional dependencies** - added via `.addDependency()` or `.setProperty()`
37
+
3.**Global context** (fallback) - shared dependencies available to all target systems
33
38
34
39
## Configuration example
35
40
36
-
Here's a comprehensive example showing dependency resolution:
41
+
Here's a comprehensive example showing the new architecture:
.addDependency(auditService); // Additional dependency for changes
44
47
45
-
// Global context with different dependencies
48
+
// Global context with shared dependencies
46
49
Flamingock.builder()
47
-
.addDependency(defaultCluster) // Different cluster in global
48
-
.addDependency(defaultBucket) // Different bucket in global
49
-
.addDependency(emailService) // Available to all targets
50
+
.addDependency(emailService) // Available to all target systems
51
+
.addDependency(logService) // Available to all target systems
50
52
.addTargetSystems(couchbaseTarget)
51
53
.build();
52
54
```
53
55
54
-
**What gets resolved for Changes in "user-database":**
55
-
-**Cluster**: Uses `productionCluster` (from target system, not `defaultCluster` from global)
56
-
-**Bucket**: Uses `userBucket` (from target system, not `defaultBucket` from global)
57
-
-**AuditService**: Available from target system context
58
-
-**EmailService**: Available from global context
56
+
**Target system configuration resolution:**
57
+
-**Cluster**: Must be provided via constructor (`productionCluster`)
58
+
-**Bucket**: Must be provided via constructor (`userBucket`)
59
+
60
+
**Change dependency resolution for Changes in "user-database":**
61
+
-**Cluster**: From target system context (`productionCluster`)
62
+
-**Bucket**: From target system context (`userBucket`)
63
+
-**AttemptContext**: From target system context (created by Flamingock)
64
+
-**AuditService**: From target system additional dependencies
65
+
-**EmailService**: From global context (fallback)
66
+
-**LogService**: From global context (fallback)
59
67
60
-
The target system context always takes precedence, ensuring proper isolation between different systems.
68
+
This architecture ensures explicit target system configuration while providing flexible dependency access for changes.
61
69
62
70
## Transactional support
63
71
@@ -116,9 +124,9 @@ Without the `AttemptContext` parameter, operations will execute but won't partic
116
124
117
125
## Available dependencies in Changes
118
126
119
-
Your Changes can inject Couchbase-specific dependencies like `Cluster`, `Bucket`, and `AttemptContext` (for transactions), but are not limited to these. Any dependency can be added to the target system contextvia `.addDependency()`, taking precedence over global dependencies.
127
+
Your Changes can inject Couchbase-specific dependencies like `Cluster`, `Bucket`, and `AttemptContext` (for transactions), but are not limited to these. The target system provides these dependencies through its context, and you can add additional dependencies via `.addDependency()` that take precedence over global dependencies.
120
128
121
-
For more details on dependency resolution, see [Context and dependencies](../flamingock-library-config/context-and-dependencies.md).
129
+
For comprehensive details on change dependency resolution, see [Change Anatomy & Structure](../changes/anatomy-and-structure.md).
Unlike specialized target systems, DefaultTargetSystem requires no mandatory dependencies. You have complete flexibility to inject whatever dependencies your Changes need.
30
+
Unlike specialized target systems, DefaultTargetSystem requires no mandatory constructor dependencies. You have complete flexibility to inject whatever dependencies your Changes need.
31
31
32
-
## Dependencies
32
+
## Target System Configuration
33
33
34
-
Following Flamingock's [dependency resolution hierarchy](../flamingock-library-config/context-and-dependencies.md), you can provide dependencies via direct injection or global context.
34
+
The Default target system uses Flamingock's [split dependency resolution architecture](introduction.md#dependency-injection) with separate flows for target system configuration and change execution dependencies.
35
35
36
-
### No required dependencies
36
+
### Constructor Dependencies (None)
37
37
38
-
DefaultTargetSystem has no `.withXXX()` methods for required dependencies. This provides maximum flexibility for working with any type of system.
All dependencies are provided through generic methods:
47
+
All dependencies and configurations are provided through generic methods with **no global context fallback** during target system configuration:
43
48
44
49
| Method | Description |
45
50
|--------|-------------|
46
-
|`.addDependency(object)`| Add a dependency by type |
47
-
|`.addDependency(name, object)`| Add a named dependency |
48
-
|`.setProperty(key, value)`| Set a configuration property |
51
+
|`.addDependency(object)`| Add a dependency by type for changes |
52
+
|`.addDependency(name, object)`| Add a named dependency for changes |
53
+
|`.setProperty(key, value)`| Set a configuration property for changes |
49
54
50
-
Remember: If not provided directly, Flamingock searches the global context for dependencies.
55
+
### Dependencies Available to Changes
56
+
57
+
Changes can access dependencies through [dependency injection with fallback](../changes/anatomy-and-structure.md#method-parameters-and-dependency-injection):
58
+
59
+
1.**Target system context** (highest priority) - any dependencies added via `.addDependency()` or properties via `.setProperty()`
60
+
2.**Global context** (fallback) - shared dependencies available to all target systems
51
61
52
62
## Configuration example
53
63
54
-
Here's a comprehensive example showing dependency resolution:
64
+
Here's a comprehensive example showing the new architecture:
55
65
56
66
```java
57
-
// Target system with Kafka Schema Registry dependencies
67
+
// Target system configuration (no mandatory constructor dependencies)
.addDependency(metricsService) // Available to all targets
66
-
.addDependency(notificationService) // Available to all targets
75
+
.addDependency(metricsService) // Available to all target systems
76
+
.addDependency(notificationService) // Available to all target systems
67
77
.addTargetSystems(schemaRegistry)
68
78
.build();
69
79
```
70
80
71
-
**What gets resolved for Changes in "kafka-schema-registry":**
72
-
-**SchemaRegistryClient**: Available from target system context
73
-
-**Registry URL**: Available as "registry-url" from target system context
74
-
-**Compatibility level**: Available as property from target system context
75
-
-**MetricsService**: Available from global context
76
-
-**NotificationService**: Available from global context
81
+
**Target system configuration resolution:**
82
+
-**No mandatory dependencies**: Target system created with name only
83
+
-**Additional dependencies**: Added via `.addDependency()` methods
84
+
-**Configuration properties**: Added via `.setProperty()` method
85
+
86
+
**Change dependency resolution for Changes in "kafka-schema-registry":**
87
+
-**SchemaRegistryClient**: From target system additional dependencies
88
+
-**Registry URL**: From target system context as named dependency ("registry-url")
89
+
-**Compatibility level**: From target system context as property ("compatibility.level")
90
+
-**MetricsService**: From global context (fallback)
91
+
-**NotificationService**: From global context (fallback)
77
92
78
-
The target system context always takes precedence, ensuring proper isolation between different systems.
93
+
This architecture provides maximum flexibility while maintaining clear separation between target system setup and change execution.
79
94
80
95
**How compensation works:**
81
96
1.**No transaction boundaries**: Operations execute immediately with no automatic rollback
@@ -86,9 +101,9 @@ The target system context always takes precedence, ensuring proper isolation bet
86
101
87
102
## Available dependencies in Changes
88
103
89
-
Your Changes can inject any dependencies you add to the target system context via `.addDependency()`, taking precedence over global dependencies. Common examples include system clients, configuration values, custom services, and properties.
104
+
Your Changes can inject any dependencies you add to the target system context via `.addDependency()` or properties via `.setProperty()`, which take precedence over global dependencies. Common examples include system clients, configuration values, custom services, and properties.
90
105
91
-
For more details on dependency resolution, see [Context and dependencies](../flamingock-library-config/context-and-dependencies.md).
106
+
For comprehensive details on change dependency resolution, see [Change Anatomy & Structure](../changes/anatomy-and-structure.md).
0 commit comments