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="http://mina.apache.org">Apache MINA Project</a>
42   */
43  public class MinaPropertyEditorRegistrar implements PropertyEditorRegistrar
44  {
45      /**
46       * Registers custom {@link PropertyEditor}s in the MINA Integration Beans
47       * module.
48       * 
49       * Note: I did not know just how useful the rest of the property editors 
50       * were or if they were redundant and replicated existing functionality of
51       * default editors packaged into Spring.  So presently we're only 
52       * registering editors for the following classes which are not found in
53       * Spring:
54       * 
55       * <ul>
56       *   <li>java.net.InetAddress</li>
57       *   <li>java.net.InetSocketAddress</li>
58       *   <li>org.apache.mina.core.session.TrafficMask</li>
59       *   <li>org.apache.mina.integration.beans.VmPipeAddressEditor</li>
60       * </ul>
61       * 
62       * @see org.springframework.beans.PropertyEditorRegistrar#
63       * registerCustomEditors(org.springframework.beans.PropertyEditorRegistry)
64       */
65      public void registerCustomEditors( PropertyEditorRegistry registry ) 
66      {
67          // it is expected that new PropertyEditor instances are created
68          registry.registerCustomEditor( InetAddress.class, new InetAddressEditor() );
69          registry.registerCustomEditor( InetSocketAddress.class, new InetSocketAddressEditor() );
70          registry.registerCustomEditor( SocketAddress.class, new InetSocketAddressEditor() );
71          registry.registerCustomEditor( VmPipeAddress.class, new VmPipeAddressEditor() );
72          // registry.registerCustomEditor( Boolean.class, new BooleanEditor() );
73      }
74  }