Skip to content

Commit

Permalink
Eliminate static methods for generating service names
Browse files Browse the repository at this point in the history
  • Loading branch information
rhusar committed Jul 23, 2018
1 parent 93873e8 commit 7151261
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 12 deletions.
Expand Up @@ -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
Expand Down
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -61,20 +60,12 @@ public class UndertowEventHandlerAdapterServiceConfigurator implements Capabilit
private volatile SupplierDependency<UndertowListener> 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));
Expand Down
@@ -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");
}
}

0 comments on commit 7151261

Please sign in to comment.