001: package org.methodize.nntprss;
002:
003: /* -----------------------------------------------------------
004: * nntp//rss - a bridge between the RSS world and NNTP clients
005: * Copyright (c) 2002, 2003 Jason Brome. All Rights Reserved.
006: *
007: * email: nntprss@methodize.org
008: * mail: Methodize Solutions
009: * PO Box 3865
010: * Grand Central Station
011: * New York NY 10163
012: *
013: * This file is part of nntp//rss
014: *
015: * nntp//rss is free software; you can redistribute it
016: * and/or modify it under the terms of the GNU General
017: * Public License as published by the Free Software Foundation;
018: * either version 2 of the License, or (at your option) any
019: * later version.
020: *
021: * This program is distributed in the hope that it will be
022: * useful, but WITHOUT ANY WARRANTY; without even the implied
023: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
024: * PURPOSE. See the GNU General Public License for more
025: * details.
026: *
027: * You should have received a copy of the GNU General Public
028: * License along with this program; if not, write to the
029: * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
030: * Boston, MA 02111-1307 USA
031: * ----------------------------------------------------- */
032:
033: import java.io.File;
034: import java.io.IOException;
035: import java.lang.reflect.Method;
036: import java.net.URL;
037: import java.net.URLClassLoader;
038:
039: /**
040: * @author Jason Brome <jason@methodize.org>
041: * @version $Id: Startup.java,v 1.3 2003/03/22 16:25:42 jasonbrome Exp $
042: */
043: public class Startup {
044:
045: private static String[] resources = new String[] { "./nntprss.jar",
046: "./ext/lib/log4j-1.2.7.jar",
047: "./ext/lib/commons-collections.jar",
048: "./ext/lib/commons-dbcp.jar", "./ext/lib/commons-pool.jar",
049: "./ext/lib/javax.servlet.jar",
050: "./ext/lib/org.mortbay.jetty-jdk1.2.jar",
051: "./ext/lib/hsqldb.jar", "./ext/lib/crimson.jar",
052: "./ext/lib/xmlrpc-1.1.jar", "./ext/lib/mailapi.jar",
053: "./ext/lib/activation.jar", "./ext/lib/systray4j.jar", ".",
054:
055: };
056:
057: public static void main(String[] args) {
058: try {
059: new Startup().run(args);
060: } catch (Exception e) {
061: e.printStackTrace();
062: }
063: }
064:
065: public void run(String[] args) throws Exception {
066: URL resourceURLs[] = new URL[resources.length];
067:
068: for (int resCount = 0; resCount < resources.length; resCount++) {
069: try {
070: File file = new File(resources[resCount]);
071: if (file.exists()) {
072: resourceURLs[resCount] = file.getCanonicalFile()
073: .toURL();
074: } else {
075: throw new RuntimeException("Missing file: "
076: + file.toString());
077: }
078: } catch (IOException ie) {
079: ie.printStackTrace();
080: }
081: }
082:
083: ClassLoader existingClassLoader = Thread.currentThread()
084: .getContextClassLoader();
085: URLClassLoader urlClassLoader = URLClassLoader.newInstance(
086: resourceURLs, existingClassLoader);
087: Thread.currentThread().setContextClassLoader(urlClassLoader);
088:
089: Class clazz = urlClassLoader
090: .loadClass("org.methodize.nntprss.Main");
091: Method methods[] = clazz.getMethods();
092: Method mainMethod = null;
093: for (int i = 0; i < methods.length; i++) {
094: if (methods[i].getName().equals("main")) {
095: mainMethod = methods[i];
096: break;
097: }
098: }
099:
100: mainMethod.invoke(null, new Object[] { args });
101: }
102:
103: // Shutdown hook for Windows Java Service Wrappers
104: // e.g. JNT
105: public static void stopApplication() {
106: System.exit(0);
107: }
108: }
|