001    /*
002     * Copyright 2011 The Kuali Foundation.
003     * 
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     * http://www.opensource.org/licenses/ecl2.php
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.ole.web;
017    
018    import javax.servlet.ServletContextEvent;
019    import javax.servlet.ServletContextListener;
020    
021    import org.kuali.ole.docstore.process.DocStoreCamelContext;
022    import org.kuali.ole.docstore.utility.DocStoreSettingsUtil;
023    import org.kuali.ole.service.DocumentStoreService;
024    
025    /**
026     * Created by IntelliJ IDEA.
027     * User: pvsubrah
028     * Date: 11/3/11
029     * Time: 1:24 PM
030     * To change this template use File | Settings | File Templates.
031     */
032    public class DocumentStoreContextListner implements ServletContextListener {
033    
034        @Override
035        public void contextInitialized(ServletContextEvent sce) {
036            try {
037                DocStoreSettingsUtil.getInstance().copyResources();
038            } catch (Exception e) {
039                e.printStackTrace();
040            }
041            DocStoreCamelContext.getInstance();
042        }
043    
044        @Override
045        public void contextDestroyed(ServletContextEvent sce) {
046    
047            DocStoreCamelContext.getInstance().stop();
048            new DocumentStoreService().shutdownRepository();
049        }
050    }