public class Configurator
extends java.lang.Object
Configurator works in two different modes:
Dependency Injection Mode
- If the Engine already has an Api set on it, then it is assumed that a developer has at least partially wired up their own Api via code. In this case, the Configurator looks for named beans in the Api object graph(s) and sets any corresponding "beanName.propertyName" values fromconfiguration on the bean.
This is a great way to inject runtime dependencies such as database credentials. If developers are hard core SpringBoot-ers, or are otherwise coding up their Inversion
Api using some existing DI framework, they may find this capability to be redundant and prefer to use their own party DI which is totally fine.
Full Wiring Mode
- when an Engine starts up and no Api's have been added to the Engine via code, then the Configurator does all of the work to fully instantiate/configure/bootstrap the Api object model based on data found in theconfiguration. Here is an outline how Full Wiring Mode works.
startup() is called on all Db objects effectively bootstrapping the full Api model.
configuration are merged down on top of the in memory pairs. This allows the configuration author to overwrite any of the bean properties set during the Db.startup()
default bootstrapping.
configuration, a default api named "api" will be instantiated for you and the Configurator
will assume all Db, Endpoints and Actions declared in the configuration belong to that single implicit Api.
configuration, a default Endpoint named "endpoint"
that matches on all HTTP methods and URL paths will be inferred by the Configurator. If you declear multiple Apis, you must declare Endpoints if you want your Api to do anything.
configuration, you must assign Dbs, Endpoints, and global Actions to the appropriate Api.
A "global" Action is one that is not explicitly assigned to an Endpoint but is instead assigned directly to the Api and can then be selected to run across requests to multiple different Endpoints.
Here is an example minimal configuration for Full Wiring Mode that will produce a fully running REST API for the underlying data source.
These name/value pairs can come from any combination of property sources loaded into configuration.
myAction.class=io.inversion.db.DbAction
myDb.class=io.inversion.jdbc.JdbcDb
myDb.driver=${YOUR JDBC DRIVER CLASS NAME}
myDb.url=${YOUR JDBC URL}
myDb.user=${YOUR JDBC USERNAME}
myDb.pass=${YOUR JDBC PASSWORD}
By default, the configuration is going to the global default CombinedConfiguration from Config.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
MASK |
static java.lang.Object[] |
MASKED_FIELDS
If a bean property field name appears in this list, it will not be logged but replaced with "************"
in the output.
|
| Constructor and Description |
|---|
Configurator() |
| Modifier and Type | Method and Description |
|---|---|
void |
configure(Engine engine,
org.apache.commons.configuration2.Configuration configuration)
Wires up an Api at runtime by reflectively setting bean properties based on key/value configuration properties.
|
public static final java.lang.Object[] MASKED_FIELDS
Put values here in lower case.
public static final java.lang.String MASK
public void configure(Engine engine, org.apache.commons.configuration2.Configuration configuration)
engine - the engine to be configuredconfiguration - the name/value pairs used to wire up the Api's that will be added to engine.Engine.startup(),
ConfigCopyright © 2021 Rocket Partners, LLC. All rights reserved.