All pastes #2048628 Raw Edit

ClientAccessTracker

public text v1 · immutable
#2048628 ·published 2011-04-20 13:01 UTC
rendered paste body
package com.raritan.ccsg.meetserv;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Inject;
import com.meetwise.serv.Disposable;
import com.meetwise.serv.console.Console;
import com.meetwise.serv.console.client.ClientAccessLog;
import com.meetwise.serv.console.client.ClientScoped;
import com.meetwise.serv.endpoint.EndpointList;

/**
 * 
 * @author Matthias Treydte <waldheinz at gmail.com>
 */
@ClientScoped
final class ClientAccessTracker implements ClientAccessLog,Disposable {

    private final static Logger LOG =
            LoggerFactory.getLogger(ClientAccessTracker.class);
    
   /* private final Console console;
    private final EndpointList endpoints;*/

    @Inject
    public ClientAccessTracker(/*Console console, EndpointList endpoints*/) {
        /*this.console = console;
        this.endpoints = endpoints;*/
    	System.out.println("Created...");
    }
    
    @Override
    public void clientAccess(String remoteAddr, AccessType type) {
    	System.out.println("Remote Addewss : " + remoteAddr + " : " + type);
        LOG.trace("{} access from {}", type, remoteAddr);
        
/*        final Endpoint e = endpoints.getEndpoint(console.getEndpointId());
        
        if (e instanceof RcCoreAdapter) {
            final RCCore core = ((RcCoreAdapter)e).getRcCore();
            
            // act as you like here
            
        } else {
            // either the endpoint was null or of a different kind
        }
*/    }
    
    @Override
    public void dispose() {
    	System.out.println("Dispose called..............");
    	
    }
    
}



Here is the Binding

  Multibinder<ClientAccessLog> clientTracker = 
            	Multibinder.newSetBinder(binder(), ClientAccessLog.class);
            clientTracker.addBinding().to(ClientAccessTracker.class);