Skip to content

Introduce Helidon Pico #5141

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 11 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ docs/se/config/images
jmh-baseline.json

# benchmark results
nima/tests/benchmark/techempower/results
nima/tests/benchmark/techempower/results
13 changes: 13 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,19 @@
<artifactId>helidon-nima-fault-tolerance</artifactId>
<version>${helidon.version}</version>
</dependency>

<!-- Pico -->
<dependency>
<groupId>io.helidon.pico</groupId>
<artifactId>helidon-pico-api</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.pico</groupId>
<artifactId>helidon-pico-types</artifactId>
<version>${helidon.version}</version>
</dependency>

</dependencies>
</dependencyManagement>
</project>
33 changes: 33 additions & 0 deletions pico/api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2022 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>io.helidon.pico</groupId>
<artifactId>helidon-pico-project</artifactId>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>helidon-pico-api</artifactId>
<name>Helidon Pico API</name>

</project>
39 changes: 39 additions & 0 deletions pico/api/src/main/java/io/helidon/pico/api/Contract.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.helidon.pico.api;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* The Contract annotation is used to relay significance to the type. While remaining optional in its use, it is typically placed
* on an interface definition to signify that the given type can be used for lookup in the service registry, or otherwise be
* eligible for injection via standard @Inject. It could also be used on other types (e.g., abstract class) as well.
* <p>
*
* If the developer does not have access to the source to place this annotation on the interface definition then consider using
* {@link ExternalContracts} instead - this annotation can be placed on the implementation class implementing the given interface.
* See io.helidon.pico.spi.ServiceInfo#getContractsImplemented()
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(java.lang.annotation.ElementType.TYPE)
public @interface Contract {

}
49 changes: 49 additions & 0 deletions pico/api/src/main/java/io/helidon/pico/api/ExternalContracts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.helidon.pico.api;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Placed on the implementation of a service as an alternative to using a {@link Contract}.
* <p>
* Use this annotation when it is impossible to place an annotation on the interface itself - for instance of the interface comes
* from a 3rd party library/provider.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(java.lang.annotation.ElementType.TYPE)
public @interface ExternalContracts {

/**
* The advertised contract type(s) for the service class implementation.
*
* @return the external contract(s)
*/
Class<?>[] value();

/**
* The optional set of module names where this contract is expected to reside.
*
* @return the optional module names
*/
String[] moduleNames() default {};

}
54 changes: 54 additions & 0 deletions pico/api/src/main/java/io/helidon/pico/api/RunLevel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.helidon.pico.api;

import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.TYPE;

/**
* Indicates the desired startup sequence for a service class.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(TYPE)
@Inherited
public @interface RunLevel {

/**
* Represents an eager singleton.
*/
int STARTUP = 0;

/**
* Anything > 0 is left to the underlying provider implementation's discretion for meaning; this is just a default for something
* that is deemed "other than startup".
*/
int NORMAL = 100;

/**
* The service ranking applied when not declared explicitly.
*
* @return the startup int value, defaulting to {@link #NORMAL}
*/
int value() default NORMAL;

}
25 changes: 25 additions & 0 deletions pico/api/src/main/java/io/helidon/pico/api/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Types that are Pico API/consumer facing. The Pico API provide types that are generally useful at compile time
* to assign special meaning to the type. In this way it also helps with readability and intentions of the code itself.
* <p>
* <li> {@link io.helidon.pico.api.Contract} - signifies that the type can be used for lookup in the service registry.
* <li> {@link io.helidon.pico.api.ExternalContracts} - same as Contract, but applied to the implementation class instead.
* <li> {@link io.helidon.pico.api.RunLevel} - ascribes meaning for when the service should start.
*/
package io.helidon.pico.api;
22 changes: 22 additions & 0 deletions pico/api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Pico API module.
*/
module io.helidon.pico.api {
exports io.helidon.pico.api;
}
82 changes: 82 additions & 0 deletions pico/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2022 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.helidon</groupId>
<artifactId>helidon-project</artifactId>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>io.helidon.pico</groupId>
<artifactId>helidon-pico-project</artifactId>
<name>Helidon Pico Project</name>

<packaging>pom</packaging>

<properties>
<!-- all pico modules should be backward compatible with 11 -->
<version.java>11</version.java>

<!-- pico supports legacy javax.inject and javax.annotations in tooling -->
<javax.injection.version>1</javax.injection.version>
</properties>

<!-- this will show the progression of what has come over, and what is left to come over -->
<modules>
<module>api</module>
<!-- <module>spi</module>-->
<module>types</module>
<!-- <module>builder</module>-->
<!-- <module>config</module>-->
<!-- <module>pico</module>-->
<!-- <module>tck</module>-->
<!-- <module>tools</module>-->
<!-- <module>processor</module>-->
<!-- <module>maven-plugin</module>-->
<!-- <module>test-support</module>-->
<!-- <module>test-utils</module>-->
<!-- <module>test-resources</module>-->
<!-- <module>test-extended-resources</module>-->
<!-- <module>test-pico</module>-->
<!-- <module>test-tck-jsr330</module>-->
<!-- <module>examples</module>-->
</modules>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<!-- This module is Java 11, we must remove enable-preview from parent project -->
<additionalOptions combine.self="override"/>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>
34 changes: 34 additions & 0 deletions pico/types/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2022 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>io.helidon.pico</groupId>
<artifactId>helidon-pico-project</artifactId>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>helidon-pico-types</artifactId>
<name>Helidon Pico Types</name>
<description>Provides the runtime types (a subset of SPI) useful for Pico</description>

</project>
Loading