+++ /dev/null
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wamblee.crawler.kiss.servlet;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-import org.wamblee.crawler.kiss.scheduling.CrawlerScheduler;
-import org.wamblee.general.BeanKernel;
-
-/**
- * The mechanism for kick starting the scheduling of the KiSS crawler.
- */
-public class Application implements ServletContextListener {
-
- /**
- * Constructs the listener.
- *
- */
- public Application() {
- // Empty.
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
- */
- public void contextInitialized(ServletContextEvent aEvent) {
- aEvent.getServletContext().log("KiSS Crawler initializing");
- try {
- getScheduler().initialize();
- } catch (Exception e) {
- aEvent.getServletContext().log("Error scheduling job", e);
- return;
- }
- aEvent.getServletContext().log("KiSS Crawler initialized");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
- */
- public void contextDestroyed(ServletContextEvent aEvent) {
- aEvent.getServletContext().log("KiSS Crawler shutting down");
- try {
- getScheduler().shutdown();
- } catch (Exception e) {
- aEvent.getServletContext().log("Error scheduling job", e);
- return;
- }
- aEvent.getServletContext().log("KiSS Crawler shut down complete");
- }
-
- /**
- * Gets the scheduler from Spring.
- * @return Scheduler.
- */
- private CrawlerScheduler getScheduler() {
- return BeanKernel.getBeanFactory().find(CrawlerScheduler.class);
- }
-
- public static void main(String[] aArgs) throws Exception {
- Application application = new Application();
- application.getScheduler().initialize();
- }
-}