Skip to content
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

ref: Refactor the way Application is initialized. #1160

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 3 additions & 24 deletions jicofo/src/main/java/org/jitsi/jicofo/rest/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@

import org.glassfish.hk2.utilities.binding.*;
import org.glassfish.jersey.server.*;
import org.jetbrains.annotations.*;
import org.jitsi.jicofo.health.*;
import org.jitsi.jicofo.metrics.*;
import org.jitsi.rest.prometheus.*;
import org.jitsi.utils.version.*;

import java.time.*;
import java.util.*;

/**
* Adds the configuration for the REST web endpoints.
Expand All @@ -33,9 +29,7 @@ public class Application
{
protected final Clock clock = Clock.systemUTC();

public Application(@NotNull Version version,
JicofoHealthChecker healthChecker,
ConferenceRequest conferenceRequest)
public Application(List<Object> components)
{
register(new AbstractBinder()
{
Expand All @@ -47,21 +41,6 @@ protected void configure()
});
packages("org.jitsi.jicofo.rest");

if (healthChecker != null)
{
register(new org.jitsi.rest.Health(healthChecker));
}

register(new org.jitsi.rest.Version(version));

if (RestConfig.config.getEnablePrometheus())
{
register(new Prometheus(JicofoMetricsContainer.getInstance()));
}

if (conferenceRequest != null)
{
register(conferenceRequest);
}
components.forEach(this::register);
}
}
20 changes: 14 additions & 6 deletions jicofo/src/main/kotlin/org/jitsi/jicofo/JicofoServices.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ import org.jitsi.jicofo.version.CurrentVersionImpl
import org.jitsi.jicofo.xmpp.XmppServices
import org.jitsi.jicofo.xmpp.initializeSmack
import org.jitsi.jicofo.xmpp.jingle.JingleStats
import org.jitsi.rest.Version
import org.jitsi.rest.createServer
import org.jitsi.rest.prometheus.Prometheus
import org.jitsi.rest.servletContextHandler
import org.jitsi.utils.OrderedJsonObject
import org.jitsi.utils.logging2.createLogger
Expand Down Expand Up @@ -145,12 +147,18 @@ class JicofoServices {
jettyServer = if (RestConfig.config.enabled) {
logger.info("Starting HTTP server with config: ${RestConfig.config.httpServerConfig}.")
val restApp = Application(
CurrentVersionImpl.VERSION,
healthChecker,
if (RestConfig.config.enableConferenceRequest) {
ConferenceRequest(xmppServices.conferenceIqHandler)
} else {
null
buildList
{
healthChecker?.let {
add(org.jitsi.rest.Health(it))
}
add(Version(CurrentVersionImpl.VERSION))
if (RestConfig.config.enableConferenceRequest) {
add(ConferenceRequest(xmppServices.conferenceIqHandler))
}
if (RestConfig.config.enablePrometheus) {
add(Prometheus(JicofoMetricsContainer.instance))
}
}
)
createServer(RestConfig.config.httpServerConfig).also {
Expand Down
Loading