Skip to content

Commit

Permalink
Merge pull request #70 from Pi4J/ContextMockCreation
Browse files Browse the repository at this point in the history
clarification of Mock Context create
  • Loading branch information
FDelporte authored Nov 23, 2024
2 parents 9bfc45e + d3839d7 commit 0bc373a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion content/about/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ All releases of Pi4J V.2 are listed on [github.com/Pi4J/pi4j-v2/releases](https:
Because of the changes in the loading of the mock providers, if you want to load them on a Raspberry Pi board, you need to use the following context builder:

```java
var pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().build();
var pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build();
```

Thanks to contributions by [@ylexus](https://github.com/ylexus), [@mores](https://github.com/mores), [@taartspi](https://github.com/taartspi), [@eitch](https://github.com/eitch), [@fdelporte](https://github.com/fdelporte).
Expand Down
8 changes: 8 additions & 0 deletions content/documentation/create-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ allowing users to customize the context configuration.
### Automatic
An auto context includes AUTO-DETECT BINDINGS enabled which will load all detected Pi4J extension libraries
(Platforms and Providers) in the class path.
Note: Starting with 2.5.0-SNAPSHOT the Mock providers are not loaded. If the Mock providers are required see
Alternate Context Creation With Mock Providers.

``` java
var pi4j = Pi4J.newAutoContext();
Expand All @@ -44,6 +46,12 @@ Context pi4j = Pi4J.newContextBuilder()
.add(new MyCustomSPIProvider(/* implements SpiProvider, id="my-spi-prov" */))
.build();
```
### Alternate Context Creation With Mock Providers
The following code example will create a Context containing all the Mock Providers and Platform.

``` java
Context pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build();
```

## More information

Expand Down
3 changes: 2 additions & 1 deletion content/documentation/providers/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Pi4J 2.0 - 2.4: Multiple providers for the same I/O type can be loaded into a Pi
inputs at the same time.

As of Pi4J 2.5 multiple providers for the same I/O type is no longer supported. During the Context initialization it will
ensure only a single provider for an I/O type is loaded.
ensure only a single provider for an I/O type is loaded. In addition the Mock Providers are not loaded unless
expressly requested when creating the Context. [See Create Context](../create-context.md)

Current supported providers:

Expand Down

0 comments on commit 0bc373a

Please sign in to comment.