1 20 package org.apache.mina.integration.spring; 21 22 import java.beans.PropertyEditorSupport ; 23 import java.net.SocketAddress ; 24 25 import org.apache.mina.transport.vmpipe.VmPipeAddress; 26 import org.springframework.util.Assert; 27 28 43 public class VmPipeAddressEditor extends PropertyEditorSupport { 44 public void setAsText(String text) throws IllegalArgumentException { 45 setValue(parseSocketAddress(text)); 46 } 47 48 private SocketAddress parseSocketAddress(String s) { 49 Assert.notNull(s, "null SocketAddress string"); 50 s = s.trim(); 51 if (s.startsWith(":")) { 52 s = s.substring(1); 53 } 54 try { 55 return new VmPipeAddress(Integer.parseInt(s.trim())); 56 } catch (NumberFormatException nfe) { 57 throw new IllegalArgumentException ("Illegal vm pipe address: " + s); 58 } 59 } 60 } 61 | Popular Tags |