001: /*
002:
003: Copyright 2004, Martian Software, Inc.
004:
005: Licensed under the Apache License, Version 2.0 (the "License");
006: you may not use this file except in compliance with the License.
007: You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016:
017: */
018:
019: package com.martiansoftware.nailgun;
020:
021: import java.util.Properties;
022:
023: /**
024: * Just a simple holder for various NailGun-related contants.
025: *
026: * @author <a href="http://www.martiansoftware.com/contact.html">Marty Lamb</a>
027: */
028: public class NGConstants {
029:
030: /**
031: * The default NailGun port (2113)
032: */
033: public static final int DEFAULT_PORT = 2113;
034:
035: /**
036: * The exit code sent to clients if an exception occurred on the server
037: */
038: public static final int EXIT_EXCEPTION = 899;
039:
040: /**
041: * The exit code sent to clients if an invalid command is sent
042: */
043: public static final int EXIT_NOSUCHCOMMAND = 898;
044:
045: /**
046: * Chunk type marker for command line arguments
047: */
048: public static final char CHUNKTYPE_ARGUMENT = 'A';
049:
050: /**
051: * Chunk type marker for client environment variables
052: */
053: public static final char CHUNKTYPE_ENVIRONMENT = 'E';
054:
055: /**
056: * Chunk type marker for the command (alias or class)
057: */
058: public static final char CHUNKTYPE_COMMAND = 'C';
059:
060: /**
061: * Chunk type marker for client working directory
062: */
063: public static final char CHUNKTYPE_WORKINGDIRECTORY = 'D';
064:
065: /**
066: * Chunk type marker for stdin
067: */
068: public static final char CHUNKTYPE_STDIN = '0';
069:
070: /**
071: * Chunk type marker for the end of stdin
072: */
073: public static final char CHUNKTYPE_STDIN_EOF = '.';
074:
075: /**
076: * Chunk type marker for stdout
077: */
078: public static final char CHUNKTYPE_STDOUT = '1';
079:
080: /**
081: * Chunk type marker for stderr
082: */
083: public static final char CHUNKTYPE_STDERR = '2';
084:
085: /**
086: * Chunk type marker for client exit chunks
087: */
088: public static final char CHUNKTYPE_EXIT = 'X';
089:
090: /**
091: * Server version number
092: */
093: public static final String VERSION;
094:
095: /**
096: * Loads the version number from a file generated by Ant.
097: */
098: static {
099: Properties props = new Properties();
100: try {
101: props
102: .load(NGConstants.class
103: .getClassLoader()
104: .getResourceAsStream(
105: "com/martiansoftware/nailgun/nailgun-version.properties"));
106: } catch (java.io.IOException e) {
107: System.err
108: .println("Unable to load nailgun-version.properties.");
109: }
110: VERSION = props.getProperty("version", "UNKNOWN");
111: }
112:
113: }
|