incubator-depot-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickcha...@apache.org
Subject svn commit: rev 10301 - in incubator/depot/trunk/update/src/java/org/apache/depot/update: tool util/net/http version
Date Tue, 27 Apr 2004 03:49:23 GMT
Author: nickchalko
Date: Mon Apr 26 20:49:22 2004
New Revision: 10301

Added:
   incubator/depot/trunk/update/src/java/org/apache/depot/update/version/VersionHelper.java
Modified:
   incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/Tool.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/http/HttpClientUserAgent.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/version/   (props changed)
Log:
Added a VersionHelper give classes access to the Version class as a VersionMarker.

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/Tool.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/Tool.java	(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/tool/Tool.java	Mon Apr 26
20:49:22 2004
@@ -1,23 +1,20 @@
 /*
- * Copyright  2004 The Apache Software Foundation
- *
- *  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.
+ * Copyright 2004 The Apache Software Foundation
+ * 
+ * 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.apache.depot.update.tool;
-
 import java.io.PrintWriter;
-
 import org.apache.depot.common.log.LogConstants;
 import org.apache.depot.common.log.Logger;
 import org.apache.depot.common.log.StandardLogListener;
@@ -31,35 +28,29 @@
 import org.apache.depot.update.config.UpdateConfig;
 import org.apache.depot.update.monitor.Monitor;
 import org.apache.depot.update.monitor.StatisticsMonitor;
-import org.apache.depot.update.version.Version;
-
+import org.apache.depot.update.version.VersionHelper;
 /**
  * @author ajack
  */
 public abstract class Tool {
-
 	private static Option l_debugOption = null;
 	private static Option l_verboseOption = null;
 	private static Option l_statsOption = null;
 	private static Option l_helpOption = null;
 	private static Option l_versionOption = null;
 	private static Options l_options = null;
-
 	private static boolean l_debug = false;
 	private static boolean l_verbose = false;
 	private static boolean l_help = false;
 	private static boolean l_version = false;
-
 	private static StatisticsMonitor l_statistics = null;
-
 	static {
-		l_versionOption = new Option("V", "version", false, "print version, and exit");
+		l_versionOption = new Option("V", "version", false,
+				"print version, and exit");
 		l_helpOption = new Option("h", "help", false, "print help, and exit");
 		l_debugOption = new Option("d", "debug", false, "debug output");
 		l_verboseOption = new Option("v", "verbose", false, "verbose output");
-
 		l_statsOption = new Option("s", "stats", false, "statistics output");
-
 		l_options = new Options();
 		l_options.addOption(l_helpOption);
 		l_options.addOption(l_versionOption);
@@ -67,66 +58,47 @@
 		l_options.addOption(l_verboseOption);
 		l_options.addOption(l_statsOption);
 	}
-
 	protected Options getOptions() {
 		return l_options;
 	}
-
 	protected PrintWriter getOutput() {
 		return SystemUtils.getSystemOut();
 	}
-
 	protected abstract String getTitle();
 	protected abstract void init();
-
 	protected void printVersion() {
-		String version = Version.VERSION.getLongVersion();		
+		String version = VersionHelper.getMarker().getLongVersion();
 		System.out.println(getTitle() + " : " + version);
-		
 	}
-	
 	protected void printHelp() {
-			printVersion();		
-			getOptions().display();
-		}
-	
+		printVersion();
+		getOptions().display();
+	}
 	protected abstract void execute(CommandLine cmdline) throws Exception;
-
 	protected CommandLine parseCommandLine(String args[]) {
 		CommandLine cmdline = null;
-
 		try {
 			CommandLineParser parser = new CommandLineParser();
-
 			parser.setStrict(true);
 			cmdline = parser.parse(l_options, args);
-
 			l_help = cmdline.isSet(l_helpOption);
 			l_version = cmdline.isSet(l_versionOption);
 			l_verbose = cmdline.isSet(l_verboseOption);
 			l_debug = cmdline.isSet(l_debugOption);
-		}
-		catch (ParseException exp) {
+		} catch (ParseException exp) {
 			System.err.println("Bad Command Line. Reason: " + exp.getMessage());
 			printHelp();
 			System.exit(1);
 		}
-
 		return cmdline;
 	}
-
 	public void run(String args[]) {
-
 		//:TODO:Hack
 		//DebugUtils.enableCommonsLogging();
 		//DebugUtils.enableHttpClientDebug();
-
 		UpdateConfig.configure();
-
 		init();
-
 		CommandLine cmdline = parseCommandLine(args);
-
 		if (l_help) {
 			printHelp();
 			System.exit(0);
@@ -135,37 +107,30 @@
 			printVersion();
 			System.exit(0);
 		}
-
 		// Set logging context
 		int level = LogConstants.INFO;
 		if (l_verbose || l_debug)
 			level = l_debug ? LogConstants.DEBUG : LogConstants.VERBOSE;
 		Logger logger = Logger.pushContext(level, new StandardLogListener());
-
 		// Monitor (and store statistics)
 		l_statistics = new StatisticsMonitor();
 		Monitor monitor = Monitor.pushContext(l_statistics);
-
 		try {
 			execute(cmdline);
-		}
-		catch (ParseException pe) {
+		} catch (ParseException pe) {
 			SystemUtils.getSystemErr().println(
-				"Error: " + pe.getLocalizedMessage());
+					"Error: " + pe.getLocalizedMessage());
 			printHelp();
 			cmdline.print();
 			System.exit(1);
-		}
-		catch (Exception exc) {
+		} catch (Exception exc) {
 			exc.printStackTrace();
-		}
-		finally {
+		} finally {
 			Monitor.popContext(monitor);
-			Logger.popContext(logger);			
-
+			Logger.popContext(logger);
 			if (cmdline.isSet(l_statsOption)) {
 				DebugUtils.dump(l_statistics);
 			}
 		}
 	}
-}
+}
\ No newline at end of file

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/http/HttpClientUserAgent.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/http/HttpClientUserAgent.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/http/HttpClientUserAgent.java
Mon Apr 26 20:49:22 2004
@@ -29,6 +29,7 @@
 import org.apache.depot.common.util.SystemUtils;
 import org.apache.depot.common.util.io.IOUtils;
 import org.apache.depot.update.version.Version;
+import org.apache.depot.update.version.VersionHelper;
 
 /**
  * @author arb_jack
@@ -167,7 +168,7 @@
 		method.setFollowRedirects(true);
 		method.setRequestHeader(
 			"User-Agent",
-			"Apache-Depot-Update/" + Version.VERSION.getLongVersion());
+			"Apache-Depot-Update/" + VersionHelper.getMarker().getLongVersion());
 	}
 
 	public static void main(String args[]) {

Added: incubator/depot/trunk/update/src/java/org/apache/depot/update/version/VersionHelper.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/version/VersionHelper.java
Mon Apr 26 20:49:22 2004
@@ -0,0 +1,27 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  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.apache.depot.update.version;
+import org.apache.depot.version.VersionMarker;
+/**
+ * Static method for getting a version Marker for this project.
+ * 
+ */
+public class VersionHelper {
+	private static VersionMarker MARKER = new Version();
+	public static VersionMarker getMarker() {
+		return MARKER;
+	}
+}
\ No newline at end of file

Mime
View raw message