1 37 38 package net.sourceforge.cruisecontrol.distributed.util; 39 40 import java.rmi.RMISecurityManager ; 41 import java.util.ArrayList ; 42 import java.util.StringTokenizer ; 43 import java.util.List ; 44 45 import net.jini.core.entry.Entry; 46 import net.sourceforge.cruisecontrol.distributed.PropertyEntry; 47 48 import org.apache.log4j.Logger; 49 50 public final class ReggieUtil { 51 52 private ReggieUtil() { } 53 54 private static final Logger LOG = Logger.getLogger(ReggieUtil.class); 55 56 63 public static Entry[] convertStringEntries(final String searchString) { 64 searchString.replace(',', ';'); 65 final StringTokenizer tokenizer = new StringTokenizer (searchString.trim(), ";"); 66 final List entriesList = new ArrayList (); 67 while (tokenizer.hasMoreElements()) { 68 final String token = tokenizer.nextToken(); 69 final PropertyEntry entry = new PropertyEntry(); 70 entry.name = token.substring(0, token.indexOf("=")).trim(); 71 entry.value = token.substring(token.indexOf("=") + 1).trim(); 72 entriesList.add(entry); 73 } 74 75 LOG.debug("Entry List: " + entriesList); 76 77 final Entry[] arrEntries; 78 if (entriesList.size() == 0) { 79 arrEntries = null; 80 } else { 81 arrEntries = (Entry[]) entriesList.toArray(new Entry[entriesList.size()]); 82 } 83 return arrEntries; 84 } 85 86 89 public static void setupRMISecurityManager() { 90 final SecurityManager origSecurityManager = System.getSecurityManager(); 91 if (origSecurityManager == null) { 92 System.setSecurityManager(new RMISecurityManager ()); 93 } else if (origSecurityManager.getClass().getName().indexOf("JavaWebStart") > -1) { 94 } else if (!(origSecurityManager instanceof RMISecurityManager )) { 96 final String msg = "Unexpected Security Manager. origSecurityManager: " 97 + origSecurityManager; 98 LOG.error(msg); 99 throw new IllegalStateException (msg); 100 } 101 } 102 } 103 | Popular Tags |