Metodo mas eficiente

Boa noite!

Criei um metodo para armazenar Interface remotas e obte-las quando preciso, mas estou em duvida quando a eficiencia do mesmo( se vai ficar lento D+)… segue abaixo código, ainda não rodei,… preciso configurar o Ant.

import static br.com.gma.server.common.entity.CONSTANTES.*;
public class ClienteService implements RemoteCliente, CallBackServerInterface{

    private Generics generics;
    private Collection<Generics> clients;    
    private ClienteJpaController jpa;
    private Iterator its;
    
    public ClienteService(Factory em) throws RemoteException{
        super();
        jpa = new ClienteJpaController(em.getfactory());        
        clients = new HashSet<Generics>();        
    }
    
    @Override
    public void cadastrarCliente(Cliente c) throws RemoteException {
        try {
            its = clients.iterator();
            while(its.hasNext()){
                generics = (Generics) its.next();
                if((Long)generics.getId() == c.getSessaoId()){
                    if(generics.getInterface() instanceof RemoteExpInterface){ /* <-- por segurança */
                        ((RemoteExpInterface)generics.getInterface()).receiverMsgFromServer(
                                INFORMACAO, "Cliente: "+c.getNome_cliente()+" cadastrado com sucesso!");
                    }
                }
            }                
            jpa.incluir(c); /* Inclusão no banco de dados */
        } catch (Exception ex) {
            while(its.hasNext()){
                generics = (Generics) its.next();
                if((Long)generics.getId() == c.getSessaoId()){
                    if(generics.getInterface() instanceof RemoteExpInterface){ /* <-- por segurança */
                        ((RemoteExpInterface)generics.getInterface()).receiverMsgFromServer(
                                ERRO, "Shiiii, erro: "+ex.getMessage());
                    }
                }
            }
        }
    }
    @Override
    public void registerForCallbackExp(RemoteExpInterface obj, Long id) throws RemoteException {
        generics = new Generics(obj, id);
        clients.add(generics);
    }

     @Override
    public void unregisterForCallbackExp(RemoteExpInterface obj, Long id) throws RemoteException {
        its = clients.iterator();
            while(its.hasNext()){
                generics = (Generics) its.next();
                if((Long)generics.getId() == id){
                    clients.remove(generics);
                }
            } 
    }
public class Generics <T,N>{
    T remote;
    N id;
    public Generics(T remote,N id){
        this.remote = remote; // Interface extends Remote
        this.id = id; // Long
    }
    public T getInterface(){
        return remote;
    }
    public N getId(){
        return id;
    }
    public void setInterface(T remote){
        this.remote = remote;        
    }
    public void setId(N id){
        this.id = id;
    }
    
}

Toda vez q precisar enviar algo para os clientes(callback usando rmi) tenho que entrar no loop, que acredito não será maior que 10.
usando o metodo equals de arraylist consigo comparar InterfaceRemota?

Obrigado!

Cara, dá uma olhada na interface Map e na implementação HashMap:

http://docs.oracle.com/javase/6/docs/api/java/util/Map.html

com ela você mantém uma lista de pares chave-valor. Assim você pode obter um serviço diretamente através da Id, sem precisar ficar executando em um laço.

Outra coisa, eu realmente não entendi o porque dessa classe Generics, já que os métodos para registrar e remover recebem um tipo específico.

Veja se não ficou mais limpo:

import static br.com.gma.server.common.entity.CONSTANTES.*;
public class ClienteService implements RemoteCliente, CallBackServerInterface{

    private Map<Long, RemoteExpInterface> remoteById;    
    private ClienteJpaController jpa;
    private Iterator its;
    
    public ClienteService(Factory em) throws RemoteException{
        super();
        jpa = new ClienteJpaController(em.getfactory());        
        remoteById = new HashMap<>();        
    }
    
    @Override
    public void cadastrarCliente(Cliente c) throws RemoteException {
		RemoteExpInterface remoteInterface = remoteById.get(c.getSessaoId);
		
        try {
			remoteInterface.receiverMsgFromServer(INFORMACAO, "Cliente: "+c.getNome_cliente()+" cadastrado com sucesso!");                
            jpa.incluir(c); /* Inclusão no banco de dados */
        } catch (Exception ex) {
            remoteInterface.receiverMsgFromServer(ERRO, "Shiiii, erro: "+ex.getMessage());
        }
    }
	
    @Override
    public void registerForCallbackExp(RemoteExpInterface obj, Long id) throws RemoteException {
        remoteById.put(id, obj)
    }

     @Override
    public void unregisterForCallbackExp(Long id) throws RemoteException {
		remoteById.remove(id);
    }
}

Perfeito, era isso que precisava.
Ainda não tinha trabalhado com Generics(foi só uma class de memorização ^^).
E para arrays utilizava:

List<> a= new ArrayList<>()

Muito obrigado!!