-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WFLY-16130 Refactor clustering API service name generation to elimina…
…te ServiceNameRegistry
- Loading branch information
Showing
55 changed files
with
759 additions
and
617 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
.../main/java/org/jboss/as/clustering/controller/CompositeCapabilityServiceConfigurator.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,52 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2022, 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.jboss.as.clustering.controller; | ||
|
||
import java.util.function.BiConsumer; | ||
import java.util.function.Consumer; | ||
|
||
import org.jboss.as.controller.OperationContext; | ||
import org.jboss.as.controller.capability.CapabilityServiceSupport; | ||
import org.wildfly.clustering.service.ServiceConfigurator; | ||
|
||
/** | ||
* A {@link CapabilityServiceConfigurator} facade for collecting, configuring, and building; or removing; a set of {@link ServiceConfigurator} instances. | ||
* @author Paul Ferraro | ||
*/ | ||
public class CompositeCapabilityServiceConfigurator extends CompositeServiceConfigurator implements CapabilityServiceConfigurator { | ||
private final BiConsumer<CapabilityServiceSupport, Consumer<ServiceConfigurator>> consumer; | ||
|
||
public CompositeCapabilityServiceConfigurator(BiConsumer<CapabilityServiceSupport, Consumer<ServiceConfigurator>> consumer) { | ||
this.consumer = consumer; | ||
} | ||
|
||
@Override | ||
public CompositeServiceConfigurator configure(CapabilityServiceSupport support) { | ||
this.consumer.accept(support, this); | ||
return this; | ||
} | ||
|
||
public void remove(OperationContext context) { | ||
this.consumer.accept(context.getCapabilityServiceSupport(), configurator -> context.removeService(configurator.getServiceName())); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...ring/common/src/main/java/org/jboss/as/clustering/controller/CompositeServiceBuilder.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,86 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2022, 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.jboss.as.clustering.controller; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
import org.jboss.msc.Service; | ||
import org.jboss.msc.service.DelegatingServiceBuilder; | ||
import org.jboss.msc.service.LifecycleListener; | ||
import org.jboss.msc.service.ServiceBuilder; | ||
import org.jboss.msc.service.ServiceController; | ||
import org.jboss.msc.service.ServiceName; | ||
|
||
/** | ||
* A {@link ServiceBuilder} facade for installing a set of {@link ServiceBuilder} instances. | ||
* @author Paul Ferraro | ||
*/ | ||
public class CompositeServiceBuilder<T> extends DelegatingServiceBuilder<T> { | ||
|
||
private final Iterable<ServiceBuilder<?>> builders; | ||
|
||
public CompositeServiceBuilder(Iterable<ServiceBuilder<?>> builders) { | ||
super(null); | ||
this.builders = builders; | ||
} | ||
|
||
@Override | ||
public ServiceBuilder<T> setInitialMode(ServiceController.Mode mode) { | ||
for (ServiceBuilder<?> builder : this.builders) { | ||
builder.setInitialMode(mode); | ||
} | ||
return this; | ||
} | ||
|
||
@Override | ||
public ServiceBuilder<T> addListener(LifecycleListener listener) { | ||
for (ServiceBuilder<?> builder : this.builders) { | ||
builder.addListener(listener); | ||
} | ||
return this; | ||
} | ||
|
||
@Override | ||
public ServiceController<T> install() { | ||
for (ServiceBuilder<?> builder : this.builders) { | ||
builder.install(); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public <V> Supplier<V> requires(ServiceName name) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public <V> Consumer<V> provides(ServiceName... names) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public ServiceBuilder<T> setInstance(Service service) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...common/src/main/java/org/jboss/as/clustering/controller/CompositeServiceConfigurator.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,61 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2022, 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.jboss.as.clustering.controller; | ||
|
||
import java.util.ArrayList; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
import org.jboss.msc.service.ServiceBuilder; | ||
import org.jboss.msc.service.ServiceName; | ||
import org.jboss.msc.service.ServiceTarget; | ||
import org.wildfly.clustering.service.ServiceConfigurator; | ||
|
||
/** | ||
* A {@link ServiceConfigurator} facade for collecting and building a set of {@link ServiceConfigurator} instances. | ||
* @author Paul Ferraro | ||
*/ | ||
public class CompositeServiceConfigurator implements ServiceConfigurator, Consumer<ServiceConfigurator> { | ||
|
||
private final List<ServiceConfigurator> configurators = new LinkedList<>(); | ||
|
||
@Override | ||
public ServiceName getServiceName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public ServiceBuilder<?> build(ServiceTarget target) { | ||
List<ServiceBuilder<?>> builders = new ArrayList<>(this.configurators.size()); | ||
for (ServiceConfigurator configurator : this.configurators) { | ||
builders.add(configurator.build(target)); | ||
} | ||
return new CompositeServiceBuilder<>(builders); | ||
} | ||
|
||
@Override | ||
public void accept(ServiceConfigurator configurator) { | ||
this.configurators.add(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
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
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
Oops, something went wrong.