Overview
TheProductFactory class is a factory utility that creates instances of TNB products based on system properties. It uses Java’s ServiceLoader mechanism to discover and instantiate the appropriate product implementation (Camel Quarkus, Camel Spring Boot, etc.) for either local or OpenShift environments.
Class information
Package:software.tnb.product
Type: Final utility class (cannot be instantiated)
Methods
create()
Creates an instance of a product based on system properties.Returns
The product instance matching the configured product type and deployment environment
Example
This method automatically determines the product type from
TestConfiguration.product() and whether to create a local or OpenShift instance based on OpenshiftConfiguration.isOpenshift().create(Class<P>)
Creates an instance of a product and returns it as the specified class type.Parameters
The class type to cast the product instance to (must extend
Product)Returns
The product instance cast to the specified class type
Throws
IllegalArgumentException- If no product implementation is found matching the configuration
Example
How it works
TheProductFactory uses the following selection criteria:
- Product type matching: Filters products where the class name contains the configured product value from
TestConfiguration.product() - Environment matching: Ensures the product type matches the deployment environment:
OpenshiftProductimplementations for OpenShift environments- Local product implementations for local environments
- ServiceLoader discovery: Uses Java’s
ServiceLoaderto find all availableProductimplementations on the classpath
Error handling
If no matching product is found, the factory throws anIllegalArgumentException with a descriptive message indicating:
- The configured product type
- The deployment environment (OpenShift or local)
Usage in tests
Configuration
The factory relies on these system properties:- test.product: Product type identifier (e.g., “quarkus”, “springboot”)
- test.openshift: Boolean indicating if running on OpenShift
- Maven profiles
- System properties (
-Dtest.product=quarkus) - Environment variables
- Test configuration files
Related
- IntegrationBuilder - Build integrations with the created product
- Customizers - Customize integration behavior