/** * Create a new cache. */ public ObjectCache(String filename, boolean persist_always, boolean persist_single, int max) { if(!persist_single && filename==null) throw new IllegalArgumentException("Filename must not null when saving to single file."); this.persist_always = persist_always; this.persist_single = persist_single; this.filename = filename; //this.cache = SCollection.createHashMap(); this.cache = SCollection.createLRU(max); }
/** * Init the transport. * @param platform The platform. * @param settings The settings. */ public TCPTransport(final IServiceProvider container, int port, final boolean async) { this.logger = Logger.getLogger(AbstractComponentAdapter.getLoggerName(container.getId())+".TCPTransport"); this.container = container; this.async = async; this.port = port; // Set up sending side. this.connections = SCollection.createLRU(MAX_CONNECTIONS); ((LRU<String, Object>)this.connections).setCleaner(new ILRUEntryCleaner<String, Object>() { public void cleanupEldestEntry(Entry<String, Object> eldest) { Object con = eldest.getValue(); if(con instanceof TCPOutputConnection) { ((TCPOutputConnection)con).close(); } } }); this.connections = Collections.synchronizedMap(this.connections); }
/** * Init the transport. * @param component The platform component. * @param port The port. * @param async true for async mode. */ public TCPTransport(final IInternalAccess component, int port, final boolean async) { this.logger = Logger.getLogger(PlatformComponent.getLoggerName(component.getComponentIdentifier())+".TCPTransport"); this.component = component; this.async = async; this.port = port; // Set up sending side. this.connections = SCollection.createLRU(MAX_CONNECTIONS); ((LRU<String, Object>)this.connections).setCleaner(new ILRUEntryCleaner<String, Object>() { public void cleanupEldestEntry(Entry<String, Object> eldest) { Object con = eldest.getValue(); if(con instanceof TCPOutputConnection) { ((TCPOutputConnection)con).close(); } } }); this.connections = Collections.synchronizedMap(this.connections); }
/** * Init the transport. * @param platform The platform. * @param settings The settings. */ public TCPTransport(final IServiceProvider container, int port, final boolean async) { this.logger = Logger.getLogger(AbstractComponentAdapter.getLoggerName(container.getId())+".TCPTransport"); this.container = container; this.async = async; this.port = port; // Set up sending side. this.connections = SCollection.createLRU(MAX_CONNECTIONS); ((LRU<String, Object>)this.connections).setCleaner(new ILRUEntryCleaner<String, Object>() { public void cleanupEldestEntry(Entry<String, Object> eldest) { Object con = eldest.getValue(); if(con instanceof TCPOutputConnection) { ((TCPOutputConnection)con).close(); } } }); this.connections = Collections.synchronizedMap(this.connections); }