Skip to content

Commit a4ea634

Browse files
authored
Introduce Helidon Pico (#5141)
Introduce Pico. Includes API and Types modules.
1 parent cf3e2fe commit a4ea634

File tree

15 files changed

+599
-1
lines changed

15 files changed

+599
-1
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ docs/se/config/images
8282
jmh-baseline.json
8383

8484
# benchmark results
85-
nima/tests/benchmark/techempower/results
85+
nima/tests/benchmark/techempower/results

bom/pom.xml

+13
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,19 @@
13451345
<artifactId>helidon-nima-fault-tolerance</artifactId>
13461346
<version>${helidon.version}</version>
13471347
</dependency>
1348+
1349+
<!-- Pico -->
1350+
<dependency>
1351+
<groupId>io.helidon.pico</groupId>
1352+
<artifactId>helidon-pico-api</artifactId>
1353+
<version>${helidon.version}</version>
1354+
</dependency>
1355+
<dependency>
1356+
<groupId>io.helidon.pico</groupId>
1357+
<artifactId>helidon-pico-types</artifactId>
1358+
<version>${helidon.version}</version>
1359+
</dependency>
1360+
13481361
</dependencies>
13491362
</dependencyManagement>
13501363
</project>

pico/api/pom.xml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (c) 2022 Oracle and/or its affiliates.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
<parent>
23+
<groupId>io.helidon.pico</groupId>
24+
<artifactId>helidon-pico-project</artifactId>
25+
<version>4.0.0-SNAPSHOT</version>
26+
<relativePath>../pom.xml</relativePath>
27+
</parent>
28+
<modelVersion>4.0.0</modelVersion>
29+
30+
<artifactId>helidon-pico-api</artifactId>
31+
<name>Helidon Pico API</name>
32+
33+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2022 Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.helidon.pico.api;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.Retention;
21+
import java.lang.annotation.RetentionPolicy;
22+
import java.lang.annotation.Target;
23+
24+
/**
25+
* The Contract annotation is used to relay significance to the type. While remaining optional in its use, it is typically placed
26+
* on an interface definition to signify that the given type can be used for lookup in the service registry, or otherwise be
27+
* eligible for injection via standard @Inject. It could also be used on other types (e.g., abstract class) as well.
28+
* <p>
29+
*
30+
* If the developer does not have access to the source to place this annotation on the interface definition then consider using
31+
* {@link ExternalContracts} instead - this annotation can be placed on the implementation class implementing the given interface.
32+
* See io.helidon.pico.spi.ServiceInfo#getContractsImplemented()
33+
*/
34+
@Documented
35+
@Retention(RetentionPolicy.RUNTIME)
36+
@Target(java.lang.annotation.ElementType.TYPE)
37+
public @interface Contract {
38+
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2022 Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.helidon.pico.api;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.Retention;
21+
import java.lang.annotation.RetentionPolicy;
22+
import java.lang.annotation.Target;
23+
24+
/**
25+
* Placed on the implementation of a service as an alternative to using a {@link Contract}.
26+
* <p>
27+
* Use this annotation when it is impossible to place an annotation on the interface itself - for instance of the interface comes
28+
* from a 3rd party library/provider.
29+
*/
30+
@Documented
31+
@Retention(RetentionPolicy.RUNTIME)
32+
@Target(java.lang.annotation.ElementType.TYPE)
33+
public @interface ExternalContracts {
34+
35+
/**
36+
* The advertised contract type(s) for the service class implementation.
37+
*
38+
* @return the external contract(s)
39+
*/
40+
Class<?>[] value();
41+
42+
/**
43+
* The optional set of module names where this contract is expected to reside.
44+
*
45+
* @return the optional module names
46+
*/
47+
String[] moduleNames() default {};
48+
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2022 Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.helidon.pico.api;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.Inherited;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
import static java.lang.annotation.ElementType.TYPE;
26+
27+
/**
28+
* Indicates the desired startup sequence for a service class.
29+
*/
30+
@Documented
31+
@Retention(RetentionPolicy.RUNTIME)
32+
@Target(TYPE)
33+
@Inherited
34+
public @interface RunLevel {
35+
36+
/**
37+
* Represents an eager singleton.
38+
*/
39+
int STARTUP = 0;
40+
41+
/**
42+
* Anything > 0 is left to the underlying provider implementation's discretion for meaning; this is just a default for something
43+
* that is deemed "other than startup".
44+
*/
45+
int NORMAL = 100;
46+
47+
/**
48+
* The service ranking applied when not declared explicitly.
49+
*
50+
* @return the startup int value, defaulting to {@link #NORMAL}
51+
*/
52+
int value() default NORMAL;
53+
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2022 Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Types that are Pico API/consumer facing. The Pico API provide types that are generally useful at compile time
19+
* to assign special meaning to the type. In this way it also helps with readability and intentions of the code itself.
20+
* <ul>
21+
* <li>{@link io.helidon.pico.api.Contract} - signifies that the type can be used for lookup in the service registry.</li>
22+
* <li>{@link io.helidon.pico.api.ExternalContracts} - same as Contract, but applied to the implementation class instead.</li>
23+
* <li>{@link io.helidon.pico.api.RunLevel} - ascribes meaning for when the service should start.</li>
24+
* </ul>
25+
*/
26+
package io.helidon.pico.api;
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (c) 2022 Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Pico API module.
19+
*/
20+
module io.helidon.pico.api {
21+
exports io.helidon.pico.api;
22+
}

pico/pom.xml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (c) 2022 Oracle and/or its affiliates.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<parent>
26+
<groupId>io.helidon</groupId>
27+
<artifactId>helidon-project</artifactId>
28+
<version>4.0.0-SNAPSHOT</version>
29+
<relativePath>../pom.xml</relativePath>
30+
</parent>
31+
32+
<groupId>io.helidon.pico</groupId>
33+
<artifactId>helidon-pico-project</artifactId>
34+
<name>Helidon Pico Project</name>
35+
36+
<packaging>pom</packaging>
37+
38+
<properties>
39+
<!-- all pico modules should be backward compatible with 11 -->
40+
<version.java>11</version.java>
41+
42+
<!-- pico supports legacy javax.inject and javax.annotations in tooling -->
43+
<javax.injection.version>1</javax.injection.version>
44+
</properties>
45+
46+
<!-- this will show the progression of what has come over, and what is left to come over -->
47+
<modules>
48+
<module>api</module>
49+
<!-- <module>spi</module>-->
50+
<module>types</module>
51+
<!-- <module>builder</module>-->
52+
<!-- <module>config</module>-->
53+
<!-- <module>pico</module>-->
54+
<!-- <module>tck</module>-->
55+
<!-- <module>tools</module>-->
56+
<!-- <module>processor</module>-->
57+
<!-- <module>maven-plugin</module>-->
58+
<!-- <module>test-support</module>-->
59+
<!-- <module>test-utils</module>-->
60+
<!-- <module>test-resources</module>-->
61+
<!-- <module>test-extended-resources</module>-->
62+
<!-- <module>test-pico</module>-->
63+
<!-- <module>test-tck-jsr330</module>-->
64+
<!-- <module>examples</module>-->
65+
</modules>
66+
67+
<build>
68+
<pluginManagement>
69+
<plugins>
70+
<plugin>
71+
<groupId>org.apache.maven.plugins</groupId>
72+
<artifactId>maven-javadoc-plugin</artifactId>
73+
<configuration>
74+
<!-- This module is Java 11, we must remove enable-preview from parent project -->
75+
<additionalOptions combine.self="override"/>
76+
</configuration>
77+
</plugin>
78+
</plugins>
79+
</pluginManagement>
80+
</build>
81+
82+
</project>

pico/types/pom.xml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (c) 2022 Oracle and/or its affiliates.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
<parent>
23+
<groupId>io.helidon.pico</groupId>
24+
<artifactId>helidon-pico-project</artifactId>
25+
<version>4.0.0-SNAPSHOT</version>
26+
<relativePath>../pom.xml</relativePath>
27+
</parent>
28+
<modelVersion>4.0.0</modelVersion>
29+
30+
<artifactId>helidon-pico-types</artifactId>
31+
<name>Helidon Pico Types</name>
32+
<description>Provides the runtime types (a subset of SPI) useful for Pico</description>
33+
34+
</project>

0 commit comments

Comments
 (0)