From 7151261bc4872d6a5db54c0ff4e4f72447887191 Mon Sep 17 00:00:00 2001 From: Radoslav Husar Date: Mon, 23 Jul 2018 12:19:49 +0200 Subject: [PATCH] Eliminate static methods for generating service names --- ...ModClusterUndertowDeploymentProcessor.java | 2 +- ...ventHandlerAdapterServiceConfigurator.java | 13 +----- ...ventHandlerAdapterServiceNameProvider.java | 44 +++++++++++++++++++ 3 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowEventHandlerAdapterServiceNameProvider.java diff --git a/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/ModClusterUndertowDeploymentProcessor.java b/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/ModClusterUndertowDeploymentProcessor.java index 52da28f63bc4..dbac8b49a1cf 100644 --- a/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/ModClusterUndertowDeploymentProcessor.java +++ b/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/ModClusterUndertowDeploymentProcessor.java @@ -69,7 +69,7 @@ public void deploy(DeploymentPhaseContext phaseContext) { // Add mod_cluster-undertow integration service as a web deployment dependency for (String adapter : adapterNames) { - deploymentUnit.addToAttachmentList(Attachments.WEB_DEPENDENCIES, UndertowEventHandlerAdapterServiceConfigurator.getServiceName(adapter)); + deploymentUnit.addToAttachmentList(Attachments.WEB_DEPENDENCIES, new UndertowEventHandlerAdapterServiceNameProvider(adapter).getServiceName()); } // Request count wrapping diff --git a/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowEventHandlerAdapterServiceConfigurator.java b/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowEventHandlerAdapterServiceConfigurator.java index 10f06cc785ce..66fdf30a04c3 100644 --- a/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowEventHandlerAdapterServiceConfigurator.java +++ b/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowEventHandlerAdapterServiceConfigurator.java @@ -31,7 +31,6 @@ import org.jboss.modcluster.container.ContainerEventHandler; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; -import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.service.AsyncServiceConfigurator; import org.wildfly.clustering.service.CompositeDependency; @@ -48,7 +47,7 @@ * @author Paul Ferraro * @author Radoslav Husar */ -public class UndertowEventHandlerAdapterServiceConfigurator implements CapabilityServiceConfigurator, UndertowEventHandlerAdapterConfiguration { +public class UndertowEventHandlerAdapterServiceConfigurator extends UndertowEventHandlerAdapterServiceNameProvider implements CapabilityServiceConfigurator, UndertowEventHandlerAdapterConfiguration { private final String proxyName; private final String listenerName; @@ -61,20 +60,12 @@ public class UndertowEventHandlerAdapterServiceConfigurator implements Capabilit private volatile SupplierDependency listener; public UndertowEventHandlerAdapterServiceConfigurator(String proxyName, String listenerName, Duration statusInterval) { + super(proxyName); this.proxyName = proxyName; this.listenerName = listenerName; this.statusInterval = statusInterval; } - @Override - public ServiceName getServiceName() { - return getServiceName(proxyName); - } - - public static ServiceName getServiceName(String name) { - return ProxyConfigurationResourceDefinition.Capability.SERVICE.getDefinition().getCapabilityServiceName(name).append("undertow"); - } - @Override public ServiceConfigurator configure(CapabilityServiceSupport support) { this.service = new ServiceSupplierDependency<>(support.getCapabilityServiceName(Capabilities.CAPABILITY_UNDERTOW)); diff --git a/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowEventHandlerAdapterServiceNameProvider.java b/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowEventHandlerAdapterServiceNameProvider.java new file mode 100644 index 000000000000..b89fcca3ed6e --- /dev/null +++ b/mod_cluster/undertow/src/main/java/org/wildfly/mod_cluster/undertow/UndertowEventHandlerAdapterServiceNameProvider.java @@ -0,0 +1,44 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2018, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.wildfly.mod_cluster.undertow; + +import org.jboss.msc.service.ServiceName; +import org.wildfly.clustering.service.ServiceNameProvider; +import org.wildfly.extension.mod_cluster.ProxyConfigurationResourceDefinition; + +/** + * @author Radoslav Husar + */ +class UndertowEventHandlerAdapterServiceNameProvider implements ServiceNameProvider { + + private final String proxyName; + + UndertowEventHandlerAdapterServiceNameProvider(String proxyName) { + this.proxyName = proxyName; + } + + @Override + public ServiceName getServiceName() { + return ProxyConfigurationResourceDefinition.Capability.SERVICE.getDefinition().getCapabilityServiceName(proxyName).append("undertow"); + } +}