User: user57
Date: 01/08/27 19:08:18
Modified: src/main/org/jboss Main.java
Added: src/main/org/jboss Version.java
Log:
o Changed Main to use Calendar.get(XXX) to avoid deprecation warnings
o Added Version, which is a singleton that holds version information
(read from version.properties, which is updated by the build system
when it is copied from src/resources to output/resources)
o Updated build.xml to include Version & version.properties in run.jar
o Added version.* properties in build.xml, which are used by copy
filtering to update version.properties.
Revision Changes Path
1.43 +70 -58 jboss/src/main/org/jboss/Main.java
Index: Main.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/Main.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- Main.java 2001/08/03 20:33:11 1.42
+++ Main.java 2001/08/28 02:08:18 1.43
@@ -16,30 +16,38 @@
import java.io.PrintWriter;
import java.io.FileWriter;
import java.net.URL;
+
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.Date;
+import java.util.Calendar;
+
import java.security.*;
-import java.util.*;
import javax.management.*;
import javax.management.loading.*;
/**
- *
- * @see <related>
- * @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a>.
- * @author <a href="mailto:[EMAIL PROTECTED]">Daniel O'Connor</a>.
- * @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>.
- * @version $Revision: 1.42 $
+ * The main entry point for the JBoss server.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a>.
+ * @author <a href="mailto:[EMAIL PROTECTED]">Daniel O'Connor</a>.
+ * @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>.
+ * @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
+ * @version $Revision: 1.43 $
*/
public class Main
{
// Constants -----------------------------------------------------
+
+ private Version version = Version.getInstance();
- String versionIdentifier = "pre-3.0 [RABBIT-HOLE]";
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
public static void main(final String[] args)
- throws Exception
+ throws Exception
{
String cn = "default"; // Default configuration name is "default", i.e. all
conf files are in "/conf/default"
String patchDir = null;
@@ -48,8 +56,8 @@
cn = args[0];
for(int a = 0; a < args.length; a ++)
{
- if( args[a].startsWith("-p") )
- patchDir = args[a+1];
+ if( args[a].startsWith("-p") )
+ patchDir = args[a+1];
}
final String confName = cn;
final String patchDirName = patchDir;
@@ -69,27 +77,27 @@
*/
if( System.getProperty("jboss.home") == null )
{
- String path =
Main.class.getProtectionDomain().getCodeSource().getLocation().getFile();
- File runJar = new File(path);
- // Home dir should be the parent of the dir containing run.jar
- File homeDir = new File(runJar.getParent(), "..");
- System.setProperty("jboss.home", homeDir.getCanonicalPath());
+ String path =
Main.class.getProtectionDomain().getCodeSource().getLocation().getFile();
+ File runJar = new File(path);
+ // Home dir should be the parent of the dir containing run.jar
+ File homeDir = new File(runJar.getParent(), "..");
+ System.setProperty("jboss.home", homeDir.getCanonicalPath());
}
System.out.println("jboss.home = "+System.getProperty("jboss.home"));
// Set the JAAS login config file if not already set
if( System.getProperty("java.security.auth.login.config") == null )
{
- URL loginConfig =
Main.class.getClassLoader().getResource(confName+"/auth.conf");
- if( loginConfig != null )
- {
- System.setProperty("java.security.auth.login.config",
loginConfig.toExternalForm());
- System.out.println("Using JAAS LoginConfig:
"+loginConfig.toExternalForm());
- }
- else
- {
- System.out.println("Warning: no auth.conf found in config="+confName);
- }
+ URL loginConfig =
Main.class.getClassLoader().getResource(confName+"/auth.conf");
+ if( loginConfig != null )
+ {
+ System.setProperty("java.security.auth.login.config",
loginConfig.toExternalForm());
+ System.out.println("Using JAAS LoginConfig:
"+loginConfig.toExternalForm());
+ }
+ else
+ {
+ System.out.println("Warning: no auth.conf found in config="+confName);
+ }
}
// Set security
@@ -109,33 +117,33 @@
// Start server - Main does not have the proper permissions
AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
{
- new Main(confName, patchDirName);
- return null;
- }
- });
+ public Object run()
+ {
+ new Main(confName, patchDirName);
+ return null;
+ }
+ });
}
// Constructors --------------------------------------------------
public Main(String confName, String patchDir)
{
- Date startTime = new Date();
+ Date startTime = new Date();
try
{
System.out.println("Using configuration \""+confName+"\"");
- final PrintStream err = System.err;
+ final PrintStream err = System.err;
com.sun.management.jmx.Trace.parseTraceProperties();
// Give feedback about from where jndi.properties is read
URL jndiLocation = this.getClass().getResource("/jndi.properties");
if (jndiLocation instanceof URL) {
- System.out.println("Please make sure the following is intended (check
your CLASSPATH):");
- System.out.println(" jndi.properties is read from "+jndiLocation);
+ System.out.println("Please make sure the following is intended (check
your CLASSPATH):");
+ System.out.println(" jndi.properties is read from "+jndiLocation);
}
// Create MBeanServer
@@ -147,26 +155,25 @@
// Add any patch jars to the MLet so they are seen ahead of the JBoss jars
if( patchDir != null )
{
- File dir = new File(patchDir);
- ArrayList tmp = new ArrayList();
- File[] jars = dir.listFiles(new java.io.FileFilter()
- {
- public boolean accept(File pathname)
- {
- String name = pathname.getName();
- return name.endsWith(".jar") || name.endsWith(".zip");
- }
- }
- );
- tmp.add(confDirectory);
- for(int j = 0; jars != null && j < jars.length; j ++)
- {
- File jar = jars[j];
- URL u = jar.getCanonicalFile().toURL();
- tmp.add(u);
- }
- urls = new URL[tmp.size()];
- tmp.toArray(urls);
+ File dir = new File(patchDir);
+ ArrayList tmp = new ArrayList();
+ File[] jars = dir.listFiles(new java.io.FileFilter()
+ {
+ public boolean accept(File pathname)
+ {
+ String name = pathname.getName();
+ return name.endsWith(".jar") || name.endsWith(".zip");
+ }
+ });
+ tmp.add(confDirectory);
+ for(int j = 0; jars != null && j < jars.length; j ++)
+ {
+ File jar = jars[j];
+ URL u = jar.getCanonicalFile().toURL();
+ tmp.add(u);
+ }
+ urls = new URL[tmp.size()];
+ tmp.toArray(urls);
}
// Create MLet
@@ -234,8 +241,13 @@
// Done
Date stopTime = new Date();
- Date lapsedTime = new Date(stopTime.getTime()-startTime.getTime());
- System.out.println("JBoss "+versionIdentifier+" Started in
"+lapsedTime.getMinutes()+"m:"+lapsedTime.getSeconds()+"s");
+ Date lapsedTime = new Date(stopTime.getTime() - startTime.getTime());
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(lapsedTime);
+ System.out.println("JBoss " + version +
+ " [" + version.getName() + "] Started in " +
+ cal.get(Calendar.MINUTE) + "m:" +
+ cal.get(Calendar.SECOND) + "s");
}
}
1.1 jboss/src/main/org/jboss/Version.java
Index: Version.java
===================================================================
/*
* JBoss, the OpenSource EJB server
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss;
import java.util.Properties;
import java.util.Map;
import java.util.Collections;
import java.io.InputStream;
import java.io.IOException;
/**
* Provides access to JBoss version (and build) properties.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
* @version $Revision: 1.1 $
*/
public final class Version
{
public static final String VERSION_MAJOR = "version.major";
public static final String VERSION_MINOR = "version.minor";
public static final String VERSION_REVISION = "version.revision";
public static final String VERSION_TAG = "version.tag";
public static final String VERSION_NAME = "version.name";
public static final String BUILD_NUMBER = "build.number";
public static final String BUILD_ID = "build.id";
/** The single instance. */
private static Version instance = null;
/**
* Get the single <tt>Version</tt> instance.
*
* @return The single <tt>Version</tt> instance.
*/
public static Version getInstance() {
if (instance == null) {
instance = new Version();
}
return instance;
}
/** The version properties. */
private Properties props;
/** Do not allow direct public construction. */
private Version() {
props = loadProperties();
}
/**
* Load the version properties from a resource.
*/
private Properties loadProperties() {
props = new Properties();
try {
InputStream in =
Version.class.getResourceAsStream("/org/jboss/version.properties");
props.load(in);
in.close();
}
catch (IOException e) {
throw new Error("missing version.properties");
}
return props;
}
/**
* Returns an unmodifiable map of version properties.
*
* @return An unmodifiable map of version properties.
*/
public Map getProperties() {
return Collections.unmodifiableMap(props);
}
/**
* Returns the value for the given property name.
*
* @param name The name of the property.
* @return The property value or null if the property is not set.
*/
public String getProperty(final String name) {
return props.getProperty(name);
}
/** Returns a property value as an int. */
private int getIntProperty(final String name) {
return Integer.valueOf(props.getProperty(name)).intValue();
}
/**
* Returns the major number of the version.
*
* @return The major number of the version.
*/
public int getMajor() {
return getIntProperty(VERSION_MAJOR);
}
/**
* Returns the minor number of the version.
*
* @return The minor number of the version.
*/
public int getMinor() {
return getIntProperty(VERSION_MINOR);
}
/**
* Returns the revision number of the version.
*
* @return The revision number of the version.
*/
public int getRevision() {
return getIntProperty(VERSION_REVISION);
}
/**
* Returns the tag of the version.
*
* @return The tag of the version.
*/
public String getTag() {
return props.getProperty(VERSION_TAG);
}
/**
* Returns the name number of the version.
*
* @return The name of the version.
*/
public String getName() {
return props.getProperty(VERSION_NAME);
}
/**
* Returns the build identifier for this version.
*
* @return The build identifier for this version.
*/
public String getBuildID() {
return props.getProperty(BUILD_ID);
}
/**
* Returns the build number for this version.
*
* @return The build number for this version.
*/
public String getBuildNumber() {
return props.getProperty(BUILD_NUMBER);
}
/**
* Returns the version information as a string.
*
* @return Basic information as a string.
*/
public String toString() {
StringBuffer buff = new StringBuffer();
buff.append(getMajor()).append(".");
buff.append(getMinor()).append(".");
buff.append(getRevision()).append(getTag());
buff.append("(").append(getBuildID()).append(")");
return buff.toString();
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development