| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.Set; | ||
| import java.util.function.Supplier; | ||
|
|
||
| import org.jboss.as.controller.registry.PlaceholderResource; | ||
| import org.jboss.as.controller.registry.Resource; | ||
| import org.wildfly.common.function.Functions; | ||
|
|
||
| /** | ||
| * A simple {@link ChildResourceProvider} containing a predefined set of children. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class SimpleChildResourceProvider implements ChildResourceProvider { | ||
|
|
||
| private final Set<String> children; | ||
| private final Supplier<Resource> provider; | ||
|
|
||
| public SimpleChildResourceProvider(Set<String> children) { | ||
| this(children, Functions.constantSupplier(PlaceholderResource.INSTANCE)); | ||
| } | ||
|
|
||
| public SimpleChildResourceProvider(Set<String> children, Supplier<Resource> provider) { | ||
| this.children = children; | ||
| this.provider = provider; | ||
| } | ||
|
|
||
| @Override | ||
| public Resource getChild(String name) { | ||
| return this.children.contains(name) ? this.provider.get() : null; | ||
| } | ||
|
|
||
| @Override | ||
| public Set<String> getChildren() { | ||
| return this.children; | ||
| } | ||
| } |
| @@ -0,0 +1,107 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.clustering.ee; | ||
|
|
||
| import java.util.List; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Iterator; | ||
|
|
||
| /** | ||
| * Used for iterating over an series of iterables, thus avoiding the need to allocate/populate a new list containing all elements. | ||
| * More efficient than the alternative when the number of iterables is arbitrary and small relative to the size of each iterable. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class CompositeIterable<T> implements Iterable<T> { | ||
|
|
||
| private final List<? extends Iterable<? extends T>> iterables; | ||
|
|
||
| /** | ||
| * Constructs a new composite iterable. | ||
| * @param iterables a series of iterables | ||
| */ | ||
| @SafeVarargs | ||
| public CompositeIterable(Iterable<? extends T>... iterables) { | ||
| this(Arrays.asList(iterables)); | ||
| } | ||
|
|
||
| /** | ||
| * Constructs a new composite iterable. | ||
| * @param iterables a series of iterables | ||
| */ | ||
| public CompositeIterable(List<? extends Iterable<? extends T>> iterables) { | ||
| this.iterables = iterables; | ||
| } | ||
|
|
||
| @Override | ||
| public Iterator<T> iterator() { | ||
| List<Iterator<? extends T>> iterators = new ArrayList<>(this.iterables.size()); | ||
| for (Iterable<? extends T> elements : this.iterables) { | ||
| iterators.add(elements.iterator()); | ||
| } | ||
| return new CompositeIterator<>(iterators); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| int result = 1; | ||
| for (Iterable<? extends T> elements : this.iterables) { | ||
| for (T element : elements) { | ||
| result = 31 * result + ((element != null) ? element.hashCode() : 0); | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object object) { | ||
| if (!(object instanceof Iterable)) return false; | ||
| @SuppressWarnings("unchecked") | ||
| Iterator<Object> otherElements = ((Iterable<Object>) object).iterator(); | ||
| for (Iterable<? extends T> iterable : this.iterables) { | ||
| Iterator<? extends T> elements = iterable.iterator(); | ||
| while (elements.hasNext() && otherElements.hasNext()) { | ||
| elements.next().equals(otherElements.next()); | ||
| } | ||
| if (elements.hasNext()) return false; | ||
| } | ||
| return !otherElements.hasNext(); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| StringBuilder builder = new StringBuilder(); | ||
| builder.append('['); | ||
| Iterator<? extends Iterable<? extends T>> iterables = this.iterables.iterator(); | ||
| while (iterables.hasNext()) { | ||
| Iterator<? extends T> elements = iterables.next().iterator(); | ||
| while (elements.hasNext()) { | ||
| if (builder.length() > 1) { | ||
| builder.append(',').append(' '); | ||
| } | ||
| builder.append(elements.next()); | ||
| } | ||
| } | ||
| return builder.append(']').toString(); | ||
| } | ||
| } |
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.clustering.ee; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Iterator; | ||
| import java.util.NoSuchElementException; | ||
|
|
||
| /** | ||
| * Iterator that iterates over a series of iterators. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class CompositeIterator<E> implements Iterator<E> { | ||
|
|
||
| private final Iterable<? extends Iterator<? extends E>> iterators; | ||
|
|
||
| /** | ||
| * Constructs a new composite iterator. | ||
| * @param iterables a series of iterators | ||
| */ | ||
| @SafeVarargs | ||
| public CompositeIterator(Iterator<? extends E>... iterators) { | ||
| this(Arrays.asList(iterators)); | ||
| } | ||
|
|
||
| /** | ||
| * Constructs a new composite iterator. | ||
| * @param iterables a series of iterators | ||
| */ | ||
| public CompositeIterator(Iterable<? extends Iterator<? extends E>> iterators) { | ||
| this.iterators = iterators; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hasNext() { | ||
| for (Iterator<? extends E> iterator : this.iterators) { | ||
| if (iterator.hasNext()) return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public E next() { | ||
| for (Iterator<? extends E> iterator : this.iterators) { | ||
| if (iterator.hasNext()) return iterator.next(); | ||
| } | ||
| throw new NoSuchElementException(); | ||
| } | ||
| } |
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.clustering.ee.immutable; | ||
|
|
||
| import java.lang.annotation.Annotation; | ||
|
|
||
| import org.wildfly.clustering.ee.Immutability; | ||
|
|
||
| /** | ||
| * Detects the presence of a specific annotation. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class AnnotationImmutability implements Immutability { | ||
|
|
||
| private final Class<? extends Annotation> annotationClass; | ||
|
|
||
| public AnnotationImmutability(Class<? extends Annotation> annotationClass) { | ||
| this.annotationClass = annotationClass; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean test(Object object) { | ||
| return object.getClass().isAnnotationPresent(this.annotationClass); | ||
| } | ||
| } |
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.clustering.ee.immutable; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| import org.wildfly.clustering.ee.Immutability; | ||
|
|
||
| /** | ||
| * Decorates a series of immutability predicates to additionally test for collection immutability. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class CompositeImmutability implements Immutability { | ||
|
|
||
| private final Iterable<? extends Immutability> immutabilities; | ||
| private final Immutability collectionImmutability; | ||
|
|
||
| public CompositeImmutability(Immutability... predicates) { | ||
| this(Arrays.asList(predicates)); | ||
| } | ||
|
|
||
| public CompositeImmutability(Iterable<? extends Immutability> immutabilities) { | ||
| this.immutabilities = immutabilities; | ||
| this.collectionImmutability = new CollectionImmutability(this); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean test(Object object) { | ||
| for (Immutability immutability : this.immutabilities) { | ||
| if (immutability.test(object)) { | ||
| return true; | ||
| } | ||
| } | ||
| return this.collectionImmutability.test(object); | ||
| } | ||
| } |
| @@ -0,0 +1,155 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2013, 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.clustering.ee.immutable; | ||
|
|
||
| import java.io.File; | ||
| import java.math.BigDecimal; | ||
| import java.math.BigInteger; | ||
| import java.math.MathContext; | ||
| import java.net.Inet4Address; | ||
| import java.net.Inet6Address; | ||
| import java.net.InetSocketAddress; | ||
| import java.net.URI; | ||
| import java.net.URL; | ||
| import java.nio.file.Path; | ||
| import java.security.Permission; | ||
| import java.time.Clock; | ||
| import java.time.Duration; | ||
| import java.time.Instant; | ||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import java.time.LocalTime; | ||
| import java.time.MonthDay; | ||
| import java.time.Period; | ||
| import java.time.Year; | ||
| import java.time.YearMonth; | ||
| import java.time.ZoneId; | ||
| import java.time.ZoneOffset; | ||
| import java.time.ZonedDateTime; | ||
| import java.time.chrono.ChronoLocalDate; | ||
| import java.time.chrono.Chronology; | ||
| import java.time.chrono.Era; | ||
| import java.time.format.DateTimeFormatter; | ||
| import java.time.format.DecimalStyle; | ||
| import java.time.temporal.TemporalField; | ||
| import java.time.temporal.TemporalUnit; | ||
| import java.time.temporal.ValueRange; | ||
| import java.time.temporal.WeekFields; | ||
| import java.time.zone.ZoneOffsetTransition; | ||
| import java.time.zone.ZoneOffsetTransitionRule; | ||
| import java.time.zone.ZoneRules; | ||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.Currency; | ||
| import java.util.Locale; | ||
| import java.util.TimeZone; | ||
| import java.util.UUID; | ||
|
|
||
| import org.wildfly.clustering.ee.Immutability; | ||
|
|
||
| /** | ||
| * Default set of immutability tests. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public enum DefaultImmutability implements Immutability { | ||
|
|
||
| // Singleton immutable objects detectable via reference equality test | ||
| OBJECT(new IdentityImmutability(Arrays.asList( | ||
| Collections.emptyEnumeration(), | ||
| Collections.emptyIterator(), | ||
| Collections.emptyList(), | ||
| Collections.emptyListIterator(), | ||
| Collections.emptyMap(), | ||
| Collections.emptyNavigableMap(), | ||
| Collections.emptyNavigableSet(), | ||
| Collections.emptySet(), | ||
| Collections.emptySortedMap(), | ||
| Collections.emptySortedSet()))), | ||
| // Concrete immutable classes detectable via reference equality test | ||
| CLASS(new SimpleImmutability(Arrays.asList( | ||
| BigDecimal.class, | ||
| BigInteger.class, | ||
| Boolean.class, | ||
| Byte.class, | ||
| Character.class, | ||
| Class.class, | ||
| Currency.class, | ||
| DateTimeFormatter.class, | ||
| DecimalStyle.class, | ||
| Double.class, | ||
| Duration.class, | ||
| File.class, | ||
| Float.class, | ||
| Inet4Address.class, | ||
| Inet6Address.class, | ||
| InetSocketAddress.class, | ||
| Instant.class, | ||
| Integer.class, | ||
| Locale.class, | ||
| LocalDate.class, | ||
| LocalDateTime.class, | ||
| LocalTime.class, | ||
| Long.class, | ||
| MathContext.class, | ||
| MonthDay.class, | ||
| Period.class, | ||
| Short.class, | ||
| StackTraceElement.class, | ||
| String.class, | ||
| URI.class, | ||
| URL.class, | ||
| UUID.class, | ||
| ValueRange.class, | ||
| WeekFields.class, | ||
| Year.class, | ||
| YearMonth.class, | ||
| ZoneOffset.class, | ||
| ZoneOffsetTransition.class, | ||
| ZoneOffsetTransitionRule.class, | ||
| ZoneRules.class, | ||
| ZonedDateTime.class))), | ||
| // Interfaces and abstract classes documented to be immutable, but only detectable via instanceof tests | ||
| ABSTRACT_CLASS(new InstanceOfImmutability(Arrays.asList( | ||
| Chronology.class, | ||
| ChronoLocalDate.class, | ||
| Clock.class, | ||
| Enum.class, // In theory, one could implement a mutable enum, but that would just be weird. | ||
| Era.class, | ||
| Path.class, | ||
| Permission.class, | ||
| TemporalField.class, | ||
| TemporalUnit.class, | ||
| TimeZone.class, // Strictly speaking, this class is mutable, although in practice it is never mutated. | ||
| ZoneId.class))), | ||
| ANNOTATION(new AnnotationImmutability(net.jcip.annotations.Immutable.class)), | ||
| ; | ||
| private final Immutability immutability; | ||
|
|
||
| DefaultImmutability(Immutability immutability) { | ||
| this.immutability = immutability; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean test(Object object) { | ||
| return this.immutability.test(object); | ||
| } | ||
| } |
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.clustering.ee.immutable; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.IdentityHashMap; | ||
| import java.util.Set; | ||
|
|
||
| import org.wildfly.clustering.ee.Immutability; | ||
|
|
||
| /** | ||
| * Test for immutability using object identity. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class IdentityImmutability implements Immutability { | ||
|
|
||
| private final Set<Object> immutableObjects; | ||
|
|
||
| public IdentityImmutability(Collection<Object> objects) { | ||
| this.immutableObjects = !objects.isEmpty() ? Collections.newSetFromMap(new IdentityHashMap<>(objects.size())) : Collections.emptySet(); | ||
| for (Object object : objects) { | ||
| this.immutableObjects.add(object); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public boolean test(Object object) { | ||
| return (object == null) || this.immutableObjects.contains(object); | ||
| } | ||
| } |
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.clustering.ee.immutable; | ||
|
|
||
| import org.wildfly.clustering.ee.Immutability; | ||
|
|
||
| /** | ||
| * Test for immutability using instanceof checks. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class InstanceOfImmutability implements Immutability { | ||
|
|
||
| private final Iterable<Class<?>> immutableClasses; | ||
|
|
||
| public InstanceOfImmutability(Iterable<Class<?>> immutableClasses) { | ||
| this.immutableClasses = immutableClasses; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean test(Object object) { | ||
| for (Class<?> immutableClass : this.immutableClasses) { | ||
| if (immutableClass.isInstance(object)) return true; | ||
| } | ||
| return false; | ||
| } | ||
| } |
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.clustering.ee.immutable; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.IdentityHashMap; | ||
| import java.util.Set; | ||
| import java.util.function.Function; | ||
|
|
||
| import org.wildfly.clustering.ee.Immutability; | ||
|
|
||
| /** | ||
| * Immutability implementation based on a pre-defined set immutable classes. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class SimpleImmutability implements Immutability { | ||
|
|
||
| private final Set<Class<?>> immutableClasses; | ||
|
|
||
| public SimpleImmutability(ClassLoader loader, Collection<String> immutableClassNames) { | ||
| this(immutableClassNames, new Function<String, Class<?>>() { | ||
| @Override | ||
| public Class<?> apply(String className) { | ||
| try { | ||
| return loader.loadClass(className); | ||
| } catch (ClassNotFoundException e) { | ||
| throw new IllegalArgumentException(className, e); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| public SimpleImmutability(Collection<Class<?>> immutableClasses) { | ||
| this(immutableClasses, Function.identity()); | ||
| } | ||
|
|
||
| private <T> SimpleImmutability(Collection<T> immutables, Function<T, Class<?>> operator) { | ||
| this.immutableClasses = !immutables.isEmpty() ? Collections.newSetFromMap(new IdentityHashMap<>(immutables.size())) : Collections.emptySet(); | ||
| for (T immutable : immutables) { | ||
| this.immutableClasses.add(operator.apply(immutable)); | ||
| } | ||
| } | ||
|
|
||
| public SimpleImmutability(Set<Class<?>> classes) { | ||
| this.immutableClasses = classes; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean test(Object object) { | ||
| return (object == null) || this.immutableClasses.contains(object.getClass()); | ||
| } | ||
| } |
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.clustering.ee; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.Iterator; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.IntStream; | ||
|
|
||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
| /** | ||
| * Unit test for {@link CompositeIterable}. | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class CompositeIterableTestCase { | ||
|
|
||
| @Test | ||
| public void test() { | ||
| Iterable<Integer> expected = IntStream.range(0, 10).mapToObj(Integer::valueOf).collect(Collectors.toList()); | ||
|
|
||
| test(expected, new CompositeIterable<>(Arrays.asList(0, 1, 2, 3, 4), Arrays.asList(5, 6, 7, 8, 9))); | ||
| test(expected, new CompositeIterable<>(Arrays.asList(0, 1), Arrays.asList(2, 3), Arrays.asList(4, 5), Arrays.asList(6, 7), Arrays.asList(8, 9))); | ||
| test(expected, new CompositeIterable<>(Collections.emptyList(), expected, Collections.emptyList())); | ||
| } | ||
|
|
||
| static void test(Iterable<Integer> expected, Iterable<Integer> subject) { | ||
| Assert.assertEquals(expected.hashCode(), subject.hashCode()); | ||
| Assert.assertEquals(expected.toString(), subject.toString()); | ||
|
|
||
| Iterator<Integer> subjectIterator = subject.iterator(); | ||
| Iterator<Integer> expectedIterator = expected.iterator(); | ||
| while (expectedIterator.hasNext()) { | ||
| Assert.assertTrue(subjectIterator.hasNext()); | ||
| Assert.assertEquals(expectedIterator.next(), subjectIterator.next()); | ||
| } | ||
| Assert.assertFalse(subjectIterator.hasNext()); | ||
| } | ||
| } |
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.infinispan.subsystem; | ||
|
|
||
| import org.jboss.as.clustering.controller.ChildResourceDefinition; | ||
| import org.jboss.as.controller.PathElement; | ||
| import org.jboss.as.controller.registry.ManagementResourceRegistration; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class CacheComponentRuntimeResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { | ||
|
|
||
| static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); | ||
|
|
||
| static final PathElement pathElement(String name) { | ||
| return PathElement.pathElement("component", name); | ||
| } | ||
|
|
||
| CacheComponentRuntimeResourceDefinition(PathElement path) { | ||
| this(path, path); | ||
| } | ||
|
|
||
| CacheComponentRuntimeResourceDefinition(PathElement path, PathElement resolverPath) { | ||
| super(new Parameters(path, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(resolverPath)).setRuntime()); | ||
| } | ||
|
|
||
| @Override | ||
| public ManagementResourceRegistration register(ManagementResourceRegistration parent) { | ||
| return parent.registerSubModel(this); | ||
| } | ||
| } |
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.infinispan.subsystem; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.Map; | ||
|
|
||
| import org.jboss.as.clustering.controller.ChildResourceProvider; | ||
| import org.jboss.as.clustering.controller.ComplexResource; | ||
| import org.jboss.as.controller.registry.Resource; | ||
| import org.wildfly.clustering.Registrar; | ||
| import org.wildfly.clustering.Registration; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class CacheContainerResource extends ComplexResource implements Registrar<String> { | ||
|
|
||
| private static final String CHILD_TYPE = CacheRuntimeResourceDefinition.WILDCARD_PATH.getKey(); | ||
|
|
||
| public CacheContainerResource(Resource resource) { | ||
| this(resource, Collections.singletonMap(CHILD_TYPE, new CacheRuntimeResourceProvider())); | ||
| } | ||
|
|
||
| private CacheContainerResource(Resource resource, Map<String, ChildResourceProvider> providers) { | ||
| super(resource, providers, CacheContainerResource::new); | ||
| } | ||
|
|
||
| @Override | ||
| public Registration register(String cache) { | ||
| ChildResourceProvider handler = this.apply(CHILD_TYPE); | ||
| handler.getChildren().add(cache); | ||
| return new Registration() { | ||
| @Override | ||
| public void close() { | ||
| handler.getChildren().remove(cache); | ||
| } | ||
| }; | ||
| } | ||
| } |
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.infinispan.subsystem; | ||
|
|
||
| import org.jboss.as.clustering.controller.ChildResourceDefinition; | ||
| import org.jboss.as.clustering.controller.MetricHandler; | ||
| import org.jboss.as.controller.ModelVersion; | ||
| import org.jboss.as.controller.PathElement; | ||
| import org.jboss.as.controller.registry.ManagementResourceRegistration; | ||
| import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class CacheRuntimeResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { | ||
|
|
||
| static final PathElement WILDCARD_PATH = PathElement.pathElement("cache"); | ||
|
|
||
| static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) { | ||
| if (InfinispanModel.VERSION_10_0_0.requiresTransformation(version)) { | ||
| parent.discardChildResource(WILDCARD_PATH); | ||
| } | ||
| } | ||
|
|
||
| CacheRuntimeResourceDefinition() { | ||
| super(new Parameters(WILDCARD_PATH, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(WILDCARD_PATH)).setRuntime()); | ||
| } | ||
|
|
||
| @Override | ||
| public ManagementResourceRegistration register(ManagementResourceRegistration parent) { | ||
| ManagementResourceRegistration registration = parent.registerSubModel(this); | ||
|
|
||
| new MetricHandler<>(new CacheMetricExecutor(), CacheMetric.class).register(registration); | ||
| new MetricHandler<>(new ClusteredCacheMetricExecutor(), ClusteredCacheMetric.class).register(registration); | ||
|
|
||
| new LockingRuntimeResourceDefinition().register(registration); | ||
| new MemoryRuntimeResourceDefinition().register(registration); | ||
| new PartitionHandlingRuntimeResourceDefinition().register(registration); | ||
| new PersistenceRuntimeResourceDefinition().register(registration); | ||
| new TransactionRuntimeResourceDefinition().register(registration); | ||
|
|
||
| return registration; | ||
| } | ||
| } |
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.infinispan.subsystem; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.HashSet; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
|
|
||
| import org.jboss.as.clustering.controller.ChildResourceProvider; | ||
| import org.jboss.as.clustering.controller.ComplexResource; | ||
| import org.jboss.as.clustering.controller.SimpleChildResourceProvider; | ||
| import org.jboss.as.controller.registry.PlaceholderResource; | ||
| import org.wildfly.common.function.Functions; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class CacheRuntimeResourceProvider extends SimpleChildResourceProvider { | ||
|
|
||
| private static final ChildResourceProvider CHILD_PROVIDER = new SimpleChildResourceProvider(Collections.unmodifiableSet(new HashSet<>(Arrays.asList( | ||
| LockingRuntimeResourceDefinition.PATH.getValue(), | ||
| MemoryRuntimeResourceDefinition.PATH.getValue(), | ||
| PersistenceRuntimeResourceDefinition.PATH.getValue(), | ||
| PartitionHandlingRuntimeResourceDefinition.PATH.getValue(), | ||
| TransactionRuntimeResourceDefinition.PATH.getValue())))); | ||
|
|
||
| public CacheRuntimeResourceProvider() { | ||
| super(ConcurrentHashMap.newKeySet(), Functions.constantSupplier(new ComplexResource(PlaceholderResource.INSTANCE, Collections.singletonMap(CacheComponentRuntimeResourceDefinition.WILDCARD_PATH.getKey(), CHILD_PROVIDER)))); | ||
| } | ||
| } |
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.infinispan.subsystem; | ||
|
|
||
| import org.jboss.as.clustering.controller.MetricHandler; | ||
| import org.jboss.as.controller.PathElement; | ||
| import org.jboss.as.controller.registry.ManagementResourceRegistration; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class LockingRuntimeResourceDefinition extends CacheComponentRuntimeResourceDefinition { | ||
|
|
||
| static final PathElement PATH = pathElement("locking"); | ||
|
|
||
| LockingRuntimeResourceDefinition() { | ||
| super(PATH); | ||
| } | ||
|
|
||
| @Override | ||
| public ManagementResourceRegistration register(ManagementResourceRegistration parent) { | ||
| ManagementResourceRegistration registration = super.register(parent); | ||
| new MetricHandler<>(new LockingMetricExecutor(), LockingMetric.class).register(registration); | ||
| return registration; | ||
| } | ||
| } |
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.infinispan.subsystem; | ||
|
|
||
| import org.jboss.as.clustering.controller.MetricHandler; | ||
| import org.jboss.as.controller.PathElement; | ||
| import org.jboss.as.controller.registry.ManagementResourceRegistration; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class MemoryRuntimeResourceDefinition extends CacheComponentRuntimeResourceDefinition { | ||
|
|
||
| static final PathElement PATH = pathElement("memory"); | ||
|
|
||
| MemoryRuntimeResourceDefinition() { | ||
| super(PATH, MemoryResourceDefinition.WILDCARD_PATH); | ||
| } | ||
|
|
||
| @Override | ||
| public ManagementResourceRegistration register(ManagementResourceRegistration parent) { | ||
| ManagementResourceRegistration registration = super.register(parent); | ||
| new MetricHandler<>(new EvictionMetricExecutor(), EvictionMetric.class).register(registration); | ||
| return registration; | ||
| } | ||
| } |
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.infinispan.subsystem; | ||
|
|
||
| import org.jboss.as.clustering.controller.MetricHandler; | ||
| import org.jboss.as.clustering.controller.OperationHandler; | ||
| import org.jboss.as.controller.PathElement; | ||
| import org.jboss.as.controller.registry.ManagementResourceRegistration; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class PartitionHandlingRuntimeResourceDefinition extends CacheComponentRuntimeResourceDefinition { | ||
|
|
||
| static final PathElement PATH = pathElement("partition-handling"); | ||
|
|
||
| PartitionHandlingRuntimeResourceDefinition() { | ||
| super(PATH); | ||
| } | ||
|
|
||
| @Override | ||
| public ManagementResourceRegistration register(ManagementResourceRegistration parent) { | ||
| ManagementResourceRegistration registration = super.register(parent); | ||
| new MetricHandler<>(new PartitionHandlingMetricExecutor(), PartitionHandlingMetric.class).register(registration); | ||
| new OperationHandler<>(new PartitionHandlingOperationExecutor(), PartitionHandlingOperation.class).register(registration); | ||
| return registration; | ||
| } | ||
| } |
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.infinispan.subsystem; | ||
|
|
||
| import org.jboss.as.clustering.controller.MetricHandler; | ||
| import org.jboss.as.controller.PathElement; | ||
| import org.jboss.as.controller.registry.ManagementResourceRegistration; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class PersistenceRuntimeResourceDefinition extends CacheComponentRuntimeResourceDefinition { | ||
|
|
||
| static final PathElement PATH = pathElement("persistence"); | ||
|
|
||
| PersistenceRuntimeResourceDefinition() { | ||
| super(PATH, StoreResourceDefinition.WILDCARD_PATH); | ||
| } | ||
|
|
||
| @Override | ||
| public ManagementResourceRegistration register(ManagementResourceRegistration parent) { | ||
| ManagementResourceRegistration registration = super.register(parent); | ||
| new MetricHandler<>(new StoreMetricExecutor(), StoreMetric.class).register(registration); | ||
| return registration; | ||
| } | ||
| } |
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * JBoss, Home of Professional Open Source. | ||
| * Copyright 2019, 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.infinispan.subsystem; | ||
|
|
||
| import org.jboss.as.clustering.controller.MetricHandler; | ||
| import org.jboss.as.controller.PathElement; | ||
| import org.jboss.as.controller.registry.ManagementResourceRegistration; | ||
|
|
||
| /** | ||
| * @author Paul Ferraro | ||
| */ | ||
| public class TransactionRuntimeResourceDefinition extends CacheComponentRuntimeResourceDefinition { | ||
|
|
||
| static final PathElement PATH = pathElement("transaction"); | ||
|
|
||
| TransactionRuntimeResourceDefinition() { | ||
| super(PATH); | ||
| } | ||
|
|
||
| @Override | ||
| public ManagementResourceRegistration register(ManagementResourceRegistration parent) { | ||
| ManagementResourceRegistration registration = super.register(parent); | ||
| new MetricHandler<>(new TransactionMetricExecutor(), TransactionMetric.class).register(registration); | ||
| return registration; | ||
| } | ||
| } |