Skip to content

Commit

Permalink
Updates for servlet based deployment.
Browse files Browse the repository at this point in the history
Adds EurekaBootStrap.getDiscoveryClientOptionalArgs() protected method.
  • Loading branch information
spencergibb committed Nov 15, 2022
1 parent 6e6b05f commit 84b45cf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
package com.netflix.eureka;

import com.netflix.appinfo.ApplicationInfoManager;
import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs;
import com.netflix.discovery.DiscoveryClient;
import com.netflix.discovery.EurekaClientConfig;
import com.netflix.discovery.shared.transport.TransportClientFactory;
import com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpClient;
import com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient;
import com.netflix.discovery.shared.transport.decorator.ServerStatusEvaluators;
import com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient;
import com.netflix.discovery.Jersey3DiscoveryClientOptionalArgs;
import com.netflix.discovery.shared.transport.jersey3.Jersey3TransportClientFactories;
import com.netflix.eureka.cluster.Jersey3PeerEurekaNodes;
import com.netflix.eureka.cluster.PeerEurekaNodes;
import com.netflix.eureka.registry.PeerAwareInstanceRegistry;
import com.netflix.eureka.resources.ServerCodecs;
import com.netflix.eureka.transport.EurekaServerHttpClientFactory;
import com.netflix.eureka.transport.Jersey3EurekaServerHttpClientFactory;
import com.netflix.eureka.transport.Jersey3RemoteRegionClientFactory;

/**
* Jersey3 eureka server bootstrapper
* @author Matt Nelson
*/
public class Jersey3EurekaBootStrap extends EurekaBootStrap {


// for servlet based deployments
public Jersey3EurekaBootStrap() {
super(null);
}

public Jersey3EurekaBootStrap(DiscoveryClient discoveryClient) {
super(discoveryClient);
}
Expand All @@ -39,6 +41,13 @@ protected PeerEurekaNodes getPeerEurekaNodes(PeerAwareInstanceRegistry registry,
return peerEurekaNodes;
}

@Override
protected AbstractDiscoveryClientOptionalArgs<?> getDiscoveryClientOptionalArgs() {
Jersey3DiscoveryClientOptionalArgs jersey3DiscoveryClientOptionalArgs = new Jersey3DiscoveryClientOptionalArgs();
jersey3DiscoveryClientOptionalArgs.setTransportClientFactories(Jersey3TransportClientFactories.getInstance());
return jersey3DiscoveryClientOptionalArgs;
}

@Override
protected EurekaServerHttpClientFactory getEurekaServerHttpClientFactory() {
return new Jersey3EurekaServerHttpClientFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.netflix.eureka;

import com.netflix.discovery.shared.transport.EurekaHttpClient;
import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs;
import com.netflix.eureka.transport.EurekaServerHttpClientFactory;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletContextEvent;
Expand Down Expand Up @@ -168,7 +168,7 @@ protected void initEurekaServerContext() throws Exception {
instanceConfig, new EurekaConfigBasedInstanceInfoProvider(instanceConfig).get());

EurekaClientConfig eurekaClientConfig = new DefaultEurekaClientConfig();
eurekaClient = new DiscoveryClient(applicationInfoManager, eurekaClientConfig);
eurekaClient = new DiscoveryClient(applicationInfoManager, eurekaClientConfig, getDiscoveryClientOptionalArgs());
} else {
applicationInfoManager = eurekaClient.getApplicationInfoManager();
}
Expand Down Expand Up @@ -223,6 +223,10 @@ protected void initEurekaServerContext() throws Exception {
EurekaMonitors.registerAllStats();
}

protected AbstractDiscoveryClientOptionalArgs<?> getDiscoveryClientOptionalArgs() {
return null;
}

protected abstract EurekaServerHttpClientFactory getEurekaServerHttpClientFactory();

protected abstract PeerEurekaNodes getPeerEurekaNodes(PeerAwareInstanceRegistry registry, EurekaServerConfig eurekaServerConfig, EurekaClientConfig eurekaClientConfig, ServerCodecs serverCodecs, ApplicationInfoManager applicationInfoManager);
Expand Down
1 change: 1 addition & 0 deletions eureka-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies {
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
testImplementation "org.eclipse.jetty:jetty-server:$jetty_version"
testImplementation "org.eclipse.jetty:jetty-webapp:$jetty_version"
testRuntimeOnly 'org.slf4j:slf4j-simple:2.0.0-beta1'
}

task copyLibs(type: Copy) {
Expand Down
4 changes: 2 additions & 2 deletions eureka-server/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<listener>
<listener-class>com.netflix.eureka.EurekaBootStrap</listener-class>
<listener-class>com.netflix.eureka.Jersey3EurekaBootStrap</listener-class>
</listener>

<filter>
Expand All @@ -28,7 +28,7 @@

<filter>
<filter-name>jersey</filter-name>
<filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
<filter-class>org.glassfish.jersey.servlet.ServletContainer</filter-class>
<init-param>
<param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
<param-value>/(flex|images|js|css|jsp)/.*</param-value>
Expand Down

0 comments on commit 84b45cf

Please sign in to comment.