All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.logicbus.backend.websocket.scanner.Sink Maven / Gradle / Ivy

There is a newer version: 1.6.17
Show newest version
package com.logicbus.backend.websocket.scanner;

import com.alogic.load.Scanner;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;
import com.logicbus.backend.websocket.WSEndpointInfo;
import com.logicbus.backend.websocket.WSEndpointScanner;

import java.util.ArrayList;
import java.util.List;

public class Sink extends Scanner.Sinkable implements WSEndpointScanner,Scanner.Listener {

    protected long ttl = 30 * 60 * 1000L;
    protected long lastScanTimestamp = 0;
    protected List objList = new ArrayList();

    @Override
    public void configure(Properties p){
        super.configure(p);
        ttl = PropertiesConstants.getLong(p,"ttl",ttl);
    }

    @Override
    public List getList() {
        long now = System.currentTimeMillis();
        if (now - lastScanTimestamp > ttl){
            scan(this);
        }
        return objList;
    }

    @Override
    public Object begin(String scannerId) {
        return this;
    }

    @Override
    public void found(Object cookie, WSEndpointInfo data) {
        objList.add(data);
    }

    @Override
    public void end(Object cookie, String scannerId) {

    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy