-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Eddie Carpenter
committed
Jul 2, 2024
1 parent
fe05d96
commit 5f7f7b4
Showing
34 changed files
with
2,371 additions
and
345 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
diameter-quarkus/diameter-client-quarkus/deployment/pom.xml
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,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.go.diameter</groupId> | ||
<artifactId>diameter-client-quarkus-parent</artifactId> | ||
<version>2.0.0</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>diameter-client-quarkus-deployment</artifactId> | ||
<name>Diameter Client Quarkus Extension - Deployment</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-arc-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.go.diameter</groupId> | ||
<artifactId>diameter-client-quarkus</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5-internal</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-processor</artifactId> | ||
<version>${quarkus.version}</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
91 changes: 91 additions & 0 deletions
91
...us/deployment/src/main/java/io/go/diameter/client/deployment/DiameterClientProcessor.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,91 @@ | ||
package io.go.diameter.client.deployment; | ||
|
||
import io.go.diameter.DiameterClient; | ||
import io.go.diameter.client.runtime.DiameterClientRecorder; | ||
import io.go.diameter.config.DiameterClientConfig; | ||
import io.quarkus.arc.deployment.SyntheticBeanBuildItem; | ||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.Record; | ||
import io.quarkus.deployment.builditem.FeatureBuildItem; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.inject.Default; | ||
import org.jboss.jandex.DotName; | ||
import org.jdiameter.api.Configuration; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT; | ||
|
||
class DiameterClientProcessor | ||
{ | ||
private static final Logger LOG = LoggerFactory.getLogger(DiameterClientProcessor.class); | ||
private static final String DEFAULT_NAME = "<default>"; | ||
private static final String FEATURE = "diameter-client"; | ||
private static final DotName CONFIGURATION_DOTNAME = DotName.createSimple("org.jdiameter.api.Configuration"); | ||
|
||
@BuildStep | ||
FeatureBuildItem feature() | ||
{ | ||
return new FeatureBuildItem(FEATURE); | ||
} | ||
|
||
|
||
@Record(RUNTIME_INIT) | ||
@BuildStep | ||
void generateDiameterClient(DiameterClientRecorder recorder, | ||
DiameterClientConfig diameterConfig, | ||
BuildProducer<SyntheticBeanBuildItem> syntheticBeanBuildItemBuildProducer) | ||
{ | ||
if (diameterConfig.defaultDiameterConfig() != null) { | ||
//Define the default diameter config producer | ||
syntheticBeanBuildItemBuildProducer | ||
.produce(createSyntheticBean(DEFAULT_NAME, | ||
false, | ||
true) | ||
.createWith(recorder.clientConfiguration(DEFAULT_NAME)) | ||
.done()); | ||
}//if | ||
|
||
|
||
if (diameterConfig.namedDiameterConfigs() != null) { | ||
for (String clientName : diameterConfig.namedDiameterConfigs().keySet()) { | ||
//Define the named diameter config producer | ||
syntheticBeanBuildItemBuildProducer | ||
.produce(createSyntheticBean(clientName, | ||
true, | ||
false) | ||
.createWith(recorder.clientConfiguration(clientName)) | ||
.done()); | ||
}//for | ||
}//if | ||
} | ||
|
||
private static SyntheticBeanBuildItem.ExtendedBeanConfigurator createSyntheticBean(String clientName, | ||
boolean isNamedPersistenceUnit, | ||
boolean defaultBean) | ||
{ | ||
LOG.info("Creating Synthetic Bean for @DiameterClient(\"{}\")", clientName); | ||
SyntheticBeanBuildItem.ExtendedBeanConfigurator configurator = SyntheticBeanBuildItem | ||
.configure(Configuration.class) | ||
.scope(ApplicationScoped.class) | ||
.unremovable() | ||
.setRuntimeInit() | ||
.addType(CONFIGURATION_DOTNAME); | ||
|
||
|
||
if (defaultBean) { | ||
configurator.defaultBean(); | ||
} | ||
|
||
if (isNamedPersistenceUnit) { | ||
configurator.addQualifier().annotation(DiameterClient.class).addValue("value", clientName).done(); | ||
} | ||
else { | ||
configurator.addQualifier(Default.class); | ||
configurator.addQualifier().annotation(DiameterClient.class).done(); | ||
} | ||
|
||
return configurator; | ||
} | ||
} |
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,64 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.go.diameter</groupId> | ||
<artifactId>diameter-quarkus-parent</artifactId> | ||
<version>2.0.0</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>diameter-client-quarkus-parent</artifactId> | ||
<packaging>pom</packaging> | ||
<name>Diameter Client Quarkus Extension - Parent</name> | ||
|
||
<modules> | ||
<module>deployment</module> | ||
<module>runtime</module> | ||
</modules> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<version>${quarkus.version}</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${surefire-plugin.version}</version> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>${maven.home}</maven.home> | ||
<maven.repo>${settings.localRepository}</maven.repo> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>${failsafe-plugin.version}</version> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>${maven.home}</maven.home> | ||
<maven.repo>${settings.localRepository}</maven.repo> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${compiler-plugin.version}</version> | ||
<configuration> | ||
<compilerArgs> | ||
<arg>-parameters</arg> | ||
</compilerArgs> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
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,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.go.diameter</groupId> | ||
<artifactId>diameter-client-quarkus-parent</artifactId> | ||
<version>2.0.0</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>diameter-client-quarkus</artifactId> | ||
<name>Diameter Client Quarkus Extension - Runtime</name> | ||
<description>Diameter Client Quarkus Extension</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-arc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.go.diameter</groupId> | ||
<artifactId>jdiameter-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.go.diameter</groupId> | ||
<artifactId>jdiameter-impl</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.go.diameter</groupId> | ||
<artifactId>diameter-quarkus-config</artifactId> | ||
<version>2.0.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-maven-plugin</artifactId> | ||
<version>${quarkus.version}</version> | ||
<executions> | ||
<execution> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>extension-descriptor</goal> | ||
</goals> | ||
<configuration> | ||
<deployment>${project.groupId}:${project.artifactId}-deployment:${project.version} | ||
</deployment> | ||
<capabilities> | ||
<provides>io.go.diameter.client</provides> | ||
</capabilities> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-processor</artifactId> | ||
<version>${quarkus.version}</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
57 changes: 57 additions & 0 deletions
57
...-quarkus/diameter-client-quarkus/runtime/src/main/java/io/go/diameter/DiameterClient.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,57 @@ | ||
package io.go.diameter; | ||
|
||
import jakarta.enterprise.util.AnnotationLiteral; | ||
import jakarta.inject.Qualifier; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
import java.util.Objects; | ||
|
||
import static java.lang.annotation.ElementType.*; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
@Target({TYPE, FIELD, METHOD, PARAMETER}) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@Qualifier | ||
public @interface DiameterClient | ||
{ | ||
String value() default "<default>"; | ||
|
||
@SuppressWarnings("ClassExplicitlyAnnotation") | ||
final class DiameterClientLiteral extends AnnotationLiteral<DiameterClient> implements DiameterClient | ||
{ | ||
|
||
private final String name; | ||
|
||
public DiameterClientLiteral(String name) | ||
{ | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String value() | ||
{ | ||
return name; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) | ||
{ | ||
if (this == o) return true; | ||
if (!(o instanceof DiameterClientLiteral that)) return false; | ||
if (!super.equals(o)) return false; | ||
|
||
return Objects.equals(name, that.name); | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
int result = super.hashCode(); | ||
result = 31 * result + (name != null ? name.hashCode() : 0); | ||
return result; | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...t-quarkus/runtime/src/main/java/io/go/diameter/client/runtime/DiameterClientRecorder.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,36 @@ | ||
package io.go.diameter.client.runtime; | ||
|
||
import io.go.diameter.config.DiameterClientConfig; | ||
import io.go.diameter.config.DiameterClientConfiguration; | ||
import io.go.diameter.config.DiameterConfig; | ||
import io.quarkus.arc.SyntheticCreationalContext; | ||
import io.quarkus.runtime.annotations.Recorder; | ||
import io.smallrye.config.SmallRyeConfig; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.eclipse.microprofile.config.ConfigProvider; | ||
import org.jdiameter.api.Configuration; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.function.Function; | ||
|
||
@Recorder | ||
@Slf4j | ||
public class DiameterClientRecorder | ||
{ | ||
private final Map<String, Configuration> configurationList = new ConcurrentHashMap<>(); | ||
|
||
public Function<SyntheticCreationalContext<Configuration>, Configuration> clientConfiguration(String clientName) | ||
{ | ||
return context -> configurationList.computeIfAbsent(clientName, k -> { | ||
SmallRyeConfig config = ConfigProvider.getConfig().unwrap(SmallRyeConfig.class); | ||
DiameterClientConfig client = config.getConfigMapping(DiameterClientConfig.class); | ||
|
||
DiameterConfig diameterConfig = client.getDiameterConfig(k); | ||
if (diameterConfig == null) { | ||
throw new IllegalArgumentException("No client configuration found for " + k); | ||
} | ||
return new DiameterClientConfiguration(diameterConfig); | ||
}); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...uarkus/diameter-client-quarkus/runtime/src/main/resources/META-INF/quarkus-extension.yaml
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,9 @@ | ||
name: Go jDiameter | ||
#description: Quarkus JDiameter Extension | ||
metadata: | ||
# keywords: | ||
# - go-jdiameter | ||
# guide: ... # To create and publish this guide, see https://github.com/quarkiverse/quarkiverse/wiki#documenting-your-extension | ||
# categories: | ||
# - "miscellaneous" | ||
# status: "preview" |
Oops, something went wrong.