Skip to content

All Pico services should default to a lesser than DEFAULT_WEIGHT #6590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
public interface ServiceInfoBasics {

/**
* Default weight for any weighted component (whether it implements this interface
* or uses {@link io.helidon.common.Weight} annotation).
* Default weight for any <i>internal</i> Pico service component. It is defined to be
* {@link Weighted#DEFAULT_WEIGHT} {@code - 1} in order to allow any other service implementation to
* naturally have a higher weight (since it will use the {@code DEFAULT_WEIGHT} unless explicitly overridden.
*/
double DEFAULT_WEIGHT = Weighted.DEFAULT_WEIGHT;
double DEFAULT_PICO_WEIGHT = Weighted.DEFAULT_WEIGHT;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see the -1 mentioned in the javadoc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! lol

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushed


/**
* The managed service implementation {@link Class}.
Expand Down Expand Up @@ -96,13 +97,13 @@ default int realizedRunLevel() {
Optional<Double> declaredWeight();

/**
* The realized weight will use the default weight if no weight was specified directly.
* The realized weight will use {@link Weighted#DEFAULT_WEIGHT} if no weight was specified directly.
*
* @return the realized weight
* @see #declaredWeight()
*/
default double realizedWeight() {
return declaredWeight().orElse(DEFAULT_WEIGHT);
return declaredWeight().orElse(Weighted.DEFAULT_WEIGHT);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
import io.helidon.builder.config.spi.ConfigBeanBuilderValidatorProvider;
import io.helidon.common.LazyValue;
import io.helidon.common.Weight;
import io.helidon.common.Weighted;

/**
* Service-loaded provider for {@link io.helidon.builder.config.spi.ConfigResolverProvider}.
*/
@Weight(Weighted.DEFAULT_WEIGHT)
@Weight(io.helidon.pico.api.ServiceInfoBasics.DEFAULT_PICO_WEIGHT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it fully qualified? There should not be a naming conflict.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be in all usages

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was just easier to do it that way. Is that somehow a problem? I did the same for the javadoc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Javadoc, you should use fully qualified. In code, only when you have conflicting types

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushed

public class DefaultConfigBeanBuilderValidatorProvider implements ConfigBeanBuilderValidatorProvider {
static final LazyValue<ConfigBeanBuilderValidator<?>> INSTANCE = LazyValue.create(DefaultConfigBuilderValidator::new);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
import io.helidon.builder.config.spi.HelidonConfigBeanRegistry;
import io.helidon.common.LazyValue;
import io.helidon.common.Weight;
import io.helidon.common.Weighted;

/**
* Service-loaded provider for {@link ConfigBeanRegistry}.
*/
@Weight(Weighted.DEFAULT_WEIGHT)
@Weight(io.helidon.pico.api.ServiceInfoBasics.DEFAULT_PICO_WEIGHT)
public class DefaultConfigBeanRegistryProvider implements ConfigBeanRegistryProvider {
static final LazyValue<ConfigBeanRegistry> INSTANCE = LazyValue.create(DefaultPicoConfigBeanRegistry::new);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
import io.helidon.builder.config.spi.ConfigResolverProvider;
import io.helidon.common.LazyValue;
import io.helidon.common.Weight;
import io.helidon.common.Weighted;

/**
* Service-loaded provider for {@link ConfigResolverProvider}.
*/
@Weight(Weighted.DEFAULT_WEIGHT)
@Weight(io.helidon.pico.api.ServiceInfoBasics.DEFAULT_PICO_WEIGHT)
public class DefaultConfigResolverProvider implements ConfigResolverProvider {
static final LazyValue<ConfigResolver> INSTANCE = LazyValue.create(DefaultConfigResolver::new);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
import io.helidon.builder.config.spi.StringValueParserProvider;
import io.helidon.common.LazyValue;
import io.helidon.common.Weight;
import io.helidon.common.Weighted;

/**
* Service-loaded provider for {@link StringValueParserProvider}.
*/
@Weight(Weighted.DEFAULT_WEIGHT)
@Weight(io.helidon.pico.api.ServiceInfoBasics.DEFAULT_PICO_WEIGHT)
public class DefaultStringValueParserProvider implements StringValueParserProvider {
static final LazyValue<StringValueParser> INSTANCE = LazyValue.create(DefaultStringValueParser::new);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.concurrent.atomic.AtomicReference;

import io.helidon.common.Weight;
import io.helidon.common.Weighted;
import io.helidon.pico.api.Bootstrap;
import io.helidon.pico.api.PicoServices;
import io.helidon.pico.api.Resettable;
Expand All @@ -36,7 +35,7 @@
* @see io.helidon.pico.api.PicoServices#picoServices()
*/
@Singleton
@Weight(Weighted.DEFAULT_WEIGHT)
@Weight(io.helidon.pico.api.ServiceInfoBasics.DEFAULT_PICO_WEIGHT)
public class DefaultPicoServicesProvider implements PicoServicesProvider, Resettable {
private static final AtomicReference<DefaultPicoServices> INSTANCE = new AtomicReference<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
@Generated(value = "example", comments = "API Version: N")
@Singleton
@Weight(DefaultServiceInfo.DEFAULT_WEIGHT)
@Weight(io.helidon.pico.api.ServiceInfoBasics.DEFAULT_PICO_WEIGHT)
@SuppressWarnings({"unchecked", "checkstyle:TypeName"})
public class HelloPicoImpl$$picoActivator extends AbstractServiceProvider<HelloPicoWorldImpl> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.helidon.common.Weight;
import io.helidon.pico.api.DefaultServiceInfo;
import io.helidon.pico.api.DependenciesInfo;
import io.helidon.pico.api.ServiceInfo;
import io.helidon.pico.runtime.AbstractServiceProvider;
import io.helidon.pico.runtime.Dependencies;

Expand All @@ -30,15 +29,15 @@

@Generated(value = "example", comments = "API Version: n")
@Singleton
@Weight(DefaultServiceInfo.DEFAULT_WEIGHT)
@Weight(io.helidon.pico.api.ServiceInfoBasics.DEFAULT_PICO_WEIGHT)
public class PicoWorldImpl$$picoActivator extends AbstractServiceProvider<PicoWorldImpl> {
private static final DefaultServiceInfo serviceInfo =
DefaultServiceInfo.builder()
.serviceTypeName(getServiceTypeName())
.activatorTypeName(PicoWorldImpl$$picoActivator.class.getName())
.addExternalContractsImplemented(PicoWorld.class.getName())
.addScopeTypeName(Singleton.class.getName())
.declaredWeight(ServiceInfo.DEFAULT_WEIGHT)
.declaredWeight(io.helidon.pico.api.ServiceInfoBasics.DEFAULT_PICO_WEIGHT)
.build();

public static final PicoWorldImpl$$picoActivator INSTANCE = new PicoWorldImpl$$picoActivator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
* {@link ActivatorCreatorRequest#codeGenPaths()} for details.
*/
@Singleton
@Weight(Weighted.DEFAULT_WEIGHT)
@Weight(io.helidon.pico.api.ServiceInfoBasics.DEFAULT_PICO_WEIGHT)
public class DefaultActivatorCreator extends AbstractCreator implements ActivatorCreator, Weighted {
/**
* The suffix name for the service type activator class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

import io.helidon.builder.processor.tools.BuilderTypeTools;
import io.helidon.common.Weight;
import io.helidon.common.Weighted;
import io.helidon.common.types.AnnotationAndValue;
import io.helidon.common.types.DefaultTypeName;
import io.helidon.common.types.TypeName;
Expand All @@ -57,7 +56,7 @@
* The default implementation for {@link io.helidon.pico.tools.spi.ApplicationCreator}.
*/
@Singleton
@Weight(Weighted.DEFAULT_WEIGHT)
@Weight(io.helidon.pico.api.ServiceInfoBasics.DEFAULT_PICO_WEIGHT)
public class DefaultApplicationCreator extends AbstractCreator implements ApplicationCreator {
/**
* The prefix to add before the generated "Application" class name (i.e., "Pico$$" in the "Pico$$Application").
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import io.helidon.common.LazyValue;
import io.helidon.common.Weight;
import io.helidon.common.Weighted;
import io.helidon.common.types.TypeName;
import io.helidon.pico.api.DependenciesInfo;
import io.helidon.pico.api.InjectionPointInfo;
Expand Down Expand Up @@ -63,7 +62,7 @@
* The default implementation of {@link io.helidon.pico.tools.spi.ExternalModuleCreator}.
*/
@Singleton
@Weight(Weighted.DEFAULT_WEIGHT)
@Weight(io.helidon.pico.api.ServiceInfoBasics.DEFAULT_PICO_WEIGHT)
public class DefaultExternalModuleCreator extends AbstractCreator implements ExternalModuleCreator {
private final LazyValue<ScanResult> scan = LazyValue.create(ReflectionHandler.INSTANCE.scan());
private final ServicesToProcess services = ServicesToProcess.servicesInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
* The default {@link io.helidon.pico.tools.spi.InterceptorCreator} provider in use.
*/
@Singleton
@Weight(Weighted.DEFAULT_WEIGHT)
@Weight(io.helidon.pico.api.ServiceInfoBasics.DEFAULT_PICO_WEIGHT)
@SuppressWarnings("unchecked")
public class DefaultInterceptorCreator extends AbstractCreator implements InterceptorCreator, Resettable {
private static final LazyValue<ScanResult> SCAN = LazyValue.create(ReflectionHandler.INSTANCE::scan);
Expand Down