Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarification of Mock Context create #70

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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