[jboss-remoting-commits] JBoss Remoting SVN: r5513 - in remoting3/trunk: jboss-remoting/src/main/java/org/jboss/remoting3/spi and 1 other directories.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Wed Sep 16 23:49:32 EDT 2009


Author: david.lloyd at jboss.com
Date: 2009-09-16 23:49:31 -0400 (Wed, 16 Sep 2009)
New Revision: 5513

Removed:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/FlagSet.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Option.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/OptionMap.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Sequence.java
Modified:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Endpoint.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalServiceConfiguration.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Options.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceRegistration.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceRegistrationListener.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProvider.java
   remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexClientExample.java
Log:
Move the Option system to XNIO, who needs it badly

Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Endpoint.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Endpoint.java	2009-09-17 01:39:06 UTC (rev 5512)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Endpoint.java	2009-09-17 03:49:31 UTC (rev 5513)
@@ -7,6 +7,7 @@
 import org.jboss.remoting3.spi.RequestHandler;
 import org.jboss.remoting3.spi.ConnectionProviderRegistration;
 import org.jboss.xnio.IoFuture;
+import org.jboss.xnio.OptionMap;
 
 /**
  * A potential participant in a JBoss Remoting communications relationship.

Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java	2009-09-17 01:39:06 UTC (rev 5512)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java	2009-09-17 03:49:31 UTC (rev 5513)
@@ -55,6 +55,7 @@
 import org.jboss.xnio.IoFuture;
 import org.jboss.xnio.IoUtils;
 import org.jboss.xnio.WeakCloseable;
+import org.jboss.xnio.OptionMap;
 import org.jboss.xnio.log.Logger;
 
 /**

Deleted: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/FlagSet.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/FlagSet.java	2009-09-17 01:39:06 UTC (rev 5512)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/FlagSet.java	2009-09-17 03:49:31 UTC (rev 5513)
@@ -1,149 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting3;
-
-import java.util.AbstractSet;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.Collections;
-import java.util.Collection;
-import java.io.Serializable;
-
-/**
- * An immutable set of some enumeration type.  Used to build immutable sets of flags for flag options.
- *
- * @param <E> the element type
- */
-public final class FlagSet<E extends Enum<E>> extends AbstractSet<E> implements Serializable {
-
-    private final Class<E> type;
-    private final EnumSet<E> values;
-    private static final long serialVersionUID = 4155828678034140336L;
-
-    private FlagSet(final Class<E> type, final EnumSet<E> values) {
-        this.type = type;
-        this.values = values;
-    }
-
-    /**
-     * Create a flag set that is a copy of a given collection.
-     *
-     * @param elementType the element type
-     * @param original the original flag collection
-     * @param <E> the element type
-     * @return the flag set
-     */
-    public static <E extends Enum<E>> FlagSet<E> copyOf(Class<E> elementType, Collection<E> original) {
-        return new FlagSet<E>(elementType, EnumSet.copyOf(original));
-    }
-
-    /**
-     * Create an empty flag set of a given type.
-     *
-     * @param elementType the element type
-     * @param <E> the element type
-     * @return the flag set
-     */
-    public static <E extends Enum<E>> FlagSet<E> noneOf(Class<E> elementType) {
-        return new FlagSet<E>(elementType, EnumSet.noneOf(elementType));
-    }
-
-    /**
-     * Create a full flag set of a given type.
-     *
-     * @param elementType the element type
-     * @param <E> the element type
-     * @return the flag set
-     */
-    public static <E extends Enum<E>> FlagSet<E> allOf(Class<E> elementType) {
-        return new FlagSet<E>(elementType, EnumSet.allOf(elementType));
-    }
-
-    /**
-     * Create a flag set of the given elements.
-     *
-     * @param elements the elements
-     * @param <E> the element type
-     * @return the flag set
-     */
-    @SuppressWarnings({ "unchecked" })
-    public static <E extends Enum<E>> FlagSet<E> of(E... elements) {
-        if (elements.length == 0) {
-            throw new IllegalArgumentException("Empty elements array");
-        }
-        Class elementType = elements[0].getClass();
-        while (elementType.getSuperclass() != Enum.class) elementType = elementType.getSuperclass();
-        return new FlagSet<E>((Class<E>)elementType, EnumSet.<E>of(elements[0], elements));
-    }
-
-    /**
-     * Get the element type for this flag set.
-     *
-     * @return the element type
-     */
-    public Class<E> getElementType() {
-        return type;
-    }
-
-    /**
-     * Cast this flag set to a flag set of the given element type.
-     *
-     * @param type the element type
-     * @param <N> the element type
-     * @return this flag set
-     * @throws ClassCastException if the elements of this flag set are not of the given type
-     */
-    @SuppressWarnings({ "unchecked" })
-    public <N extends Enum<N>> FlagSet<N> cast(Class<N> type) throws ClassCastException {
-        this.type.asSubclass(type);
-        return (FlagSet<N>) this;
-    }
-
-    /**
-     * Determine if this flag set contains the given value.
-     *
-     * @param o the value
-     * @return {@code true} if the value is within this set
-     */
-    public boolean contains(final Object o) {
-        return values.contains(o);
-    }
-
-    /**
-     * Get an iterator over this flag set.
-     *
-     * @return an iterator
-     */
-    public Iterator<E> iterator() {
-        return Collections.unmodifiableSet(values).iterator();
-    }
-
-    /**
-     * Get the number of elements in this flag set.
-     *
-     * @return the number of elements
-     */
-    public int size() {
-        return values.size();
-    }
-}

Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalServiceConfiguration.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalServiceConfiguration.java	2009-09-17 01:39:06 UTC (rev 5512)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalServiceConfiguration.java	2009-09-17 03:49:31 UTC (rev 5513)
@@ -22,6 +22,8 @@
 
 package org.jboss.remoting3;
 
+import org.jboss.xnio.OptionMap;
+
 /**
  * A configuration for a service to be deployed into the endpoint.
  *

Deleted: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Option.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Option.java	2009-09-17 01:39:06 UTC (rev 5512)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Option.java	2009-09-17 03:49:31 UTC (rev 5513)
@@ -1,200 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting3;
-
-import java.util.Collection;
-import java.io.Serializable;
-import java.io.ObjectStreamException;
-import java.io.InvalidObjectException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
-/**
- * A strongly-typed option to configure an aspect of a service or connection.  Options are immutable and use identity comparisons
- * and hash codes.  Options should always be declared as {@code public static final} members in order to support serialization.
- *
- * @param <T> the option value type
- */
-public abstract class Option<T> implements Serializable {
-
-    private static final long serialVersionUID = -1564427329140182760L;
-
-    private final Class<?> declClass;
-    private final String name;
-
-    Option(final Class<?> declClass, final String name) {
-        this.declClass = declClass;
-        if (name == null) {
-            throw new NullPointerException("name is null");
-        }
-        this.name = name;
-    }
-
-    /**
-     * Create an option with a simple type.  The class object given <b>must</b> represent some immutable type, otherwise
-     * unexpected behavior may result.
-     *
-     * @param declClass the declaring class of the option
-     * @param name the (field) name of this option
-     * @param type the class of the value associated with this option
-     * @return the option instance
-     */
-    public static <T> Option<T> simple(final Class<?> declClass, final String name, final Class<T> type) {
-        return new SingleOption<T>(declClass, name, type);
-    }
-
-    /**
-     * Create an option with a sequence type.  The class object given <b>must</b> represent some immutable type, otherwise
-     * unexpected behavior may result.
-     *
-     * @param declClass the declaring class of the option
-     * @param name the (field) name of this option
-     * @param elementType the class of the sequence element value associated with this option
-     * @return the option instance
-     */
-    public static <T> Option<Sequence<T>> sequence(final Class<?> declClass, final String name, final Class<T> elementType) {
-        return new SequenceOption<T>(declClass, name, elementType);
-    }
-
-    /**
-     * Create an option with a flag set type.  The class object given <b>must</b> represent some immutable type, otherwise
-     * unexpected behavior may result.
-     *
-     * @param declClass the declaring class of the option
-     * @param name the (field) name of this option
-     * @param elementType the class of the flag values associated with this option
-     * @param <T> the type of the flag values associated with this option
-     * @return the option instance
-     */
-    public static <T extends Enum<T>> Option<FlagSet<T>> flags(final Class<?> declClass, final String name, final Class<T> elementType) {
-        return new FlagsOption<T>(declClass, name, elementType);
-    }
-
-    /**
-     * Get the name of this option.
-     *
-     * @return the option name
-     */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * Get a human-readible string representation of this object.
-     *
-     * @return the string representation
-     */
-    public String toString() {
-        return super.toString() + " (" + declClass.getName() + "#" + name + ")";
-    }
-
-    /**
-     * Return the given object as the type of this option.  If the cast could not be completed, an exception is thrown.
-     *
-     * @param o the object to cast
-     * @return the cast object
-     * @throws ClassCastException if the object is not of a compatible type
-     */
-    public abstract T cast(Object o) throws ClassCastException;
-
-    /**
-     * Resolve this instance for serialization.
-     *
-     * @return the resolved object
-     * @throws ObjectStreamException if the object could not be resolved
-     */
-    protected final Object readResolve() throws ObjectStreamException {
-        try {
-            final Field field = declClass.getField(name);
-            final int modifiers = field.getModifiers();
-            if (! Modifier.isProtected(modifiers)) {
-                throw new InvalidObjectException("Invalid Option instance (the field is not public)");
-            }
-            if (! Modifier.isStatic(modifiers)) {
-                throw new InvalidObjectException("Invalid Option instance (the field is not static)");
-            }
-            return field.get(null);
-        } catch (NoSuchFieldException e) {
-            throw new InvalidObjectException("Invalid Option instance (no matching field)");
-        } catch (IllegalAccessException e) {
-            throw new InvalidObjectException("Invalid Option instance (Illegal access on field get)");
-        }
-    }
-}
-
-final class SingleOption<T> extends Option<T> {
-
-    private static final long serialVersionUID = 2449094406108952764L;
-
-    private transient final Class<T> type;
-
-    SingleOption(final Class<?> declClass, final String name, final Class<T> type) {
-        super(declClass, name);
-        this.type = type;
-    }
-
-    public T cast(final Object o) {
-        return type.cast(o);
-    }
-}
-
-final class SequenceOption<T> extends Option<Sequence<T>> {
-
-    private static final long serialVersionUID = -4328676629293125136L;
-
-    private transient final Class<T> elementType;
-
-    SequenceOption(final Class<?> declClass, final String name, final Class<T> elementType) {
-        super(declClass, name);
-        this.elementType = elementType;
-    }
-
-    public Sequence<T> cast(final Object o) {
-        if (o instanceof Sequence) {
-            return ((Sequence<?>)o).cast(elementType);
-        } else if (o instanceof Object[]){
-            return Sequence.of((Object[])o).cast(elementType);
-        } else if (o instanceof Collection) {
-            return Sequence.of((Collection<?>)o).cast(elementType);
-        } else {
-            throw new ClassCastException("Not a sequence");
-        }
-    }
-}
-
-final class FlagsOption<T extends Enum<T>> extends Option<FlagSet<T>> {
-
-    private static final long serialVersionUID = -5487268452958691541L;
-
-    private transient final Class<T> elementType;
-
-    FlagsOption(final Class<?> declClass, final String name, final Class<T> elementType) {
-        super(declClass, name);
-        this.elementType = elementType;
-    }
-
-    public FlagSet<T> cast(final Object o) throws ClassCastException {
-        final FlagSet<?> flagSet = (FlagSet<?>) o;
-        return flagSet.cast(elementType);
-    }
-}
\ No newline at end of file

Deleted: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/OptionMap.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/OptionMap.java	2009-09-17 01:39:06 UTC (rev 5512)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/OptionMap.java	2009-09-17 03:49:31 UTC (rev 5513)
@@ -1,304 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting3;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.Collections;
-import java.util.IdentityHashMap;
-import java.io.Serializable;
-
-/**
- * An immutable map of options to option values.  No {@code null} keys or values are permitted.
- */
-public final class OptionMap implements Iterable<Option<?>>, Serializable {
-
-    private static final long serialVersionUID = 3632842565346928132L;
-
-    private final Map<Option<?>, Object> value;
-
-    private OptionMap(final Map<Option<?>, Object> value) {
-        this.value = value;
-    }
-
-    /**
-     * Determine whether this option map contains the given option.
-     *
-     * @param option the option to check
-     * @return {@code true} if the option is present in the option map
-     */
-    public boolean contains(Option<?> option) {
-        return value.containsKey(option);
-    }
-
-    /**
-     * Get the value of an option from this option map.
-     *
-     * @param option the option to get
-     * @param <T> the type of the option
-     * @return the option value, or {@code null} if it is not present
-     */
-    public <T> T get(Option<T> option) {
-        return option.cast(value.get(option));
-    }
-
-    /**
-     * Iterate over the options in this map.
-     *
-     * @return an iterator over the options
-     */
-    public Iterator<Option<?>> iterator() {
-        return Collections.unmodifiableCollection(value.keySet()).iterator();
-    }
-
-    /**
-     * Get the number of options stored in this map.
-     *
-     * @return the number of options
-     */
-    public int size() {
-        return value.size();
-    }
-
-    /**
-     * The empty option map.
-     */
-    public static final OptionMap EMPTY = new OptionMap(Collections.<Option<?>, Object>emptyMap());
-
-    /**
-     * Create a new builder.
-     *
-     * @return a new builder
-     */
-    public static Builder builder() {
-        return new Builder();
-    }
-
-    /**
-     * A builder for immutable option maps.  Create an instance with the {@link OptionMap#builder()} method.
-     */
-    public static final class Builder {
-
-        private Builder() {
-        }
-
-        private static class OVPair<T> {
-            Option<T> option;
-            T value;
-
-            private OVPair(final Option<T> option, final T value) {
-                this.option = option;
-                this.value = value;
-            }
-        }
-
-        private List<OVPair<?>> list = new ArrayList<OVPair<?>>();
-
-        /**
-         * Add a key-value pair.
-         *
-         * @param key the key
-         * @param value the value
-         * @param <T> the option type
-         * @return this builder
-         */
-        public <T> Builder add(Option<T> key, T value) {
-            if (value == null) {
-                throw new NullPointerException("value is null");
-            }
-            list.add(new OVPair<T>(key, value));
-            return this;
-        }
-
-        /**
-         * Add an int value to an Integer key.
-         *
-         * @param key the option
-         * @param value the value
-         * @return this builder
-         */
-        public Builder add(Option<Integer> key, int value) {
-            list.add(new OVPair<Integer>(key, Integer.valueOf(value)));
-            return this;
-        }
-
-        /**
-         * Add int values to an Integer sequence key.
-         *
-         * @param key the key
-         * @param values the values
-         * @return this builder
-         */
-        public Builder addSequence(Option<Sequence<Integer>> key, int... values) {
-            Integer[] a = new Integer[values.length];
-            for (int i = 0; i < values.length; i++) {
-                a[i] = Integer.valueOf(values[i]);
-            }
-            list.add(new OVPair<Sequence<Integer>>(key, Sequence.of(a)));
-            return this;
-        }
-
-        /**
-         * Add a long value to a Long key.
-         *
-         * @param key the option
-         * @param value the value
-         * @return this builder
-         */
-        public Builder add(Option<Long> key, long value) {
-            list.add(new OVPair<Long>(key, Long.valueOf(value)));
-            return this;
-        }
-
-        /**
-         * Add long values to an Long sequence key.
-         *
-         * @param key the key
-         * @param values the values
-         * @return this builder
-         */
-        public Builder addSequence(Option<Sequence<Long>> key, long... values) {
-            Long[] a = new Long[values.length];
-            for (int i = 0; i < values.length; i++) {
-                a[i] = Long.valueOf(values[i]);
-            }
-            list.add(new OVPair<Sequence<Long>>(key, Sequence.of(a)));
-            return this;
-        }
-
-        /**
-         * Add a boolean value to a Boolean key.
-         *
-         * @param key the option
-         * @param value the value
-         * @return this builder
-         */
-        public Builder add(Option<Boolean> key, boolean value) {
-            list.add(new OVPair<Boolean>(key, Boolean.valueOf(value)));
-            return this;
-        }
-
-
-        /**
-         * Add boolean values to an Boolean sequence key.
-         *
-         * @param key the key
-         * @param values the values
-         * @return this builder
-         */
-        public Builder addSequence(Option<Sequence<Boolean>> key, boolean... values) {
-            Boolean[] a = new Boolean[values.length];
-            for (int i = 0; i < values.length; i++) {
-                a[i] = Boolean.valueOf(values[i]);
-            }
-            list.add(new OVPair<Sequence<Boolean>>(key, Sequence.of(a)));
-            return this;
-        }
-
-        /**
-         * Add a key-value pair, where the value is a sequence type.
-         *
-         * @param key the key
-         * @param values the values
-         * @param <T> the option type
-         * @return this builder
-         */
-        public <T> Builder addSequence(Option<Sequence<T>> key, T... values) {
-            list.add(new OVPair<Sequence<T>>(key, Sequence.of(values)));
-            return this;
-        }
-
-        /**
-         * Add a key-value pair, where the value is a flag type.
-         *
-         * @param key the key
-         * @param values the values
-         * @param <T> the option type
-         * @return this builder
-         */
-        public <T extends Enum<T>> Builder addFlags(Option<FlagSet<T>> key, T... values) {
-            list.add(new OVPair<FlagSet<T>>(key, FlagSet.of(values)));
-            return this;
-        }
-
-        private <T> void copy(Map<?, ?> map, Option<T> option) {
-            add(option, option.cast(map.get(option)));
-        }
-
-        /**
-         * Add all the entries of a map.  Any keys of the map which are not valid {@link Option}s, or whose
-         * values are not valid arguments for the given {@code Option}, will cause an exception to be thrown.
-         *
-         * @param map the map
-         * @return this builder
-         * @throws ClassCastException if any entries of the map are not valid option-value pairs
-         */
-        public Builder add(Map<?, ?> map) throws ClassCastException {
-            for (Object key : map.keySet()) {
-                final Option<?> option = Option.class.cast(key);
-                copy(map, option);
-            }
-            return this;
-        }
-
-        private <T> void copy(OptionMap optionMap, Option<T> option) {
-            add(option, optionMap.get(option));
-        }
-
-        /**
-         * Add all entries from an existing option map to the one being built.
-         *
-         * @param optionMap the original option map
-         * @return this builder
-         */
-        public Builder addAll(OptionMap optionMap) {
-            for (Option<?> option : optionMap) {
-                copy(optionMap, option);
-            }
-            return this;
-        }
-
-        /**
-         * Build a map that reflects the current state of this builder.
-         *
-         * @return the new immutable option map
-         */
-        public OptionMap getMap() {
-            final List<OVPair<?>> list = this.list;
-            if (list.size() == 0) {
-                return EMPTY;
-            } else if (list.size() == 1) {
-                final OVPair<?> pair = list.get(0);
-                return new OptionMap(Collections.<Option<?>, Object>singletonMap(pair.option, pair.value));
-            } else {
-                final Map<Option<?>, Object> map = new IdentityHashMap<Option<?>, Object>();
-                for (OVPair<?> ovPair : list) {
-                    map.put(ovPair.option, ovPair.value);
-                }
-                return new OptionMap(map);
-            }
-        }
-    }
-}

Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Options.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Options.java	2009-09-17 01:39:06 UTC (rev 5512)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Options.java	2009-09-17 03:49:31 UTC (rev 5513)
@@ -22,6 +22,9 @@
 
 package org.jboss.remoting3;
 
+import org.jboss.xnio.Option;
+import org.jboss.xnio.Sequence;
+
 /**
  * Common options for service registration.
  */

Deleted: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Sequence.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Sequence.java	2009-09-17 01:39:06 UTC (rev 5512)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Sequence.java	2009-09-17 03:49:31 UTC (rev 5513)
@@ -1,166 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting3;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.AbstractList;
-import java.util.List;
-import java.util.RandomAccess;
-
-/**
- * An immutable sequence of elements.  Though this class implements {@link java.util.List}, it is in fact
- * immutable.
- *
- * @param <T> the element type
- */
-public final class Sequence<T> extends AbstractList<T> implements List<T>, RandomAccess, Serializable {
-
-    private static final long serialVersionUID = 3042164316147742903L;
-
-    private final Object[] values;
-
-    private static final Object[] empty = new Object[0];
-
-    private Sequence(final Object[] values) {
-        final Object[] realValues = values.clone();
-        this.values = realValues;
-        for (Object realValue : realValues) {
-            if (realValue == null) {
-                throw new NullPointerException("value member is null");
-            }
-        }
-    }
-
-    private static final Sequence EMPTY = new Sequence(empty);
-
-    /**
-     * Return a sequence of the given members.
-     *
-     * @param members the members
-     * @param <T> the element type
-     * @return a sequence
-     */
-    public static <T> Sequence<T> of(T... members) {
-        if (members.length == 0) {
-            return empty();
-        } else {
-            return new Sequence<T>(members);
-        }
-    }
-
-    /**
-     * Return a sequence of the given members.
-     *
-     * @param members the members
-     * @param <T> the element type
-     * @return a sequence
-     */
-    public static <T> Sequence<T> of(Collection<T> members) {
-        if (members instanceof Sequence) {
-            return (Sequence<T>) members;
-        }
-        final Object[] objects = members.toArray();
-        if (objects.length == 0) {
-            return empty();
-        }
-        return new Sequence<T>(objects);
-    }
-
-    /**
-     * Cast a sequence to a different type <b>if</b> all the contained elements are of the subtype.
-     *
-     * @param newType the class to cast to
-     * @param <N> the new type
-     * @return the typecast sequence
-     * @throws ClassCastException if any elements could not be cast
-     */
-    @SuppressWarnings({ "unchecked" })
-    public <N> Sequence<N> cast(Class<N> newType) throws ClassCastException {
-        for (Object value : values) {
-            newType.cast(value);
-        }
-        return (Sequence<N>) this;
-    }
-
-    /**
-     * Return an empty sequence.
-     *
-     * @param <T> the element type
-     * @return the empty sequence
-     */
-    @SuppressWarnings({ "unchecked" })
-    public static <T> Sequence<T> empty() {
-        return (Sequence<T>) EMPTY;
-    }
-
-    /**
-     * Get an iterator over the elements of this sequence.
-     *
-     * @return an iterator over the elements of this sequence
-     */
-    @SuppressWarnings({ "unchecked" })
-    public Iterator<T> iterator() {
-        return Arrays.<T>asList((T[]) values).iterator();
-    }
-
-    /**
-     * Return the number of elements in this sequence.
-     *
-     * @return the number of elements
-     */
-    public int size() {
-        return values.length;
-    }
-
-    /**
-     * Determine whether this sequence is empty.
-     *
-     * @return {@code true} if the sequence has no elements
-     */
-    public boolean isEmpty() {
-        return values.length != 0;
-    }
-
-    /**
-     * Get a copy of the values array.
-     *
-     * @return a copy of the values array
-     */
-    public Object[] toArray() {
-        return values.clone();
-    }
-
-    /**
-     * Get the value at a certain index.
-     *
-     * @param index the index
-     * @return the value
-     */
-    @SuppressWarnings({ "unchecked" })
-    public T get(final int index) {
-        return (T) values[index];
-    }
-}

Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceRegistration.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceRegistration.java	2009-09-17 01:39:06 UTC (rev 5512)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceRegistration.java	2009-09-17 03:49:31 UTC (rev 5513)
@@ -23,6 +23,7 @@
 package org.jboss.remoting3;
 
 import org.jboss.remoting3.spi.RequestHandlerConnector;
+import org.jboss.xnio.OptionMap;
 
 /**
  *

Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceRegistrationListener.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceRegistrationListener.java	2009-09-17 01:39:06 UTC (rev 5512)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceRegistrationListener.java	2009-09-17 03:49:31 UTC (rev 5513)
@@ -23,6 +23,7 @@
 package org.jboss.remoting3;
 
 import org.jboss.remoting3.spi.RequestHandlerConnector;
+import org.jboss.xnio.OptionMap;
 
 /**
  * A listener for watching service registrations on an endpoint.

Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProvider.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProvider.java	2009-09-17 01:39:06 UTC (rev 5512)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProvider.java	2009-09-17 03:49:31 UTC (rev 5513)
@@ -23,7 +23,7 @@
 package org.jboss.remoting3.spi;
 
 import java.net.URI;
-import org.jboss.remoting3.OptionMap;
+import org.jboss.xnio.OptionMap;
 
 /**
  * A connection provider.  Used to establish connections with remote systems.  There is typically one instance

Modified: remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexClientExample.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexClientExample.java	2009-09-17 01:39:06 UTC (rev 5512)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexClientExample.java	2009-09-17 03:49:31 UTC (rev 5513)
@@ -24,7 +24,7 @@
 
 import org.jboss.remoting3.Endpoint;
 import org.jboss.remoting3.Remoting;
-import org.jboss.remoting3.OptionMap;
+import org.jboss.xnio.OptionMap;
 import org.jboss.remoting3.Connection;
 import org.jboss.remoting3.Client;
 import org.jboss.xnio.IoUtils;



More information about the jboss-remoting-commits mailing list