View Javadoc

1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
18   *
19   */
20  package org.apache.mina.integration.xbean;
21  
22  
23  import java.beans.PropertyEditor;
24  import java.net.InetAddress;
25  import java.net.InetSocketAddress;
26  import java.net.SocketAddress;
27  
28  import org.apache.mina.integration.beans.InetAddressEditor;
29  import org.apache.mina.integration.beans.InetSocketAddressEditor;
30  import org.apache.mina.integration.beans.VmPipeAddressEditor;
31  import org.apache.mina.transport.vmpipe.VmPipeAddress;
32  import org.springframework.beans.PropertyEditorRegistrar;
33  import org.springframework.beans.PropertyEditorRegistry;
34  
35  
36  /**
37   * A custom Spring {@link PropertyEditorRegistrar} implementation which 
38   * registers by default all the {@link PropertyEditor} implementations in the 
39   * MINA Integration Beans module.
40   *
41   * @author <a href="mailto:dev@mina.apache.org">Apache MINA Project</a>
42   * @version $Rev$, $Date$
43   */
44  public class MinaPropertyEditorRegistrar implements PropertyEditorRegistrar
45  {
46      /**
47       * Registers custom {@link PropertyEditor}s in the MINA Integration Beans
48       * module.
49       * 
50       * Note: I did not know just how useful the rest of the property editors 
51       * were or if they were redundant and replicated existing functionality of
52       * default editors packaged into Spring.  So presently we're only 
53       * registering editors for the following classes which are not found in
54       * Spring:
55       * 
56       * <ul>
57       *   <li>java.net.InetAddress</li>
58       *   <li>java.net.InetSocketAddress</li>
59       *   <li>org.apache.mina.core.session.TrafficMask</li>
60       *   <li>org.apache.mina.integration.beans.VmPipeAddressEditor</li>
61       * </ul>
62       * 
63       * @see org.springframework.beans.PropertyEditorRegistrar#
64       * registerCustomEditors(org.springframework.beans.PropertyEditorRegistry)
65       */
66      public void registerCustomEditors( PropertyEditorRegistry registry ) 
67      {
68          // it is expected that new PropertyEditor instances are created
69          registry.registerCustomEditor( InetAddress.class, new InetAddressEditor() );
70          registry.registerCustomEditor( InetSocketAddress.class, new InetSocketAddressEditor() );
71          registry.registerCustomEditor( SocketAddress.class, new InetSocketAddressEditor() );
72          registry.registerCustomEditor( VmPipeAddress.class, new VmPipeAddressEditor() );
73          // registry.registerCustomEditor( Boolean.class, new BooleanEditor() );
74      }
75  }