diff --git a/clustering/infinispan/extension/pom.xml b/clustering/infinispan/extension/pom.xml index 35b333d7bb53..38979fb612cb 100644 --- a/clustering/infinispan/extension/pom.xml +++ b/clustering/infinispan/extension/pom.xml @@ -54,6 +54,10 @@ org.wildfly wildfly-clustering-marshalling-infinispan + + org.wildfly + wildfly-clustering-marshalling-spi + org.wildfly wildfly-clustering-spi diff --git a/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/GlobalConfigurationBuilder.java b/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/GlobalConfigurationBuilder.java index 219bfd2c1eb8..29593894a63f 100644 --- a/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/GlobalConfigurationBuilder.java +++ b/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/GlobalConfigurationBuilder.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Objects; import java.util.stream.Stream; +import java.util.stream.StreamSupport; import javax.management.MBeanServer; @@ -59,6 +60,7 @@ import org.jboss.msc.value.Value; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.marshalling.infinispan.AdvancedExternalizerAdapter; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; import org.wildfly.clustering.service.Builder; import org.wildfly.clustering.service.InjectedValueDependency; import org.wildfly.clustering.service.ValueDependency; @@ -115,7 +117,11 @@ public GlobalConfiguration getValue() { builder.serialization().classResolver(ModularClassResolver.getInstance(this.loader.getValue())); builder.classLoader(module.getClassLoader()); int id = Ids.MAX_ID; - for (Externalizer externalizer : module.loadService(Externalizer.class)) { + Stream> commonExternalizers = EnumSet.allOf(DefaultExternalizer.class).stream(); + @SuppressWarnings("unchecked") + Stream> moduleExternalizers = (Stream>) (Stream) StreamSupport.stream(module.loadService(Externalizer.class).spliterator(), false); + Iterable> externalizers = Stream.concat(commonExternalizers, moduleExternalizers)::iterator; + for (Externalizer externalizer : externalizers) { InfinispanLogger.ROOT_LOGGER.debugf("Cache container %s will use an externalizer for %s", this.name, externalizer.getTargetClass().getName()); builder.serialization().addAdvancedExternalizer(id++, new AdvancedExternalizerAdapter<>(externalizer)); } diff --git a/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/ExternalizerObjectTable.java b/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/ExternalizerObjectTable.java index 444d129b9a0b..88ccb8a7793c 100644 --- a/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/ExternalizerObjectTable.java +++ b/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/ExternalizerObjectTable.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.lang.reflect.Modifier; +import java.util.EnumSet; import java.util.IdentityHashMap; import java.util.Map; import java.util.ServiceLoader; @@ -35,6 +36,7 @@ import org.jboss.marshalling.Unmarshaller; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.marshalling.spi.IndexExternalizer; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; /** * {@link ObjectTable} implementation that dynamically loads {@link Externalizer} instances available from a given {@link ClassLoader}. @@ -47,12 +49,8 @@ public class ExternalizerObjectTable implements ObjectTable { private final IndexExternalizer indexExternalizer; public ExternalizerObjectTable(ClassLoader loader) { - this(Stream.concat(loadExternalizers(ExternalizerObjectTable.class.getClassLoader()), loadExternalizers(loader)).toArray(Externalizer[]::new)); - } - - @SuppressWarnings("rawtypes") - private static Stream loadExternalizers(ClassLoader loader) { - return StreamSupport.stream(ServiceLoader.load(Externalizer.class, loader).spliterator(), false); + this(Stream.concat(EnumSet.allOf(DefaultExternalizer.class).stream(), StreamSupport.stream(ServiceLoader.load(Externalizer.class, loader).spliterator(), false)) + .toArray(Externalizer[]::new)); } public ExternalizerObjectTable(Externalizer... externalizers) { diff --git a/clustering/marshalling/spi/pom.xml b/clustering/marshalling/spi/pom.xml index c90f491b0f0d..c4b6266dcb4b 100644 --- a/clustering/marshalling/spi/pom.xml +++ b/clustering/marshalling/spi/pom.xml @@ -46,11 +46,6 @@ org.wildfly.security wildfly-elytron - - org.kohsuke.metainf-services - metainf-services - provided - diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/OptionalExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/BooleanExternalizer.java similarity index 57% rename from clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/OptionalExternalizer.java rename to clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/BooleanExternalizer.java index 84690eac2e4d..3ff510193d57 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/OptionalExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/BooleanExternalizer.java @@ -20,36 +20,43 @@ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ -package org.wildfly.clustering.marshalling.spi.util; +package org.wildfly.clustering.marshalling.spi; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.util.Optional; +import java.util.function.Function; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; /** - * {@link Externalizer} for {@link Optional} values. + * Base {@link Externalizer} for boolean-based externalization. * @author Paul Ferraro */ -@MetaInfServices(Externalizer.class) -public class OptionalExternalizer implements Externalizer> { +public class BooleanExternalizer implements Externalizer { + + private final Class targetClass; + private final Function reader; + private final Function writer; + + public BooleanExternalizer(Class targetClass, Function reader, Function writer) { + this.targetClass = targetClass; + this.reader = reader; + this.writer = writer; + } @Override - public void writeObject(ObjectOutput output, Optional optional) throws IOException { - output.writeObject(optional.orElse(null)); + public void writeObject(ObjectOutput output, T object) throws IOException { + output.writeBoolean(this.writer.apply(object).booleanValue()); } @Override - public Optional readObject(ObjectInput input) throws IOException, ClassNotFoundException { - return Optional.ofNullable(input.readObject()); + public T readObject(ObjectInput input) throws IOException, ClassNotFoundException { + return this.reader.apply(Boolean.valueOf(input.readBoolean())); } - @SuppressWarnings("unchecked") @Override - public Class> getTargetClass() { - return (Class>) (Class) Optional.class; + public Class getTargetClass() { + return this.targetClass; } } diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/DefaultExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/DefaultExternalizer.java new file mode 100644 index 000000000000..a9845ea088ef --- /dev/null +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/DefaultExternalizer.java @@ -0,0 +1,189 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, 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.marshalling.spi; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.Month; +import java.time.Year; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.util.AbstractMap; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Currency; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.Locale; +import java.util.Optional; +import java.util.TimeZone; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedDeque; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ConcurrentSkipListMap; +import java.util.concurrent.ConcurrentSkipListSet; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; + +import org.wildfly.clustering.marshalling.Externalizer; +import org.wildfly.clustering.marshalling.spi.net.URLExternalizer; +import org.wildfly.clustering.marshalling.spi.time.DurationExternalizer; +import org.wildfly.clustering.marshalling.spi.time.InstantExternalizer; +import org.wildfly.clustering.marshalling.spi.time.LocalDateTimeExternalizer; +import org.wildfly.clustering.marshalling.spi.time.MonthDayExternalizer; +import org.wildfly.clustering.marshalling.spi.time.PeriodExternalizer; +import org.wildfly.clustering.marshalling.spi.time.YearMonthExternalizer; +import org.wildfly.clustering.marshalling.spi.util.CalendarExternalizer; +import org.wildfly.clustering.marshalling.spi.util.CollectionExternalizer; +import org.wildfly.clustering.marshalling.spi.util.CopyOnWriteCollectionExternalizer; +import org.wildfly.clustering.marshalling.spi.util.DateExternalizer; +import org.wildfly.clustering.marshalling.spi.util.MapEntryExternalizer; +import org.wildfly.clustering.marshalling.spi.util.MapExternalizer; +import org.wildfly.clustering.marshalling.spi.util.SingletonCollectionExternalizer; +import org.wildfly.clustering.marshalling.spi.util.SingletonMapExternalizer; +import org.wildfly.clustering.marshalling.spi.util.SortedMapExternalizer; +import org.wildfly.clustering.marshalling.spi.util.SortedSetExternalizer; +import org.wildfly.clustering.marshalling.spi.util.UUIDExternalizer; + +/** + * Default externalizers for common JDK types + * @author Paul Ferraro + */ +public enum DefaultExternalizer implements Externalizer { + // java.net + URI(new StringExternalizer<>(java.net.URI.class, java.net.URI::create, java.net.URI::toString)), + URL(new URLExternalizer()), + // java.time + DAY_OF_WEEK(new EnumExternalizer<>(DayOfWeek.class)), + DURATION(new DurationExternalizer()), + INSTANT(new InstantExternalizer()), + LOCAL_DATE(new LongExternalizer<>(LocalDate.class, LocalDate::ofEpochDay, LocalDate::toEpochDay)), + LOCAL_DATE_TIME(new LocalDateTimeExternalizer()), + LOCAL_TIME(new LongExternalizer<>(LocalTime.class, LocalTime::ofNanoOfDay, LocalTime::toNanoOfDay)), + MONTH(new EnumExternalizer<>(Month.class)), + MONTH_DAY(new MonthDayExternalizer()), + PERIOD(new PeriodExternalizer()), + YEAR(new IntExternalizer<>(Year.class, Year::of, Year::getValue)), + YEAR_MONTH(new YearMonthExternalizer()), + ZONE_ID(new StringExternalizer<>(ZoneId.class, ZoneId::of, ZoneId::getId)), + ZONE_OFFSET(new StringExternalizer<>(ZoneOffset.class, ZoneOffset::of, ZoneOffset::getId)), + // java.util + ARRAY_DEQUE(new CollectionExternalizer<>(ArrayDeque.class, ArrayDeque::new)), + ARRAY_LIST(new CollectionExternalizer<>(ArrayList.class, ArrayList::new)), + ATOMIC_BOOLEAN(new BooleanExternalizer<>(AtomicBoolean.class, AtomicBoolean::new, AtomicBoolean::get)), + ATOMIC_INTEGER(new IntExternalizer<>(AtomicInteger.class, AtomicInteger::new, AtomicInteger::get)), + ATOMIC_LONG(new LongExternalizer<>(AtomicLong.class, AtomicLong::new, AtomicLong::get)), + ATOMIC_REFERENCE(new ObjectExternalizer<>(AtomicReference.class, AtomicReference::new, AtomicReference::get)), + CALENDAR(new CalendarExternalizer()), + CONCURRENT_HASH_MAP(new MapExternalizer<>(ConcurrentHashMap.class, ConcurrentHashMap::new)), + CONCURRENT_HASH_SET(new CollectionExternalizer<>(ConcurrentHashMap.KeySetView.class, ConcurrentHashMap::newKeySet)), + CONCURRENT_LINKED_DEQUE(new CollectionExternalizer<>(ConcurrentLinkedDeque.class, size -> new ConcurrentLinkedDeque<>())), + CONCURRENT_LINKED_QUEUE(new CollectionExternalizer<>(ConcurrentLinkedQueue.class, size -> new ConcurrentLinkedQueue<>())), + CONCURRENT_SKIP_LIST_MAP(new SortedMapExternalizer<>(ConcurrentSkipListMap.class, ConcurrentSkipListMap::new)), + CONCURRENT_SKIP_LIST_SET(new SortedSetExternalizer<>(ConcurrentSkipListSet.class, ConcurrentSkipListSet::new)), + COPY_ON_WRITE_ARRAY_LIST(new CopyOnWriteCollectionExternalizer<>(CopyOnWriteArrayList.class, CopyOnWriteArrayList::new)), + COPY_ON_WRITE_ARRAY_SET(new CopyOnWriteCollectionExternalizer<>(CopyOnWriteArraySet.class, CopyOnWriteArraySet::new)), + CURRENCY(new StringExternalizer<>(Currency.class, Currency::getInstance, Currency::getCurrencyCode)), + DATE(new DateExternalizer<>(Date.class, Date::new)), + EMPTY_ENUMERATION(new ValueExternalizer<>(Collections.emptyEnumeration())), + EMPTY_ITERATOR(new ValueExternalizer<>(Collections.emptyIterator())), + EMPTY_LIST(new ValueExternalizer<>(Collections.emptyList())), + EMPTY_LIST_ITERATOR(new ValueExternalizer<>(Collections.emptyListIterator())), + EMPTY_MAP(new ValueExternalizer<>(Collections.emptyMap())), + EMPTY_NAVIGABLE_MAP(new ValueExternalizer<>(Collections.emptyNavigableMap())), + EMPTY_NAVIGABLE_SET(new ValueExternalizer<>(Collections.emptyNavigableSet())), + EMPTY_SET(new ValueExternalizer<>(Collections.emptySet())), + EMPTY_SORTED_MAP(new ValueExternalizer<>(Collections.emptySortedMap())), + EMPTY_SORTED_SET(new ValueExternalizer<>(Collections.emptySortedSet())), + HASH_MAP(new MapExternalizer<>(HashMap.class, HashMap::new)), + HASH_SET(new CollectionExternalizer<>(HashSet.class, HashSet::new)), + LINKED_HASH_MAP(new MapExternalizer<>(LinkedHashMap.class, LinkedHashMap::new)), + LINKED_HASH_SET(new CollectionExternalizer<>(LinkedHashSet.class, LinkedHashSet::new)), + LINKED_LIST(new CollectionExternalizer<>(LinkedList.class, size -> new LinkedList<>())), + LOCALE(new StringExternalizer<>(Locale.class, Locale::forLanguageTag, Locale::toLanguageTag)), + @SuppressWarnings("unchecked") + OPTIONAL(new ObjectExternalizer<>(Optional.class, Optional::ofNullable, optional -> optional.orElse(null))), + SIMPLE_ENTRY(new MapEntryExternalizer<>(AbstractMap.SimpleEntry.class, AbstractMap.SimpleEntry::new)), + SIMPLE_IMMUTABLE_ENTRY(new MapEntryExternalizer<>(AbstractMap.SimpleImmutableEntry.class, AbstractMap.SimpleImmutableEntry::new)), + SINGLETON_LIST(new SingletonCollectionExternalizer<>(Collections::singletonList)), + SINGLETON_MAP(new SingletonMapExternalizer()), + SINGLETON_SET(new SingletonCollectionExternalizer<>(Collections::singleton)), + SQL_DATE(new DateExternalizer<>(java.sql.Date.class, java.sql.Date::new)), + SQL_TIME(new DateExternalizer<>(java.sql.Time.class, java.sql.Time::new)), + SQL_TIMESTAMP(new DateExternalizer.SqlTimestampExternalizer()), + TIME_ZONE(new StringExternalizer<>(TimeZone.class, TimeZone::getTimeZone, TimeZone::getID)), + TREE_MAP(new SortedMapExternalizer<>(TreeMap.class, TreeMap::new)), + TREE_SET(new SortedSetExternalizer<>(TreeSet.class, TreeSet::new)), + UUID(new UUIDExternalizer()), + ; + + private final Externalizer externalizer; + + @SuppressWarnings("unchecked") + DefaultExternalizer(Externalizer externalizer) { + this.externalizer = (Externalizer) externalizer; + } + + @Override + public void writeObject(ObjectOutput output, Object object) throws IOException { + this.externalizer.writeObject(output, object); + } + + @Override + public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException { + return this.externalizer.readObject(input); + } + + @Override + public Class getTargetClass() { + return this.externalizer.getTargetClass(); + } + + /** + * Cast this externalizer to its target type. + * @param type the externalizer type + * @return the externalizer + */ + @SuppressWarnings("unchecked") + public Externalizer cast(Class type) { + if (!type.isAssignableFrom(this.externalizer.getTargetClass())) { + throw new IllegalArgumentException(type.getName()); + } + return (Externalizer) this.externalizer; + } +} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/AtomicReferenceExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/ObjectExternalizer.java similarity index 58% rename from clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/AtomicReferenceExternalizer.java rename to clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/ObjectExternalizer.java index 7db11dcd7653..80e7ab8e3a56 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/AtomicReferenceExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/ObjectExternalizer.java @@ -20,36 +20,42 @@ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ -package org.wildfly.clustering.marshalling.spi.util; +package org.wildfly.clustering.marshalling.spi; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Function; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; /** - * {@link Externalizer} for an {@link AtomicReference> + * Base {@link Externalizer} for object wrapper externalization. * @author Paul Ferraro */ -@MetaInfServices(Externalizer.class) -public class AtomicReferenceExternalizer implements Externalizer> { +public class ObjectExternalizer implements Externalizer { + private final Function reader; + private final Function writer; + private final Class targetClass; + + public ObjectExternalizer(Class targetClass, Function reader, Function writer) { + this.targetClass = targetClass; + this.reader = reader; + this.writer = writer; + } @Override - public void writeObject(ObjectOutput output, AtomicReference reference) throws IOException { - output.writeObject(reference.get()); + public void writeObject(ObjectOutput output, T object) throws IOException { + output.writeObject(this.writer.apply(object)); } @Override - public AtomicReference readObject(ObjectInput input) throws IOException, ClassNotFoundException { - return new AtomicReference<>(input.readObject()); + public T readObject(ObjectInput input) throws IOException, ClassNotFoundException { + return this.reader.apply(input.readObject()); } - @SuppressWarnings("unchecked") @Override - public Class> getTargetClass() { - return (Class>) (Class) AtomicReference.class; + public Class getTargetClass() { + return this.targetClass; } } diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/StringExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/StringExternalizer.java index b672576e3e7c..5b84860fed7c 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/StringExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/StringExternalizer.java @@ -38,6 +38,10 @@ public class StringExternalizer implements Externalizer { private final Function writer; private final Class targetClass; + public StringExternalizer(Class targetClass, Function reader) { + this(targetClass, reader, Object::toString); + } + public StringExternalizer(Class targetClass, Function reader, Function writer) { this.reader = reader; this.writer = writer; diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/AtomicBooleanExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/ValueExternalizer.java similarity index 65% rename from clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/AtomicBooleanExternalizer.java rename to clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/ValueExternalizer.java index c5e5c58a1fb1..73e7fd8e5853 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/AtomicBooleanExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/ValueExternalizer.java @@ -20,35 +20,39 @@ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ -package org.wildfly.clustering.marshalling.spi.util; +package org.wildfly.clustering.marshalling.spi; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.util.concurrent.atomic.AtomicBoolean; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; /** - * Externalizer for an {@link AtomicBoolean}. + * Trivial {@link Externalizer} for a constant value. * @author Paul Ferraro */ -@MetaInfServices(Externalizer.class) -public class AtomicBooleanExternalizer implements Externalizer { +public class ValueExternalizer implements Externalizer { + + private final T value; + + public ValueExternalizer(T value) { + this.value = value; + } @Override - public void writeObject(ObjectOutput output, AtomicBoolean value) throws IOException { - output.writeBoolean(value.get()); + public void writeObject(ObjectOutput output, T object) throws IOException { + // Nothing to write } @Override - public AtomicBoolean readObject(ObjectInput input) throws IOException, ClassNotFoundException { - return new AtomicBoolean(input.readBoolean()); + public T readObject(ObjectInput input) throws IOException, ClassNotFoundException { + return this.value; } + @SuppressWarnings("unchecked") @Override - public Class getTargetClass() { - return AtomicBoolean.class; + public Class getTargetClass() { + return (Class) this.value.getClass(); } } diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/net/URIExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/net/URIExternalizer.java deleted file mode 100644 index a8872ef2d456..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/net/URIExternalizer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, 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.marshalling.spi.net; - -import java.net.URI; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; -import org.wildfly.clustering.marshalling.spi.StringExternalizer; - -/** - * Externalizer for a {@link URI}. - * @author Paul Ferraro - */ -@MetaInfServices(Externalizer.class) -public class URIExternalizer extends StringExternalizer { - - public URIExternalizer() { - super(URI.class, URI::create, URI::toString); - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/net/URLExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/net/URLExternalizer.java index 6a9cef4fc95a..89150291de4f 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/net/URLExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/net/URLExternalizer.java @@ -29,22 +29,19 @@ import java.net.URISyntaxException; import java.net.URL; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; /** * Externalizer for a {@link URL}. * @author Paul Ferraro */ -@MetaInfServices(Externalizer.class) public class URLExternalizer implements Externalizer { - private static final Externalizer URI_EXTERNALIZER = new URIExternalizer(); - @Override public void writeObject(ObjectOutput output, URL url) throws IOException { try { - URI_EXTERNALIZER.writeObject(output, url.toURI()); + DefaultExternalizer.URI.cast(URI.class).writeObject(output, url.toURI()); } catch (URISyntaxException e) { throw new IOException(e); } @@ -52,7 +49,7 @@ public void writeObject(ObjectOutput output, URL url) throws IOException { @Override public URL readObject(ObjectInput input) throws IOException, ClassNotFoundException { - return URI_EXTERNALIZER.readObject(input).toURL(); + return DefaultExternalizer.URI.cast(URI.class).readObject(input).toURL(); } @Override diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/DayOfWeekExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/DayOfWeekExternalizer.java deleted file mode 100644 index e6269885e4ba..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/DayOfWeekExternalizer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, 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.marshalling.spi.time; - -import java.time.DayOfWeek; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; -import org.wildfly.clustering.marshalling.spi.EnumExternalizer; - -/** - * Externalizer for a {@link DayOfWeek}. - * @author Paul Ferraro - */ -@MetaInfServices(Externalizer.class) -public class DayOfWeekExternalizer extends EnumExternalizer { - - public DayOfWeekExternalizer() { - super(DayOfWeek.class); - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/DurationExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/DurationExternalizer.java index 7109c9941a19..617792dc67ed 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/DurationExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/DurationExternalizer.java @@ -27,14 +27,12 @@ import java.io.ObjectOutput; import java.time.Duration; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; /** * Externalizer for a {@link Duration}. * @author Paul Ferraro */ -@MetaInfServices(Externalizer.class) public class DurationExternalizer implements Externalizer { @Override diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/InstantExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/InstantExternalizer.java index 2593c3bb183b..4006c013ea97 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/InstantExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/InstantExternalizer.java @@ -27,14 +27,12 @@ import java.io.ObjectOutput; import java.time.Instant; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; /** * Externalizer for an {@link Instant}. * @author Paul Ferraro */ -@MetaInfServices(Externalizer.class) public class InstantExternalizer implements Externalizer { @Override diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/LocalDateExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/LocalDateExternalizer.java deleted file mode 100644 index 28607daec087..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/LocalDateExternalizer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, 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.marshalling.spi.time; - -import java.time.LocalDate; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; -import org.wildfly.clustering.marshalling.spi.LongExternalizer; - -/** - * Externalizer for a {@link LocalDate}. - * @author Paul Ferraro - */ -@MetaInfServices(Externalizer.class) -public class LocalDateExternalizer extends LongExternalizer { - - public LocalDateExternalizer() { - super(LocalDate.class, LocalDate::ofEpochDay, LocalDate::toEpochDay); - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/LocalDateTimeExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/LocalDateTimeExternalizer.java index 23a1d5488feb..378d460d2ef6 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/LocalDateTimeExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/LocalDateTimeExternalizer.java @@ -29,29 +29,25 @@ import java.time.LocalDateTime; import java.time.LocalTime; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; /** * Externalizer for a {@link LocalDateTime}. * @author Paul Ferraro */ -@MetaInfServices(Externalizer.class) public class LocalDateTimeExternalizer implements Externalizer { - private static final Externalizer DATE_EXTERNALIZER = new LocalDateExternalizer(); - private static final Externalizer TIME_EXTERNALIZER = new LocalTimeExternalizer(); - @Override public void writeObject(ObjectOutput output, LocalDateTime dateTime) throws IOException { - DATE_EXTERNALIZER.writeObject(output, dateTime.toLocalDate()); - TIME_EXTERNALIZER.writeObject(output, dateTime.toLocalTime()); + DefaultExternalizer.LOCAL_DATE.cast(LocalDate.class).writeObject(output, dateTime.toLocalDate()); + DefaultExternalizer.LOCAL_TIME.cast(LocalTime.class).writeObject(output, dateTime.toLocalTime()); } @Override public LocalDateTime readObject(ObjectInput input) throws IOException, ClassNotFoundException { - LocalDate date = DATE_EXTERNALIZER.readObject(input); - LocalTime time = TIME_EXTERNALIZER.readObject(input); + LocalDate date = DefaultExternalizer.LOCAL_DATE.cast(LocalDate.class).readObject(input); + LocalTime time = DefaultExternalizer.LOCAL_TIME.cast(LocalTime.class).readObject(input); return LocalDateTime.of(date, time); } diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/LocalTimeExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/LocalTimeExternalizer.java deleted file mode 100644 index d93cd076701b..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/LocalTimeExternalizer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, 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.marshalling.spi.time; - -import java.time.LocalTime; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; -import org.wildfly.clustering.marshalling.spi.LongExternalizer; - -/** - * Externalizer for a {@link LocalTime}. - * @author Paul Ferraro - */ -@MetaInfServices(Externalizer.class) -public class LocalTimeExternalizer extends LongExternalizer { - - public LocalTimeExternalizer() { - super(LocalTime.class, LocalTime::ofNanoOfDay, LocalTime::toNanoOfDay); - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/MonthDayExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/MonthDayExternalizer.java index a6fdce6b1c82..b174c9dbb400 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/MonthDayExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/MonthDayExternalizer.java @@ -28,26 +28,25 @@ import java.time.Month; import java.time.MonthDay; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; import org.wildfly.clustering.marshalling.spi.IndexExternalizer; /** * Externalizer for a {@link MonthDay}. * @author Paul Ferraro */ -@MetaInfServices(Externalizer.class) public class MonthDayExternalizer implements Externalizer { @Override public void writeObject(ObjectOutput output, MonthDay monthDay) throws IOException { - MonthExternalizer.INSTANCE.writeObject(output, monthDay.getMonth()); + DefaultExternalizer.MONTH.cast(Month.class).writeObject(output, monthDay.getMonth()); IndexExternalizer.UNSIGNED_BYTE.writeData(output, monthDay.getDayOfMonth()); } @Override public MonthDay readObject(ObjectInput input) throws IOException, ClassNotFoundException { - Month month = MonthExternalizer.INSTANCE.readObject(input); + Month month = DefaultExternalizer.MONTH.cast(Month.class).readObject(input); int day = IndexExternalizer.UNSIGNED_BYTE.readData(input); return MonthDay.of(month, day); } diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/MonthExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/MonthExternalizer.java deleted file mode 100644 index 972d5dc19fab..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/MonthExternalizer.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, 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.marshalling.spi.time; - -import java.time.Month; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; -import org.wildfly.clustering.marshalling.spi.EnumExternalizer; - -/** - * Externalizer for a {@link Month}. - * @author Paul Ferraro - */ -@MetaInfServices(Externalizer.class) -public class MonthExternalizer extends EnumExternalizer { - - static final Externalizer INSTANCE = new MonthExternalizer(); - - public MonthExternalizer() { - super(Month.class); - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/PeriodExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/PeriodExternalizer.java index 45c470fd741f..3016c0bf1da5 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/PeriodExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/PeriodExternalizer.java @@ -27,14 +27,12 @@ import java.io.ObjectOutput; import java.time.Period; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; /** * Externalizer for a {@link Period}. * @author Paul Ferraro */ -@MetaInfServices(Externalizer.class) public class PeriodExternalizer implements Externalizer { @Override diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/YearExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/YearExternalizer.java deleted file mode 100644 index 8346ce6e11fe..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/YearExternalizer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, 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.marshalling.spi.time; - -import java.time.Year; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; -import org.wildfly.clustering.marshalling.spi.IntExternalizer; - -/** - * Externalizer for a {@link Year}. - * @author Paul Ferraro - */ -@MetaInfServices(Externalizer.class) -public class YearExternalizer extends IntExternalizer { - - public YearExternalizer() { - super(Year.class, Year::of, Year::getValue); - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/YearMonthExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/YearMonthExternalizer.java index ab575e653e85..5eab3c5c864e 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/YearMonthExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/YearMonthExternalizer.java @@ -28,26 +28,25 @@ import java.time.Month; import java.time.YearMonth; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; /** * Externalizer for a {@link YearMonth}. * @author Paul Ferraro */ -@MetaInfServices(Externalizer.class) public class YearMonthExternalizer implements Externalizer { @Override public void writeObject(ObjectOutput output, YearMonth value) throws IOException { output.writeInt(value.getYear()); - MonthExternalizer.INSTANCE.writeObject(output, value.getMonth()); + DefaultExternalizer.MONTH.cast(Month.class).writeObject(output, value.getMonth()); } @Override public YearMonth readObject(ObjectInput input) throws IOException, ClassNotFoundException { int year = input.readInt(); - Month month = MonthExternalizer.INSTANCE.readObject(input); + Month month = DefaultExternalizer.MONTH.cast(Month.class).readObject(input); return YearMonth.of(year, month); } diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/ZoneIdExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/ZoneIdExternalizer.java deleted file mode 100644 index 749baf3ee5a3..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/ZoneIdExternalizer.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2017, 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.marshalling.spi.time; - -import java.time.ZoneId; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; -import org.wildfly.clustering.marshalling.spi.StringExternalizer; - -/** - * @author Paul Ferraro - */ -@MetaInfServices(Externalizer.class) -public class ZoneIdExternalizer extends StringExternalizer { - - public ZoneIdExternalizer() { - super(ZoneId.class, ZoneId::of, ZoneId::getId); - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/ZoneOffsetExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/ZoneOffsetExternalizer.java deleted file mode 100644 index 09ac5f68f1d9..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/time/ZoneOffsetExternalizer.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, 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.marshalling.spi.time; - -import java.time.ZoneOffset; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; -import org.wildfly.clustering.marshalling.spi.StringExternalizer; - -/** - * @author Paul Ferraro - */ -@MetaInfServices(Externalizer.class) -public class ZoneOffsetExternalizer extends StringExternalizer { - - public ZoneOffsetExternalizer() { - super(ZoneOffset.class, ZoneOffset::of, ZoneOffset::getId); - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/AtomicIntegerExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/AtomicIntegerExternalizer.java deleted file mode 100644 index b742d818f587..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/AtomicIntegerExternalizer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, 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.marshalling.spi.util; - -import java.util.concurrent.atomic.AtomicInteger; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; -import org.wildfly.clustering.marshalling.spi.IntExternalizer; - -/** - * Externalizer for an {@link AtomicInteger}. - * @author Paul Ferraro - */ -@MetaInfServices(Externalizer.class) -public class AtomicIntegerExternalizer extends IntExternalizer { - - public AtomicIntegerExternalizer() { - super(AtomicInteger.class, AtomicInteger::new, AtomicInteger::get); - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/AtomicLongExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/AtomicLongExternalizer.java deleted file mode 100644 index e8674dd23da2..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/AtomicLongExternalizer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, 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.marshalling.spi.util; - -import java.util.concurrent.atomic.AtomicLong; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; -import org.wildfly.clustering.marshalling.spi.LongExternalizer; - -/** - * Externalizer for an {@link AtomicLong}. - * @author Paul Ferraro - */ -@MetaInfServices(Externalizer.class) -public class AtomicLongExternalizer extends LongExternalizer { - - public AtomicLongExternalizer() { - super(AtomicLong.class, AtomicLong::new, AtomicLong::get); - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CalendarExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CalendarExternalizer.java index 2ec7b6221081..655dd63aeb7f 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CalendarExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CalendarExternalizer.java @@ -28,13 +28,11 @@ import java.util.Calendar; import java.util.TimeZone; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; /** * @author Paul Ferraro */ -@MetaInfServices(Externalizer.class) public class CalendarExternalizer implements Externalizer { @Override diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CollectionExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CollectionExternalizer.java index 7d80744eb66f..504c4d95936a 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CollectionExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CollectionExternalizer.java @@ -25,18 +25,9 @@ import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.util.ArrayDeque; -import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedDeque; -import java.util.concurrent.ConcurrentLinkedQueue; import java.util.function.IntFunction; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.marshalling.spi.IndexExternalizer; @@ -50,7 +41,7 @@ public class CollectionExternalizer> implements Ext private final IntFunction factory; @SuppressWarnings("unchecked") - CollectionExternalizer(Class targetClass, IntFunction factory) { + public CollectionExternalizer(Class targetClass, IntFunction factory) { this.targetClass = (Class) targetClass; this.factory = factory; } @@ -84,60 +75,4 @@ static > T readCollection(ObjectInput input, T coll public Class getTargetClass() { return this.targetClass; } - - @MetaInfServices(Externalizer.class) - public static class ArrayDequeExternalizer extends CollectionExternalizer> { - public ArrayDequeExternalizer() { - super(ArrayDeque.class, ArrayDeque::new); - } - } - - @MetaInfServices(Externalizer.class) - public static class ArrayListExternalizer extends CollectionExternalizer> { - public ArrayListExternalizer() { - super(ArrayList.class, ArrayList::new); - } - } - - @MetaInfServices(Externalizer.class) - public static class ConcurrentHashSetExternalizer extends CollectionExternalizer> { - public ConcurrentHashSetExternalizer() { - super(ConcurrentHashMap.KeySetView.class, capacity -> ConcurrentHashMap.newKeySet(capacity)); - } - } - - @MetaInfServices(Externalizer.class) - public static class ConcurrentLinkedDequeExternalizer extends CollectionExternalizer> { - public ConcurrentLinkedDequeExternalizer() { - super(ConcurrentLinkedDeque.class, size -> new ConcurrentLinkedDeque<>()); - } - } - - @MetaInfServices(Externalizer.class) - public static class ConcurrentLinkedQueueExternalizer extends CollectionExternalizer> { - public ConcurrentLinkedQueueExternalizer() { - super(ConcurrentLinkedQueue.class, size -> new ConcurrentLinkedQueue<>()); - } - } - - @MetaInfServices(Externalizer.class) - public static class HashSetExternalizer extends CollectionExternalizer> { - public HashSetExternalizer() { - super(HashSet.class, HashSet::new); - } - } - - @MetaInfServices(Externalizer.class) - public static class LinkedHashSetExternalizer extends CollectionExternalizer> { - public LinkedHashSetExternalizer() { - super(LinkedHashSet.class, LinkedHashSet::new); - } - } - - @MetaInfServices(Externalizer.class) - public static class LinkedListExternalizer extends CollectionExternalizer> { - public LinkedListExternalizer() { - super(LinkedList.class, size -> new LinkedList<>()); - } - } } diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CopyOnWriteCollectionExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CopyOnWriteCollectionExternalizer.java index 89f577eef937..0dd8d4083449 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CopyOnWriteCollectionExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CopyOnWriteCollectionExternalizer.java @@ -27,11 +27,8 @@ import java.io.ObjectOutput; import java.util.ArrayList; import java.util.Collection; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.CopyOnWriteArraySet; import java.util.function.Function; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.marshalling.spi.IndexExternalizer; @@ -45,7 +42,7 @@ public class CopyOnWriteCollectionExternalizer> imp private final Function, T> factory; @SuppressWarnings("unchecked") - CopyOnWriteCollectionExternalizer(Class targetClass, Function, T> factory) { + public CopyOnWriteCollectionExternalizer(Class targetClass, Function, T> factory) { this.targetClass = (Class) targetClass; this.factory = factory; } @@ -66,18 +63,4 @@ public T readObject(ObjectInput input) throws IOException, ClassNotFoundExceptio public Class getTargetClass() { return this.targetClass; } - - @MetaInfServices(Externalizer.class) - public static class CopyOnWriteArrayListExternalizer extends CopyOnWriteCollectionExternalizer> { - public CopyOnWriteArrayListExternalizer() { - super(CopyOnWriteArrayList.class, CopyOnWriteArrayList::new); - } - } - - @MetaInfServices(Externalizer.class) - public static class CopyOnWriteArraySetExternalizer extends CopyOnWriteCollectionExternalizer> { - public CopyOnWriteArraySetExternalizer() { - super(CopyOnWriteArraySet.class, CopyOnWriteArraySet::new); - } - } } diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CurrencyExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CurrencyExternalizer.java deleted file mode 100644 index e30fb0429668..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/CurrencyExternalizer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, 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.marshalling.spi.util; - -import java.util.Currency; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; -import org.wildfly.clustering.marshalling.spi.StringExternalizer; - -/** - * Externalizer for {@link Currency}. - * @author Paul Ferraro - */ -@MetaInfServices(Externalizer.class) -public class CurrencyExternalizer extends StringExternalizer { - - public CurrencyExternalizer() { - super(Currency.class, Currency::getInstance, Currency::getCurrencyCode); - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/DateExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/DateExternalizer.java index 49c12d8b0f5d..0110323c7734 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/DateExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/DateExternalizer.java @@ -29,8 +29,6 @@ import java.util.Date; import java.util.function.LongFunction; -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.marshalling.spi.LongExternalizer; /** @@ -39,35 +37,13 @@ */ public class DateExternalizer extends LongExternalizer { - DateExternalizer(LongFunction factory, Class targetClass) { + public DateExternalizer(Class targetClass, LongFunction factory) { super(targetClass, factory, Date::getTime); } - @MetaInfServices(Externalizer.class) - public static class UtilDateExternalizer extends DateExternalizer { - public UtilDateExternalizer() { - super(Date::new, Date.class); - } - } - - @MetaInfServices(Externalizer.class) - public static class SqlDateExternalizer extends DateExternalizer { - public SqlDateExternalizer() { - super(java.sql.Date::new, java.sql.Date.class); - } - } - - @MetaInfServices(Externalizer.class) - public static class SqlTimeExternalizer extends DateExternalizer { - public SqlTimeExternalizer() { - super(java.sql.Time::new, java.sql.Time.class); - } - } - - @MetaInfServices(Externalizer.class) - public static class SqlTimestampExternalizer extends DateExternalizer { + public static class SqlTimestampExternalizer extends DateExternalizer { public SqlTimestampExternalizer() { - super(java.sql.Timestamp::new, java.sql.Timestamp.class); + super(Timestamp.class, Timestamp::new); } @Override diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/EmptyCollectionExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/EmptyCollectionExternalizer.java deleted file mode 100644 index 3bdd0771eb57..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/EmptyCollectionExternalizer.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, 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.marshalling.spi.util; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Collections; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.NavigableMap; -import java.util.NavigableSet; -import java.util.Set; -import java.util.SortedMap; -import java.util.SortedSet; -import java.util.function.Supplier; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; - -/** - * @author Paul Ferraro - */ -public class EmptyCollectionExternalizer implements Externalizer { - - private final Supplier factory; - - EmptyCollectionExternalizer(Supplier factory) { - this.factory = factory; - } - - @Override - public void writeObject(ObjectOutput output, T object) throws IOException { - // Nothing to write - } - - @Override - public T readObject(ObjectInput input) throws IOException, ClassNotFoundException { - return this.factory.get(); - } - - @SuppressWarnings("unchecked") - @Override - public Class getTargetClass() { - return (Class) this.factory.get().getClass(); - } - - @MetaInfServices(Externalizer.class) - public static class EmptyEnumerationExternalizer extends EmptyCollectionExternalizer> { - public EmptyEnumerationExternalizer() { - super(() -> Collections.emptyEnumeration()); - } - } - - @MetaInfServices(Externalizer.class) - public static class EmptyIteratorExternalizer extends EmptyCollectionExternalizer> { - public EmptyIteratorExternalizer() { - super(() -> Collections.emptyIterator()); - } - } - - @MetaInfServices(Externalizer.class) - public static class EmptyListExternalizer extends EmptyCollectionExternalizer> { - public EmptyListExternalizer() { - super(() -> Collections.emptyList()); - } - } - - @MetaInfServices(Externalizer.class) - public static class EmptyListIteratorExternalizer extends EmptyCollectionExternalizer> { - public EmptyListIteratorExternalizer() { - super(() -> Collections.emptyListIterator()); - } - } - - @MetaInfServices(Externalizer.class) - public static class EmptyMapExternalizer extends EmptyCollectionExternalizer> { - public EmptyMapExternalizer() { - super(() -> Collections.emptyMap()); - } - } - - @MetaInfServices(Externalizer.class) - public static class EmptyNavigableMapExternalizer extends EmptyCollectionExternalizer> { - public EmptyNavigableMapExternalizer() { - super(() -> Collections.emptyNavigableMap()); - } - } - - @MetaInfServices(Externalizer.class) - public static class EmptyNavigableSetExternalizer extends EmptyCollectionExternalizer> { - public EmptyNavigableSetExternalizer() { - super(() -> Collections.emptyNavigableSet()); - } - } - - @MetaInfServices(Externalizer.class) - public static class EmptySetExternalizer extends EmptyCollectionExternalizer> { - public EmptySetExternalizer() { - super(() -> Collections.emptySet()); - } - } - - @MetaInfServices(Externalizer.class) - public static class EmptySortedMapExternalizer extends EmptyCollectionExternalizer> { - public EmptySortedMapExternalizer() { - super(() -> Collections.emptySortedMap()); - } - } - - @MetaInfServices(Externalizer.class) - public static class EmptySortedSetExternalizer extends EmptyCollectionExternalizer> { - public EmptySortedSetExternalizer() { - super(() -> Collections.emptySortedSet()); - } - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/LocaleExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/LocaleExternalizer.java deleted file mode 100644 index 132f0c94d38c..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/LocaleExternalizer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, 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.marshalling.spi.util; - -import java.util.Locale; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; -import org.wildfly.clustering.marshalling.spi.StringExternalizer; - -/** - * Externalizer for a {@link Locale}. - * @author Paul Ferraro - */ -@MetaInfServices(Externalizer.class) -public class LocaleExternalizer extends StringExternalizer { - - public LocaleExternalizer() { - super(Locale.class, Locale::forLanguageTag, Locale::toLanguageTag); - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/MapEntryExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/MapEntryExternalizer.java index 3eabef2eb10c..510fec7514a0 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/MapEntryExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/MapEntryExternalizer.java @@ -25,14 +25,13 @@ import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.util.AbstractMap; import java.util.Map; import java.util.function.BiFunction; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; /** + * Externalizer for {@link Map.Entry} types * @author Paul Ferraro */ public class MapEntryExternalizer> implements Externalizer { @@ -41,7 +40,7 @@ public class MapEntryExternalizer> implement private final BiFunction factory; @SuppressWarnings("unchecked") - MapEntryExternalizer(Class targetClass, BiFunction factory) { + public MapEntryExternalizer(Class targetClass, BiFunction factory) { this.targetClass = (Class) targetClass; this.factory = factory; } @@ -61,18 +60,4 @@ public T readObject(ObjectInput input) throws IOException, ClassNotFoundExceptio public Class getTargetClass() { return this.targetClass; } - - @MetaInfServices(Externalizer.class) - public static class SimpleEntryExternalizer extends MapEntryExternalizer> { - public SimpleEntryExternalizer() { - super(AbstractMap.SimpleEntry.class, AbstractMap.SimpleEntry::new); - } - } - - @MetaInfServices(Externalizer.class) - public static class SimpleImmutableEntryExternalizer extends MapEntryExternalizer> { - public SimpleImmutableEntryExternalizer() { - super(AbstractMap.SimpleImmutableEntry.class, AbstractMap.SimpleImmutableEntry::new); - } - } } diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/MapExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/MapExternalizer.java index 22255ccff919..bdc7f972fdb5 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/MapExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/MapExternalizer.java @@ -25,13 +25,9 @@ import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import java.util.function.IntFunction; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.marshalling.spi.IndexExternalizer; @@ -45,7 +41,7 @@ public class MapExternalizer> implements Externali private final IntFunction factory; @SuppressWarnings("unchecked") - MapExternalizer(Class targetClass, IntFunction factory) { + public MapExternalizer(Class targetClass, IntFunction factory) { this.targetClass = (Class) targetClass; this.factory = factory; } @@ -80,25 +76,4 @@ static > T readMap(ObjectInput input, T map, int s public Class getTargetClass() { return this.targetClass; } - - @MetaInfServices(Externalizer.class) - public static class ConcurrentHashMapExternalizer extends MapExternalizer> { - public ConcurrentHashMapExternalizer() { - super(ConcurrentHashMap.class, ConcurrentHashMap::new); - } - } - - @MetaInfServices(Externalizer.class) - public static class HashMapExternalizer extends MapExternalizer> { - public HashMapExternalizer() { - super(HashMap.class, HashMap::new); - } - } - - @MetaInfServices(Externalizer.class) - public static class LinkedHashMapExternalizer extends MapExternalizer> { - public LinkedHashMapExternalizer() { - super(LinkedHashMap.class, LinkedHashMap::new); - } - } } diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SingletonCollectionExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SingletonCollectionExternalizer.java index 9dc5cae1be17..ae5d3ce5ab51 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SingletonCollectionExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SingletonCollectionExternalizer.java @@ -26,12 +26,8 @@ import java.io.ObjectInput; import java.io.ObjectOutput; import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Set; import java.util.function.Function; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; /** @@ -41,7 +37,7 @@ public class SingletonCollectionExternalizer> imple private final Function factory; - SingletonCollectionExternalizer(Function factory) { + public SingletonCollectionExternalizer(Function factory) { this.factory = factory; } @@ -60,18 +56,4 @@ public T readObject(ObjectInput input) throws IOException, ClassNotFoundExceptio public Class getTargetClass() { return (Class) this.factory.apply(null).getClass(); } - - @MetaInfServices(Externalizer.class) - public static class SingletonListExternalizer extends SingletonCollectionExternalizer> { - public SingletonListExternalizer() { - super(Collections::singletonList); - } - } - - @MetaInfServices(Externalizer.class) - public static class SingletonSetExternalizer extends SingletonCollectionExternalizer> { - public SingletonSetExternalizer() { - super(Collections::singleton); - } - } } diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SingletonMapExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SingletonMapExternalizer.java index f901a8bddeca..dd2493f139ec 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SingletonMapExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SingletonMapExternalizer.java @@ -28,13 +28,11 @@ import java.util.Collections; import java.util.Map; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; /** * @author Paul Ferraro */ -@MetaInfServices(Externalizer.class) public class SingletonMapExternalizer implements Externalizer> { @Override diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SortedMapExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SortedMapExternalizer.java index 82f411102cd4..16d193c40237 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SortedMapExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SortedMapExternalizer.java @@ -27,11 +27,8 @@ import java.io.ObjectOutput; import java.util.Comparator; import java.util.SortedMap; -import java.util.TreeMap; -import java.util.concurrent.ConcurrentSkipListMap; import java.util.function.Function; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.marshalling.spi.IndexExternalizer; @@ -46,7 +43,7 @@ public class SortedMapExternalizer> implemen private final Function, T> factory; @SuppressWarnings("unchecked") - SortedMapExternalizer(Class targetClass, Function, T> factory) { + public SortedMapExternalizer(Class targetClass, Function, T> factory) { this.targetClass = (Class) targetClass; this.factory = factory; } @@ -69,18 +66,4 @@ public T readObject(ObjectInput input) throws IOException, ClassNotFoundExceptio public Class getTargetClass() { return this.targetClass; } - - @MetaInfServices(Externalizer.class) - public static class ConcurrentSkipListMapExternalizer extends SortedMapExternalizer> { - public ConcurrentSkipListMapExternalizer() { - super(ConcurrentSkipListMap.class, ConcurrentSkipListMap::new); - } - } - - @MetaInfServices(Externalizer.class) - public static class TreeMapExternalizer extends SortedMapExternalizer> { - public TreeMapExternalizer() { - super(TreeMap.class, TreeMap::new); - } - } } diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SortedSetExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SortedSetExternalizer.java index 38c453b70fda..3eb4f2d424c6 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SortedSetExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/SortedSetExternalizer.java @@ -27,11 +27,8 @@ import java.io.ObjectOutput; import java.util.Comparator; import java.util.SortedSet; -import java.util.TreeSet; -import java.util.concurrent.ConcurrentSkipListSet; import java.util.function.Function; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.marshalling.spi.IndexExternalizer; @@ -46,7 +43,7 @@ public class SortedSetExternalizer> implements Exter private final Function, T> factory; @SuppressWarnings("unchecked") - SortedSetExternalizer(Class targetClass, Function, T> factory) { + public SortedSetExternalizer(Class targetClass, Function, T> factory) { this.targetClass = (Class) targetClass; this.factory = factory; } @@ -69,18 +66,4 @@ public T readObject(ObjectInput input) throws IOException, ClassNotFoundExceptio public Class getTargetClass() { return this.targetClass; } - - @MetaInfServices(Externalizer.class) - public static class ConcurrentSkipListSetExternalizer extends SortedSetExternalizer> { - public ConcurrentSkipListSetExternalizer() { - super(ConcurrentSkipListSet.class, ConcurrentSkipListSet::new); - } - } - - @MetaInfServices(Externalizer.class) - public static class TreeSetExternalizer extends SortedSetExternalizer> { - public TreeSetExternalizer() { - super(TreeSet.class, TreeSet::new); - } - } } diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/TimeZoneExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/TimeZoneExternalizer.java deleted file mode 100644 index e1d17199988d..000000000000 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/TimeZoneExternalizer.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2017, 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.marshalling.spi.util; - -import java.util.TimeZone; - -import org.kohsuke.MetaInfServices; -import org.wildfly.clustering.marshalling.Externalizer; -import org.wildfly.clustering.marshalling.spi.StringExternalizer; - -/** - * @author Paul Ferraro - */ -@MetaInfServices(Externalizer.class) -public class TimeZoneExternalizer extends StringExternalizer { - - public TimeZoneExternalizer() { - super(TimeZone.class, TimeZone::getTimeZone, TimeZone::getID); - } -} diff --git a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/UUIDExternalizer.java b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/UUIDExternalizer.java index 0cd0ae2e007b..78437d5603ee 100644 --- a/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/UUIDExternalizer.java +++ b/clustering/marshalling/spi/src/main/java/org/wildfly/clustering/marshalling/spi/util/UUIDExternalizer.java @@ -26,14 +26,12 @@ import java.io.ObjectOutput; import java.util.UUID; -import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.Externalizer; /** * {@link Externalizer} for {@link UUID} instances. * @author Paul Ferraro */ -@MetaInfServices(Externalizer.class) public class UUIDExternalizer implements Externalizer { @Override diff --git a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/net/NetExternalizerTestCase.java b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/net/NetExternalizerTestCase.java index 815db1f0ae70..225ae84cc3f5 100644 --- a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/net/NetExternalizerTestCase.java +++ b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/net/NetExternalizerTestCase.java @@ -28,6 +28,7 @@ import org.junit.Test; import org.wildfly.clustering.marshalling.spi.ExternalizerTestUtil; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; /** * Unit test for {@link URIExternalizer}. @@ -37,7 +38,7 @@ public class NetExternalizerTestCase { @Test public void test() throws ClassNotFoundException, IOException { - ExternalizerTestUtil.test(new URIExternalizer(), URI.create("http://wildfly.org/news/")); - ExternalizerTestUtil.test(new URLExternalizer(), new URL("http://wildfly.org/news/")); + ExternalizerTestUtil.test(DefaultExternalizer.URI.cast(URI.class), URI.create("http://wildfly.org/news/")); + ExternalizerTestUtil.test(DefaultExternalizer.URL.cast(URL.class), new URL("http://wildfly.org/news/")); } } diff --git a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/time/TimeExternalizerTestCase.java b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/time/TimeExternalizerTestCase.java index 6d884b41e68d..548588085863 100644 --- a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/time/TimeExternalizerTestCase.java +++ b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/time/TimeExternalizerTestCase.java @@ -23,11 +23,13 @@ package org.wildfly.clustering.marshalling.spi.time; import java.io.IOException; +import java.time.DayOfWeek; import java.time.Duration; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.Month; import java.time.MonthDay; import java.time.Period; import java.time.Year; @@ -38,6 +40,7 @@ import org.junit.Test; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.marshalling.spi.ExternalizerTestUtil; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; /** * Unit test for java.time.* externalizers @@ -48,20 +51,20 @@ public class TimeExternalizerTestCase { @Test public void test() throws ClassNotFoundException, IOException { - test(new DayOfWeekExternalizer()); - test(new MonthExternalizer()); + test(DefaultExternalizer.DAY_OF_WEEK.cast(DayOfWeek.class)); + test(DefaultExternalizer.MONTH.cast(Month.class)); - ExternalizerTestUtil.test(new DurationExternalizer(), Duration.between(Instant.EPOCH, Instant.now())); - ExternalizerTestUtil.test(new InstantExternalizer(), Instant.now()); - ExternalizerTestUtil.test(new LocalDateExternalizer(), LocalDate.now()); - ExternalizerTestUtil.test(new LocalDateTimeExternalizer(), LocalDateTime.now()); - ExternalizerTestUtil.test(new LocalTimeExternalizer(), LocalTime.now()); - ExternalizerTestUtil.test(new MonthDayExternalizer(), MonthDay.now()); - ExternalizerTestUtil.test(new PeriodExternalizer(), Period.between(LocalDate.ofEpochDay(0), LocalDate.now())); - ExternalizerTestUtil.test(new YearExternalizer(), Year.now()); - ExternalizerTestUtil.test(new YearMonthExternalizer(), YearMonth.now()); - ExternalizerTestUtil.test(new ZoneOffsetExternalizer(), ZoneOffset.UTC); - ExternalizerTestUtil.test(new ZoneIdExternalizer(), ZoneId.of("America/New_York")); + ExternalizerTestUtil.test(DefaultExternalizer.DURATION.cast(Duration.class), Duration.between(Instant.EPOCH, Instant.now())); + ExternalizerTestUtil.test(DefaultExternalizer.INSTANT.cast(Instant.class), Instant.now()); + ExternalizerTestUtil.test(DefaultExternalizer.LOCAL_DATE.cast(LocalDate.class), LocalDate.now()); + ExternalizerTestUtil.test(DefaultExternalizer.LOCAL_DATE_TIME.cast(LocalDateTime.class), LocalDateTime.now()); + ExternalizerTestUtil.test(DefaultExternalizer.LOCAL_TIME.cast(LocalTime.class), LocalTime.now()); + ExternalizerTestUtil.test(DefaultExternalizer.MONTH_DAY.cast(MonthDay.class), MonthDay.now()); + ExternalizerTestUtil.test(DefaultExternalizer.PERIOD.cast(Period.class), Period.between(LocalDate.ofEpochDay(0), LocalDate.now())); + ExternalizerTestUtil.test(DefaultExternalizer.YEAR.cast(Year.class), Year.now()); + ExternalizerTestUtil.test(DefaultExternalizer.YEAR_MONTH.cast(YearMonth.class), YearMonth.now()); + ExternalizerTestUtil.test(DefaultExternalizer.ZONE_OFFSET.cast(ZoneOffset.class), ZoneOffset.UTC); + ExternalizerTestUtil.test(DefaultExternalizer.ZONE_ID, ZoneId.of("America/New_York")); } private static > void test(Externalizer externalizer) throws ClassNotFoundException, IOException { diff --git a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/AtomicExternalizerTestCase.java b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/AtomicExternalizerTestCase.java index 8c8fbfbb4b30..fe6d139023f7 100644 --- a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/AtomicExternalizerTestCase.java +++ b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/AtomicExternalizerTestCase.java @@ -32,6 +32,7 @@ import org.junit.Test; import org.wildfly.clustering.marshalling.spi.ExternalizerTestUtil; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; /** * Unit test for java.util.concurrent.atomic externalizers. @@ -41,9 +42,9 @@ public class AtomicExternalizerTestCase { @Test public void test() throws ClassNotFoundException, IOException { - ExternalizerTestUtil.test(new AtomicBooleanExternalizer(), new AtomicBoolean(Boolean.TRUE), (expected, actual) -> assertEquals(expected.get(), actual.get())); - ExternalizerTestUtil.test(new AtomicIntegerExternalizer(), new AtomicInteger(Integer.MAX_VALUE), (expected, actual) -> assertEquals(expected.get(), actual.get())); - ExternalizerTestUtil.test(new AtomicLongExternalizer(), new AtomicLong(Long.MAX_VALUE), (expected, actual) -> assertEquals(expected.get(), actual.get())); - ExternalizerTestUtil.test(new AtomicReferenceExternalizer(), new AtomicReference(Boolean.TRUE), (expected, actual) -> assertEquals(expected.get(), actual.get())); + ExternalizerTestUtil.test(DefaultExternalizer.ATOMIC_BOOLEAN.cast(AtomicBoolean.class), new AtomicBoolean(Boolean.TRUE), (expected, actual) -> assertEquals(expected.get(), actual.get())); + ExternalizerTestUtil.test(DefaultExternalizer.ATOMIC_INTEGER.cast(AtomicInteger.class), new AtomicInteger(Integer.MAX_VALUE), (expected, actual) -> assertEquals(expected.get(), actual.get())); + ExternalizerTestUtil.test(DefaultExternalizer.ATOMIC_LONG.cast(AtomicLong.class), new AtomicLong(Long.MAX_VALUE), (expected, actual) -> assertEquals(expected.get(), actual.get())); + ExternalizerTestUtil.test(DefaultExternalizer.ATOMIC_REFERENCE.cast(AtomicReference.class), new AtomicReference(Boolean.TRUE), (expected, actual) -> assertEquals(expected.get(), actual.get())); } } diff --git a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/CollectionExternalizerTestCase.java b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/CollectionExternalizerTestCase.java index 89e116d5b456..4e227d2594ab 100644 --- a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/CollectionExternalizerTestCase.java +++ b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/CollectionExternalizerTestCase.java @@ -37,6 +37,11 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; +import java.util.NavigableSet; +import java.util.Set; +import java.util.SortedSet; import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedDeque; @@ -49,6 +54,7 @@ import org.junit.Test; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.marshalling.spi.ExternalizerTestUtil; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; /** * Unit test for {@link CollectionExternalizer} externalizers. @@ -56,36 +62,37 @@ */ public class CollectionExternalizerTestCase { + @SuppressWarnings("unchecked") @Test public void test() throws ClassNotFoundException, IOException { Collection basis = Arrays.asList(1, 2, 3, 4, 5); - test(new CollectionExternalizer.ArrayDequeExternalizer(), new ArrayDeque<>(basis)); - test(new CollectionExternalizer.ArrayListExternalizer(), new ArrayList<>(basis)); - test(new CollectionExternalizer.ConcurrentLinkedDequeExternalizer(), new ConcurrentLinkedDeque<>(basis)); - test(new CollectionExternalizer.ConcurrentLinkedQueueExternalizer(), new ConcurrentLinkedQueue<>(basis)); - test(new CollectionExternalizer.HashSetExternalizer(), new HashSet<>(basis)); - test(new CollectionExternalizer.LinkedHashSetExternalizer(), new LinkedHashSet<>(basis)); - test(new CollectionExternalizer.LinkedListExternalizer(), new LinkedList<>(basis)); + test(DefaultExternalizer.ARRAY_DEQUE.cast(ArrayDeque.class), new ArrayDeque<>(basis)); + test(DefaultExternalizer.ARRAY_LIST.cast(ArrayList.class), new ArrayList<>(basis)); + test(DefaultExternalizer.CONCURRENT_LINKED_DEQUE.cast(ConcurrentLinkedDeque.class), new ConcurrentLinkedDeque<>(basis)); + test(DefaultExternalizer.CONCURRENT_LINKED_QUEUE.cast(ConcurrentLinkedQueue.class), new ConcurrentLinkedQueue<>(basis)); + test(DefaultExternalizer.HASH_SET.cast(HashSet.class), new HashSet<>(basis)); + test(DefaultExternalizer.LINKED_HASH_SET.cast(LinkedHashSet.class), new LinkedHashSet<>(basis)); + test(DefaultExternalizer.LINKED_LIST.cast(LinkedList.class), new LinkedList<>(basis)); ConcurrentHashMap.KeySetView keySetView = ConcurrentHashMap.newKeySet(); keySetView.addAll(basis); - test(new CollectionExternalizer.ConcurrentHashSetExternalizer(), keySetView); + test(DefaultExternalizer.CONCURRENT_HASH_SET.cast(ConcurrentHashMap.KeySetView.class), keySetView); - test(new CopyOnWriteCollectionExternalizer.CopyOnWriteArrayListExternalizer(), new CopyOnWriteArrayList<>(basis)); - test(new CopyOnWriteCollectionExternalizer.CopyOnWriteArraySetExternalizer(), new CopyOnWriteArraySet<>(basis)); + test(DefaultExternalizer.COPY_ON_WRITE_ARRAY_LIST.cast(CopyOnWriteArrayList.class), new CopyOnWriteArrayList<>(basis)); + test(DefaultExternalizer.COPY_ON_WRITE_ARRAY_SET.cast(CopyOnWriteArraySet.class), new CopyOnWriteArraySet<>(basis)); - test(new EmptyCollectionExternalizer.EmptyEnumerationExternalizer(), Collections.emptyEnumeration()); - test(new EmptyCollectionExternalizer.EmptyIteratorExternalizer(), Collections.emptyIterator()); - test(new EmptyCollectionExternalizer.EmptyListExternalizer(), Collections.emptyList()); - test(new EmptyCollectionExternalizer.EmptyListIteratorExternalizer(), Collections.emptyListIterator()); - test(new EmptyCollectionExternalizer.EmptyNavigableSetExternalizer(), Collections.emptyNavigableSet()); - test(new EmptyCollectionExternalizer.EmptySetExternalizer(), Collections.emptySet()); - test(new EmptyCollectionExternalizer.EmptySortedSetExternalizer(), Collections.emptySortedSet()); + test(DefaultExternalizer.EMPTY_ENUMERATION.cast(Enumeration.class), Collections.emptyEnumeration()); + test(DefaultExternalizer.EMPTY_ITERATOR.cast(Iterator.class), Collections.emptyIterator()); + test(DefaultExternalizer.EMPTY_LIST.cast(List.class), Collections.emptyList()); + test(DefaultExternalizer.EMPTY_LIST_ITERATOR.cast(ListIterator.class), Collections.emptyListIterator()); + test(DefaultExternalizer.EMPTY_NAVIGABLE_SET.cast(NavigableSet.class), Collections.emptyNavigableSet()); + test(DefaultExternalizer.EMPTY_SET.cast(Set.class), Collections.emptySet()); + test(DefaultExternalizer.EMPTY_SORTED_SET.cast(SortedSet.class), Collections.emptySortedSet()); - test(new SingletonCollectionExternalizer.SingletonListExternalizer(), Collections.singletonList(1)); - test(new SingletonCollectionExternalizer.SingletonSetExternalizer(), Collections.singleton(1)); + test(DefaultExternalizer.SINGLETON_LIST.cast(List.class), Collections.singletonList(1)); + test(DefaultExternalizer.SINGLETON_SET.cast(Set.class), Collections.singleton(1)); - test(new SortedSetExternalizer.ConcurrentSkipListSetExternalizer(), new ConcurrentSkipListSet<>(basis)); - test(new SortedSetExternalizer.TreeSetExternalizer(), new TreeSet<>(basis)); + test(DefaultExternalizer.CONCURRENT_SKIP_LIST_SET.cast(ConcurrentSkipListSet.class), new ConcurrentSkipListSet<>(basis)); + test(DefaultExternalizer.TREE_SET.cast(TreeSet.class), new TreeSet<>(basis)); } public static > void test(Externalizer externalizer, T collection) throws ClassNotFoundException, IOException { diff --git a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/DateExternalizerTestCase.java b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/DateExternalizerTestCase.java index ae6a2840d9ef..0b8d2ed8fe06 100644 --- a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/DateExternalizerTestCase.java +++ b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/DateExternalizerTestCase.java @@ -34,10 +34,7 @@ import org.junit.Test; import org.wildfly.clustering.marshalling.spi.ExternalizerTestUtil; -import org.wildfly.clustering.marshalling.spi.util.DateExternalizer.SqlDateExternalizer; -import org.wildfly.clustering.marshalling.spi.util.DateExternalizer.SqlTimeExternalizer; -import org.wildfly.clustering.marshalling.spi.util.DateExternalizer.SqlTimestampExternalizer; -import org.wildfly.clustering.marshalling.spi.util.DateExternalizer.UtilDateExternalizer; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; /** * Unit test for {@link Date} externalizers. @@ -47,18 +44,18 @@ public class DateExternalizerTestCase { @Test public void test() throws ClassNotFoundException, IOException { - ExternalizerTestUtil.test(new UtilDateExternalizer(), Date.from(Instant.now())); - ExternalizerTestUtil.test(new SqlDateExternalizer(), java.sql.Date.valueOf(LocalDate.now())); - ExternalizerTestUtil.test(new SqlTimeExternalizer(), java.sql.Time.valueOf(LocalTime.now())); - ExternalizerTestUtil.test(new SqlTimestampExternalizer(), java.sql.Timestamp.valueOf(LocalDateTime.now())); + ExternalizerTestUtil.test(DefaultExternalizer.DATE.cast(Date.class), Date.from(Instant.now())); + ExternalizerTestUtil.test(DefaultExternalizer.SQL_DATE.cast(java.sql.Date.class), java.sql.Date.valueOf(LocalDate.now())); + ExternalizerTestUtil.test(DefaultExternalizer.SQL_TIME.cast(java.sql.Time.class), java.sql.Time.valueOf(LocalTime.now())); + ExternalizerTestUtil.test(DefaultExternalizer.SQL_TIMESTAMP.cast(java.sql.Timestamp.class), java.sql.Timestamp.valueOf(LocalDateTime.now())); // Validate default calendar - ExternalizerTestUtil.test(new CalendarExternalizer(), Calendar.getInstance()); + ExternalizerTestUtil.test(DefaultExternalizer.CALENDAR.cast(Calendar.class), Calendar.getInstance()); // Validate Gregorian calendar w/locale - ExternalizerTestUtil.test(new CalendarExternalizer(), new Calendar.Builder().setLenient(false).setLocale(Locale.FRANCE).build()); + ExternalizerTestUtil.test(DefaultExternalizer.CALENDAR.cast(Calendar.class), new Calendar.Builder().setLenient(false).setLocale(Locale.FRANCE).build()); // Validate Japanese Imperial calendar - ExternalizerTestUtil.test(new CalendarExternalizer(), Calendar.getInstance(TimeZone.getTimeZone("Asia/Tokyo"), Locale.JAPAN)); + ExternalizerTestUtil.test(DefaultExternalizer.CALENDAR.cast(Calendar.class), Calendar.getInstance(TimeZone.getTimeZone("Asia/Tokyo"), Locale.JAPAN)); // Validate Buddhist calendar - ExternalizerTestUtil.test(new CalendarExternalizer(), Calendar.getInstance(TimeZone.getTimeZone("Asia/Bangkok"), Locale.forLanguageTag("th_TH"))); + ExternalizerTestUtil.test(DefaultExternalizer.CALENDAR.cast(Calendar.class), Calendar.getInstance(TimeZone.getTimeZone("Asia/Bangkok"), Locale.forLanguageTag("th_TH"))); } } diff --git a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/MapEntryExternalizerTestCase.java b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/MapEntryExternalizerTestCase.java index efb46ff42f4d..d86afbd39ad1 100644 --- a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/MapEntryExternalizerTestCase.java +++ b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/MapEntryExternalizerTestCase.java @@ -27,6 +27,7 @@ import org.junit.Test; import org.wildfly.clustering.marshalling.spi.ExternalizerTestUtil; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; /** * Unit test for {@link MapEntryExternalizer} externalizers @@ -38,7 +39,7 @@ public class MapEntryExternalizerTestCase { public void test() throws ClassNotFoundException, IOException { Object key = "key"; Object value = "value"; - ExternalizerTestUtil.test(new MapEntryExternalizer.SimpleEntryExternalizer(), new AbstractMap.SimpleEntry<>(key, value)); - ExternalizerTestUtil.test(new MapEntryExternalizer.SimpleImmutableEntryExternalizer(), new AbstractMap.SimpleImmutableEntry<>(key, value)); + ExternalizerTestUtil.test(DefaultExternalizer.SIMPLE_ENTRY.cast(AbstractMap.SimpleEntry.class), new AbstractMap.SimpleEntry<>(key, value)); + ExternalizerTestUtil.test(DefaultExternalizer.SIMPLE_IMMUTABLE_ENTRY.cast(AbstractMap.SimpleImmutableEntry.class), new AbstractMap.SimpleImmutableEntry<>(key, value)); } } diff --git a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/MapExternalizerTestCase.java b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/MapExternalizerTestCase.java index 1426257b8a9c..9663e66e6ea7 100644 --- a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/MapExternalizerTestCase.java +++ b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/MapExternalizerTestCase.java @@ -30,6 +30,8 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; +import java.util.NavigableMap; +import java.util.SortedMap; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentSkipListMap; @@ -40,6 +42,7 @@ import org.junit.Test; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.marshalling.spi.ExternalizerTestUtil; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; /** * Unit test for {@link MapExternalizer} externalizers @@ -47,21 +50,22 @@ */ public class MapExternalizerTestCase { + @SuppressWarnings("unchecked") @Test public void test() throws ClassNotFoundException, IOException { Map basis = Stream.of(1, 2, 3, 4, 5).collect(Collectors.toMap(i -> i, i -> Integer.toString(i))); - test(new MapExternalizer.ConcurrentHashMapExternalizer(), new ConcurrentHashMap<>(basis)); - test(new MapExternalizer.HashMapExternalizer(), new HashMap<>(basis)); - test(new MapExternalizer.LinkedHashMapExternalizer(), new LinkedHashMap<>(basis)); + test(DefaultExternalizer.CONCURRENT_HASH_MAP.cast(ConcurrentHashMap.class), new ConcurrentHashMap<>(basis)); + test(DefaultExternalizer.HASH_MAP.cast(HashMap.class), new HashMap<>(basis)); + test(DefaultExternalizer.LINKED_HASH_MAP.cast(LinkedHashMap.class), new LinkedHashMap<>(basis)); - test(new EmptyCollectionExternalizer.EmptyMapExternalizer(), Collections.emptyMap()); - test(new EmptyCollectionExternalizer.EmptyNavigableMapExternalizer(), Collections.emptyNavigableMap()); - test(new EmptyCollectionExternalizer.EmptySortedMapExternalizer(), Collections.emptySortedMap()); + test(DefaultExternalizer.EMPTY_MAP.cast(Map.class), Collections.emptyMap()); + test(DefaultExternalizer.EMPTY_NAVIGABLE_MAP.cast(NavigableMap.class), Collections.emptyNavigableMap()); + test(DefaultExternalizer.EMPTY_SORTED_MAP.cast(SortedMap.class), Collections.emptySortedMap()); - test(new SingletonMapExternalizer(), Collections.singletonMap(1, 2)); + test(DefaultExternalizer.SINGLETON_MAP.cast(Map.class), Collections.singletonMap(1, 2)); - test(new SortedMapExternalizer.ConcurrentSkipListMapExternalizer(), new ConcurrentSkipListMap<>(basis)); - test(new SortedMapExternalizer.TreeMapExternalizer(), new TreeMap<>(basis)); + test(DefaultExternalizer.CONCURRENT_SKIP_LIST_MAP.cast(ConcurrentSkipListMap.class), new ConcurrentSkipListMap<>(basis)); + test(DefaultExternalizer.TREE_MAP.cast(TreeMap.class), new TreeMap<>(basis)); } public static > void test(Externalizer externalizer, T collection) throws ClassNotFoundException, IOException { diff --git a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/UtilExternalizerTestCase.java b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/UtilExternalizerTestCase.java index 61a233bdf205..b188dd2d5ba8 100644 --- a/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/UtilExternalizerTestCase.java +++ b/clustering/marshalling/spi/src/test/java/org/wildfly/clustering/marshalling/spi/util/UtilExternalizerTestCase.java @@ -31,6 +31,7 @@ import org.junit.Test; import org.wildfly.clustering.marshalling.spi.ExternalizerTestUtil; +import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; /** * Unit test for java.util.* externalizers. @@ -40,11 +41,11 @@ public class UtilExternalizerTestCase { @Test public void test() throws ClassNotFoundException, IOException { - ExternalizerTestUtil.test(new CurrencyExternalizer(), Currency.getInstance(Locale.US)); - ExternalizerTestUtil.test(new LocaleExternalizer(), Locale.US); - ExternalizerTestUtil.test(new OptionalExternalizer(), Optional.empty()); - ExternalizerTestUtil.test(new TimeZoneExternalizer(), TimeZone.getDefault()); - ExternalizerTestUtil.test(new TimeZoneExternalizer(), TimeZone.getTimeZone("America/New_York")); - ExternalizerTestUtil.test(new UUIDExternalizer(), UUID.randomUUID()); + ExternalizerTestUtil.test(DefaultExternalizer.CURRENCY.cast(Currency.class), Currency.getInstance(Locale.US)); + ExternalizerTestUtil.test(DefaultExternalizer.LOCALE.cast(Locale.class), Locale.US); + ExternalizerTestUtil.test(DefaultExternalizer.OPTIONAL.cast(Optional.class), Optional.empty()); + ExternalizerTestUtil.test(DefaultExternalizer.TIME_ZONE.cast(TimeZone.class), TimeZone.getDefault()); + ExternalizerTestUtil.test(DefaultExternalizer.TIME_ZONE.cast(TimeZone.class), TimeZone.getTimeZone("America/New_York")); + ExternalizerTestUtil.test(DefaultExternalizer.UUID.cast(UUID.class), UUID.randomUUID()); } } diff --git a/feature-pack/src/main/resources/modules/system/layers/base/org/jboss/as/clustering/infinispan/main/module.xml b/feature-pack/src/main/resources/modules/system/layers/base/org/jboss/as/clustering/infinispan/main/module.xml index 6231bac4bd7b..b4a2029904a3 100644 --- a/feature-pack/src/main/resources/modules/system/layers/base/org/jboss/as/clustering/infinispan/main/module.xml +++ b/feature-pack/src/main/resources/modules/system/layers/base/org/jboss/as/clustering/infinispan/main/module.xml @@ -66,6 +66,7 @@ + diff --git a/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/ejb/infinispan/main/module.xml b/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/ejb/infinispan/main/module.xml index 0968cd508c7d..4255b8b19d95 100644 --- a/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/ejb/infinispan/main/module.xml +++ b/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/ejb/infinispan/main/module.xml @@ -57,7 +57,7 @@ - + diff --git a/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/marshalling/jboss/main/module.xml b/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/marshalling/jboss/main/module.xml index 5fbdc40eec6d..4c73e8ad16b4 100644 --- a/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/marshalling/jboss/main/module.xml +++ b/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/marshalling/jboss/main/module.xml @@ -37,7 +37,7 @@ - + diff --git a/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/server/main/module.xml b/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/server/main/module.xml index 7ea80fcd2c03..c870453c3010 100644 --- a/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/server/main/module.xml +++ b/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/server/main/module.xml @@ -54,8 +54,8 @@ - - + + diff --git a/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/web/infinispan/main/module.xml b/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/web/infinispan/main/module.xml index 95d107826396..7afe0f8ab685 100644 --- a/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/web/infinispan/main/module.xml +++ b/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/web/infinispan/main/module.xml @@ -54,7 +54,7 @@ - + diff --git a/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/web/undertow/main/module.xml b/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/web/undertow/main/module.xml index 2e6a94c4f890..b0db19861abc 100644 --- a/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/web/undertow/main/module.xml +++ b/feature-pack/src/main/resources/modules/system/layers/base/org/wildfly/clustering/web/undertow/main/module.xml @@ -47,7 +47,7 @@ - +