001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.helpers;
020
021import java.io.IOException;
022import java.net.MalformedURLException;
023import java.net.URL;
024
025import javax.servlet.http.HttpSessionBindingEvent;
026import javax.servlet.http.HttpSessionBindingListener;
027
028import lucee.runtime.type.Collection;
029import lucee.runtime.type.StructImpl;
030
031public final class HttpSessionBindingListenerStruct extends StructImpl implements HttpSessionBindingListener {
032    
033    private URL url;
034
035    /**
036     * Constructor of the class
037     * @param strUrl
038     * @throws MalformedURLException
039     */
040    public HttpSessionBindingListenerStruct(String strUrl) throws MalformedURLException {
041        this(new URL(strUrl));
042    }
043    
044    /**
045     * Constructor of the class
046     * @param url
047     */
048    public HttpSessionBindingListenerStruct(URL url) {
049        this.url=url;
050    }
051    
052    public void valueBound(HttpSessionBindingEvent event) {
053        //SystemOut.printDate("------------------------------- bound session -------------------------------");
054    }
055
056    public void valueUnbound(HttpSessionBindingEvent event) {
057        //SystemOut.printDate("------------------------------- unbound session -------------------------------");
058        try {
059            url.getContent();
060        } 
061        catch (IOException e) {}
062    }
063
064        @Override
065        public Collection duplicate(boolean deepCopy) {
066                HttpSessionBindingListenerStruct trg=new HttpSessionBindingListenerStruct(url);
067                copy(this, trg, deepCopy);
068                return trg;
069        }
070}