1 14 15 package org.quickserver.net.server.impl; 16 17 import java.io.*; 18 import java.util.*; 19 import java.util.logging.*; 20 import org.quickserver.util.pool.*; 21 import org.quickserver.net.server.*; 22 import java.util.regex.*; 23 24 29 public class SyncClientIdentifier extends BasicClientIdentifier { 30 private static final Logger logger = Logger.getLogger(SyncClientIdentifier.class.getName()); 31 32 public ClientHandler findFirstClientById(String id) { 33 ClientHandler foundClientHandler = null; 34 35 synchronized(getObjectToSynchronize()) { 36 Iterator iterator = findAllClient(); 37 while(iterator.hasNext()) { 38 foundClientHandler = checkClientId( 39 (ClientHandler) iterator.next(), id); 40 41 if(foundClientHandler!=null) break; 42 } } 44 return foundClientHandler; 45 } 46 47 public Iterator findAllClientById(String pattern) { 48 ArrayList list = new ArrayList(); 49 Pattern p = Pattern.compile(pattern); 50 ClientHandler foundClientHandler = null; 51 52 synchronized(getObjectToSynchronize()) { 53 Iterator iterator = findAllClient(); 54 55 while(iterator.hasNext()) { 56 foundClientHandler = checkClientId( 57 (ClientHandler) iterator.next(), p); 58 59 if(foundClientHandler!=null) 60 list.add(foundClientHandler); 61 } } 63 return list.iterator(); 64 } 65 66 public ClientHandler findClientByKey(String key) { 67 ClientHandler foundClientHandler = null; 68 69 synchronized(getObjectToSynchronize()) { 70 Iterator iterator = findAllClient(); 71 while(iterator.hasNext()) { 72 foundClientHandler = checkClientKey( 73 (ClientHandler) iterator.next(), key); 74 75 if(foundClientHandler!=null) break; 76 } } 78 return foundClientHandler; 79 } 80 81 public Iterator findAllClientByKey(String pattern) { 82 ArrayList list = new ArrayList(); 83 Pattern p = Pattern.compile(pattern); 84 ClientHandler foundClientHandler = null; 85 86 synchronized(getObjectToSynchronize()) { 87 Iterator iterator = findAllClient(); 88 while(iterator.hasNext()) { 89 foundClientHandler = checkClientKey( 90 (ClientHandler) iterator.next(), pattern); 91 92 if(foundClientHandler!=null) 93 list.add(foundClientHandler); 94 foundClientHandler = null; 95 } } 97 return list.iterator(); 98 } 99 } 100 | Popular Tags |