001/*
002 * Stallion Core: A Modern Web Framework
003 *
004 * Copyright (C) 2015 - 2016 Stallion Software LLC.
005 *
006 * This program is free software: you can redistribute it and/or modify it under the terms of the
007 * GNU General Public License as published by the Free Software Foundation, either version 2 of
008 * the License, or (at your option) any later version. This program is distributed in the hope that
009 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
011 * License for more details. You should have received a copy of the GNU General Public License
012 * along with this program.  If not, see <http://www.gnu.org/licenses/gpl-2.0.html>.
013 *
014 *
015 *
016 */
017
018package io.stallion.plugins.javascript;
019
020import io.stallion.asyncTasks.AsyncTaskHandlerBase;
021import io.stallion.services.Log;
022
023import java.util.Collection;
024import java.util.HashMap;
025import java.util.Map;
026import java.util.Set;
027
028
029public abstract class JsAsyncTaskHandler extends AsyncTaskHandlerBase implements Map {
030    private Map map = new HashMap<>();
031
032    public abstract String getHandlerClassName();
033
034    public abstract void processData(Map data);
035
036    @Override
037    public void process() {
038        Log.info("call process(data) {0}", getInternalMap());
039        processData(getInternalMap());
040    }
041
042    @Override
043    public int size() {
044        return map.size();
045    }
046
047    @Override
048    public boolean isEmpty() {
049        return map.isEmpty();
050    }
051
052    @Override
053    public boolean containsKey(Object key) {
054        return map.containsKey(key);
055    }
056
057    @Override
058    public boolean containsValue(Object value) {
059        return map.containsValue(value);
060    }
061
062    @Override
063    public Object get(Object key) {
064        return map.get(key);
065    }
066
067    @Override
068    public Object put(Object key, Object value) {
069        Log.info("PUT VKEYVL {0} value={1}", key, value);
070        return map.put(key, value);
071    }
072
073    @Override
074    public Object remove(Object key) {
075        return map.remove(key);
076    }
077
078    @Override
079    public void putAll(Map m) {
080        map.putAll(m);
081    }
082
083    @Override
084    public void clear() {
085        map.clear();
086    }
087
088    @Override
089    public Set keySet() {
090        return map.keySet();
091    }
092
093    @Override
094    public Collection values() {
095        return map.values();
096    }
097
098    @Override
099    public Set<Entry> entrySet() {
100        return map.entrySet();
101    }
102
103    public Map getInternalMap() {
104        return map;
105    }
106
107}