You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tr...@apache.org on 2007/12/05 08:13:21 UTC

svn commit: r601229 [1/2] - in /mina/trunk: core/src/main/java/org/apache/mina/common/ integration-beans/src/main/java/org/apache/mina/integration/beans/ integration-jmx/src/main/java/org/apache/mina/integration/jmx/ integration-ognl/src/main/java/org/...

Author: trustin
Date: Tue Dec  4 23:13:18 2007
New Revision: 601229

URL: http://svn.apache.org/viewvc?rev=601229&view=rev
Log:
* Revamped JMX integration to make it work better with more POJO
* Added more PropertyEditors to support JMX integration
* Added PropertyTypeConverter to OGNL integration module


Added:
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ArrayEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/BooleanEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ByteEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CharacterEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ClassEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CollectionEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DateEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DoubleEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/EnumEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FileEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FloatEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/IntegerEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ListEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/LongEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/MapEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NullEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NumberEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PatternEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PropertiesEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/SetEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ShortEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/StringEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/URIEditor.java   (with props)
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/URLEditor.java   (with props)
    mina/trunk/integration-ognl/src/main/java/org/apache/mina/integration/ognl/PropertyTypeConverter.java   (with props)
Modified:
    mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoAcceptor.java
    mina/trunk/core/src/main/java/org/apache/mina/common/IoAcceptor.java
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/AbstractPropertyEditor.java
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/InetAddressEditor.java
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/InetSocketAddressEditor.java
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PropertyEditorFactory.java
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/SerialAddressEditor.java
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/TrafficMaskAddressEditor.java
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/VmPipeAddressEditor.java
    mina/trunk/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceMBean.java
    mina/trunk/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoSessionMBean.java
    mina/trunk/integration-jmx/src/main/java/org/apache/mina/integration/jmx/ObjectMBean.java
    mina/trunk/integration-ognl/src/main/java/org/apache/mina/integration/ognl/AbstractPropertyAccessor.java
    mina/trunk/integration-ognl/src/main/java/org/apache/mina/integration/ognl/IoSessionFinder.java

Modified: mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoAcceptor.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoAcceptor.java?rev=601229&r1=601228&r2=601229&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoAcceptor.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoAcceptor.java Tue Dec  4 23:13:18 2007
@@ -84,27 +84,21 @@
     }
 
     public final void setDefaultLocalAddress(SocketAddress localAddress) {
-        setDefaultLocalAddresses(new SocketAddress[] { localAddress });
+        setDefaultLocalAddresses(localAddress);
     }
 
     public final List<SocketAddress> getDefaultLocalAddresses() {
         return unmodifiableDefaultLocalAddresses;
     }
 
-    public final void setDefaultLocalAddresses(Iterable<? extends SocketAddress> localAddresses) {
+    public final void setDefaultLocalAddresses(List<? extends SocketAddress> localAddresses) {
         if (localAddresses == null) {
             throw new NullPointerException("localAddresses");
         }
-        
-        List<SocketAddress> list = new ArrayList<SocketAddress>();
-        for (SocketAddress a: localAddresses) {
-            list.add(a);
-        }
-        
-        setDefaultLocalAddresses(list.toArray(new SocketAddress[list.size()]));
+        setDefaultLocalAddresses((Iterable<? extends SocketAddress>) localAddresses);
     }
 
-    public final void setDefaultLocalAddresses(SocketAddress... localAddresses) {
+    public final void setDefaultLocalAddresses(Iterable<? extends SocketAddress> localAddresses) {
         if (localAddresses == null) {
             throw new NullPointerException("localAddresses");
         }
@@ -129,6 +123,22 @@
             this.defaultLocalAddresses.clear();
             this.defaultLocalAddresses.addAll(newLocalAddresses);
         }
+    }
+
+    public final void setDefaultLocalAddresses(SocketAddress firstLocalAddress, SocketAddress... otherLocalAddresses) {
+        if (otherLocalAddresses == null) {
+            otherLocalAddresses = new SocketAddress[0];
+        }
+        
+        Collection<SocketAddress> newLocalAddresses =
+            new ArrayList<SocketAddress>(otherLocalAddresses.length + 1);
+        
+        newLocalAddresses.add(firstLocalAddress);
+        for (SocketAddress a: otherLocalAddresses) {
+            newLocalAddresses.add(a);
+        }
+        
+        setDefaultLocalAddresses(newLocalAddresses);
     }
 
     public final boolean isCloseOnDeactivation() {

Modified: mina/trunk/core/src/main/java/org/apache/mina/common/IoAcceptor.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/IoAcceptor.java?rev=601229&r1=601228&r2=601229&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/IoAcceptor.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/IoAcceptor.java Tue Dec  4 23:13:18 2007
@@ -60,7 +60,7 @@
      * in {@link #bind()} method.  Please note that the default will not be
      * used if any local address is specified.  If more than one address are
      * set, only one of them will be returned, but it's not necessarily the
-     * firstly specified address in {@link #setDefaultLocalAddresses(SocketAddress...)}.
+     * firstly specified address in {@link #setDefaultLocalAddresses(List)}.
      * 
      */
     SocketAddress getDefaultLocalAddress();
@@ -84,7 +84,7 @@
      * in {@link #bind()} method.  Please note that the default will not be
      * used if any local address is specified.
      */
-    void setDefaultLocalAddresses(SocketAddress... localAddresses);
+    void setDefaultLocalAddresses(SocketAddress firstLocalAddress, SocketAddress... otherLocalAddresses);
     
     /**
      * Sets the default local addresses to bind when no argument is specified
@@ -94,6 +94,13 @@
     void setDefaultLocalAddresses(Iterable<? extends SocketAddress> localAddresses);
 
     /**
+     * Sets the default local addresses to bind when no argument is specified
+     * in {@link #bind()} method.  Please note that the default will not be
+     * used if any local address is specified.
+     */
+    void setDefaultLocalAddresses(List<? extends SocketAddress> localAddresses);
+
+        /**
      * Returns <tt>true</tt> if and only if all clients are closed when this
      * acceptor unbinds from all the related local address (i.e. when the
      * service is deactivated).

Modified: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/AbstractPropertyEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/AbstractPropertyEditor.java?rev=601229&r1=601228&r2=601229&view=diff
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/AbstractPropertyEditor.java (original)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/AbstractPropertyEditor.java Tue Dec  4 23:13:18 2007
@@ -32,7 +32,12 @@
 
     private String text;
     private Object value;
+    private boolean trimText = true;
     
+    protected void setTrimText(boolean trimText) {
+        this.trimText = trimText;
+    }
+
     @Override
     public String getAsText() {
         return text;
@@ -47,9 +52,9 @@
     public void setAsText(String text) throws IllegalArgumentException {
         this.text = text;
         if (text == null) {
-            value = null;
+            value = defaultValue();
         } else {
-            value = toValue(text.trim());
+            value = toValue(trimText? text.trim() : text);
         }
     }
 
@@ -57,12 +62,20 @@
     public void setValue(Object value) {
         this.value = value;
         if (value == null) {
-            text = null;
+            text = defaultText();
         } else {
             text = toText(value);
         }
     }
     
+    protected String defaultText() {
+        return null;
+    }
+    
+    protected Object defaultValue() {
+        return null;
+    }
+
     protected abstract String toText(Object value);
     protected abstract Object toValue(String text) throws IllegalArgumentException;
     

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ArrayEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ArrayEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ArrayEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ArrayEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,122 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a one-dimensional array and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class ArrayEditor extends AbstractPropertyEditor {
+    private final Class<?> componentType;
+    
+    public ArrayEditor(Class<?> componentType) {
+        if (componentType == null) {
+            throw new NullPointerException("componentType");
+        }
+        
+        this.componentType = componentType;
+        getComponentEditor();
+        setTrimText(false);
+    }
+
+    private PropertyEditor getComponentEditor() {
+        PropertyEditor e = PropertyEditorFactory.getInstance(componentType);
+        if (e == null) {
+            throw new IllegalArgumentException(
+                    "No " + PropertyEditor.class.getSimpleName() + 
+                    " found for " + componentType.getSimpleName() + '.');
+        }
+        return e;
+    }
+
+    @Override
+    protected String toText(Object value) {
+        Class<?> componentType = value.getClass().getComponentType();
+        if (componentType == null) {
+            throw new IllegalArgumentException("not an array: " + value);
+        }
+        
+        PropertyEditor e = PropertyEditorFactory.getInstance(componentType);
+        if (e == null) {
+            throw new IllegalArgumentException(
+                    "No " + PropertyEditor.class.getSimpleName() + 
+                    " found for " + componentType.getSimpleName() + '.');
+        }
+        
+        StringBuilder buf = new StringBuilder();
+        for (int i = 0; i < Array.getLength(value); i ++) {
+            e.setValue(Array.get(value, i));
+            // TODO normalize.
+            String s = e.getAsText();
+            buf.append(s);
+            buf.append(", ");
+        }
+        
+        // Remove the last delimiter.
+        if (buf.length() >= 2) {
+            buf.setLength(buf.length() - 2);
+        }
+        return buf.toString();
+    }
+
+    @Override
+    protected Object toValue(String text) throws IllegalArgumentException {
+        PropertyEditor e = getComponentEditor();
+        List<Object> values = new ArrayList<Object>();
+        Matcher m = CollectionEditor.ELEMENT.matcher(text);
+        boolean matchedDelimiter = true;
+
+        while (m.find()) {
+            if (m.group(1) != null) {
+                matchedDelimiter = true;
+                continue;
+            }
+            
+            if (!matchedDelimiter) {
+                throw new IllegalArgumentException("No delimiter between elements: " + text);
+            }
+
+            // TODO escape here.
+            e.setAsText(m.group());
+            values.add(e.getValue());
+            
+            matchedDelimiter = false;
+            if (m.group(2) != null || m.group(3) != null) {
+                // Skip the last '"'.
+                m.region(m.end() + 1, m.regionEnd());
+            }
+        }
+        
+        Object answer = Array.newInstance(componentType, values.size());
+        for (int i = 0; i < Array.getLength(answer); i ++) {
+            Array.set(answer, i, values.get(i));
+        }
+        return answer;
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ArrayEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ArrayEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/BooleanEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/BooleanEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/BooleanEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/BooleanEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,55 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+import java.util.regex.Pattern;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link Character} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class BooleanEditor extends AbstractPropertyEditor {
+    private static final Pattern TRUE = Pattern.compile(
+            "(?:true|t|yes|y|1)", Pattern.CASE_INSENSITIVE);
+    private static final Pattern FALSE = Pattern.compile(
+            "(?:false|f|no|n|1)", Pattern.CASE_INSENSITIVE);
+    
+    @Override
+    protected String toText(Object value) {
+        return String.valueOf(value);
+    }
+
+    @Override
+    protected Object toValue(String text) throws IllegalArgumentException {
+        if (TRUE.matcher(text).matches()) {
+            return Boolean.TRUE;
+        }
+        
+        if (FALSE.matcher(text).matches()) {
+            return Boolean.FALSE;
+        }
+        
+        throw new IllegalArgumentException("Wrong boolean value: " + text);
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/BooleanEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/BooleanEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ByteEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ByteEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ByteEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ByteEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * an {@link Byte} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class ByteEditor extends NumberEditor {
+    @Override
+    protected Object toValue(String text, int radix) {
+        return Byte.parseByte(text, radix);
+    }
+
+    @Override
+    protected Object defaultValue() {
+        return Byte.valueOf((byte) 0);
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ByteEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ByteEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CharacterEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CharacterEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CharacterEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CharacterEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,56 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+import java.util.regex.Pattern;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link Character} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class CharacterEditor extends AbstractPropertyEditor {
+    private static final Pattern UNICODE = Pattern.compile("\\\\[uU][0-9a-fA-F]+");
+    
+    @Override
+    protected String toText(Object value) {
+        return String.valueOf(value);
+    }
+
+    @Override
+    protected Object toValue(String text) throws IllegalArgumentException {
+        if (text.isEmpty()) {
+            return Character.valueOf(Character.MIN_VALUE);
+        }
+        
+        if (UNICODE.matcher(text).matches()) {
+            return Character.valueOf((char) Integer.parseInt(text.substring(2)));
+        }
+        
+        if (text.length() != 1) {
+            throw new IllegalArgumentException("Too many characters: " + text);
+        }
+
+        return Character.valueOf(text.charAt(0));
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CharacterEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CharacterEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ClassEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ClassEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ClassEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ClassEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,50 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link Character} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class ClassEditor extends AbstractPropertyEditor {
+    @Override
+    @SuppressWarnings("unchecked")
+    protected String toText(Object value) {
+        return ((Class) value).getName();
+    }
+
+    @Override
+    protected Object toValue(String text) throws IllegalArgumentException {
+        try {
+            return Class.forName(text);
+        } catch (ClassNotFoundException e) {
+            try {
+                return getClass().getClassLoader().loadClass(text);
+            } catch (ClassNotFoundException e1) {
+                throw new IllegalArgumentException("Failed to load the class: " + text);
+            }
+        }
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ClassEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ClassEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CollectionEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CollectionEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CollectionEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CollectionEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,140 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link Collection} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class CollectionEditor extends AbstractPropertyEditor {
+    static final Pattern ELEMENT = Pattern.compile(
+            "([,\\s]+)|" + // Delimiter
+            "(?<=\")((?:\\\\\"|\\\\'|\\\\\\\\|\\\\ |[^\"])*)(?=\")|" +
+            "(?<=')((?:\\\\\"|\\\\'|\\\\\\\\|\\\\ |[^'])*)(?=')|" +
+            "((?:[^\\\\\\s'\",]|\\\\ |\\\\\"|\\\\')+)");
+    
+    private final Class<?> elementType;
+    
+    public CollectionEditor(Class<?> elementType) {
+        if (elementType == null) {
+            throw new NullPointerException("elementType");
+        }
+        
+        this.elementType = elementType;
+        getElementEditor();
+        setTrimText(false);
+    }
+
+    private PropertyEditor getElementEditor() {
+        PropertyEditor e = PropertyEditorFactory.getInstance(elementType);
+        if (e == null) {
+            throw new IllegalArgumentException(
+                    "No " + PropertyEditor.class.getSimpleName() + 
+                    " found for " + elementType.getSimpleName() + '.');
+        }
+        return e;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    protected final String toText(Object value) {
+        StringBuilder buf = new StringBuilder();
+        for (Object v: (Collection) value) {
+            if (v == null) {
+                v = defaultElement();
+            }
+            
+            PropertyEditor e = PropertyEditorFactory.getInstance(v);
+            if (e == null) {
+                throw new IllegalArgumentException(
+                        "No " + PropertyEditor.class.getSimpleName() + 
+                        " found for " + v.getClass().getSimpleName() + '.');
+            }            
+            e.setValue(v);
+            // TODO normalize.
+            String s = e.getAsText();
+            buf.append(s);
+            buf.append(", ");
+        }
+        
+        // Remove the last delimiter.
+        if (buf.length() >= 2) {
+            buf.setLength(buf.length() - 2);
+        }
+        return buf.toString();
+    }
+
+    @Override
+    protected final Object toValue(String text) throws IllegalArgumentException {
+        PropertyEditor e = getElementEditor();
+        Collection<Object> answer = newCollection();
+        Matcher m = ELEMENT.matcher(text);
+        boolean matchedDelimiter = true;
+
+        while (m.find()) {
+            if (m.group(1) != null) {
+                matchedDelimiter = true;
+                continue;
+            }
+            
+            if (!matchedDelimiter) {
+                throw new IllegalArgumentException("No delimiter between elements: " + text);
+            }
+
+            // TODO escape here.
+            e.setAsText(m.group());
+            answer.add(e.getValue());
+            
+            matchedDelimiter = false;
+            if (m.group(2) != null || m.group(3) != null) {
+                // Skip the last '"'.
+                m.region(m.end() + 1, m.regionEnd());
+            }
+        }
+        
+        return answer;
+    }
+    
+    protected Collection<Object> newCollection() {
+        return new ArrayList<Object>();
+    }
+    
+    protected Object defaultElement() {
+        PropertyEditor e = PropertyEditorFactory.getInstance(elementType);
+        if (e == null) {
+            return null;
+        }
+        
+        if (e instanceof AbstractPropertyEditor) {
+            return ((AbstractPropertyEditor) e).defaultValue();
+        }
+
+        return null;
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CollectionEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/CollectionEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DateEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DateEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DateEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DateEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,86 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.regex.Pattern;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link Date} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class DateEditor extends AbstractPropertyEditor {
+    private static final Pattern MILLIS = Pattern.compile("[0-9][0-9]*");
+    
+    private final DateFormat[] formats = new DateFormat[] {
+            new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH),
+            new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", Locale.ENGLISH),
+            new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH),
+            new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH),
+            new SimpleDateFormat("yyyy-MM", Locale.ENGLISH),
+            new SimpleDateFormat("yyyy", Locale.ENGLISH),
+    };
+            
+    public DateEditor() {
+        for (DateFormat f: formats) {
+            f.setLenient(true);
+        }
+    }
+
+    @Override
+    protected String toText(Object value) {
+        if (value instanceof Number) {
+            long time = ((Number) value).longValue();
+            if (time <= 0) {
+                return null;
+            }
+            value = new Date(time);
+        }
+        return formats[0].format((Date) value);
+    }
+
+    @Override
+    protected Object toValue(String text) throws IllegalArgumentException {
+        if (MILLIS.matcher(text).matches()) {
+            long time = Long.parseLong(text);
+            if (time <= 0) {
+                return null;
+            }
+            return new Date(time);
+        }
+        
+        for (DateFormat f: formats) {
+            try {
+                return f.parse(text);
+            } catch (ParseException e) {
+            }
+        }
+        
+        throw new IllegalArgumentException("Wrong date: " + text);
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DateEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DateEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DoubleEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DoubleEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DoubleEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DoubleEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * an {@link Double} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class DoubleEditor extends NumberEditor {
+    @Override
+    protected Object toValue(String text, int radix) {
+        if (radix != 10) {
+            return Double.valueOf(String.valueOf(Long.parseLong(text, radix)));
+        }
+        return Double.parseDouble(text);
+    }
+
+    @Override
+    protected Object defaultValue() {
+        return Double.valueOf(0f);
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DoubleEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/DoubleEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/EnumEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/EnumEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/EnumEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/EnumEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,76 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+import java.util.EnumSet;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * an {@link Enum} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+@SuppressWarnings("unchecked")
+public class EnumEditor extends AbstractPropertyEditor {
+    private static final Pattern ORDINAL = Pattern.compile("[0-9]+");
+    
+    private final Class enumType;
+    private final Set<Enum> enums;
+
+    public EnumEditor(Class enumType) {
+        if (enumType == null) {
+            throw new NullPointerException("enumType");
+        }
+        
+        this.enumType = enumType;
+        this.enums = EnumSet.allOf(enumType);
+    }
+
+    @Override
+    protected String toText(Object value) {
+        return value.toString();
+    }
+
+    @Override
+    protected Object toValue(String text) throws IllegalArgumentException {
+        if (ORDINAL.matcher(text).matches()) {
+            int ordinal = Integer.parseInt(text);
+            for (Enum e: enums) {
+                if (e.ordinal() == ordinal) {
+                    return e;
+                }
+            }
+            
+            throw new IllegalArgumentException("wrong ordinal: " + ordinal);
+        }
+        
+        for (Enum e: enums) {
+            if (text.equalsIgnoreCase(e.toString())) {
+                return e;
+            }
+        }
+        
+        return Enum.valueOf(enumType, text);
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/EnumEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/EnumEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FileEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FileEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FileEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FileEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+import java.io.File;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link File} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class FileEditor extends AbstractPropertyEditor {
+
+    @Override
+    protected String toText(Object value) {
+        return ((File) value).getPath();
+    }
+
+    @Override
+    protected Object toValue(String text) throws IllegalArgumentException {
+        return new File(text);
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FileEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FileEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FloatEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FloatEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FloatEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FloatEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * an {@link Float} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class FloatEditor extends NumberEditor {
+    @Override
+    protected Object toValue(String text, int radix) {
+        if (radix != 10) {
+            return Float.valueOf(String.valueOf(Long.parseLong(text, radix)));
+        }
+        return Float.parseFloat(text);
+    }
+
+    @Override
+    protected Object defaultValue() {
+        return Float.valueOf(0f);
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FloatEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/FloatEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/InetAddressEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/InetAddressEditor.java?rev=601229&r1=601228&r2=601229&view=diff
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/InetAddressEditor.java (original)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/InetAddressEditor.java Tue Dec  4 23:13:18 2007
@@ -24,7 +24,7 @@
 import java.net.UnknownHostException;
 
 /**
- * Java Bean {@link PropertyEditor} which converts a {@link String} into a
+ * A {@link PropertyEditor} which converts a {@link String} into an
  * {@link InetAddress}.
  * This editor simply calls {@link InetAddress#getByName(java.lang.String)}
  * when converting from a {@link String}, and {@link InetAddress#getHostAddress()}
@@ -38,17 +38,40 @@
 public class InetAddressEditor extends AbstractPropertyEditor {
     @Override
     protected String toText(Object value) {
-        return ((InetAddress) value).getHostAddress();
+        String hostname = ((InetAddress) value).getHostAddress();
+        if (hostname.equals("0:0:0:0:0:0:0:0") || hostname.equals("0.0.0.0") ||
+                hostname.equals("00:00:00:00:00:00:00:00")) {
+            hostname = "*";
+        }
+        return hostname;
     }
 
     @Override
     protected Object toValue(String text) throws IllegalArgumentException {
+        if (text.isEmpty() || text.equals("*")) {
+            return defaultValue();
+        }
+
         try {
             return InetAddress.getByName(text);
         } catch (UnknownHostException uhe) {
             IllegalArgumentException iae = new IllegalArgumentException();
             iae.initCause(uhe);
             throw iae;
+        }
+    }
+
+    @Override
+    protected String defaultText() {
+        return "*";
+    }
+
+    @Override
+    protected Object defaultValue() {
+        try {
+            return InetAddress.getByName("0.0.0.0");
+        } catch (UnknownHostException e) {
+            throw new InternalError();
         }
     }
 }

Modified: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/InetSocketAddressEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/InetSocketAddressEditor.java?rev=601229&r1=601228&r2=601229&view=diff
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/InetSocketAddressEditor.java (original)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/InetSocketAddressEditor.java Tue Dec  4 23:13:18 2007
@@ -23,7 +23,7 @@
 import java.net.InetSocketAddress;
 
 /**
- * Java Bean {@link PropertyEditor} which converts a {@link String} into an
+ * A {@link PropertyEditor} which converts a {@link String} into an
  * {@link InetSocketAddress}. Valid values include a hostname or IP
  * address and a port number separated by a ':'. If the hostname or IP address
  * is omitted the wildcard address will be used. E.g.:
@@ -56,7 +56,10 @@
 
     @Override
     protected Object toValue(String text) throws IllegalArgumentException {
-        text = text.trim();
+        if (text.isEmpty()) {
+            return defaultValue();
+        }
+
         int colonIndex = text.lastIndexOf(":");
         if (colonIndex > 0) {
             String host = text.substring(0, colonIndex);
@@ -68,6 +71,16 @@
 
         int port = parsePort(text.substring(colonIndex + 1));
         return new InetSocketAddress(port);
+    }
+
+    @Override
+    protected String defaultText() {
+        return "*:0";
+    }
+
+    @Override
+    protected Object defaultValue() {
+        return new InetSocketAddress(0);
     }
 
     private int parsePort(String s) {

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/IntegerEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/IntegerEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/IntegerEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/IntegerEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * an {@link Integer} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class IntegerEditor extends NumberEditor {
+    @Override
+    protected Object toValue(String text, int radix) {
+        return Integer.parseInt(text, radix);
+    }
+
+    @Override
+    protected Object defaultValue() {
+        return Integer.valueOf(0);
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/IntegerEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/IntegerEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ListEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ListEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ListEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ListEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link List} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class ListEditor extends CollectionEditor {
+
+    public ListEditor(Class<?> elementType) {
+        super(elementType);
+    }
+
+    @Override
+    protected Collection<Object> newCollection() {
+        return new ArrayList<Object>();
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ListEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ListEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/LongEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/LongEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/LongEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/LongEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link Long} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class LongEditor extends NumberEditor {
+    @Override
+    protected Object toValue(String text, int radix) {
+        return Long.parseLong(text, radix);
+    }
+
+    @Override
+    protected Object defaultValue() {
+        return Long.valueOf(0);
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/LongEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/LongEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/MapEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/MapEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/MapEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/MapEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,197 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link Collection} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class MapEditor extends AbstractPropertyEditor {
+    static final Pattern ELEMENT = Pattern.compile(
+            "([,\\s]+)|" + // Entry delimiter
+            "(\\s*=\\s*)|" + // Key-Value delimiter
+            "(?<=\")((?:\\\\\"|\\\\'|\\\\\\\\|\\\\ |[^\"])*)(?=\")|" +
+            "(?<=')((?:\\\\\"|\\\\'|\\\\\\\\|\\\\ |[^'])*)(?=')|" +
+            "((?:[^\\\\\\s'\",]|\\\\ |\\\\\"|\\\\')+)");
+    
+    private final Class<?> keyType;
+    private final Class<?> valueType;
+    
+    public MapEditor(Class<?> keyType, Class<?> valueType) {
+        if (keyType == null) {
+            throw new NullPointerException("keyType");
+        }
+        if (valueType == null) {
+            throw new NullPointerException("valueType");
+        }
+        this.keyType = keyType;
+        this.valueType = valueType;
+        getKeyEditor();
+        getValueEditor();
+        setTrimText(false);
+    }
+
+    private PropertyEditor getKeyEditor() {
+        PropertyEditor e = PropertyEditorFactory.getInstance(keyType);
+        if (e == null) {
+            throw new IllegalArgumentException(
+                    "No key " + PropertyEditor.class.getSimpleName() + 
+                    " found for " + keyType.getSimpleName() + '.');
+        }
+        return e;
+    }
+
+    private PropertyEditor getValueEditor() {
+        PropertyEditor e = PropertyEditorFactory.getInstance(valueType);
+        if (e == null) {
+            throw new IllegalArgumentException(
+                    "No value " + PropertyEditor.class.getSimpleName() + 
+                    " found for " + valueType.getSimpleName() + '.');
+        }
+        return e;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    protected final String toText(Object value) {
+        StringBuilder buf = new StringBuilder();
+        for (Object o: ((Map) value).entrySet()) {
+            Map.Entry entry = (Map.Entry) o;
+            Object ekey = entry.getKey();
+            Object evalue = entry.getValue();
+            
+            PropertyEditor ekeyEditor = PropertyEditorFactory.getInstance(ekey);
+            if (ekeyEditor == null) {
+                throw new IllegalArgumentException(
+                        "No key " + PropertyEditor.class.getSimpleName() + 
+                        " found for " + ekey.getClass().getSimpleName() + '.');
+            }
+            ekeyEditor.setValue(ekey);
+            
+            PropertyEditor evalueEditor = PropertyEditorFactory.getInstance(evalue);
+            if (evalueEditor == null) {
+                throw new IllegalArgumentException(
+                        "No value " + PropertyEditor.class.getSimpleName() + 
+                        " found for " + evalue.getClass().getSimpleName() + '.');
+            }
+            ekeyEditor.setValue(ekey);
+            evalueEditor.setValue(evalue);
+            
+            // TODO normalize.
+            String keyString = ekeyEditor.getAsText();
+            String valueString = evalueEditor.getAsText();
+            buf.append(keyString);
+            buf.append(" = ");
+            buf.append(valueString);
+            buf.append(", ");
+        }
+        
+        // Remove the last delimiter.
+        if (buf.length() >= 2) {
+            buf.setLength(buf.length() - 2);
+        }
+        return buf.toString();
+    }
+
+    @Override
+    protected final Object toValue(String text) throws IllegalArgumentException {
+        PropertyEditor keyEditor = getKeyEditor();
+        PropertyEditor valueEditor = getValueEditor();
+        Map<Object, Object> answer = newMap();
+        Matcher m = ELEMENT.matcher(text);
+        TokenType lastTokenType = TokenType.ENTRY_DELIM;
+        Object key = null;
+        Object value = null;
+
+        while (m.find()) {
+            if (m.group(1) != null) {
+                switch (lastTokenType) {
+                case VALUE: case ENTRY_DELIM:
+                    break;
+                default:
+                    throw new IllegalArgumentException(
+                            "Unexpected entry delimiter: " + text);
+                }
+                
+                lastTokenType = TokenType.ENTRY_DELIM;
+                continue;
+            }
+            
+            if (m.group(2) != null) {
+                if (lastTokenType != TokenType.KEY) {
+                    throw new IllegalArgumentException(
+                            "Unexpected key-value delimiter: " + text);
+                }
+                
+                lastTokenType = TokenType.KEY_VALUE_DELIM;
+                continue;
+            }
+            
+            
+            // TODO escape here.
+            String region = m.group();
+
+            if (m.group(3) != null || m.group(4) != null) {
+                // Skip the last '"'.
+                m.region(m.end() + 1, m.regionEnd());
+            }
+            
+            switch (lastTokenType) {
+            case ENTRY_DELIM:
+                keyEditor.setAsText(region);
+                key = keyEditor.getValue();
+                lastTokenType = TokenType.KEY;
+                break;
+            case KEY_VALUE_DELIM:
+                valueEditor.setAsText(region);
+                value = valueEditor.getValue();
+                lastTokenType = TokenType.VALUE;
+                answer.put(key, value);
+                break;
+            case KEY: case VALUE:
+                throw new IllegalArgumentException(
+                        "Unexpected key or value: " + text);
+            }
+        }
+        
+        return answer;
+    }
+    
+    protected Map<Object, Object> newMap() {
+        return new LinkedHashMap<Object, Object>();
+    }
+    
+    private static enum TokenType {
+        ENTRY_DELIM,
+        KEY_VALUE_DELIM,
+        KEY,
+        VALUE,
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/MapEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/MapEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NullEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NullEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NullEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NullEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,46 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+
+/**
+ * A dummy {@link PropertyEditor} for <tt>null</tt>.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class NullEditor extends AbstractPropertyEditor {
+    @Override
+    protected String toText(Object value) {
+        if (String.valueOf(value).equalsIgnoreCase("null")) {
+            return null;
+        }
+        throw new IllegalArgumentException("value is not null or 'null'.");
+    }
+
+    @Override
+    protected Object toValue(String text) throws IllegalArgumentException {
+        if (text.equalsIgnoreCase("null")) {
+            return null;
+        }
+        throw new IllegalArgumentException("text is not null or 'null'.");
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NullEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NullEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NumberEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NumberEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NumberEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NumberEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,71 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+import java.util.regex.Pattern;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link Number} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class NumberEditor extends AbstractPropertyEditor {
+    private static final Pattern DECIMAL = Pattern.compile(
+            "[-+]?[0-9]*\\.?[0-9]*(?:[Ee][-+]?[0-9]+)?");
+    private static final Pattern HEXADECIMAL = Pattern.compile("0x[0-9a-fA-F]+");
+    private static final Pattern OCTET = Pattern.compile("0[0-9][0-9]*");
+    
+    @Override
+    protected final String toText(Object value) {
+        return value.toString();
+    }
+
+    @Override
+    protected final Object toValue(String text) throws IllegalArgumentException {
+        if (text.isEmpty()) {
+            return defaultValue();
+        }
+        
+        if (HEXADECIMAL.matcher(text).matches()) {
+            return toValue(text.substring(2), 16);
+        }
+        
+        if (OCTET.matcher(text).matches()) {
+            return toValue(text, 8);
+        }
+        
+        if (DECIMAL.matcher(text).matches()) {
+            return toValue(text, 10);
+        }
+        
+        throw new NumberFormatException("Not a number: " + text);
+    }
+    
+    protected Object toValue(String text, int radix) {
+        return Integer.parseInt(text, radix);
+    }
+    
+    protected Object defaultValue() {
+        return Integer.valueOf(0);
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NumberEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/NumberEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PatternEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PatternEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PatternEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PatternEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+import java.util.regex.Pattern;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link Pattern} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class PatternEditor extends AbstractPropertyEditor {
+
+    @Override
+    protected String toText(Object value) {
+        return ((Pattern) value).pattern();
+    }
+
+    @Override
+    protected Object toValue(String text) throws IllegalArgumentException {
+        return Pattern.compile(text);
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PatternEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PatternEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PropertiesEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PropertiesEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PropertiesEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PropertiesEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link Properties} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class PropertiesEditor extends MapEditor {
+    
+    public PropertiesEditor() {
+        super(String.class, String.class);
+        setTrimText(false);
+    }
+
+    @Override
+    protected Map<Object, Object> newMap() {
+        return new Properties();
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PropertiesEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PropertiesEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PropertyEditorFactory.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PropertyEditorFactory.java?rev=601229&r1=601228&r2=601229&view=diff
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PropertyEditorFactory.java (original)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/PropertyEditorFactory.java Tue Dec  4 23:13:18 2007
@@ -20,6 +20,12 @@
 package org.apache.mina.integration.beans;
 
 import java.beans.PropertyEditor;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.sun.xml.internal.fastinfoset.sax.Properties;
 
 /**
  * A factory that creates a new {@link PropertyEditor} which is appropriate for
@@ -29,26 +35,128 @@
  * @version $Rev$, $Date$
  */
 public final class PropertyEditorFactory {
+    @SuppressWarnings("unchecked")
     public static PropertyEditor getInstance(Object object) {
         if (object == null) {
-            throw new NullPointerException("object");
+            return new NullEditor();
+        }
+        
+        if (object instanceof Collection) {
+            Class<?> elementType = null;
+            for (Object e: (Collection) object) {
+                if (e != null) {
+                    elementType = e.getClass();
+                    break;
+                }
+            }
+            
+            if (elementType != null) {
+                if (object instanceof Set) {
+                    return new SetEditor(elementType);
+                }
+                
+                if (object instanceof List) {
+                    return new ListEditor(elementType);
+                }
+                
+                return new CollectionEditor(elementType);
+            }
+        }
+        
+        if (object instanceof Map) {
+            Class<?> keyType = null;
+            Class<?> valueType = null;
+            for (Object entry: ((Map) object).entrySet()) {
+                Map.Entry e = (Map.Entry) entry;
+                if (e.getKey() != null && e.getValue() != null) {
+                    keyType = e.getKey().getClass();
+                    valueType = e.getValue().getClass();
+                    break;
+                }
+            }
+            
+            if (keyType != null && valueType != null) {
+                return new MapEditor(keyType, valueType);
+            }
         }
         
         return getInstance(object.getClass());
     }
     
+    // parent type / property name / property type
     public static PropertyEditor getInstance(Class<?> type) {
         if (type == null) {
             throw new NullPointerException("type");
         }
         
+        if (type.isEnum()) {
+            return new EnumEditor(type);
+        }
+        
+        if (type.isArray()) {
+            return new ArrayEditor(type.getComponentType());
+        }
+        
+        if (Collection.class.isAssignableFrom(type)) {
+            if (Set.class.isAssignableFrom(type)) {
+                return new SetEditor(String.class);
+            }
+            
+            if (List.class.isAssignableFrom(type)) {
+                return new ListEditor(String.class);
+            }
+            
+            return new CollectionEditor(String.class);
+        }
+        
+        if (Map.class.isAssignableFrom(type)) {
+            return new MapEditor(String.class, String.class);
+        }
+        
+        if (Properties.class.isAssignableFrom(type)) {
+            return new PropertiesEditor();
+        }
+        
+        type = filterPrimitiveType(type);
+
         try {
-            return (PropertyEditor) PropertyEditorFactory.class.getClassLoader().loadClass(
-                    PropertyEditorFactory.class.getPackage().getName() + '.' +
-                    type.getSimpleName() + "Editor").newInstance();
+            return (PropertyEditor)
+                    PropertyEditorFactory.class.getClassLoader().loadClass(
+                            PropertyEditorFactory.class.getPackage().getName() +
+                            '.' + type.getSimpleName() + "Editor").newInstance();
         } catch (Exception e) {
             return null;
         }
+    }
+    
+    private static Class<?> filterPrimitiveType(Class<?> type) {
+        if (type.isPrimitive()) {
+            if (type == boolean.class) {
+                type = Boolean.class;
+            }
+            if (type == byte.class) {
+                type = Byte.class;
+            }
+            if (type == char.class) {
+                type = Character.class;
+            }
+            if (type == double.class) {
+                type = Double.class;
+            }
+            if (type == float.class) {
+                type = Float.class;
+            }
+            if (type == int.class) {
+                type = Integer.class;
+            }
+            if (type == long.class) {
+                type = Long.class;
+            }
+            if (type == short.class) {
+                type = Short.class;
+            }
+        }
+        return type;
     }
     
     private PropertyEditorFactory() {

Modified: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/SerialAddressEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/SerialAddressEditor.java?rev=601229&r1=601228&r2=601229&view=diff
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/SerialAddressEditor.java (original)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/SerialAddressEditor.java Tue Dec  4 23:13:18 2007
@@ -28,7 +28,7 @@
 import org.apache.mina.transport.serial.SerialAddress.StopBits;
 
 /**
- * Java Bean {@link PropertyEditor} which converts a {@link String} into a
+ * A {@link PropertyEditor} which converts a {@link String} into a
  * {@link SerialAddress} and vice versa.  Valid values specify 6 address
  * components separated by colon (e.g. <tt>COM1:9600:7:1:even:rtscts-in</tt>);
  * port name, bauds, data bits, stop bits, parity and flow control respectively.

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/SetEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/SetEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/SetEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/SetEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link Set} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class SetEditor extends CollectionEditor {
+
+    public SetEditor(Class<?> elementType) {
+        super(elementType);
+    }
+
+    @Override
+    protected Collection<Object> newCollection() {
+        return new LinkedHashSet<Object>();
+    }
+}

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/SetEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/SetEditor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ShortEditor.java
URL: http://svn.apache.org/viewvc/mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ShortEditor.java?rev=601229&view=auto
==============================================================================
--- mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ShortEditor.java (added)
+++ mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/ShortEditor.java Tue Dec  4 23:13:18 2007
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.integration.beans;
+
+import java.beans.PropertyEditor;
+
+/**
+ * A {@link PropertyEditor} which converts a {@link String} into
+ * a {@link Short} and vice versa.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class ShortEditor extends NumberEditor {
+    @Override
+    protected Object toValue(String text, int radix) {
+        return Short.parseShort(text, radix);
+    }
+
+    @Override
+    protected Object defaultValue() {
+        return Short.valueOf((short) 0);
+    }
+}