Skip to content

Commit 13c05d7

Browse files
authored
Rename Pico Module (#6682)
* resolved issue #6610
1 parent d130dce commit 13c05d7

File tree

37 files changed

+88
-82
lines changed

37 files changed

+88
-82
lines changed

nima/webserver/webserver/src/main/java/module-info.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io.helidon.common.features.api.Feature;
1818
import io.helidon.common.features.api.HelidonFlavor;
1919
import io.helidon.nima.webserver.http.spi.SinkProvider;
20+
import io.helidon.pico.api.ModuleComponent;
2021

2122
/**
2223
* Loom based WebServer.
@@ -72,5 +73,5 @@
7273
uses SinkProvider;
7374

7475
provides io.helidon.nima.webserver.spi.ServerConnectionProvider with io.helidon.nima.webserver.http1.Http1ConnectionProvider;
75-
provides io.helidon.pico.api.Module with io.helidon.nima.webserver.Pico$$Module;
76+
provides ModuleComponent with io.helidon.nima.webserver.Pico$$Module;
7677
}

pico/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Request and Session scopes are simply not made available in Pico. We believe tha
4949
* Dependency - An <i>injection point</i> represents what is considered to be a dependency, perhaps <i>qualified</i> or Optional, on another service or contract. This is just another what to describe an <i>injection point</i>.
5050
* Activator (aka ServiceProvider) - This is what is code generated by Pico to lazily activate your <i>service</i> instance(s) in the Pico <i>services registry</i>, and it handles resolving all <i>dependencies</i> it has, along with <i>inject</i>ing the fields, methods, etc. that are required to be satisfied as part of that activation process.
5151
* Services (aka services registry) - This is the collection of all services that are known to the JVM/runtime in Pico.
52-
* Module - This is where your application will "bind" services into the <i>services registry</i> - typically code generated, and typically with one module per jar/module in your application.
52+
* ModuleComponent - This is where your application will "bind" services into the <i>services registry</i> - typically code generated, and typically with one module per jar/module in your application.
5353
* Application - The fully realized set of modules and services/service providers that constitute your application, and code-generated using <b>Helidon Pico Tooling</b>.
5454

5555
## Getting Started

pico/api/src/main/java/io/helidon/pico/api/Application.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* <p>
2626
* Note: instances of this type are not eligible for injection.
2727
*
28-
* @see Module
28+
* @see ModuleComponent
2929
*/
3030
@Contract
3131
public interface Application extends OptionallyNamed {

pico/api/src/main/java/io/helidon/pico/api/Module.java renamed to pico/api/src/main/java/io/helidon/pico/api/ModuleComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* @see Application
3030
*/
3131
@Contract
32-
public interface Module extends OptionallyNamed {
32+
public interface ModuleComponent extends OptionallyNamed {
3333

3434
/**
3535
* Called by the provider implementation at bootstrapping time to bind all services / service providers to the

pico/api/src/main/java/io/helidon/pico/api/PicoServicesConfig.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,25 +279,25 @@ public boolean usesCompileTimeApplications() {
279279

280280

281281
/**
282-
* The key that controls whether any {@link io.helidon.pico.api.Module}'s
282+
* The key that controls whether any {@link io.helidon.pico.api.ModuleComponent}'s
283283
* (typically produced at compile-time by Pico tooling) can be discovered and is used during Pico startup processing. It is
284284
* strongly suggested for developers to adopt a compile-time strategy for producing the dependency/injection model as it will
285285
* lead to faster startup times as well as be deterministic and validated during compile-time instead of at runtime.
286286
*/
287287
public static final String KEY_USES_COMPILE_TIME_MODULES = "uses-compile-time-modules";
288288
/**
289-
* The default value for this is true, meaning that the Pico will attempt to find and use {@link io.helidon.pico.api.Module} code
289+
* The default value for this is true, meaning that the Pico will attempt to find and use {@link io.helidon.pico.api.ModuleComponent} code
290290
* generated during compile-time (see Pico's APT <i>processor</i> and <i>maven-plugin</i> modules for usage).
291291
*/
292292
public static final String DEFAULT_USES_COMPILE_TIME_MODULES = "true";
293293

294294
/**
295-
* Flag indicating whether compile-time generated {@link io.helidon.pico.api.Module}'s should be used at Pico's startup
295+
* Flag indicating whether compile-time generated {@link io.helidon.pico.api.ModuleComponent}'s should be used at Pico's startup
296296
* initialization. Setting this value to false will have no affect if the underlying provider does not support compile-time
297297
* generation via {@link #supportsCompileTime()}.
298298
*
299299
* @return the flag indicating whether the provider is permitted to use Application generated code from compile-time
300-
* @see io.helidon.pico.api.Module
300+
* @see ModuleComponent
301301
* @see io.helidon.pico.api.Activator
302302
*/
303303
@ConfiguredOption(key = KEY_USES_COMPILE_TIME_MODULES, value = DEFAULT_USES_COMPILE_TIME_MODULES)
@@ -310,7 +310,7 @@ public boolean usesCompileTimeModules() {
310310
* The key that represents whether the provider supports compile-time code generation of DI artifacts.
311311
*
312312
* @see io.helidon.pico.api.Application
313-
* @see io.helidon.pico.api.Module
313+
* @see io.helidon.pico.api.ModuleComponent
314314
* @see io.helidon.pico.api.Activator
315315
* @see #usesCompileTimeApplications()
316316
* @see #usesCompileTimeModules()

pico/api/src/main/java/io/helidon/pico/api/ServiceProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public interface ServiceProvider<T> extends InjectionPointProvider<T>, Weighted
115115
* The agent/instance to be used for binding this service provider to the pico application that was code generated.
116116
*
117117
* @return the service provider that should be used for binding, or empty if this provider does not support binding
118-
* @see Module
118+
* @see ModuleComponent
119119
* @see ServiceBinder
120120
* @see ServiceProviderBindable
121121
*/

pico/api/src/main/java/io/helidon/pico/api/ServiceProviderBindable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* and thereby works in conjunction with the {@link ServiceBinder} during pico service registry
2424
* initialization.
2525
* <p>
26-
* The only guarantee the provider implementation has is ensuring that {@link Module} instances
26+
* The only guarantee the provider implementation has is ensuring that {@link ModuleComponent} instances
2727
* are bound to the pico services instances, as well as informed on the module name.
2828
* <p>
2929
* Generally this class should be called internally by the framework, and typically occurs only during initialization sequences.
@@ -36,7 +36,7 @@ public interface ServiceProviderBindable<T> extends ServiceProvider<T> {
3636

3737
/**
3838
* Called to inform a service provider the module name it is bound to. Will only be called when there is a non-null
39-
* module name associated for the given {@link Module}. A service provider can be associated with
39+
* module name associated for the given {@link ModuleComponent}. A service provider can be associated with
4040
* 0..1 modules.
4141
*
4242
* @param moduleName the non-null module name

pico/maven-plugin/src/main/java/io/helidon/pico/maven/plugin/AbstractApplicationCreatorMojo.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import io.helidon.pico.api.CallingContextFactory;
3838
import io.helidon.pico.api.DefaultCallingContext;
3939
import io.helidon.pico.api.DefaultServiceInfoCriteria;
40-
import io.helidon.pico.api.Module;
40+
import io.helidon.pico.api.ModuleComponent;
4141
import io.helidon.pico.api.PicoServices;
4242
import io.helidon.pico.api.PicoServicesConfig;
4343
import io.helidon.pico.api.ServiceProvider;
@@ -143,9 +143,9 @@ String getThisModuleName() {
143143
return moduleName;
144144
}
145145

146-
ServiceProvider<Module> lookupThisModule(String name,
147-
Services services) {
148-
return services.lookupFirst(Module.class, name, false).orElseThrow(() -> noModuleFoundError(name));
146+
ServiceProvider<ModuleComponent> lookupThisModule(String name,
147+
Services services) {
148+
return services.lookupFirst(ModuleComponent.class, name, false).orElseThrow(() -> noModuleFoundError(name));
149149
}
150150

151151
String getClassPrefixName() {
@@ -260,7 +260,9 @@ protected void innerExecute() {
260260
ApplicationCreator creator = applicationCreator();
261261

262262
List<ServiceProvider<?>> allModules = services
263-
.lookupAll(DefaultServiceInfoCriteria.builder().addContractImplemented(Module.class.getName()).build());
263+
.lookupAll(DefaultServiceInfoCriteria.builder()
264+
.addContractImplemented(ModuleComponent.class.getName())
265+
.build());
264266
getLog().info("processing modules: " + toDescriptions(allModules));
265267
if (allModules.isEmpty()) {
266268
warn("no modules to process");
@@ -284,7 +286,7 @@ protected void innerExecute() {
284286
? moduleInfoPathRef.get().getPath()
285287
: null;
286288
String moduleInfoModuleName = getThisModuleName();
287-
ServiceProvider<Module> moduleSp = lookupThisModule(moduleInfoModuleName, services);
289+
ServiceProvider<ModuleComponent> moduleSp = lookupThisModule(moduleInfoModuleName, services);
288290
String packageName = determinePackageName(Optional.ofNullable(moduleSp), serviceTypeNames, descriptor, true);
289291

290292
CodeGenPaths codeGenPaths = DefaultCodeGenPaths.builder()

pico/maven-plugin/src/main/java/io/helidon/pico/maven/plugin/AbstractCreatorMojo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import io.helidon.common.types.DefaultTypeName;
2828
import io.helidon.common.types.TypeName;
29-
import io.helidon.pico.api.Module;
29+
import io.helidon.pico.api.ModuleComponent;
3030
import io.helidon.pico.api.PicoServicesConfig;
3131
import io.helidon.pico.api.ServiceProvider;
3232
import io.helidon.pico.tools.AbstractCreator;
@@ -264,7 +264,7 @@ public void execute() throws MojoExecutionException {
264264
* @param persistIt pass true to write it to scratch, so that we can use it in the future for this module
265265
* @return the package name (which also typically doubles as the application name)
266266
*/
267-
protected String determinePackageName(Optional<ServiceProvider<Module>> optModuleSp,
267+
protected String determinePackageName(Optional<ServiceProvider<ModuleComponent>> optModuleSp,
268268
Collection<TypeName> typeNames,
269269
ModuleInfoDescriptor descriptor,
270270
boolean persistIt) {
@@ -276,7 +276,7 @@ protected String determinePackageName(Optional<ServiceProvider<Module>> optModul
276276
return packageName;
277277
}
278278

279-
ServiceProvider<Module> moduleSp = optModuleSp.orElse(null);
279+
ServiceProvider<ModuleComponent> moduleSp = optModuleSp.orElse(null);
280280
if (moduleSp != null) {
281281
packageName = DefaultTypeName.createFromTypeName(moduleSp.serviceInfo().serviceTypeName()).packageName();
282282
} else {

pico/maven-plugin/src/main/java/io/helidon/pico/maven/plugin/ExternalModuleCreatorMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
import static io.helidon.pico.maven.plugin.MavenPluginUtils.externalModuleCreator;
5252

5353
/**
54-
* Responsible for creating pico {@link io.helidon.pico.api.Activator}'s and a {@link io.helidon.pico.api.Module}
54+
* Responsible for creating pico {@link io.helidon.pico.api.Activator}'s and a {@link io.helidon.pico.api.ModuleComponent}
5555
* wrapping a set of packages from an external third-party jar.
5656
*/
5757
@Mojo(name = "external-module-create", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true,

pico/runtime/src/main/java/io/helidon/pico/runtime/DefaultPicoServices.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
import io.helidon.pico.api.Injector;
5555
import io.helidon.pico.api.InjectorOptions;
5656
import io.helidon.pico.api.Metrics;
57-
import io.helidon.pico.api.Module;
57+
import io.helidon.pico.api.ModuleComponent;
5858
import io.helidon.pico.api.Phase;
5959
import io.helidon.pico.api.PicoException;
6060
import io.helidon.pico.api.PicoServices;
@@ -75,7 +75,7 @@ class DefaultPicoServices implements PicoServices, Resettable {
7575
private final AtomicBoolean initializingServicesFinished = new AtomicBoolean(false);
7676
private final AtomicBoolean isBinding = new AtomicBoolean(false);
7777
private final AtomicReference<DefaultServices> services = new AtomicReference<>();
78-
private final AtomicReference<List<Module>> moduleList = new AtomicReference<>();
78+
private final AtomicReference<List<ModuleComponent>> moduleList = new AtomicReference<>();
7979
private final AtomicReference<List<Application>> applicationList = new AtomicReference<>();
8080
private final Bootstrap bootstrap;
8181
private final PicoServicesConfig cfg;
@@ -303,7 +303,7 @@ private void initializeServices() {
303303

304304
if (isGlobal) {
305305
// iterate over all modules, binding to each one's set of services, but with NO activations
306-
List<Module> modules = findModules(true);
306+
List<ModuleComponent> modules = findModules(true);
307307
try {
308308
isBinding.set(true);
309309
bindModules(thisServices, modules);
@@ -372,16 +372,16 @@ private List<Application> findApplications(boolean load) {
372372
return result;
373373
}
374374

375-
private List<Module> findModules(boolean load) {
376-
List<Module> result = moduleList.get();
375+
private List<ModuleComponent> findModules(boolean load) {
376+
List<ModuleComponent> result = moduleList.get();
377377
if (result != null) {
378378
return result;
379379
}
380380

381381
result = new ArrayList<>();
382382
if (load) {
383-
ServiceLoader<Module> serviceLoader = ServiceLoader.load(Module.class);
384-
for (Module module : serviceLoader) {
383+
ServiceLoader<ModuleComponent> serviceLoader = ServiceLoader.load(ModuleComponent.class);
384+
for (ModuleComponent module : serviceLoader) {
385385
result.add(module);
386386
}
387387

@@ -413,14 +413,14 @@ private void bindApplications(DefaultServices services,
413413
}
414414

415415
private void bindModules(DefaultServices services,
416-
Collection<Module> modules) {
416+
Collection<ModuleComponent> modules) {
417417
if (!cfg.usesCompileTimeModules()) {
418418
LOGGER.log(System.Logger.Level.DEBUG, "module binding is disabled");
419419
return;
420420
}
421421

422422
if (modules.isEmpty()) {
423-
LOGGER.log(System.Logger.Level.WARNING, "no " + Module.class.getName() + " was found.");
423+
LOGGER.log(System.Logger.Level.WARNING, "no " + ModuleComponent.class.getName() + " was found.");
424424
} else {
425425
modules.forEach(module -> services.bind(this, module, isBinding.get()));
426426
}

pico/runtime/src/main/java/io/helidon/pico/runtime/DefaultServices.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import io.helidon.pico.api.InjectionException;
3939
import io.helidon.pico.api.Intercepted;
4040
import io.helidon.pico.api.Metrics;
41-
import io.helidon.pico.api.Module;
41+
import io.helidon.pico.api.ModuleComponent;
4242
import io.helidon.pico.api.Phase;
4343
import io.helidon.pico.api.PicoException;
4444
import io.helidon.pico.api.PicoServices;
@@ -460,7 +460,7 @@ void bind(PicoServices picoServices,
460460
}
461461

462462
void bind(PicoServices picoServices,
463-
Module module,
463+
ModuleComponent module,
464464
boolean initializing) {
465465
String moduleName = module.named().orElse(module.getClass().getName());
466466
boolean isLoggable = DefaultPicoServices.LOGGER.isLoggable(System.Logger.Level.TRACE);
@@ -475,7 +475,7 @@ void bind(PicoServices picoServices,
475475
}
476476
}
477477

478-
private ServiceProvider<?> createServiceProvider(Module module,
478+
private ServiceProvider<?> createServiceProvider(ModuleComponent module,
479479
String moduleName,
480480
PicoServices picoServices) {
481481
return new PicoModuleServiceProvider(module, moduleName, picoServices);

pico/runtime/src/main/java/io/helidon/pico/runtime/PicoModuleServiceProvider.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,27 @@
1818

1919
import io.helidon.pico.api.DefaultQualifierAndValue;
2020
import io.helidon.pico.api.DefaultServiceInfo;
21-
import io.helidon.pico.api.Module;
21+
import io.helidon.pico.api.ModuleComponent;
2222
import io.helidon.pico.api.PicoServices;
2323
import io.helidon.pico.api.ServiceInfo;
2424

2525
/**
26-
* Basic {@link io.helidon.pico.api.Module} implementation. A Pico module is-a service provider also.
26+
* Basic {@link ModuleComponent} implementation. A Pico module is-a service provider also.
2727
*/
28-
class PicoModuleServiceProvider extends AbstractServiceProvider<Module> {
28+
class PicoModuleServiceProvider extends AbstractServiceProvider<ModuleComponent> {
2929

30-
PicoModuleServiceProvider(Module module,
30+
PicoModuleServiceProvider(ModuleComponent module,
3131
String moduleName,
3232
PicoServices picoServices) {
3333
super(module, PicoServices.terminalActivationPhase(), createServiceInfo(module, moduleName), picoServices);
3434
serviceRef(module);
3535
}
3636

37-
static ServiceInfo createServiceInfo(Module module,
37+
static ServiceInfo createServiceInfo(ModuleComponent module,
3838
String moduleName) {
3939
DefaultServiceInfo.Builder builder = DefaultServiceInfo.builder()
4040
.serviceTypeName(module.getClass().getName())
41-
.addContractsImplemented(Module.class.getName());
41+
.addContractsImplemented(ModuleComponent.class.getName());
4242
if (moduleName != null) {
4343
builder.moduleName(moduleName)
4444
.addQualifier(DefaultQualifierAndValue.createNamed(moduleName));

pico/runtime/src/main/java/io/helidon/pico/runtime/ServiceUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import io.helidon.pico.api.Application;
2626
import io.helidon.pico.api.DependenciesInfo;
27-
import io.helidon.pico.api.Module;
27+
import io.helidon.pico.api.ModuleComponent;
2828
import io.helidon.pico.api.ServiceInfo;
2929
import io.helidon.pico.api.ServiceProvider;
3030

@@ -48,7 +48,7 @@ public static boolean isQualifiedInjectionTarget(ServiceProvider<?> sp) {
4848
DependenciesInfo deps = sp.dependencies();
4949
return (deps != AbstractServiceProvider.NO_DEPS)
5050
|| (!contractsImplemented.isEmpty()
51-
&& !contractsImplemented.contains(Module.class.getName())
51+
&& !contractsImplemented.contains(ModuleComponent.class.getName())
5252
&& !contractsImplemented.contains(Application.class.getName()));
5353
}
5454

pico/runtime/src/main/java/module-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
provides io.helidon.pico.spi.PicoServicesProvider
3232
with io.helidon.pico.runtime.DefaultPicoServicesProvider;
3333

34-
uses io.helidon.pico.api.Module;
34+
uses io.helidon.pico.api.ModuleComponent;
3535
uses io.helidon.pico.api.Application;
3636
}

pico/runtime/src/test/java/io/helidon/pico/runtime/HelloPicoWorldSanityTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import io.helidon.pico.api.DefaultBootstrap;
3333
import io.helidon.pico.api.DefaultInjectorOptions;
3434
import io.helidon.pico.api.Injector;
35-
import io.helidon.pico.api.Module;
35+
import io.helidon.pico.api.ModuleComponent;
3636
import io.helidon.pico.api.Phase;
3737
import io.helidon.pico.api.PicoServices;
3838
import io.helidon.pico.api.PicoServicesConfig;
@@ -91,7 +91,7 @@ void tearDown() {
9191
void sanity() {
9292
Services services = PicoServices.realizedServices();
9393

94-
List<ServiceProvider<Module>> moduleProviders = services.lookupAll(Module.class);
94+
List<ServiceProvider<ModuleComponent>> moduleProviders = services.lookupAll(ModuleComponent.class);
9595
assertThat(moduleProviders.size(),
9696
equalTo(EXPECTED_MODULES));
9797
List<String> descriptions = ServiceUtils.toDescriptions(moduleProviders);

pico/runtime/src/test/java/io/helidon/pico/runtime/testsubjects/EmptyModule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.helidon.pico.runtime.testsubjects;
1818

19-
import io.helidon.pico.api.Module;
19+
import io.helidon.pico.api.ModuleComponent;
2020
import io.helidon.pico.api.ServiceBinder;
2121

2222
import jakarta.inject.Singleton;
@@ -25,7 +25,7 @@
2525
* For testing.
2626
*/
2727
@Singleton
28-
public final class EmptyModule implements Module {
28+
public final class EmptyModule implements ModuleComponent {
2929

3030
@Override
3131
public void configure(ServiceBinder binder) {

pico/runtime/src/test/java/io/helidon/pico/runtime/testsubjects/HelloPico$$Module.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import java.util.Optional;
2020

21-
import io.helidon.pico.api.Module;
21+
import io.helidon.pico.api.ModuleComponent;
2222
import io.helidon.pico.api.ServiceBinder;
2323

2424
import jakarta.annotation.Generated;
@@ -28,7 +28,7 @@
2828
@Generated(value = "example", comments = "API Version: n")
2929
@Singleton
3030
@Named(HelloPico$$Module.NAME)
31-
public final class HelloPico$$Module implements Module {
31+
public final class HelloPico$$Module implements ModuleComponent {
3232

3333
public static final String NAME = "example";
3434

pico/tests/resources-pico/src/main/java/module-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
exports io.helidon.pico.tests.pico.stacking;
3333
exports io.helidon.pico.tests.pico.tbox;
3434

35-
provides io.helidon.pico.api.Module with io.helidon.pico.tests.pico.Pico$$Module;
35+
provides io.helidon.pico.api.ModuleComponent with io.helidon.pico.tests.pico.Pico$$Module;
3636
provides io.helidon.pico.api.Application with io.helidon.pico.tests.pico.Pico$$Application;
3737
}

0 commit comments

Comments
 (0)