Search in sources :

Example 1 with DefaultServiceConfigurer

use of io.cdap.cdap.internal.app.services.DefaultServiceConfigurer in project cdap by caskdata.

the class DefaultAppConfigurer method addService.

@Override
public void addService(Service service) {
    Preconditions.checkArgument(service != null, "Service cannot be null.");
    // check that a system service is only used in system namespace
    if (!deployNamespace.equals(Id.Namespace.fromEntityId(NamespaceId.SYSTEM))) {
        TypeToken<?> type = TypeToken.of(service.getClass()).resolveType(Service.class.getTypeParameters()[0]);
        if (SystemServiceConfigurer.class.isAssignableFrom(type.getRawType())) {
            throw new IllegalArgumentException(String.format("Invalid service '%s'. Services can only use a SystemServiceConfigurer if the application is " + "deployed in the system namespace.", service.getClass().getSimpleName()));
        }
    }
    DefaultSystemTableConfigurer systemTableConfigurer = new DefaultSystemTableConfigurer();
    DefaultServiceConfigurer configurer = new DefaultServiceConfigurer(service, deployNamespace, artifactId, pluginFinder, pluginInstantiator, systemTableConfigurer, runtimeInfo, getFeatureFlagsProvider());
    service.configure(configurer);
    ServiceSpecification spec = configurer.createSpecification();
    addDatasetsAndPlugins(configurer);
    addSystemTableSpecs(systemTableConfigurer.getTableSpecs());
    services.put(spec.getName(), spec);
}
Also used : ServiceSpecification(io.cdap.cdap.api.service.ServiceSpecification) DefaultSystemTableConfigurer(io.cdap.cdap.internal.app.services.DefaultSystemTableConfigurer) DefaultServiceConfigurer(io.cdap.cdap.internal.app.services.DefaultServiceConfigurer)

Aggregations

ServiceSpecification (io.cdap.cdap.api.service.ServiceSpecification)1 DefaultServiceConfigurer (io.cdap.cdap.internal.app.services.DefaultServiceConfigurer)1 DefaultSystemTableConfigurer (io.cdap.cdap.internal.app.services.DefaultSystemTableConfigurer)1