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