forked from helidon-io/helidon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Special treatment for ParamConverterProviders with multiple apps (mas…
…ter) (helidon-io#3857) * Special treatment for ParamConverterProviders with multiple apps (helidon-io#3846) * Special treatment for ParamConverterProviders. They are now all registered in the shared injection manager when more than one application is present. This ensures they are all properly installed; otherwise, Jersey will only consider those known after the first of the applications is registered. Signed-off-by: Santiago Pericasgeertsen <[email protected]> * Updated copyright year. Signed-off-by: Santiago Pericasgeertsen <[email protected]> * New approach that calls getClasses/getSingletons and does require finding ParamConverterProviders via class scanning. Signed-off-by: Santiago Pericasgeertsen <[email protected]> * Restore ExceptionMapper registration statement. Signed-off-by: Santiago Pericasgeertsen <[email protected]> * Fixed support for singletons and additional testing. Signed-off-by: Santiago Pericasgeertsen <[email protected]> * Fixed Helidon version after cherry-pick. Signed-off-by: Santiago Pericasgeertsen <[email protected]> * Fixed imports. Signed-off-by: Santiago Pericasgeertsen <[email protected]> * Renamed javax packages in imports. Signed-off-by: Santiago Pericasgeertsen <[email protected]>
- Loading branch information
Showing
15 changed files
with
507 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?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> | ||
<artifactId>helidon-tests-functional-project</artifactId> | ||
<groupId>io.helidon.tests.functional</groupId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>helidon-tests-param-converter-provider</artifactId> | ||
<name>Helidon Functional Test: ParamConverterProviders and injection managers</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.helidon.microprofile.bundles</groupId> | ||
<artifactId>helidon-microprofile</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss</groupId> | ||
<artifactId>jandex</artifactId> | ||
<scope>runtime</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-all</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.microprofile.tests</groupId> | ||
<artifactId>helidon-microprofile-tests-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
39 changes: 39 additions & 0 deletions
39
...ovider/src/main/java/io/helidon/tests/functional/paramconverterprovider/Application1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.tests.functional.paramconverterprovider; | ||
|
||
import java.util.Set; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.ws.rs.core.Application; | ||
import jakarta.ws.rs.ext.ParamConverterProvider; | ||
|
||
@ApplicationScoped | ||
public class Application1 extends Application { | ||
|
||
private final ParamConverterProvider provider = new ParamConverterProvider3(); | ||
|
||
@Override | ||
public Set<Class<?>> getClasses() { | ||
return Set.of(Resource1.class, ParamConverterProvider1.class); | ||
} | ||
|
||
@Override | ||
public Set<Object> getSingletons() { | ||
return Set.of(provider); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...ovider/src/main/java/io/helidon/tests/functional/paramconverterprovider/Application2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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.tests.functional.paramconverterprovider; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.ws.rs.core.Application; | ||
import java.util.Set; | ||
|
||
@ApplicationScoped | ||
public class Application2 extends Application { | ||
|
||
@Override | ||
public Set<Class<?>> getClasses() { | ||
return Set.of(Resource2.class, ParamConverterProvider2.class); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...ain/java/io/helidon/tests/functional/paramconverterprovider/ParamConverterAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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.tests.functional.paramconverterprovider; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target({java.lang.annotation.ElementType.PARAMETER, | ||
java.lang.annotation.ElementType.METHOD, | ||
java.lang.annotation.ElementType.FIELD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface ParamConverterAnnotation { | ||
|
||
String value(); | ||
} |
45 changes: 45 additions & 0 deletions
45
...main/java/io/helidon/tests/functional/paramconverterprovider/ParamConverterProvider1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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.tests.functional.paramconverterprovider; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.ws.rs.ext.ParamConverter; | ||
import jakarta.ws.rs.ext.ParamConverterProvider; | ||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Type; | ||
|
||
@ApplicationScoped | ||
public class ParamConverterProvider1 implements ParamConverterProvider { | ||
|
||
public ParamConverterProvider1() { | ||
TestCollector.PARAM_CONVERTER_PROVIDERS.add(getClass()); | ||
} | ||
|
||
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) { | ||
return new ParamConverter<T>() { | ||
@Override | ||
public T fromString(String value) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String toString(T value) { | ||
return null; | ||
} | ||
}; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...main/java/io/helidon/tests/functional/paramconverterprovider/ParamConverterProvider2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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.tests.functional.paramconverterprovider; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.ws.rs.ext.ParamConverter; | ||
import jakarta.ws.rs.ext.ParamConverterProvider; | ||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Type; | ||
|
||
@ApplicationScoped | ||
public class ParamConverterProvider2 implements ParamConverterProvider { | ||
|
||
public ParamConverterProvider2() { | ||
TestCollector.PARAM_CONVERTER_PROVIDERS.add(getClass()); | ||
} | ||
|
||
@Override | ||
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) { | ||
return new ParamConverter<T>() { | ||
@Override | ||
public T fromString(String value) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String toString(T value) { | ||
return null; | ||
} | ||
}; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...main/java/io/helidon/tests/functional/paramconverterprovider/ParamConverterProvider3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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.tests.functional.paramconverterprovider; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.ws.rs.ext.ParamConverter; | ||
import jakarta.ws.rs.ext.ParamConverterProvider; | ||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Type; | ||
|
||
@ApplicationScoped | ||
public class ParamConverterProvider3 implements ParamConverterProvider { | ||
|
||
public ParamConverterProvider3() { | ||
TestCollector.PARAM_CONVERTER_PROVIDERS.add(getClass()); | ||
} | ||
|
||
@Override | ||
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) { | ||
return new ParamConverter<T>() { | ||
@Override | ||
public T fromString(String value) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String toString(T value) { | ||
return null; | ||
} | ||
}; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...-provider/src/main/java/io/helidon/tests/functional/paramconverterprovider/Resource1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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.tests.functional.paramconverterprovider; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.QueryParam; | ||
|
||
@Path("hello1") | ||
public class Resource1 { | ||
|
||
@GET | ||
public String get(@QueryParam("foo") @ParamConverterAnnotation("bar") String s) { | ||
return "hello"; | ||
} | ||
} |
Oops, something went wrong.