Datastore configuration classes

Optional

Configuration classes can keep the standard pattern of defining individual stores and references, exposed as Collection Spring Beans autowired in the main datastore configuration class.

The preferred usage is for configuration classes to extend AConfigurableSchema and override the createStores() and createReferences() methods, adding the stores and references directly to the configurator object.

Instantiate the resulting classes individually, set the configurator object using setConfigurator() and call the aforementioned methods. This should be done in an instance of the IDatastoreConfiguratorSetup interface, which exposes the configurator Spring Bean for further use.

For example, a given schema:

public class DefaultSchema extends AConfigurableSchema {

    public static final String SCHEMA = "Default";

    /**
     * {@inheritDoc}
     * If this method is not overridden in concrete implementation, it will not have any effect.
     */
    @Override
    public void createStores() {
        getConfigurator().addStore(SCHEMA,
                getConfigurator()
                        .storeBuilder(SCHEMA)
                        .withStoreName(StoreAndFieldConstants.TRADES_STORE_NAME)
                        .withField(StoreAndFieldConstants.ASOFDATE, LOCAL_DATE).asKeyField()
                        .withField(StoreAndFieldConstants.TRADES__TRADEID, STRING).asKeyField()
                        .withField(StoreAndFieldConstants.TRADES__NOTIONAL, DOUBLE)
                        .build()
        );
    }
}

would then be instantiated:

@Configuration
public class DatastoreConfiguratorSetup implements IDatastoreConfiguratorSetup {
    /**
     * Adds all customisations to the configurator.
     *
     * @param configurator The application datastore configurator.
     */
    @Override
    public void addModifications(IDatastoreConfigurator configurator) {

    }

    /**
     * Builds the datastores and references included in schemas. Must be called after {@link #addModifications}.
     *
     * @param configurator The application datastore configurator.
     */
    @Override
    public void buildSchemas(IDatastoreConfigurator configurator) {
        IConfigurableSchema schema = new DefaultSchema();
        schema.setConfigurator(configurator);
        schema.createStores();
        schema.createReferences();
        configurator.enableSchema(DefaultSchema.SCHEMA);
    }
}
search.js